From 2a665781f675dfa9202a267efa879289b1e914d7 Mon Sep 17 00:00:00 2001 From: jun Date: Thu, 13 Jun 2024 22:28:16 +0800 Subject: [PATCH] =?UTF-8?q?PCN=E6=9D=A1=E7=A0=81=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/mes/pcn/api/base/IMesPartService.java | 22 ++++ .../ext/mes/pcn/api/base/IMesTemplateService.java | 16 +++ .../pcn/api/busi/IMesProduceSnPrintService.java | 20 +++ .../controller/busi/MesPartController.java | 43 +++++++ .../busi/MesProduceSnPrintController.java | 81 ++++++++++++ .../serviceimpl/base/MesPartServiceImpl.java | 51 ++++++++ .../serviceimpl/base/MesTemplateServiceImpl.java | 57 +++++++++ .../busi/MesProduceSnPrintServiceImpl.java | 136 +++++++++++++++++++++ .../mes/pcn/pojo/model/MesProduceSnPrintModel.java | 56 +++++++++ 9 files changed, 482 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPartService.java create mode 100644 modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesTemplateService.java create mode 100644 modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProduceSnPrintService.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartController.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesProduceSnPrintController.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPartServiceImpl.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesTemplateServiceImpl.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintServiceImpl.java create mode 100644 modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesProduceSnPrintModel.java diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPartService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPartService.java new file mode 100644 index 0000000..da46c8e --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPartService.java @@ -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 queryMesPart(MesPart mesPart, Pager pager); + + @ApiOperation(value = "根据物料代码查询物料信息") + MesPart getMesPartByPartNo(String partNo,String organizeCode); +} diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesTemplateService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesTemplateService.java new file mode 100644 index 0000000..ec503a2 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesTemplateService.java @@ -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); +} diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProduceSnPrintService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProduceSnPrintService.java new file mode 100644 index 0000000..97ab747 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProduceSnPrintService.java @@ -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 findMesPackingDefine(MesProduceSnPrintModel mesProduceSnPrintModel); + + @ApiOperation(value = "查询条码信息") + MesProduceSn findMesProduceSn(MesProduceSnPrintModel mesProduceSnPrintModel); + + @ApiOperation(value = "打印") + MesProduceSnPrintModel doPrint(MesProduceSnPrintModel mesProduceSnPrintModel); +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartController.java new file mode 100644 index 0000000..7b08899 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartController.java @@ -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); + } + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesProduceSnPrintController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesProduceSnPrintController.java new file mode 100644 index 0000000..5d6b34a --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesProduceSnPrintController.java @@ -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); + } + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPartServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPartServiceImpl.java new file mode 100644 index 0000000..729a009 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPartServiceImpl.java @@ -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 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 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; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesTemplateServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesTemplateServiceImpl.java new file mode 100644 index 0000000..c769840 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesTemplateServiceImpl.java @@ -0,0 +1,57 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base; + +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; +import cn.estsh.i3plus.platform.common.util.MesPcnConstWords; +import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; +import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate; +import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateParam; +import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository; +import org.apache.shiro.util.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Description : 打印模板 + * @Reference : + * @Author : junsheng.li + * @CreateDate 2024/6/13 17:51 + * @Modify: + **/ +@Service +public class MesTemplateServiceImpl implements IMesTemplateService { + + @Autowired + private MesLabelTemplateRepository mesLabelTemplateRDao; + + @Autowired + private MesLabelTemplateParamRepository mesLabelTemplateParamRDao; + + @Override + public MesLabelTemplate getMesLabelTemplate(String templateCode) { + // 根据标签模板代码,查询【MES_标签模板表】,获取对应的方法代码 + MesLabelTemplate labelTemplate = mesLabelTemplateRDao.getByProperty( + new String[]{MesPcnConstWords.IS_VALID, MesPcnConstWords.IS_DELETED, "templateCode"}, + new Object[]{CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), templateCode}); + + if (labelTemplate == null) { + MesPcnException.throwFlowException("标签模板代码【%s】在标签模板表不存在!", templateCode); + } + + // 根据模板代码查询模板参数信息 + List templateParamList = mesLabelTemplateParamRDao.findByProperty(new String[]{"templateCode", + MesPcnConstWords.IS_VALID, MesPcnConstWords.IS_DELETED}, + new Object[]{templateCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), + CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()}); + + if (CollectionUtils.isEmpty(templateParamList)) { + MesPcnException.throwFlowException("标签模板代码【%s】在标签模板明细表不存在!", templateCode); + } + labelTemplate.setLabelTemplateParamList(templateParamList); + + return labelTemplate; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintServiceImpl.java new file mode 100644 index 0000000..ec3987a --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintServiceImpl.java @@ -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 findMesPackingDefine(MesProduceSnPrintModel mesProduceSnPrintModel) { + //查询包装定义明细 + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "partNo", ddlPackBean); + List 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 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 getStringList(MesProduceSnPrintModel mesProduceSnPrintModel) { + GenSerialNoModel genSerialNoModel = new GenSerialNoModel(mesProduceSnPrintModel.getSnRule()); + List 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; + } +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesProduceSnPrintModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesProduceSnPrintModel.java new file mode 100644 index 0000000..13c8426 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesProduceSnPrintModel.java @@ -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 mesProduceSnList = new ArrayList<>(); +}