完善 添加检验数据
This commit is contained in:
parent
9f33ffdd1f
commit
e86b8716d5
@ -43,6 +43,8 @@ public class QcItemEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型
|
* 类型
|
||||||
|
* "0":文本格式
|
||||||
|
* "1":图片格式
|
||||||
*/
|
*/
|
||||||
@Column(length = 85, columnDefinition = "varchar(85)")
|
@Column(length = 85, columnDefinition = "varchar(85)")
|
||||||
private String type;
|
private String type;
|
||||||
@ -100,13 +102,6 @@ public class QcItemEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "QcItemEntity{" +
|
return "QcItemEntity{" + "id=" + id + ", createTime='" + createTime + '\'' + ", updateTime='" + updateTime + '\'' + ", no='" + no + '\'' + ", name='" + name + '\'' + ", type='" + type + '\'' + '}';
|
||||||
"id=" + id +
|
|
||||||
", createTime='" + createTime + '\'' +
|
|
||||||
", updateTime='" + updateTime + '\'' +
|
|
||||||
", no='" + no + '\'' +
|
|
||||||
", name='" + name + '\'' +
|
|
||||||
", type='" + type + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
package com.xkrs.newpro.service.impl;
|
package com.xkrs.newpro.service.impl;
|
||||||
|
|
||||||
import com.xkrs.encapsulation.PromptMessageEnum;
|
import com.xkrs.encapsulation.PromptMessageEnum;
|
||||||
|
import com.xkrs.newpro.dao.QcItemDao;
|
||||||
import com.xkrs.newpro.dao.QcSourceDao;
|
import com.xkrs.newpro.dao.QcSourceDao;
|
||||||
|
import com.xkrs.newpro.model.entity.QcItemEntity;
|
||||||
import com.xkrs.newpro.model.entity.QcSourceEntity;
|
import com.xkrs.newpro.model.entity.QcSourceEntity;
|
||||||
import com.xkrs.newpro.model.qo.QcSourceQoDelete;
|
import com.xkrs.newpro.model.qo.QcSourceQoDelete;
|
||||||
import com.xkrs.newpro.model.qo.QcSourceQoInsert;
|
import com.xkrs.newpro.model.qo.QcSourceQoInsert;
|
||||||
import com.xkrs.newpro.service.QcSourceService;
|
import com.xkrs.newpro.service.QcSourceService;
|
||||||
|
import com.xkrs.newpro.utils.Constant;
|
||||||
import com.xkrs.newpro.utils.LocalDateUtils;
|
import com.xkrs.newpro.utils.LocalDateUtils;
|
||||||
import com.xkrs.newpro.utils.LocalStringUtils;
|
import com.xkrs.newpro.utils.LocalStringUtils;
|
||||||
|
import com.xkrs.util.ExcelUploadUtil;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -25,6 +30,9 @@ public class QcSourceServiceImpl implements QcSourceService {
|
|||||||
|
|
||||||
private Locale locale = LocaleContextHolder.getLocale();
|
private Locale locale = LocaleContextHolder.getLocale();
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QcItemDao qcItemDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private QcSourceDao qcSourceDao;
|
private QcSourceDao qcSourceDao;
|
||||||
|
|
||||||
@ -33,7 +41,6 @@ public class QcSourceServiceImpl implements QcSourceService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String insertQcSource(QcSourceQoInsert insertQo, MultipartFile picture) {
|
public String insertQcSource(QcSourceQoInsert insertQo, MultipartFile picture) {
|
||||||
|
|
||||||
String batchNo = insertQo.getBatchNo();
|
String batchNo = insertQo.getBatchNo();
|
||||||
String machineNo = insertQo.getMachineNo();
|
String machineNo = insertQo.getMachineNo();
|
||||||
String materialNo = insertQo.getMaterialNo();
|
String materialNo = insertQo.getMaterialNo();
|
||||||
@ -41,7 +48,11 @@ public class QcSourceServiceImpl implements QcSourceService {
|
|||||||
String varietyNo = insertQo.getVarietyNo();
|
String varietyNo = insertQo.getVarietyNo();
|
||||||
String qcItemNo = insertQo.getQcItemNo();
|
String qcItemNo = insertQo.getQcItemNo();
|
||||||
String qcValue = insertQo.getQcValue();
|
String qcValue = insertQo.getQcValue();
|
||||||
|
Optional<QcItemEntity> qcItemEntityByNo = qcItemDao.findByNo(qcItemNo);
|
||||||
|
if (qcItemEntityByNo.isEmpty()) {
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "不存在该检验项目,请先添加检验项目!", locale);
|
||||||
|
}
|
||||||
|
if (Constant.QC_ITEM_TYPE_STRING.equals(qcItemEntityByNo.get().getType())) {
|
||||||
QcSourceEntity entity = new QcSourceEntity();
|
QcSourceEntity entity = new QcSourceEntity();
|
||||||
entity.setCreateTime(LocalDateUtils.getCurrentSecond());
|
entity.setCreateTime(LocalDateUtils.getCurrentSecond());
|
||||||
entity.setBatchNo(LocalStringUtils.formatEmptyValue(batchNo));
|
entity.setBatchNo(LocalStringUtils.formatEmptyValue(batchNo));
|
||||||
@ -52,9 +63,33 @@ public class QcSourceServiceImpl implements QcSourceService {
|
|||||||
entity.setQcItemNo(LocalStringUtils.formatEmptyValue(qcItemNo));
|
entity.setQcItemNo(LocalStringUtils.formatEmptyValue(qcItemNo));
|
||||||
entity.setQcValue(LocalStringUtils.formatEmptyValue(qcValue));
|
entity.setQcValue(LocalStringUtils.formatEmptyValue(qcValue));
|
||||||
qcSourceDao.save(entity);
|
qcSourceDao.save(entity);
|
||||||
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功!", locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功!", locale);
|
||||||
}
|
}
|
||||||
|
if (Constant.QC_ITEM_TYPE_PICTURE.equals(qcItemEntityByNo.get().getType())) {
|
||||||
|
if (picture == null) {
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "上传图片不能为空!", locale);
|
||||||
|
}
|
||||||
|
String picturePath;
|
||||||
|
try {
|
||||||
|
picturePath = ExcelUploadUtil.memoryFile(picture, 2);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "上传图片失败!", locale);
|
||||||
|
}
|
||||||
|
QcSourceEntity entity = new QcSourceEntity();
|
||||||
|
entity.setCreateTime(LocalDateUtils.getCurrentSecond());
|
||||||
|
entity.setBatchNo(LocalStringUtils.formatEmptyValue(batchNo));
|
||||||
|
entity.setMachineNo(LocalStringUtils.formatEmptyValue(machineNo));
|
||||||
|
entity.setMaterialNo(LocalStringUtils.formatEmptyValue(materialNo));
|
||||||
|
entity.setMouldNo(LocalStringUtils.formatEmptyValue(mouldNo));
|
||||||
|
entity.setVarietyNo(LocalStringUtils.formatEmptyValue(varietyNo));
|
||||||
|
entity.setQcItemNo(LocalStringUtils.formatEmptyValue(qcItemNo));
|
||||||
|
entity.setQcValue(LocalStringUtils.formatEmptyValue(picturePath));
|
||||||
|
qcSourceDao.save(entity);
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功!", locale);
|
||||||
|
}
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "添加失败!", locale);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除检验数据
|
* 删除检验数据
|
||||||
|
14
src/main/java/com/xkrs/newpro/utils/Constant.java
Normal file
14
src/main/java/com/xkrs/newpro/utils/Constant.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.xkrs.newpro.utils;
|
||||||
|
|
||||||
|
public interface Constant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检验项目类型:文本
|
||||||
|
*/
|
||||||
|
String QC_ITEM_TYPE_STRING = "0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检验项目类型:图片
|
||||||
|
*/
|
||||||
|
String QC_ITEM_TYPE_PICTURE = "1";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user