添加质检项

This commit is contained in:
liuchengqian 2022-03-10 20:09:26 +08:00
parent f0aea24726
commit 4ec6479321
6 changed files with 87 additions and 1 deletions

View File

@ -5,6 +5,11 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;
import java.util.Optional;
@Component
public interface QcItemDao extends JpaRepository<QcItemEntity, Long>, JpaSpecificationExecutor<QcItemEntity> {
Optional<QcItemEntity> findByNo(String no);
}

View File

@ -5,6 +5,9 @@ import com.xkrs.newpro.model.qo.QcItemQoUpdate;
public interface QcItemService {
/**
* 添加质检项
*/
String insertQcItem(QcItemQoInsert insertQo);
String updateQcItem(QcItemQoUpdate updateQo);

View File

@ -1,13 +1,51 @@
package com.xkrs.newpro.service.impl;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.newpro.dao.QcItemDao;
import com.xkrs.newpro.model.entity.QcItemEntity;
import com.xkrs.newpro.model.qo.QcItemQoInsert;
import com.xkrs.newpro.model.qo.QcItemQoUpdate;
import com.xkrs.newpro.service.QcItemService;
import com.xkrs.newpro.utils.LocalDateUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import javax.annotation.Resource;
import java.util.Locale;
import java.util.Optional;
import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject;
public class QcItemServiceImpl implements QcItemService {
private Locale locale = LocaleContextHolder.getLocale();
@Resource
private QcItemDao qcItemDao;
/**
* 添加质检项
*/
@Override
public String insertQcItem(QcItemQoInsert insertQo) {
return null;
String no = insertQo.getNo();
String name = insertQo.getName();
String type = insertQo.getType();
Optional<QcItemEntity> entityByNo = qcItemDao.findByNo(no);
if (entityByNo.isPresent()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "该检验项目已存在,请勿重复添加!", locale);
}
QcItemEntity entity = new QcItemEntity();
entity.setCreateTime(LocalDateUtils.getFormatDateToSecond());
entity.setUpdateTime("");
entity.setNo(no);
entity.setName(name);
entity.setType(type);
qcItemDao.save(entity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功!", locale);
}
@Override

View File

@ -1,9 +1,20 @@
package com.xkrs.newpro.service.impl;
import com.xkrs.newpro.dao.QcSourceDao;
import com.xkrs.newpro.model.qo.QcSourceQoInsert;
import com.xkrs.newpro.service.QcSourceService;
import org.springframework.context.i18n.LocaleContextHolder;
import javax.annotation.Resource;
import java.util.Locale;
public class QcSourceServiceImpl implements QcSourceService {
private Locale locale = LocaleContextHolder.getLocale();
@Resource
private QcSourceDao qcSourceDao;
@Override
public String insertQcSource(QcSourceQoInsert insertQo) {
return null;

View File

@ -1,10 +1,22 @@
package com.xkrs.newpro.service.impl;
import com.xkrs.newpro.dao.QcSourceDao;
import com.xkrs.newpro.dao.QcSpecDao;
import com.xkrs.newpro.model.qo.QcSpecQoInsert;
import com.xkrs.newpro.model.qo.QcSpecQoUpdate;
import com.xkrs.newpro.service.QcSpecService;
import org.springframework.context.i18n.LocaleContextHolder;
import javax.annotation.Resource;
import java.util.Locale;
public class QcSpecServiceImpl implements QcSpecService {
private Locale locale = LocaleContextHolder.getLocale();
@Resource
private QcSpecDao qcSpecDao;
@Override
public String insertQcSpec(QcSpecQoInsert insertQo) {
return null;

View File

@ -0,0 +1,17 @@
package com.xkrs.newpro.utils;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
public class LocalDateUtils {
private LocalDateUtils() {
}
public static String getFormatDateToSecond() {
return DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}
}