forked from I3-YF/i3plus-mes-pcn-yfai
PCN条码打印功能开发
parent
c9a0c0e4ce
commit
2a665781f6
@ -0,0 +1,22 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.api.base;
|
||||
|
||||
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @Description : 物料信息
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/6/13 15:18
|
||||
* @Modify:
|
||||
**/
|
||||
public interface IMesPartService {
|
||||
|
||||
@ApiOperation(value = "查询物料信息")
|
||||
ListPager<MesPart> queryMesPart(MesPart mesPart, Pager pager);
|
||||
|
||||
@ApiOperation(value = "根据物料代码查询物料信息")
|
||||
MesPart getMesPartByPartNo(String partNo,String organizeCode);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.api.base;
|
||||
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
public interface IMesTemplateService {
|
||||
|
||||
/**
|
||||
* 根据模板编号获取模板信息
|
||||
*
|
||||
* @param templateCode 模板编号
|
||||
* @return 标签模板
|
||||
*/
|
||||
@ApiOperation(value = "按条件查询", notes = "按条件查询")
|
||||
MesLabelTemplate getMesLabelTemplate(String templateCode);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPackingDefine;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IMesProduceSnPrintService {
|
||||
|
||||
@ApiOperation(value = "查询包装信息")
|
||||
List<MesPackingDefine> findMesPackingDefine(MesProduceSnPrintModel mesProduceSnPrintModel);
|
||||
|
||||
@ApiOperation(value = "查询条码信息")
|
||||
MesProduceSn findMesProduceSn(MesProduceSnPrintModel mesProduceSnPrintModel);
|
||||
|
||||
@ApiOperation(value = "打印")
|
||||
MesProduceSnPrintModel doPrint(MesProduceSnPrintModel mesProduceSnPrintModel);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Description : 物料信息主数据
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/6/13 15:13
|
||||
* @Modify:
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "物料信息")
|
||||
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mes-part")
|
||||
public class MesPartController {
|
||||
|
||||
@Autowired
|
||||
private IMesPartService mesPartService;
|
||||
|
||||
@GetMapping("/query")
|
||||
@ApiOperation(value = "查询信息")
|
||||
public ResultBean queryMesPart(MesPart mesPart, Pager pager) {
|
||||
try {
|
||||
return ResultBean.success("查询成功").setListPager(mesPartService.queryMesPart(mesPart, pager));
|
||||
} catch (ImppBusiException imppException) {
|
||||
return ResultBean.fail(imppException);
|
||||
} catch (Exception e) {
|
||||
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnPrintService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Description : 物料信息主数据
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/6/13 15:13
|
||||
* @Modify:
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "物料信息")
|
||||
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mes-produce-sn-print")
|
||||
public class MesProduceSnPrintController {
|
||||
|
||||
@Autowired
|
||||
private IMesProduceSnPrintService mesProduceSnPrintService;
|
||||
|
||||
@GetMapping("/mes-packing-define/find")
|
||||
@ApiOperation(value = "查询信息")
|
||||
public ResultBean findMesPackingDefine(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
||||
try {
|
||||
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getPartNo(), "ERP零件号不能为空");
|
||||
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getOrganizeCode(), "工厂代码不能为空");
|
||||
return ResultBean.success("查询成功").setResultList(mesProduceSnPrintService.findMesPackingDefine(mesProduceSnPrintModel));
|
||||
} catch (ImppBusiException imppException) {
|
||||
return ResultBean.fail(imppException);
|
||||
} catch (Exception e) {
|
||||
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/mes-produce-sn/find")
|
||||
@ApiOperation(value = "查询信息")
|
||||
public ResultBean findMesProduceSn(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
||||
try {
|
||||
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getProductSn(), "条码信息不能为空");
|
||||
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getOrganizeCode(), "工厂代码不能为空");
|
||||
return ResultBean.success("查询成功").setResultObject(mesProduceSnPrintService.findMesProduceSn(mesProduceSnPrintModel));
|
||||
} catch (ImppBusiException imppException) {
|
||||
return ResultBean.fail(imppException);
|
||||
} catch (Exception e) {
|
||||
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/do-print")
|
||||
@ApiOperation(value = "打印")
|
||||
public ResultBean doPrint(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
||||
try {
|
||||
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getPartNo(), "ERP零件号不能为空");
|
||||
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getOrganizeCode(), "工厂代码不能为空");
|
||||
if (Objects.isNull(mesProduceSnPrintModel.getPrintQty()) || mesProduceSnPrintModel.getPrintQty() <= 0) {
|
||||
MesPcnException.throwFlowException("打印数量不能小于等于零");
|
||||
}
|
||||
mesProduceSnPrintModel.setUserName(AuthUtil.getSessionUser().getUserName());
|
||||
return ResultBean.success("查询成功").setResultObject(mesProduceSnPrintService.doPrint(mesProduceSnPrintModel));
|
||||
} catch (ImppBusiException imppException) {
|
||||
return ResultBean.fail(imppException);
|
||||
} catch (Exception e) {
|
||||
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
||||
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
||||
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Description : 物料信息
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/6/13 15:18
|
||||
* @Modify:
|
||||
**/
|
||||
@Service
|
||||
public class MesPartServiceImpl implements IMesPartService {
|
||||
|
||||
@Autowired
|
||||
private MesPartRepository mesPartRDao;
|
||||
|
||||
@Override
|
||||
public ListPager<MesPart> queryMesPart(MesPart mesPart, Pager pager) {
|
||||
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesPart.getOrganizeCode());
|
||||
DdlPreparedPack.getStringLikerPack(mesPart.getPartNo(), "partNo", packBean);
|
||||
DdlPreparedPack.getStringLikerPack(mesPart.getPartName(), "partName", packBean);
|
||||
pager = PagerHelper.getPager(pager, mesPartRDao.findByHqlWhereCount(packBean));
|
||||
List<MesPart> list = mesPartRDao.findByHqlWherePage(packBean, pager);
|
||||
return new ListPager<>(list, pager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MesPart getMesPartByPartNo(String partNo, String organizeCode) {
|
||||
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
||||
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
|
||||
MesPart mesPart = mesPartRDao.getByProperty(packBean);
|
||||
if(Objects.isNull(mesPart)){
|
||||
MesPcnException.throwFlowException("物料【%s】信息不存在",partNo);
|
||||
}
|
||||
return mesPart;
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnPrintService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
||||
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
||||
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPackingDefine;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPackingDefineDetails;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.MesPackingDefineDetailsRepository;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.MesPackingDefineRepository;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository;
|
||||
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description : 条码补打
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/6/13 15:52
|
||||
* @Modify:
|
||||
**/
|
||||
@Service
|
||||
public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
||||
|
||||
@Autowired
|
||||
private MesPackingDefineDetailsRepository mesPackingDefineDetailsRDao;
|
||||
|
||||
@Autowired
|
||||
private MesPackingDefineRepository mesPackingDefineRDao;
|
||||
|
||||
@Autowired
|
||||
private MesProduceSnRepository mesProduceSnRDao;
|
||||
|
||||
@Autowired
|
||||
private SnowflakeIdMaker snowflakeIdMaker;
|
||||
|
||||
@Autowired
|
||||
private ISyncFuncService syncFuncService;
|
||||
|
||||
@Autowired
|
||||
private IMesPartService mesPartService;
|
||||
|
||||
@Autowired
|
||||
private IMesTemplateService mesTemplateService;
|
||||
|
||||
@Override
|
||||
public List<MesPackingDefine> findMesPackingDefine(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
||||
//查询包装定义明细
|
||||
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
|
||||
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "partNo", ddlPackBean);
|
||||
List<MesPackingDefineDetails> packingDefineDetails = mesPackingDefineDetailsRDao.findByHqlWhere(ddlPackBean);
|
||||
if (CollectionUtils.isEmpty(packingDefineDetails)) {
|
||||
MesPcnException.throwFlowException("物料【%s】未维护包装定义信息", mesProduceSnPrintModel.getPartNo());
|
||||
}
|
||||
//查询包装定义主表
|
||||
ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
|
||||
DdlPreparedPack.getInPackList(packingDefineDetails.stream().map(MesPackingDefineDetails::getPackCode).collect(Collectors.toList()), "packCode", ddlPackBean);
|
||||
return mesPackingDefineRDao.findByHqlWhere(ddlPackBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MesProduceSn findMesProduceSn(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
||||
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
|
||||
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getProductSn(), "productSn", ddlPackBean);
|
||||
MesProduceSn mesProduceSn = mesProduceSnRDao.getByProperty(ddlPackBean);
|
||||
if (Objects.isNull(mesProduceSn)) {
|
||||
MesPcnException.throwFlowException("条码【%s】信息不存在", mesProduceSnPrintModel.getProductSn());
|
||||
}
|
||||
return mesProduceSn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MesProduceSnPrintModel doPrint(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
||||
//获取打印模板信息
|
||||
mesProduceSnPrintModel.setMesLabelTemplate(mesTemplateService.getMesLabelTemplate(mesProduceSnPrintModel.getPrintTemplate()));
|
||||
//条码生成
|
||||
if (StringUtils.isEmpty(mesProduceSnPrintModel.getProductSn())) {
|
||||
//物料信息
|
||||
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), mesProduceSnPrintModel.getOrganizeCode());
|
||||
//生成条码
|
||||
List<String> snList = getStringList(mesProduceSnPrintModel);
|
||||
for (String sn : snList) {
|
||||
mesProduceSnPrintModel.getMesProduceSnList().add(generateMesProduceSn(mesPart, sn, mesProduceSnPrintModel.getUserName()));
|
||||
}
|
||||
mesProduceSnRDao.saveAll(mesProduceSnPrintModel.getMesProduceSnList());
|
||||
//条码补打
|
||||
} else {
|
||||
mesProduceSnPrintModel.getMesProduceSnList().add(findMesProduceSn(mesProduceSnPrintModel));
|
||||
}
|
||||
return mesProduceSnPrintModel;
|
||||
}
|
||||
|
||||
private List<String> getStringList(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
||||
GenSerialNoModel genSerialNoModel = new GenSerialNoModel(mesProduceSnPrintModel.getSnRule());
|
||||
List<String> resultList = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getOrganizeCode(), mesProduceSnPrintModel.getPrintQty()).getResultList();
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName) {
|
||||
MesProduceSn mesProduceSn = new MesProduceSn();
|
||||
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
|
||||
mesProduceSn.setProductSn(sn);
|
||||
mesProduceSn.setCustSn(sn);
|
||||
mesProduceSn.setPartNo(mesPart.getPartNo());
|
||||
mesProduceSn.setPartName(mesPart.getPartName());
|
||||
mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate());
|
||||
mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate());
|
||||
mesProduceSn.setProdLabelTemplate(mesPart.getProductLabelTemplate());
|
||||
mesProduceSn.setQty(1d);
|
||||
mesProduceSn.setSnStatus(10);
|
||||
mesProduceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
||||
mesProduceSn.setLotNo(TimeTool.getDateTimeShort());
|
||||
mesProduceSn.setPrintCount(1);
|
||||
mesProduceSn.setPrintStatus(20);
|
||||
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
|
||||
ConvertBean.serviceModelInitialize(mesProduceSn, userName);
|
||||
return mesProduceSn;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
|
||||
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 条码补打Model
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/6/13 15:48
|
||||
* @Modify:
|
||||
**/
|
||||
@Data
|
||||
public class MesProduceSnPrintModel {
|
||||
|
||||
@ApiParam("工厂代码")
|
||||
private String organizeCode;
|
||||
|
||||
@ApiParam("物料号")
|
||||
private String partNo;
|
||||
|
||||
@ApiParam("物料名称")
|
||||
private String partName;
|
||||
|
||||
@ApiParam("条码")
|
||||
private String productSn;
|
||||
|
||||
@ApiParam("打印数量")
|
||||
private Integer printQty;
|
||||
|
||||
@ApiParam("标包数量")
|
||||
private Integer qty;
|
||||
|
||||
@ApiParam("打印模板")
|
||||
private String printTemplate;
|
||||
|
||||
@ApiParam("条码规则")
|
||||
private String snRule;
|
||||
|
||||
@ApiParam(name = "包装规则代码")
|
||||
private String packCode;
|
||||
|
||||
@ApiParam(name = "用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiParam(name = "打印模板信息")
|
||||
private MesLabelTemplate mesLabelTemplate;
|
||||
|
||||
@ApiParam(name = "产品条码信息")
|
||||
private List<MesProduceSn> mesProduceSnList = new ArrayList<>();
|
||||
}
|
Loading…
Reference in New Issue