diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgDetailService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgDetailService.java new file mode 100644 index 0000000..60845ad --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgDetailService.java @@ -0,0 +1,4 @@ +package cn.estsh.i3plus.ext.mes.pcn.api.busi; + +public interface IMesShippingKanbanCfgDetailService { +} diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgService.java new file mode 100644 index 0000000..153bd52 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgService.java @@ -0,0 +1,8 @@ +package cn.estsh.i3plus.ext.mes.pcn.api.busi; + +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanCfgModel; + +public interface IMesShippingKanbanCfgService { + MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode); + void saveShippingKanbanCfg(String organizeCode, MesShippingKanbanCfgModel request); +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgController.java new file mode 100644 index 0000000..9f3f417 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgController.java @@ -0,0 +1,54 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesShippingKanbanCfgService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanCfgModel; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesLoadingList; +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 io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +/** + * @Description: 产线与班组的对应关系 + * @Author: gsz + * @Date: 2024/5/25 18:16 + * @Modify: + */ +@RestController +@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesShippingKanbanCfg") +public class MesShippingKanbanCfgController { + @Autowired + private IMesShippingKanbanCfgService shippingKanbanCfgService; + + @GetMapping("/query") + @ApiOperation(value = "查询发运看板配置项") + public ResultBean queryShippingKanbanCfg(String organizeCode) { + try { + organizeCode = !StringUtils.isEmpty(organizeCode) ? organizeCode : AuthUtil.getOrganize().getOrganizeCode(); + return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanCfg(organizeCode)); + } catch (ImppBusiException imppException) { + return ResultBean.fail(imppException); + } catch (Exception e) { + return ImppExceptionBuilder.newInstance().buildExceptionResult(e); + } + } + + @PostMapping("/save") + @ApiOperation(value = "保存发运看板配置项") + public ResultBean saveShippingKanbanCfg(@RequestBody MesShippingKanbanCfgModel request) { + try { + String organizeCode = !StringUtils.isEmpty(request.getOrganizeCode()) ? request.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode(); + shippingKanbanCfgService.saveShippingKanbanCfg(organizeCode, request); + return ResultBean.success("保存成功"); + } 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/MesShippingKanbanCfgDetailController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgDetailController.java new file mode 100644 index 0000000..1007c3e --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgDetailController.java @@ -0,0 +1,16 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi; + +import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Description: 产线与班组的对应关系 + * @Author: gsz + * @Date: 2024/5/25 18:16 + * @Modify: + */ +@RestController +@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesShippingKanbanCfgDetail") +public class MesShippingKanbanCfgDetailController { +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgDetailServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgDetailServiceImpl.java new file mode 100644 index 0000000..542af33 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgDetailServiceImpl.java @@ -0,0 +1,8 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesShippingKanbanCfgDetailService; +import org.springframework.stereotype.Service; + +@Service +public class MesShippingKanbanCfgDetailServiceImpl implements IMesShippingKanbanCfgDetailService { +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java new file mode 100644 index 0000000..d4a5f1b --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java @@ -0,0 +1,78 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesShippingKanbanCfgService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanCfgModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.platform.common.tool.TimeTool; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingKanbanCfg; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingKanbanCfgDetail; +import cn.estsh.i3plus.pojo.mes.repository.MesShippingKanbanCfgDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesShippingKanbanCfgRepository; +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 java.util.List; + +@Service +public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgService { + @Autowired + private MesShippingKanbanCfgRepository shippingKanbanCfgRDao; + @Autowired + private MesShippingKanbanCfgDetailRepository shippingKanbanCfgDetailRDao; + + @Override + public MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode) { + MesShippingKanbanCfgModel model = new MesShippingKanbanCfgModel(); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + MesShippingKanbanCfg kanbanCfg = shippingKanbanCfgRDao.getByProperty(packBean); + model.setConfig(kanbanCfg); + if (kanbanCfg != null) { + DdlPackBean detailPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getNumberBiggerEqualPack(kanbanCfg.getId(), "configID", packBean); + List details = shippingKanbanCfgDetailRDao.findByHqlWhere(detailPackBean); + model.setDetails(details); + } + + return model; + } + + @Override + public void saveShippingKanbanCfg(String organizeCode, MesShippingKanbanCfgModel request) { + if (request.getConfig() == null) { + return; + } + + MesShippingKanbanCfg cfg = request.getConfig(); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + MesShippingKanbanCfg oldCfg = shippingKanbanCfgRDao.getByProperty(packBean); + if (oldCfg == null) { + oldCfg = shippingKanbanCfgRDao.insert(cfg); + } else { + oldCfg.setShippingGroupCode(cfg.getShippingGroupCode()); + oldCfg.setRefreshFrequency(cfg.getRefreshFrequency()); + oldCfg.setKanbanName(cfg.getKanbanName()); + oldCfg.setOnlinePoint(cfg.getOnlinePoint()); + oldCfg.setAdjustValue(cfg.getAdjustValue()); + oldCfg.setRefinedPoint(cfg.getRefinedPoint()); + oldCfg.setOnWayDate(cfg.getOnWayDate()); + oldCfg.setCustStartShift(cfg.getCustStartShift()); + oldCfg.setInterStartShift(cfg.getInterStartShift()); + oldCfg.setCustJph(cfg.getCustJph()); + shippingKanbanCfgRDao.update(oldCfg); + + shippingKanbanCfgDetailRDao.deleteByProperties(new String[]{"organizeCode", "configID"}, + new Object[]{organizeCode, oldCfg.getId()}); + } + + if (!CollectionUtils.isEmpty(request.getDetails())) { + for (MesShippingKanbanCfgDetail detail : request.getDetails()) { + detail.setConfigID(oldCfg.getId()); + shippingKanbanCfgDetailRDao.insert(detail); + } + } + } +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanCfgModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanCfgModel.java new file mode 100644 index 0000000..918c41c --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanCfgModel.java @@ -0,0 +1,20 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.model; + +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingKanbanCfg; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingKanbanCfgDetail; +import io.swagger.annotations.ApiParam; +import lombok.Data; + +import java.util.List; + +@Data +public class MesShippingKanbanCfgModel { + @ApiParam("组织代码") + private String organizeCode; + + @ApiParam("看板配置项") + private MesShippingKanbanCfg config; + + @ApiParam("看板配置明细") + private List details; +}