添加质检规格

This commit is contained in:
liuchengqian 2022-03-10 21:18:49 +08:00
parent 5f43e1b56e
commit c2b9050fd6
7 changed files with 75 additions and 8 deletions

View File

@ -5,6 +5,11 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Optional;
@Component @Component
public interface QcSpecDao extends JpaRepository<QcSpecEntity, Long>, JpaSpecificationExecutor<QcSpecEntity> { public interface QcSpecDao extends JpaRepository<QcSpecEntity, Long>, JpaSpecificationExecutor<QcSpecEntity> {
Optional<QcSpecEntity> findByVarietyNoAndQcItemNo(String varietyNo, String qcItemNo);
} }

View File

@ -5,6 +5,9 @@ import com.xkrs.newpro.model.qo.QcSpecQoUpdate;
public interface QcSpecService { public interface QcSpecService {
/**
* 添加质检规格
*/
String insertQcSpec(QcSpecQoInsert insertQo); String insertQcSpec(QcSpecQoInsert insertQo);
String updateQcSpec(QcSpecQoUpdate updateQo); String updateQcSpec(QcSpecQoUpdate updateQo);

View File

@ -38,7 +38,7 @@ public class QcItemServiceImpl implements QcItemService {
} }
QcItemEntity entity = new QcItemEntity(); QcItemEntity entity = new QcItemEntity();
entity.setCreateTime(LocalDateUtils.getFormatDateToSecond()); entity.setCreateTime(LocalDateUtils.getCurrentSecond());
entity.setUpdateTime(""); entity.setUpdateTime("");
entity.setNo(no); entity.setNo(no);
entity.setName(name); entity.setName(name);

View File

@ -35,7 +35,7 @@ public class QcSourceServiceImpl implements QcSourceService {
String qcValue = insertQo.getQcValue(); String qcValue = insertQo.getQcValue();
QcSourceEntity entity = new QcSourceEntity(); QcSourceEntity entity = new QcSourceEntity();
entity.setCreateTime(LocalDateUtils.getFormatDateToSecond()); entity.setCreateTime(LocalDateUtils.getCurrentSecond());
entity.setBatchNo(batchNo); entity.setBatchNo(batchNo);
entity.setMachineNo(machineNo); entity.setMachineNo(machineNo);
entity.setMaterialNo(materialNo); entity.setMaterialNo(materialNo);

View File

@ -1,25 +1,73 @@
package com.xkrs.newpro.service.impl; package com.xkrs.newpro.service.impl;
import com.xkrs.newpro.dao.QcSourceDao; import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.newpro.dao.QcItemDao;
import com.xkrs.newpro.dao.QcSpecDao; import com.xkrs.newpro.dao.QcSpecDao;
import com.xkrs.newpro.model.entity.QcItemEntity;
import com.xkrs.newpro.model.entity.QcSpecEntity;
import com.xkrs.newpro.model.qo.QcSpecQoInsert; import com.xkrs.newpro.model.qo.QcSpecQoInsert;
import com.xkrs.newpro.model.qo.QcSpecQoUpdate; import com.xkrs.newpro.model.qo.QcSpecQoUpdate;
import com.xkrs.newpro.service.QcSpecService; import com.xkrs.newpro.service.QcSpecService;
import com.xkrs.newpro.utils.LocalDateUtils;
import com.xkrs.newpro.utils.LocalStringUtils;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Locale; import java.util.Locale;
import java.util.Optional;
import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject;
public class QcSpecServiceImpl implements QcSpecService { public class QcSpecServiceImpl implements QcSpecService {
private Locale locale = LocaleContextHolder.getLocale(); private Locale locale = LocaleContextHolder.getLocale();
@Resource
private QcItemDao qcItemDao;
@Resource @Resource
private QcSpecDao qcSpecDao; private QcSpecDao qcSpecDao;
/**
* 添加质检规格
*/
@Override @Override
public String insertQcSpec(QcSpecQoInsert insertQo) { public String insertQcSpec(QcSpecQoInsert insertQo) {
return null;
String varietyNo = insertQo.getVarietyNo();
String qcItemNo = insertQo.getQcItemNo();
String max = insertQo.getMax();
String mean = insertQo.getMean();
String min = insertQo.getMin();
String unit = insertQo.getUnit();
String method = insertQo.getMethod();
String standard = insertQo.getStandard();
String remark = insertQo.getRemark();
Optional<QcItemEntity> entityByNo = qcItemDao.findByNo(qcItemNo);
if (entityByNo.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "不存在该检验项目,请先添加检验项目!", locale);
}
Optional<QcSpecEntity> entityByVarietyNoAndQcItemNo = qcSpecDao.findByVarietyNoAndQcItemNo(varietyNo, qcItemNo);
if (entityByVarietyNoAndQcItemNo.isPresent()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "该检验规格已存在,请勿重复添加!", locale);
}
QcSpecEntity entity = new QcSpecEntity();
entity.setCreateTime(LocalDateUtils.getCurrentSecond());
entity.setUpdateTime("");
entity.setVarietyNo(varietyNo);
entity.setQcItemNo(qcItemNo);
entity.setMax(LocalStringUtils.formatEmptyValue(max));
entity.setMean(LocalStringUtils.formatEmptyValue(mean));
entity.setMin(LocalStringUtils.formatEmptyValue(min));
entity.setUnit(LocalStringUtils.formatEmptyValue(unit));
entity.setMethod(LocalStringUtils.formatEmptyValue(method));
entity.setStandard(LocalStringUtils.formatEmptyValue(standard));
entity.setRemark(LocalStringUtils.formatEmptyValue(remark));
qcSpecDao.save(entity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功!", locale);
} }
@Override @Override

View File

@ -1,7 +1,5 @@
package com.xkrs.newpro.utils; package com.xkrs.newpro.utils;
import cn.hutool.core.date.DateUtil;
import java.util.Date; import java.util.Date;
public class LocalDateUtils { public class LocalDateUtils {
@ -9,9 +7,10 @@ public class LocalDateUtils {
private LocalDateUtils() { private LocalDateUtils() {
} }
public static String getFormatDateToSecond() { public static String getCurrentSecond() {
return DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); // return DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
return String.valueOf(new Date().getTime() / 1000L);
} }
} }

View File

@ -0,0 +1,12 @@
package com.xkrs.newpro.utils;
public class LocalStringUtils {
private LocalStringUtils() {
}
public static String formatEmptyValue(String value) {
return value == null ? "" : value;
}
}