From 54ce53f6383e0401bcd4bb359a57550ede2977f6 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 19 Feb 2025 13:18:17 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=BE=99=E5=85=B4?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busi/IMesShippingKanbanCfgDetailService.java | 4 ++ .../pcn/api/busi/IMesShippingKanbanCfgService.java | 8 +++ .../busi/MesShippingKanbanCfgController.java | 54 +++++++++++++++ .../busi/MesShippingKanbanCfgDetailController.java | 16 +++++ .../MesShippingKanbanCfgDetailServiceImpl.java | 8 +++ .../busi/MesShippingKanbanCfgServiceImpl.java | 78 ++++++++++++++++++++++ .../pcn/pojo/model/MesShippingKanbanCfgModel.java | 20 ++++++ 7 files changed, 188 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgDetailService.java create mode 100644 modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgService.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgController.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgDetailController.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgDetailServiceImpl.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java create mode 100644 modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanCfgModel.java 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; +} From d765e02a4bf1c29de958a13ad8466910656f3850 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 21 Feb 2025 15:18:02 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=BE=99=E5=85=B4?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/IMesShippingKanbanCfgService.java | 4 + .../busi/MesShippingKanbanCfgController.java | 13 ++++ .../busi/MesShippingKanbanCfgServiceImpl.java | 90 +++++++++++++++++++++- .../pcn/pojo/model/MesShippingKanbanViewModel.java | 23 ++++++ 4 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanViewModel.java 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 index 153bd52..6a99563 100644 --- 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 @@ -1,8 +1,12 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanCfgModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanViewModel; + +import java.util.List; public interface IMesShippingKanbanCfgService { MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode); void saveShippingKanbanCfg(String organizeCode, MesShippingKanbanCfgModel request); + List queryShippingKanbanContext(String organizeCode); } 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 index 9f3f417..7c78aad 100644 --- 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 @@ -51,4 +51,17 @@ public class MesShippingKanbanCfgController { return ImppExceptionBuilder.newInstance().buildExceptionResult(e); } } + + @GetMapping("/queryContext") + @ApiOperation(value = "查询发运看板内容") + public ResultBean queryShippingKanbanContext(String organizeCode) { + try { + organizeCode = !StringUtils.isEmpty(organizeCode) ? organizeCode : AuthUtil.getOrganize().getOrganizeCode(); + return ResultBean.success("查询成功").setResultList(shippingKanbanCfgService.queryShippingKanbanContext(organizeCode)); + } 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/busi/MesShippingKanbanCfgServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java index d4a5f1b..7e7c632 100644 --- 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 @@ -2,6 +2,7 @@ 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.model.MesShippingKanbanViewModel; 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; @@ -14,8 +15,10 @@ 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.*; +import java.util.stream.Collectors; @Service public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgService { @@ -32,7 +35,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer model.setConfig(kanbanCfg); if (kanbanCfg != null) { DdlPackBean detailPackBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getNumberBiggerEqualPack(kanbanCfg.getId(), "configID", packBean); + DdlPreparedPack.getNumEqualPack(kanbanCfg.getId(), "configID", packBean); List details = shippingKanbanCfgDetailRDao.findByHqlWhere(detailPackBean); model.setDetails(details); } @@ -75,4 +78,87 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer } } } + + @Override + public List queryShippingKanbanContext(String organizeCode) { + List viewModels = new ArrayList<>(); + Map cfgDetailMap = null; + MesShippingKanbanCfgModel cfgModel = queryShippingKanbanCfg(organizeCode); + if (cfgModel != null && !CollectionUtils.isEmpty(cfgModel.getDetails())) { + cfgDetailMap = cfgModel.getDetails().stream().collect(Collectors.toMap(MesShippingKanbanCfgDetail::getDetailCode, v -> v)); + } + + for (MesExtEnumUtil.SHIPPING_KANBAN_DETAIL_INDEX index : MesExtEnumUtil.SHIPPING_KANBAN_DETAIL_INDEX.values()) { + MesShippingKanbanCfgDetail cfgDetail = cfgDetailMap != null ? cfgDetailMap.get(index.getValue()) : null; + if (cfgDetail == null || cfgDetail.getIsShow() == null || !cfgDetail.getIsShow() || cfgDetail.getOrderNumber() == null) { + continue; + } + + MesShippingKanbanViewModel model = new MesShippingKanbanViewModel(); + model.setDetailName(index.getDescription()); + model.setOrderNumber(cfgDetail.getOrderNumber()); + String rangDescription = ""; + if (!StringUtils.isEmpty(cfgDetail.getRangValueLess())) { + rangDescription += "<" + cfgDetail.getRangValueLess(); + } + if (!StringUtils.isEmpty(cfgDetail.getRangValueMore())) { + if (StringUtils.isEmpty(rangDescription)) { + rangDescription += "&"; + } + rangDescription += ">=" + cfgDetail.getRangValueMore(); + } + model.setRangDescription(rangDescription); + List values = null; + switch (index) { + case CLIENT_STOCK_QTY: + values = getClientStockQty(cfgDetail); + break; + case WAIT_SHIPPING_QTY: + values = getWaitShippingQty(cfgDetail); + break; + case CP_WAIT_SHIPPING_QTY: + break; + case WAIT_PRODUCT_QTY: + break; + case LAST_SHIPPING_TIME: + break; + case CP_LAST_SHIPPING_TIME: + break; + case NEXT_SHIPPING_TIME: + break; + case TREE_STOP_WARNING: + break; + case SHIPPING_VIN: + break; + case CP_SHIPPING_VIN: + break; + case TODAY_ONLINE: + break; + case TODAY_SHIPPING: + break; + case TODAY_CAR: + break; + case CLIENT_JPH: + break; + case PRODUCT_JPH: + break; + } + model.setValues(values); + viewModels.add(model); + } + viewModels.sort(Comparator.comparing(MesShippingKanbanViewModel::getOrderNumber)); + return viewModels; + } + + private List getClientStockQty(MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + + return values; + } + + private List getWaitShippingQty(MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + + return values; + } } diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanViewModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanViewModel.java new file mode 100644 index 0000000..eec677f --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanViewModel.java @@ -0,0 +1,23 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.model; + +import io.swagger.annotations.ApiParam; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class MesShippingKanbanViewModel { + + @ApiParam("名称") + private String detailName; + + @ApiParam("排序") + private Integer orderNumber; + + @ApiParam("计算值") + private List values = new ArrayList<>(); + + @ApiParam("范围描述") + private String rangDescription; +} From 0dc14ff147e6e33ac0a78ccd988dc64a9488d43a Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 24 Feb 2025 21:24:13 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BE=99=E5=85=B4?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/IMesShippingKanbanCfgService.java | 2 +- .../busi/MesShippingKanbanCfgController.java | 3 +- .../busi/MesShippingKanbanCfgServiceImpl.java | 850 ++++++++++++++++++++- .../pcn/pojo/model/MesShippingKanbanCfgModel.java | 3 + .../pcn/pojo/model/MesShippingKanbanViewModel.java | 3 + 5 files changed, 851 insertions(+), 10 deletions(-) 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 index 6a99563..768d560 100644 --- 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 @@ -7,6 +7,6 @@ import java.util.List; public interface IMesShippingKanbanCfgService { MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode); - void saveShippingKanbanCfg(String organizeCode, MesShippingKanbanCfgModel request); + void saveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username); List queryShippingKanbanContext(String organizeCode); } 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 index 7c78aad..62d5069 100644 --- 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 @@ -43,7 +43,7 @@ public class MesShippingKanbanCfgController { public ResultBean saveShippingKanbanCfg(@RequestBody MesShippingKanbanCfgModel request) { try { String organizeCode = !StringUtils.isEmpty(request.getOrganizeCode()) ? request.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode(); - shippingKanbanCfgService.saveShippingKanbanCfg(organizeCode, request); + shippingKanbanCfgService.saveShippingKanbanCfg(request, organizeCode, request.getUsername()); return ResultBean.success("保存成功"); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); @@ -61,6 +61,7 @@ public class MesShippingKanbanCfgController { } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); } catch (Exception e) { + e.printStackTrace(); 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/busi/MesShippingKanbanCfgServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java index 7e7c632..5b5c08b 100644 --- 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 @@ -4,19 +4,36 @@ 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.model.MesShippingKanbanViewModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.mes.pcn.util.DateUtil; +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.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; +import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresJisVinOverPoint; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesLoadingListDetail; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingKanbanCfg; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingKanbanCfgDetail; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; +import cn.estsh.i3plus.pojo.mes.repository.MesPartShippingGroupRepository; import cn.estsh.i3plus.pojo.mes.repository.MesShippingKanbanCfgDetailRepository; import cn.estsh.i3plus.pojo.mes.repository.MesShippingKanbanCfgRepository; +import cn.estsh.i3plus.pojo.mes.repository.seres.IMesCimSeresJisVinOverPointRepository; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -26,25 +43,49 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer private MesShippingKanbanCfgRepository shippingKanbanCfgRDao; @Autowired private MesShippingKanbanCfgDetailRepository shippingKanbanCfgDetailRDao; + @Autowired + private MesPartShippingGroupRepository partShippingGroupRDao; + @Autowired + private IMesCimSeresJisVinOverPointRepository vinOverPointRDao; + @Autowired + private EntityManager entityManager; @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.getNumEqualPack(kanbanCfg.getId(), "configID", packBean); List details = shippingKanbanCfgDetailRDao.findByHqlWhere(detailPackBean); model.setDetails(details); + } else { + kanbanCfg = new MesShippingKanbanCfg(); + } + model.setConfig(kanbanCfg); + + if (model.getDetails() == null) { + model.setDetails(new ArrayList<>()); + } + Map cfgDetailMap = model.getDetails().stream().collect(Collectors.toMap(MesShippingKanbanCfgDetail::getDetailCode, v -> v)); + for (MesExtEnumUtil.SHIPPING_KANBAN_DETAIL_INDEX index : MesExtEnumUtil.SHIPPING_KANBAN_DETAIL_INDEX.values()) { + if (cfgDetailMap.containsKey(index.getValue())) { + continue; + } + MesShippingKanbanCfgDetail detail = new MesShippingKanbanCfgDetail(); + detail.setConfigID(kanbanCfg.getId()); + detail.setDetailCode(index.getValue()); + detail.setDetailName(index.getDescription()); + detail.setIsShow(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); + model.getDetails().add(detail); } return model; } @Override - public void saveShippingKanbanCfg(String organizeCode, MesShippingKanbanCfgModel request) { + public void saveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username) { if (request.getConfig() == null) { return; } @@ -53,6 +94,8 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); MesShippingKanbanCfg oldCfg = shippingKanbanCfgRDao.getByProperty(packBean); if (oldCfg == null) { + cfg.setOrganizeCode(organizeCode); + ConvertBean.serviceModelInitialize(cfg, username); oldCfg = shippingKanbanCfgRDao.insert(cfg); } else { oldCfg.setShippingGroupCode(cfg.getShippingGroupCode()); @@ -65,6 +108,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer oldCfg.setCustStartShift(cfg.getCustStartShift()); oldCfg.setInterStartShift(cfg.getInterStartShift()); oldCfg.setCustJph(cfg.getCustJph()); + ConvertBean.serviceModelUpdate(oldCfg, username); shippingKanbanCfgRDao.update(oldCfg); shippingKanbanCfgDetailRDao.deleteByProperties(new String[]{"organizeCode", "configID"}, @@ -73,7 +117,10 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer if (!CollectionUtils.isEmpty(request.getDetails())) { for (MesShippingKanbanCfgDetail detail : request.getDetails()) { + detail.setId(null); detail.setConfigID(oldCfg.getId()); + detail.setOrganizeCode(oldCfg.getOrganizeCode()); + ConvertBean.serviceModelInitialize(detail, username); shippingKanbanCfgDetailRDao.insert(detail); } } @@ -84,13 +131,17 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List viewModels = new ArrayList<>(); Map cfgDetailMap = null; MesShippingKanbanCfgModel cfgModel = queryShippingKanbanCfg(organizeCode); - if (cfgModel != null && !CollectionUtils.isEmpty(cfgModel.getDetails())) { + MesShippingKanbanCfg cfg = cfgModel != null ? cfgModel.getConfig() : null; + if (cfg == null) { + return viewModels; + } + if (!CollectionUtils.isEmpty(cfgModel.getDetails())) { cfgDetailMap = cfgModel.getDetails().stream().collect(Collectors.toMap(MesShippingKanbanCfgDetail::getDetailCode, v -> v)); } for (MesExtEnumUtil.SHIPPING_KANBAN_DETAIL_INDEX index : MesExtEnumUtil.SHIPPING_KANBAN_DETAIL_INDEX.values()) { MesShippingKanbanCfgDetail cfgDetail = cfgDetailMap != null ? cfgDetailMap.get(index.getValue()) : null; - if (cfgDetail == null || cfgDetail.getIsShow() == null || !cfgDetail.getIsShow() || cfgDetail.getOrderNumber() == null) { + if (cfgDetail == null || cfgDetail.getIsShow() == null || cfgDetail.getIsShow() != CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue() || cfgDetail.getOrderNumber() == null) { continue; } @@ -111,54 +162,837 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List values = null; switch (index) { case CLIENT_STOCK_QTY: - values = getClientStockQty(cfgDetail); + values = getClientStockQty(cfg, cfgDetail); break; case WAIT_SHIPPING_QTY: - values = getWaitShippingQty(cfgDetail); + values = getWaitShippingQty(cfg, cfgDetail); break; case CP_WAIT_SHIPPING_QTY: + values = getCPWaitShippingQty(cfg, cfgDetail); break; case WAIT_PRODUCT_QTY: + values = getWaitProductQty(cfg, cfgDetail); break; case LAST_SHIPPING_TIME: + values = getLastShippingTime(cfg, cfgDetail); break; case CP_LAST_SHIPPING_TIME: + values = getCPLastShippingTime(cfg, cfgDetail); break; case NEXT_SHIPPING_TIME: + values = getNextShippingTime(cfg, cfgDetail); break; case TREE_STOP_WARNING: + values = getTreeStopWarning(cfg, cfgDetail); break; case SHIPPING_VIN: + values = getShippingVin(cfg, cfgDetail); break; case CP_SHIPPING_VIN: + values = getCPShippingVin(cfg, cfgDetail); break; case TODAY_ONLINE: + values = getTodayOnline(cfg, cfgDetail); break; case TODAY_SHIPPING: + values = getTodayShipping(cfg, cfgDetail); break; case TODAY_CAR: + values = getTodayCar(cfg, cfgDetail); break; case CLIENT_JPH: + values = getClientJPH(cfg, cfgDetail); break; case PRODUCT_JPH: + values = getProductJPH(cfg, cfgDetail); break; } + if (values == null) { + values = new ArrayList<>(); + } model.setValues(values); + model.setColor(getColor(cfgDetail, values)); viewModels.add(model); } viewModels.sort(Comparator.comparing(MesShippingKanbanViewModel::getOrderNumber)); return viewModels; } - private List getClientStockQty(MesShippingKanbanCfgDetail cfgDetail) { + private String getColor(MesShippingKanbanCfgDetail cfgDetail, List values) { + if (CollectionUtils.isEmpty(values)) { + return cfgDetail.getDefaultColor(); + } + if (!StringUtils.isEmpty(cfgDetail.getRangValueLess())) { + String rangValue = cfgDetail.getRangValueLess(); + for (String value : values) { + if (StringUtils.isEmpty(value)) { + continue; + } + if (NumberUtil.isNumber(value)) { + if (Integer.parseInt(value) < Integer.parseInt(rangValue)) { + return cfgDetail.getRangColorLess(); + } + } else { + if (value.compareTo(rangValue) < 0) { + return cfgDetail.getRangColorLess(); + } + } + } + } + + if (!StringUtils.isEmpty(cfgDetail.getRangValueMore())) { + String rangValue = cfgDetail.getRangValueMore(); + for (String value : values) { + if (StringUtils.isEmpty(value)) { + continue; + } + if (NumberUtil.isNumber(value)) { + if (Integer.parseInt(value) >= Integer.parseInt(rangValue)) { + return cfgDetail.getRangColorMore(); + } + } else { + if (value.compareTo(rangValue) >= 0) { + return cfgDetail.getRangColorMore(); + } + } + } + } + + return cfgDetail.getDefaultColor(); + } + + private List getShippingGroups(MesShippingKanbanCfg cfg) { + List shippingGroups = new ArrayList<>(); + if (StringUtils.isEmpty(cfg.getShippingGroupCode())) { + return shippingGroups; + } + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return shippingGroups; + } + DdlPackBean packBean = DdlPackBean.getDdlPackBean(cfg.getOrganizeCode()); + DdlPreparedPack.getInPackList(strShippingGroupList, "shippingGroupCode", packBean); + return partShippingGroupRDao.findByHqlWhere(packBean); + } + + private String getShippingVin(String organizeCode, List shippingGroupCodes, List status) { + StringBuilder hql = new StringBuilder(); + hql.append("select sd.vin"); + hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); + hql.append(" and s.status in (:status) "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" ORDER BY sd.id desc"); + return entityManager.createQuery(hql.toString(), String.class) + .setParameter("organizeCode", organizeCode) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", status) + .setParameter("shippingGroupCode", shippingGroupCodes) + .setMaxResults(1) + .getSingleResult(); + } + + /** + * 最新下线的排序发运单客户流水号 + * @param organizeCode + * @param shippingGroupCodes + * @return + */ + private String getMaxOffNumber(String organizeCode, List shippingGroupCodes) { + String vinCode = getShippingVin(organizeCode, shippingGroupCodes, Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())); + StringBuilder offNumberHql = new StringBuilder(); + offNumberHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); + offNumberHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); + offNumberHql.append(" and vin = :vin "); + return entityManager.createQuery(offNumberHql.toString(), String.class) + .setParameter("organizeCode", organizeCode) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("vin", vinCode) + .getSingleResult(); + } + + private List getClientStockQty(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return values; + } + + // 获取赛力斯上线的最新流水号 + String onNumber = ""; + if (!StringUtils.isEmpty(cfg.getOnlinePoint())) { + StringBuilder onNumberHql = new StringBuilder(); + onNumberHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); + onNumberHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); + onNumberHql.append(" and overPoint = :overPoint "); + onNumber = entityManager.createQuery(onNumberHql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getOnlinePoint()) + .getSingleResult(); + } + if (StringUtils.isEmpty(onNumber)) { + onNumber = "0"; + } + + String offNumber = getMaxOffNumber(cfg.getOrganizeCode(), strShippingGroupList); + if (StringUtils.isEmpty(offNumber)) { + offNumber = "0"; + } + int adjustValue = cfg.getAdjustValue() != null ? cfg.getAdjustValue() : 0; + int result = Integer.parseInt(offNumber) - Integer.parseInt(onNumber) + adjustValue; + values.add(String.valueOf(result)); return values; } - private List getWaitShippingQty(MesShippingKanbanCfgDetail cfgDetail) { + private List getWaitShippingQty(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return values; + } + + if (strShippingGroupList.stream().anyMatch(s -> s.contains("CK"))) { + // 获获取精排信息点的流水号 + String refinedPointNumber = ""; + if (!StringUtils.isEmpty(cfg.getRefinedPoint())) { + StringBuilder refinedPointHql = new StringBuilder(); + refinedPointHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); + refinedPointHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); + refinedPointHql.append(" and overPoint = :overPoint "); + refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getRefinedPoint()) + .getSingleResult(); + } + if (StringUtils.isEmpty(refinedPointNumber)) { + refinedPointNumber = "0"; + } + + String offNumber = getMaxOffNumber(cfg.getOrganizeCode(), strShippingGroupList); + if (StringUtils.isEmpty(offNumber)) { + offNumber = "0"; + } + + int result = Integer.parseInt(refinedPointNumber) - Integer.parseInt(offNumber); + values.add(String.valueOf(result)); + } else { + StringBuilder hql = new StringBuilder(); + hql.append("select new Map(s.shippingGroupCode as shippingGroupCode, COUNT(sd.id) as COUNT)"); + hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); + hql.append(" and s.status = :status "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" group by s.shippingGroupCode"); + List ddd = entityManager.createQuery(hql.toString()) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue()) + .setParameter("shippingGroupCode", strShippingGroupList) + .getResultList(); + Map shippingGroupCount = new HashMap<>(); + if (!CollectionUtils.isEmpty(ddd)) { + for (Map dd : ddd) { + shippingGroupCount.put(dd.get("shippingGroupCode").toString(), dd.get("COUNT").toString()); + } + } + for (String shippingGroupCode : strShippingGroupList) { + values.add(shippingGroupCount.getOrDefault(shippingGroupCode, "0")); + } + } + return values; + } + + private List getCPWaitShippingQty(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return values; + } + + if (strShippingGroupList.stream().anyMatch(s -> s.contains("CK"))) { + // 获获取精排信息点的流水号 + String refinedPointNumber = ""; + if (!StringUtils.isEmpty(cfg.getRefinedPoint())) { + StringBuilder refinedPointHql = new StringBuilder(); + refinedPointHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); + refinedPointHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); + refinedPointHql.append(" and overPoint = :overPoint "); + refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getRefinedPoint()) + .getSingleResult(); + } + if (StringUtils.isEmpty(refinedPointNumber)) { + refinedPointNumber = "0"; + } + + strShippingGroupList = strShippingGroupList.stream().filter(s -> s.contains("CK")).collect(Collectors.toList()); + String offNumber = getMaxOffNumber(cfg.getOrganizeCode(), strShippingGroupList); + if (StringUtils.isEmpty(offNumber)) { + offNumber = "0"; + } + + int result = Integer.parseInt(refinedPointNumber) - Integer.parseInt(offNumber); + values.add(String.valueOf(result)); + } else { + values.add("0"); + } + return values; + } + + /** + * 待生产/装箱数量 + * @param cfg + * @param cfgDetail + * @return + */ + private List getWaitProductQty(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return values; + } + + if (strShippingGroupList.stream().anyMatch(s -> s.contains("CK"))) { + values.add("0"); + } else { + // 获获取精排信息点的流水号 + String refinedPointNumber = ""; + if (!StringUtils.isEmpty(cfg.getRefinedPoint())) { + StringBuilder refinedPointHql = new StringBuilder(); + refinedPointHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); + refinedPointHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); + refinedPointHql.append(" and overPoint = :overPoint "); + refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getRefinedPoint()) + .getSingleResult(); + } + if (StringUtils.isEmpty(refinedPointNumber)) { + refinedPointNumber = "0"; + } + + StringBuilder hql = new StringBuilder(); + hql.append("select new Map(s.shippingGroupCode as shippingGroupCode, max(sd.custInfoSeq) as custInfoSeq)"); + hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); + hql.append(" and s.status in (:status) "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" group by s.shippingGroupCode"); + List ddd = entityManager.createQuery(hql.toString()) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getResultList(); + Map shippingGroupCount = new HashMap<>(); + if (!CollectionUtils.isEmpty(ddd)) { + for (Map dd : ddd) { + Object custInfoSeq = dd.get("custInfoSeq"); + if (custInfoSeq != null) { + shippingGroupCount.put(dd.get("shippingGroupCode").toString(), custInfoSeq.toString()); + } + } + } + for (String shippingGroupCode : strShippingGroupList) { + if (shippingGroupCount.containsKey(shippingGroupCode)) { + values.add(Integer.parseInt(refinedPointNumber) - Integer.parseInt(shippingGroupCount.get(shippingGroupCode)) + ""); + } else { + values.add("0"); + } + } + } + return values; + } + + /** + * 距离上一次发运时间(Min) + * @param cfg + * @param cfgDetail + * @return + */ + private List getLastShippingTime(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return values; + } + + if (strShippingGroupList.stream().anyMatch(s -> s.contains("CK"))) { + StringBuilder hql = new StringBuilder(); + hql.append("select max(s.endScanTime)"); + hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); + hql.append(" and s.status in (:status) "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + String strScanEndTime = entityManager.createQuery(hql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getSingleResult(); + if (!StringUtils.isEmpty(strScanEndTime)) { + Date scanEndTime = DateUtil.parse(strScanEndTime); + values.add(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, scanEndTime)); + } + } else { + StringBuilder hql = new StringBuilder(); + hql.append("select new Map(s.shippingGroupCode as shippingGroupCode, max(l.endScanTime) as endScanTime)"); + hql.append(" from MesLoadingList l inner join MesLoadingListDetail ld on l.id = ld.pid inner join MesShippingOrderManagement s on s.id = ld.shippingId and l.organizeCode = :organizeCode and l.isDeleted=:isDeleted and l.isValid=:isValid "); + hql.append(" and l.status in (:status) "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" group by s.shippingGroupCode"); + List ddd = entityManager.createQuery(hql.toString()) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.LOADING_ORDER_STATUS.LOADED.getValue(), MesExtEnumUtil.LOADING_ORDER_STATUS.SHIPPING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getResultList(); + Map shippingGroupCount = new HashMap<>(); + if (!CollectionUtils.isEmpty(ddd)) { + for (Map dd : ddd) { + Object endScanTime = dd.get("endScanTime"); + if (endScanTime != null) { + shippingGroupCount.put(dd.get("shippingGroupCode").toString(), endScanTime.toString()); + } + } + } + for (String shippingGroupCode : strShippingGroupList) { + if (shippingGroupCount.containsKey(shippingGroupCode)) { + String strScanEndTime = shippingGroupCount.get(shippingGroupCode); + if (!StringUtils.isEmpty(strScanEndTime)) { + Date scanEndTime = DateUtil.parse(strScanEndTime); + values.add(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, scanEndTime)); + } + } else { + values.add(""); + } + } + } + return values; + } + + private List getCPLastShippingTime(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(cfg.getOrganizeCode()); + List shippingGroups = partShippingGroupRDao.findByHqlWhere(packBean); + if (CollectionUtils.isEmpty(shippingGroups)) { + return values; + } + + List strShippingGroupList = shippingGroups.stream().map(MesPartShippingGroup::getShippingGroupCode).collect(Collectors.toList()); + if (strShippingGroupList.stream().anyMatch(s -> s.contains("CK"))) { + strShippingGroupList = strShippingGroupList.stream().filter(s -> s.contains("CK")).collect(Collectors.toList()); + StringBuilder hql = new StringBuilder(); + hql.append("select max(s.endScanTime)"); + hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); + hql.append(" and s.status in (:status) "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + String strScanEndTime = entityManager.createQuery(hql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getSingleResult(); + if (!StringUtils.isEmpty(strScanEndTime)) { + Date scanEndTime = DateUtil.parse(strScanEndTime); + values.add(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, scanEndTime)); + } + } else { + values.add("0"); + } + return values; + } + + /** + * 下一车最晚发运时间 + * @param cfg + * @param cfgDetail + * @return + */ + private List getNextShippingTime(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + Date nowTime = DateUtil.now(); + //获取客户端库存 + List clientStockValue = getClientStockQty(cfg, cfgDetail); + if (StringUtils.isEmpty(clientStockValue)) { + return values; + } + //获取客户JPH + List customerJPHValue = getClientJPH(cfg, cfgDetail); + if (CollectionUtils.isEmpty(customerJPHValue)) { + return values; + } + double clientStock = Double.parseDouble(clientStockValue.get(0)); + double customerJPH = Double.parseDouble(customerJPHValue.get(0)); + //获取在途时间 + int onTheWayDate = cfg.getOnWayDate() != null ? cfg.getOnWayDate() : 0; + + //客户端库存除以客户JPH + double customerJPHInt = clientStock / customerJPH; + BigDecimal b = new BigDecimal(customerJPHInt); + customerJPHInt = b.setScale(1, RoundingMode.HALF_UP).doubleValue(); + + int minutes = (int)(customerJPHInt * 60); + Date newDate = DateUtil.addMinutes(nowTime, minutes - onTheWayDate); + values.add(DateUtil.formatDate(DateUtil.BASE_FORMAT3, newDate)); + return values; + } + + /** + * 三级停线预警(Min) + * @param cfg + * @param cfgDetail + * @return + */ + private List getTreeStopWarning(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + //获取客户端库存 + List nextShippingTimeValue = getNextShippingTime(cfg, cfgDetail); + if (StringUtils.isEmpty(nextShippingTimeValue)) { + return values; + } + Date nowTime = DateUtil.parse(DateUtil.formatDate(DateUtil.BASE_FORMAT3, DateUtil.now()), DateUtil.BASE_FORMAT3); + Date nextShippingTime = DateUtil.parse(nextShippingTimeValue.get(0), DateUtil.BASE_FORMAT3); + long minutes = DateUtil.minutesBetweenTwoTime(nextShippingTime, nowTime); + values.add(String.valueOf(minutes)); + return values; + } + + private List getShippingVin(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return values; + } + + if (strShippingGroupList.stream().anyMatch(s -> s.contains("CK"))) { + StringBuilder hql = new StringBuilder(); + hql.append("select sd.custInfoSeq"); + hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); + hql.append(" and s.status in (:status) "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" ORDER BY sd.id DESC"); + Long custInfoSeq = entityManager.createQuery(hql.toString(), Long.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getSingleResult(); + String strCustInfoSeq = custInfoSeq != null ? Long.toString(custInfoSeq) : ""; + if (strCustInfoSeq.length() >= 6) { + values.add(strCustInfoSeq.substring(strCustInfoSeq.length() - 6)); + } else { + values.add(strCustInfoSeq); + } + } else { + StringBuilder hql = new StringBuilder(); + hql.append("select new Map(s.shippingGroupCode as shippingGroupCode, max(sd.custInfoSeq) as custInfoSeq)"); + hql.append(" from MesLoadingList l inner join MesLoadingListDetail ld on l.id = ld.pid inner join MesShippingOrderManagement s on s.id = ld.shippingId inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and l.organizeCode = :organizeCode and l.isDeleted=:isDeleted and l.isValid=:isValid "); + hql.append(" and l.status in (:status) "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" group by s.shippingGroupCode"); + List ddd = entityManager.createQuery(hql.toString()) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.LOADING_ORDER_STATUS.LOADED.getValue(), MesExtEnumUtil.LOADING_ORDER_STATUS.SHIPPING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getResultList(); + + Map shippingGroupCount = new HashMap<>(); + if (!CollectionUtils.isEmpty(ddd)) { + for (Map dd : ddd) { + Object custInfoSeq = dd.get("custInfoSeq"); + if (custInfoSeq != null) { + shippingGroupCount.put(dd.get("shippingGroupCode").toString(), custInfoSeq.toString()); + } + } + } + for (String shippingGroupCode : strShippingGroupList) { + if (shippingGroupCount.containsKey(shippingGroupCode)) { + String strCustInfoSeq = shippingGroupCount.get(shippingGroupCode); + if (StringUtils.isEmpty(strCustInfoSeq)) { + strCustInfoSeq = "0"; + } + if (strCustInfoSeq.length() >= 6) { + values.add(strCustInfoSeq.substring(strCustInfoSeq.length() - 6)); + } else { + values.add(strCustInfoSeq); + } + } else { + values.add("0"); + } + } + } + return values; + } + + private List getCPShippingVin(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(cfg.getOrganizeCode()); + List shippingGroups = partShippingGroupRDao.findByHqlWhere(packBean); + if (CollectionUtils.isEmpty(shippingGroups)) { + return values; + } + + List strShippingGroupList = shippingGroups.stream().map(MesPartShippingGroup::getShippingGroupCode).collect(Collectors.toList()); + if (strShippingGroupList.stream().anyMatch(s -> s.contains("CK"))) { + strShippingGroupList = strShippingGroupList.stream().filter(s -> s.contains("CK")).collect(Collectors.toList()); + StringBuilder hql = new StringBuilder(); + hql.append("select sd.custInfoSeq"); + hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); + hql.append(" and s.status in (:status) "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" ORDER BY sd.id DESC"); + Long custInfoSeq = entityManager.createQuery(hql.toString(), Long.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getSingleResult(); + String strCustInfoSeq = custInfoSeq != null ? Long.toString(custInfoSeq) : ""; + if (strCustInfoSeq.length() >= 6) { + values.add(strCustInfoSeq.substring(strCustInfoSeq.length() - 6)); + } else { + values.add(strCustInfoSeq); + } + } else { + values.add("0"); + } + return values; + } + + /** + * 当天上线数 + * @param cfg + * @param cfgDetail + * @return + */ + private List getTodayOnline(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + if (StringUtils.isEmpty(cfg.getCustStartShift()) || StringUtils.isEmpty(cfg.getOnlinePoint())) { + return values; + } + + String startDateTime = ""; + String endDateTime = ""; + + Date nowTime = DateUtil.now(); + Date configTime = DateUtil.parse(cfg.getCustStartShift(), DateUtil.SHORT_FORMAT_HOUR); + Date currentTime = DateUtil.parse(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, nowTime), DateUtil.SHORT_FORMAT_HOUR); + if (!configTime.after(currentTime)) { + startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getCustStartShift(); + endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, 1)) + " " + cfg.getCustStartShift(); + } else { + //小于配置时间,如凌晨1点则跨天,需将当前时间减一天 + startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, -1)) + " " + cfg.getCustStartShift(); + endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getCustStartShift(); + } + + StringBuilder onNumberHql = new StringBuilder(); + onNumberHql.append("select count(1) from " + MesCimSeresJisVinOverPoint.class.getName()); + onNumberHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); + onNumberHql.append(" and overPoint = :overPoint "); + onNumberHql.append(" and createDatetime BETWEEN :startDateTime AND :endDateTime "); + Long onNumber = entityManager.createQuery(onNumberHql.toString(), Long.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getOnlinePoint()) + .setParameter("startDateTime", startDateTime) + .setParameter("endDateTime", endDateTime) + .getSingleResult(); + values.add(String.valueOf(onNumber != null ? onNumber : 0)); + return values; + } + + /** + * 当天发运数 + * @param cfg + * @param cfgDetail + * @return + */ + private List getTodayShipping(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList) || StringUtils.isEmpty(cfg.getInterStartShift())) { + return values; + } + + String startDateTime = ""; + String endDateTime = ""; + + Date nowTime = DateUtil.now(); + Date configTime = DateUtil.parse(cfg.getInterStartShift(), DateUtil.SHORT_FORMAT_HOUR); + Date currentTime = DateUtil.parse(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, nowTime), DateUtil.SHORT_FORMAT_HOUR); + if (!configTime.after(currentTime)) { + startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getInterStartShift(); + endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, 1)) + " " + cfg.getCustStartShift(); + } else { + //小于配置时间,如凌晨1点则跨天,需将当前时间减一天 + startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, -1)) + " " + cfg.getCustStartShift(); + endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getInterStartShift(); + } + + StringBuilder hql = new StringBuilder(); + hql.append("select new Map(s.shippingGroupCode as shippingGroupCode, count(sd.id) as totalCount)"); + hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); + hql.append(" and s.status in (:status) "); + hql.append(" and s.modifyDatetime BETWEEN :startDateTime AND :endDateTime "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" group by s.shippingGroupCode"); + List ddd = entityManager.createQuery(hql.toString()) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("startDateTime", startDateTime) + .setParameter("endDateTime", endDateTime) + .setParameter("shippingGroupCode", strShippingGroupList) + .getResultList(); + Map shippingGroupCount = new HashMap<>(); + if (!CollectionUtils.isEmpty(ddd)) { + for (Map dd : ddd) { + Object totalCount = dd.get("totalCount"); + if (totalCount != null) { + shippingGroupCount.put(dd.get("shippingGroupCode").toString(), totalCount.toString()); + } + } + } + for (String shippingGroupCode : strShippingGroupList) { + values.add(shippingGroupCount.getOrDefault(shippingGroupCode, "0")); + } + return values; + } + + /** + * 当天装车数 + * @param cfg + * @param cfgDetail + * @return + */ + private List getTodayCar(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList) || StringUtils.isEmpty(cfg.getInterStartShift())) { + return values; + } + + String startDateTime = ""; + String endDateTime = ""; + + Date nowTime = DateUtil.now(); + Date configTime = DateUtil.parse(cfg.getInterStartShift(), DateUtil.SHORT_FORMAT_HOUR); + Date currentTime = DateUtil.parse(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, nowTime), DateUtil.SHORT_FORMAT_HOUR); + if (!configTime.after(currentTime)) { + startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getInterStartShift(); + endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, 1)) + " " + cfg.getCustStartShift(); + } else { + //小于配置时间,如凌晨1点则跨天,需将当前时间减一天 + startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, -1)) + " " + cfg.getCustStartShift(); + endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getInterStartShift(); + } + + StringBuilder hql = new StringBuilder(); + hql.append("select new Map(s.shippingGroupCode as shippingGroupCode, sum(sd.planQty) as totalCount)"); + hql.append(" from MesLoadingList l inner join MesLoadingListDetail ld on l.id = ld.pid inner join MesShippingOrderManagement s on s.id = ld.shippingId inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and l.organizeCode = :organizeCode and l.isDeleted=:isDeleted and l.isValid=:isValid "); + hql.append(" and l.status = :status "); + hql.append(" and l.modifyDatetime BETWEEN :startDateTime AND :endDateTime "); + hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); + hql.append(" group by s.shippingGroupCode "); + List ddd = entityManager.createQuery(hql.toString()) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", MesExtEnumUtil.LOADING_ORDER_STATUS.SHIPPING.getValue()) + .setParameter("startDateTime", startDateTime) + .setParameter("endDateTime", endDateTime) + .setParameter("shippingGroupCode", strShippingGroupList) + .getResultList(); + + Map shippingGroupCount = new HashMap<>(); + if (!CollectionUtils.isEmpty(ddd)) { + for (Map dd : ddd) { + Object totalCount = dd.get("totalCount"); + if (totalCount != null) { + shippingGroupCount.put(dd.get("shippingGroupCode").toString(), totalCount.toString()); + } + } + } + for (String shippingGroupCode : strShippingGroupList) { + values.add(shippingGroupCount.getOrDefault(shippingGroupCode, "0")); + } + return values; + } + + /** + * 客户端JPH + * @param cfg + * @param cfgDetail + * @return + */ + private List getClientJPH(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return values; + } + + Date nowTime = DateUtil.now(); + Date prevHourTime = DateUtil.addMinutes(nowTime, -60); + + StringBuilder offNumberHql = new StringBuilder(); + offNumberHql.append("select count(1) from " + MesCimSeresJisVinOverPoint.class.getName()); + offNumberHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); + offNumberHql.append(" and createDatetime BETWEEN :startDateTime AND :endDateTime "); + offNumberHql.append(" and overPoint = :overPoint "); + Long vpCount = entityManager.createQuery(offNumberHql.toString(), Long.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("startDateTime", DateUtil.formatDate(nowTime)) + .setParameter("endDateTime", DateUtil.formatDate(prevHourTime)) + .setParameter("overPoint", cfg.getOnlinePoint()) + .getSingleResult(); + + if (vpCount == null || Objects.equals(vpCount, 0L)) { + values.add(cfg.getCustJph()); + } else { + values.add(vpCount.toString()); + } + return values; + } + + /** + * 生产JPH + * @param cfg + * @param cfgDetail + * @return + */ + private List getProductJPH(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { + List values = new ArrayList<>(); + List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); + if (CollectionUtils.isEmpty(strShippingGroupList)) { + return values; + } + Date nowTime = DateUtil.now(); + Date prevHourTime = DateUtil.addMinutes(nowTime, -60); return values; } } 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 index 918c41c..663b736 100644 --- 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 @@ -12,6 +12,9 @@ public class MesShippingKanbanCfgModel { @ApiParam("组织代码") private String organizeCode; + @ApiParam("用户名") + private String username; + @ApiParam("看板配置项") private MesShippingKanbanCfg config; diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanViewModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanViewModel.java index eec677f..28fe8f3 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanViewModel.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanViewModel.java @@ -20,4 +20,7 @@ public class MesShippingKanbanViewModel { @ApiParam("范围描述") private String rangDescription; + + @ApiParam("颜色") + private String color; } From cb50635c6cc011be8215f8a882dd3e82ebd2b479 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 25 Feb 2025 13:16:04 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=BE=99=E5=85=B4?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/IMesShippingKanbanCfgService.java | 2 +- .../busi/MesShippingKanbanCfgController.java | 3 +- .../busi/MesShippingKanbanCfgServiceImpl.java | 288 +++++++++++++++------ 3 files changed, 210 insertions(+), 83 deletions(-) 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 index 768d560..aeaac04 100644 --- 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 @@ -7,6 +7,6 @@ import java.util.List; public interface IMesShippingKanbanCfgService { MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode); - void saveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username); + void doSaveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username); List queryShippingKanbanContext(String organizeCode); } 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 index 62d5069..c0b508f 100644 --- 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 @@ -3,7 +3,6 @@ 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; @@ -43,7 +42,7 @@ public class MesShippingKanbanCfgController { public ResultBean saveShippingKanbanCfg(@RequestBody MesShippingKanbanCfgModel request) { try { String organizeCode = !StringUtils.isEmpty(request.getOrganizeCode()) ? request.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode(); - shippingKanbanCfgService.saveShippingKanbanCfg(request, organizeCode, request.getUsername()); + shippingKanbanCfgService.doSaveShippingKanbanCfg(request, organizeCode, request.getUsername()); return ResultBean.success("保存成功"); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); 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 index 5b5c08b..ab97e52 100644 --- 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 @@ -11,6 +11,7 @@ import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; +import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord; import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresJisVinOverPoint; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesLoadingListDetail; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingKanbanCfg; @@ -31,6 +32,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import javax.persistence.EntityManager; +import javax.persistence.NoResultException; import javax.persistence.Query; import java.math.BigDecimal; import java.math.RoundingMode; @@ -85,7 +87,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer } @Override - public void saveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username) { + public void doSaveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username) { if (request.getConfig() == null) { return; } @@ -229,7 +231,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer continue; } if (NumberUtil.isNumber(value)) { - if (Integer.parseInt(value) < Integer.parseInt(rangValue)) { + if (Long.parseLong(value) < Long.parseLong(rangValue)) { return cfgDetail.getRangColorLess(); } } else { @@ -247,7 +249,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer continue; } if (NumberUtil.isNumber(value)) { - if (Integer.parseInt(value) >= Integer.parseInt(rangValue)) { + if (Long.parseLong(value) >= Long.parseLong(rangValue)) { return cfgDetail.getRangColorMore(); } } else { @@ -275,21 +277,25 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer return partShippingGroupRDao.findByHqlWhere(packBean); } - private String getShippingVin(String organizeCode, List shippingGroupCodes, List status) { + private String getMesShippingVin(String organizeCode, List shippingGroupCodes, List status) { StringBuilder hql = new StringBuilder(); hql.append("select sd.vin"); hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); hql.append(" and s.status in (:status) "); hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); hql.append(" ORDER BY sd.id desc"); - return entityManager.createQuery(hql.toString(), String.class) - .setParameter("organizeCode", organizeCode) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("status", status) - .setParameter("shippingGroupCode", shippingGroupCodes) - .setMaxResults(1) - .getSingleResult(); + try { + return entityManager.createQuery(hql.toString(), String.class) + .setParameter("organizeCode", organizeCode) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", status) + .setParameter("shippingGroupCode", shippingGroupCodes) + .setMaxResults(1) + .getSingleResult(); + } catch (NoResultException e) { + return ""; + } } /** @@ -299,23 +305,38 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer * @return */ private String getMaxOffNumber(String organizeCode, List shippingGroupCodes) { - String vinCode = getShippingVin(organizeCode, shippingGroupCodes, Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())); + String vinCode = getMesShippingVin(organizeCode, shippingGroupCodes, Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())); + if (StringUtils.isEmpty(vinCode)) { + return ""; + } StringBuilder offNumberHql = new StringBuilder(); offNumberHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); offNumberHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); offNumberHql.append(" and vin = :vin "); - return entityManager.createQuery(offNumberHql.toString(), String.class) - .setParameter("organizeCode", organizeCode) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("vin", vinCode) - .getSingleResult(); + try { + return entityManager.createQuery(offNumberHql.toString(), String.class) + .setParameter("organizeCode", organizeCode) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("vin", vinCode) + .getSingleResult(); + } catch (NoResultException e) { + return ""; + } } + /** + * 客户端库存 + * 最新下线的排序发运单客户流水号(SERIAL_NUMBER)- 赛力斯上线的最新流水号+调整值。 + * @param cfg + * @param cfgDetail + * @return + */ private List getClientStockQty(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList)) { + values.add("0"); return values; } @@ -326,12 +347,15 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer onNumberHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); onNumberHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); onNumberHql.append(" and overPoint = :overPoint "); - onNumber = entityManager.createQuery(onNumberHql.toString(), String.class) - .setParameter("organizeCode", cfg.getOrganizeCode()) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("overPoint", cfg.getOnlinePoint()) - .getSingleResult(); + try { + onNumber = entityManager.createQuery(onNumberHql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getOnlinePoint()) + .getSingleResult(); + } catch (NoResultException ignored) { + } } if (StringUtils.isEmpty(onNumber)) { onNumber = "0"; @@ -348,10 +372,18 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer return values; } + /** + * 待发运数量 + * 排序单装箱扫描流水号-发运扫描流水号,精排最新流水号-辊道线下件流水号(cockpit) + * @param cfg + * @param cfgDetail + * @return + */ private List getWaitShippingQty(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList)) { + values.add("0"); return values; } @@ -363,12 +395,15 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer refinedPointHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); refinedPointHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); refinedPointHql.append(" and overPoint = :overPoint "); - refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) - .setParameter("organizeCode", cfg.getOrganizeCode()) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("overPoint", cfg.getRefinedPoint()) - .getSingleResult(); + try { + refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getRefinedPoint()) + .getSingleResult(); + } catch (NoResultException ignored) { + } } if (StringUtils.isEmpty(refinedPointNumber)) { refinedPointNumber = "0"; @@ -398,7 +433,10 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer Map shippingGroupCount = new HashMap<>(); if (!CollectionUtils.isEmpty(ddd)) { for (Map dd : ddd) { - shippingGroupCount.put(dd.get("shippingGroupCode").toString(), dd.get("COUNT").toString()); + Object count = dd.get("COUNT"); + if (count != null) { + shippingGroupCount.put(dd.get("shippingGroupCode").toString(), count.toString()); + } } } for (String shippingGroupCode : strShippingGroupList) { @@ -412,6 +450,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList)) { + values.add("0"); return values; } @@ -423,12 +462,15 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer refinedPointHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); refinedPointHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); refinedPointHql.append(" and overPoint = :overPoint "); - refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) - .setParameter("organizeCode", cfg.getOrganizeCode()) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("overPoint", cfg.getRefinedPoint()) - .getSingleResult(); + try { + refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getRefinedPoint()) + .getSingleResult(); + } catch (NoResultException ignored) { + } } if (StringUtils.isEmpty(refinedPointNumber)) { refinedPointNumber = "0"; @@ -450,6 +492,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer /** * 待生产/装箱数量 + * 精排最新流水号-排序单装箱扫描流水号 * @param cfg * @param cfgDetail * @return @@ -458,6 +501,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList)) { + values.add("0"); return values; } @@ -471,12 +515,15 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer refinedPointHql.append("select max(serialNumber) from " + MesCimSeresJisVinOverPoint.class.getName()); refinedPointHql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); refinedPointHql.append(" and overPoint = :overPoint "); - refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) - .setParameter("organizeCode", cfg.getOrganizeCode()) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("overPoint", cfg.getRefinedPoint()) - .getSingleResult(); + try { + refinedPointNumber = entityManager.createQuery(refinedPointHql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("overPoint", cfg.getRefinedPoint()) + .getSingleResult(); + } catch (NoResultException ignored) { + } } if (StringUtils.isEmpty(refinedPointNumber)) { refinedPointNumber = "0"; @@ -506,7 +553,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer } for (String shippingGroupCode : strShippingGroupList) { if (shippingGroupCount.containsKey(shippingGroupCode)) { - values.add(Integer.parseInt(refinedPointNumber) - Integer.parseInt(shippingGroupCount.get(shippingGroupCode)) + ""); + values.add(Long.parseLong(refinedPointNumber) - Long.parseLong(shippingGroupCount.get(shippingGroupCode)) + ""); } else { values.add("0"); } @@ -517,6 +564,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer /** * 距离上一次发运时间(Min) + * 当前时间-最近一次发运扫描时间 * @param cfg * @param cfgDetail * @return @@ -534,13 +582,18 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); hql.append(" and s.status in (:status) "); hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); - String strScanEndTime = entityManager.createQuery(hql.toString(), String.class) - .setParameter("organizeCode", cfg.getOrganizeCode()) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) - .setParameter("shippingGroupCode", strShippingGroupList) - .getSingleResult(); + String strScanEndTime = ""; + try { + strScanEndTime = entityManager.createQuery(hql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getSingleResult(); + } catch (NoResultException ignored) { + } + if (!StringUtils.isEmpty(strScanEndTime)) { Date scanEndTime = DateUtil.parse(strScanEndTime); values.add(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, scanEndTime)); @@ -556,7 +609,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer .setParameter("organizeCode", cfg.getOrganizeCode()) .setParameter("isValid", CommonEnumUtil.VALID) .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("status", Arrays.asList(MesExtEnumUtil.LOADING_ORDER_STATUS.LOADED.getValue(), MesExtEnumUtil.LOADING_ORDER_STATUS.SHIPPING.getValue())) + .setParameter("status", Arrays.asList(MesExtEnumUtil.MES_LOADING_STATUS.PUBLISH.getValue(), MesExtEnumUtil.MES_LOADING_STATUS.SCANNED.getValue())) .setParameter("shippingGroupCode", strShippingGroupList) .getResultList(); Map shippingGroupCount = new HashMap<>(); @@ -599,13 +652,17 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer hql.append(" from MesShippingOrderManagement s inner join MesShippingOrderManagementDetail sd on s.id = sd.pid and sd.organizeCode = :organizeCode and sd.isDeleted=:isDeleted and sd.isValid=:isValid "); hql.append(" and s.status in (:status) "); hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); - String strScanEndTime = entityManager.createQuery(hql.toString(), String.class) - .setParameter("organizeCode", cfg.getOrganizeCode()) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) - .setParameter("shippingGroupCode", strShippingGroupList) - .getSingleResult(); + String strScanEndTime = ""; + try { + strScanEndTime = entityManager.createQuery(hql.toString(), String.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .getSingleResult(); + } catch (NoResultException ignored) { + } if (!StringUtils.isEmpty(strScanEndTime)) { Date scanEndTime = DateUtil.parse(strScanEndTime); values.add(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, scanEndTime)); @@ -618,6 +675,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer /** * 下一车最晚发运时间 + * 当前时间+客户端库存/客户JPH-在途时间 * @param cfg * @param cfgDetail * @return @@ -653,15 +711,17 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer /** * 三级停线预警(Min) + * 当前时间+客户端库存/客户JPH-在途时间 * @param cfg * @param cfgDetail * @return */ private List getTreeStopWarning(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); - //获取客户端库存 + //获取下一车最晚发运时间 List nextShippingTimeValue = getNextShippingTime(cfg, cfgDetail); if (StringUtils.isEmpty(nextShippingTimeValue)) { + values.add("0"); return values; } Date nowTime = DateUtil.parse(DateUtil.formatDate(DateUtil.BASE_FORMAT3, DateUtil.now()), DateUtil.BASE_FORMAT3); @@ -671,10 +731,17 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer return values; } + /** + * 最近发运VIN/流水号,客户排序信息序号,截取后6位 + * @param cfg + * @param cfgDetail + * @return + */ private List getShippingVin(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList)) { + values.add("0"); return values; } @@ -685,13 +752,18 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer hql.append(" and s.status in (:status) "); hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); hql.append(" ORDER BY sd.id DESC"); - Long custInfoSeq = entityManager.createQuery(hql.toString(), Long.class) - .setParameter("organizeCode", cfg.getOrganizeCode()) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) - .setParameter("shippingGroupCode", strShippingGroupList) - .getSingleResult(); + Long custInfoSeq = null; + try { + custInfoSeq = entityManager.createQuery(hql.toString(), Long.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .setMaxResults(1) + .getSingleResult(); + } catch (NoResultException e) { + } String strCustInfoSeq = custInfoSeq != null ? Long.toString(custInfoSeq) : ""; if (strCustInfoSeq.length() >= 6) { values.add(strCustInfoSeq.substring(strCustInfoSeq.length() - 6)); @@ -709,7 +781,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer .setParameter("organizeCode", cfg.getOrganizeCode()) .setParameter("isValid", CommonEnumUtil.VALID) .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("status", Arrays.asList(MesExtEnumUtil.LOADING_ORDER_STATUS.LOADED.getValue(), MesExtEnumUtil.LOADING_ORDER_STATUS.SHIPPING.getValue())) + .setParameter("status", Arrays.asList(MesExtEnumUtil.MES_LOADING_STATUS.PUBLISH.getValue(), MesExtEnumUtil.MES_LOADING_STATUS.SCANNED.getValue())) .setParameter("shippingGroupCode", strShippingGroupList) .getResultList(); @@ -741,11 +813,18 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer return values; } + /** + * 最近发运VIN/流水号,客户排序信息序号,截取后6位 + * @param cfg + * @param cfgDetail + * @return + */ private List getCPShippingVin(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); DdlPackBean packBean = DdlPackBean.getDdlPackBean(cfg.getOrganizeCode()); List shippingGroups = partShippingGroupRDao.findByHqlWhere(packBean); if (CollectionUtils.isEmpty(shippingGroups)) { + values.add("0"); return values; } @@ -758,13 +837,19 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer hql.append(" and s.status in (:status) "); hql.append(" and s.shippingGroupCode in (:shippingGroupCode) "); hql.append(" ORDER BY sd.id DESC"); - Long custInfoSeq = entityManager.createQuery(hql.toString(), Long.class) - .setParameter("organizeCode", cfg.getOrganizeCode()) - .setParameter("isValid", CommonEnumUtil.VALID) - .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) - .setParameter("shippingGroupCode", strShippingGroupList) - .getSingleResult(); + Long custInfoSeq = null; + try { + custInfoSeq = entityManager.createQuery(hql.toString(), Long.class) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("status", Arrays.asList(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue(), MesExtEnumUtil.SHIPPING_ORDER_STATUS.LOADING.getValue())) + .setParameter("shippingGroupCode", strShippingGroupList) + .setMaxResults(1) + .getSingleResult(); + } catch (NoResultException e) { + } + String strCustInfoSeq = custInfoSeq != null ? Long.toString(custInfoSeq) : ""; if (strCustInfoSeq.length() >= 6) { values.add(strCustInfoSeq.substring(strCustInfoSeq.length() - 6)); @@ -778,7 +863,9 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer } /** - * 当天上线数 + * 当天上线数,要设置客户开班时间、信息点 + * 基于信息点到当前时间过点数量。按天显示。 + * 当天上线数/当班上线数 * @param cfg * @param cfgDetail * @return @@ -786,6 +873,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer private List getTodayOnline(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); if (StringUtils.isEmpty(cfg.getCustStartShift()) || StringUtils.isEmpty(cfg.getOnlinePoint())) { + values.add("0"); return values; } @@ -823,6 +911,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer /** * 当天发运数 + * 设置内部开班时间,显示已发运数、已装车数,发运单状态为已发运及已装车。 * @param cfg * @param cfgDetail * @return @@ -831,6 +920,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList) || StringUtils.isEmpty(cfg.getInterStartShift())) { + values.add("0"); return values; } @@ -882,6 +972,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer /** * 当天装车数 + * 设置内部开班时间,显示已装车数,装车单状态为已扫描。 * @param cfg * @param cfgDetail * @return @@ -890,6 +981,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList) || StringUtils.isEmpty(cfg.getInterStartShift())) { + values.add("0"); return values; } @@ -919,7 +1011,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer .setParameter("organizeCode", cfg.getOrganizeCode()) .setParameter("isValid", CommonEnumUtil.VALID) .setParameter("isDeleted", CommonEnumUtil.FALSE) - .setParameter("status", MesExtEnumUtil.LOADING_ORDER_STATUS.SHIPPING.getValue()) + .setParameter("status", MesExtEnumUtil.MES_LOADING_STATUS.SCANNED.getValue()) .setParameter("startDateTime", startDateTime) .setParameter("endDateTime", endDateTime) .setParameter("shippingGroupCode", strShippingGroupList) @@ -942,6 +1034,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer /** * 客户端JPH + * 上线点,当前时间往前一小时的过点总数维护默认值,当数值为0时,显示为默认值 * @param cfg * @param cfgDetail * @return @@ -950,6 +1043,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList)) { + values.add("0"); return values; } @@ -980,19 +1074,53 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer /** * 生产JPH + * 当前时间往前一小时的完成数/下线数 * @param cfg * @param cfgDetail * @return */ private List getProductJPH(MesShippingKanbanCfg cfg, MesShippingKanbanCfgDetail cfgDetail) { List values = new ArrayList<>(); - List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); - if (CollectionUtils.isEmpty(strShippingGroupList)) { + List partShippingGroups = getShippingGroups(cfg); + if (CollectionUtils.isEmpty(partShippingGroups)) { + values.add("0"); return values; } Date nowTime = DateUtil.now(); Date prevHourTime = DateUtil.addMinutes(nowTime, -60); + + StringBuilder hql = new StringBuilder(); + hql.append("select new map(workCenterCode, count(1) as totalCount) from " + MesProductionRecord.class.getName()); + hql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); + hql.append(" and createDatetime BETWEEN :startDateTime AND :endDateTime "); + hql.append(" group by workCenterCode"); + List ddd = entityManager.createQuery(hql.toString()) + .setParameter("organizeCode", cfg.getOrganizeCode()) + .setParameter("isValid", CommonEnumUtil.VALID) + .setParameter("isDeleted", CommonEnumUtil.FALSE) + .setParameter("startDateTime", DateUtil.formatDate(nowTime)) + .setParameter("endDateTime", DateUtil.formatDate(prevHourTime)) + .getResultList(); + + Map shippingGroupCount = new HashMap<>(); + if (!CollectionUtils.isEmpty(ddd)) { + for (Map dd : ddd) { + Object totalCount = dd.get("totalCount"); + if (totalCount != null) { + shippingGroupCount.put(dd.get("workCenterCode").toString(), totalCount.toString()); + } + } + } + for (MesPartShippingGroup shippingGroup : partShippingGroups) { + if (StringUtils.isEmpty(shippingGroup.getCarrierCode())) { + continue; + } + values.add(shippingGroupCount.getOrDefault(shippingGroup.getCarrierCode(), "0")); + } + if (values.isEmpty()) { + values.add("0"); + } return values; } } From ff7b11e27179964e870633c1cee105ff02f0c561 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 25 Feb 2025 16:25:20 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=BE=99=E5=85=B4?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busi/MesShippingKanbanCfgServiceImpl.java | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) 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 index ab97e52..c4780ac 100644 --- 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 @@ -1043,8 +1043,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List values = new ArrayList<>(); List strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(",")); if (CollectionUtils.isEmpty(strShippingGroupList)) { - values.add("0"); - return values; + return Collections.singletonList("0"); } Date nowTime = DateUtil.now(); @@ -1083,19 +1082,19 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer List values = new ArrayList<>(); List partShippingGroups = getShippingGroups(cfg); if (CollectionUtils.isEmpty(partShippingGroups)) { - values.add("0"); - return values; + return Collections.singletonList("0"); } Date nowTime = DateUtil.now(); Date prevHourTime = DateUtil.addMinutes(nowTime, -60); - StringBuilder hql = new StringBuilder(); - hql.append("select new map(workCenterCode, count(1) as totalCount) from " + MesProductionRecord.class.getName()); - hql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid "); - hql.append(" and createDatetime BETWEEN :startDateTime AND :endDateTime "); - hql.append(" group by workCenterCode"); - List ddd = entityManager.createQuery(hql.toString()) + // Use a single query to fetch counts grouped by work center code + List productionCounts = entityManager.createQuery( + "SELECT new map(pr.workCenterCode as workCenterCode, COUNT(pr) as totalCount) " + + "FROM " + MesProductionRecord.class.getName() + " pr " + + "WHERE pr.organizeCode = :organizeCode AND pr.isDeleted = :isDeleted AND pr.isValid = :isValid " + + "AND pr.createDatetime BETWEEN :startDateTime AND :endDateTime " + + "GROUP BY pr.workCenterCode", Map.class) .setParameter("organizeCode", cfg.getOrganizeCode()) .setParameter("isValid", CommonEnumUtil.VALID) .setParameter("isDeleted", CommonEnumUtil.FALSE) @@ -1103,21 +1102,23 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer .setParameter("endDateTime", DateUtil.formatDate(prevHourTime)) .getResultList(); - Map shippingGroupCount = new HashMap<>(); - if (!CollectionUtils.isEmpty(ddd)) { - for (Map dd : ddd) { - Object totalCount = dd.get("totalCount"); - if (totalCount != null) { - shippingGroupCount.put(dd.get("workCenterCode").toString(), totalCount.toString()); - } - } - } + // Use a map to store counts for quick access + Map shippingGroupCount = productionCounts.stream() + .collect(Collectors.toMap( + map -> map.get("workCenterCode").toString(), + map -> map.get("totalCount").toString(), + (existing, replacement) -> existing // Handle duplicates if any + )); + + // Collect counts for each shipping group for (MesPartShippingGroup shippingGroup : partShippingGroups) { if (StringUtils.isEmpty(shippingGroup.getCarrierCode())) { continue; } values.add(shippingGroupCount.getOrDefault(shippingGroup.getCarrierCode(), "0")); } + + // Ensure at least one value is returned if (values.isEmpty()) { values.add("0"); } From 84c3d427f22a39fac9431fcda91a2df6a3635e76 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 26 Feb 2025 11:47:01 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=BE=99=E5=85=B4?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/IMesShippingKanbanCfgService.java | 6 +-- .../busi/MesShippingKanbanCfgController.java | 2 +- .../busi/MesShippingKanbanCfgServiceImpl.java | 46 ++++++++++++++++------ .../mes/pcn/pojo/model/MesShippingKanbanModel.java | 16 ++++++++ 4 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanModel.java 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 index aeaac04..4864b29 100644 --- 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 @@ -1,12 +1,10 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanCfgModel; -import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanViewModel; - -import java.util.List; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanModel; public interface IMesShippingKanbanCfgService { MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode); void doSaveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username); - List queryShippingKanbanContext(String organizeCode); + MesShippingKanbanModel queryShippingKanbanContext(String organizeCode); } 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 index c0b508f..c687281 100644 --- 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 @@ -56,7 +56,7 @@ public class MesShippingKanbanCfgController { public ResultBean queryShippingKanbanContext(String organizeCode) { try { organizeCode = !StringUtils.isEmpty(organizeCode) ? organizeCode : AuthUtil.getOrganize().getOrganizeCode(); - return ResultBean.success("查询成功").setResultList(shippingKanbanCfgService.queryShippingKanbanContext(organizeCode)); + return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanContext(organizeCode)); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); } catch (Exception e) { 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 index c4780ac..9cbd260 100644 --- 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 @@ -2,6 +2,7 @@ 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.model.MesShippingKanbanModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanViewModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.util.DateUtil; @@ -129,14 +130,35 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer } @Override - public List queryShippingKanbanContext(String organizeCode) { - List viewModels = new ArrayList<>(); + public MesShippingKanbanModel queryShippingKanbanContext(String organizeCode) { + MesShippingKanbanModel model = new MesShippingKanbanModel(); + Map cfgDetailMap = null; MesShippingKanbanCfgModel cfgModel = queryShippingKanbanCfg(organizeCode); MesShippingKanbanCfg cfg = cfgModel != null ? cfgModel.getConfig() : null; if (cfg == null) { - return viewModels; + return model; + } + StringBuilder kabanTitle = new StringBuilder(); + if (!StringUtils.isEmpty(cfg.getShippingGroupCode())) { + for (String groupCode : cfg.getShippingGroupCode().split(",")) { + DdlPackBean groupPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(groupCode, "shippingGroupCode", groupPackBean); + MesPartShippingGroup shippingGroup = partShippingGroupRDao.getByProperty(groupPackBean); + if (shippingGroup != null) { + if (kabanTitle.length() > 0) { + kabanTitle.append(" "); + } + kabanTitle.append(shippingGroup.getShippingGroupName()); + } + } + } + if (kabanTitle.length() > 0) { + kabanTitle.append("|"); } + kabanTitle.append("发运看板"); + model.setKanbanTitle(kabanTitle.toString()); + if (!CollectionUtils.isEmpty(cfgModel.getDetails())) { cfgDetailMap = cfgModel.getDetails().stream().collect(Collectors.toMap(MesShippingKanbanCfgDetail::getDetailCode, v -> v)); } @@ -147,9 +169,9 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer continue; } - MesShippingKanbanViewModel model = new MesShippingKanbanViewModel(); - model.setDetailName(index.getDescription()); - model.setOrderNumber(cfgDetail.getOrderNumber()); + MesShippingKanbanViewModel viewModel = new MesShippingKanbanViewModel(); + viewModel.setDetailName(index.getDescription()); + viewModel.setOrderNumber(cfgDetail.getOrderNumber()); String rangDescription = ""; if (!StringUtils.isEmpty(cfgDetail.getRangValueLess())) { rangDescription += "<" + cfgDetail.getRangValueLess(); @@ -160,7 +182,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer } rangDescription += ">=" + cfgDetail.getRangValueMore(); } - model.setRangDescription(rangDescription); + viewModel.setRangDescription(rangDescription); List values = null; switch (index) { case CLIENT_STOCK_QTY: @@ -212,12 +234,12 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer if (values == null) { values = new ArrayList<>(); } - model.setValues(values); - model.setColor(getColor(cfgDetail, values)); - viewModels.add(model); + viewModel.setValues(values); + viewModel.setColor(getColor(cfgDetail, values)); + model.getDetails().add(viewModel); } - viewModels.sort(Comparator.comparing(MesShippingKanbanViewModel::getOrderNumber)); - return viewModels; + model.getDetails().sort(Comparator.comparing(MesShippingKanbanViewModel::getOrderNumber)); + return model; } private String getColor(MesShippingKanbanCfgDetail cfgDetail, List values) { diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanModel.java new file mode 100644 index 0000000..0dc2e22 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesShippingKanbanModel.java @@ -0,0 +1,16 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.model; + +import io.swagger.annotations.ApiParam; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class MesShippingKanbanModel { + @ApiParam("看板标题") + private String kanbanTitle; + + @ApiParam("指标明细") + private List details = new ArrayList<>(); +} From ab6f09114a108713c166252b2a63ee7258edcd89 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 27 Feb 2025 13:36:12 +0800 Subject: [PATCH 7/8] =?UTF-8?q?45335=20=E4=BF=AE=E5=A4=8Dcockpit=E5=8F=91?= =?UTF-8?q?=E8=BF=90=E6=A0=A1=E9=AA=8C=E6=98=8E=E7=BB=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=89=AB=E6=8F=8F=E8=B7=B3=E8=BF=87=E7=A0=81=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=BE=80mes=5Fjis=5Fshipping=E8=A1=A8=E5=86=99?= =?UTF-8?q?=E5=85=A5=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/apiservice/serviceimpl/busi/MesJisShippingServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesJisShippingServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesJisShippingServiceImpl.java index 7b31e7e..9e8ccce 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesJisShippingServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesJisShippingServiceImpl.java @@ -13,6 +13,7 @@ import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrderPart; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -81,6 +82,9 @@ public class MesJisShippingServiceImpl implements IMesJisShippingService { MesConfig useCustOrderNo = configService.getMesConfigNoError(orderManagement.getOrganizeCode(), MesPcnExtConstWords.USE_CUST_ORDER_NO); List jisShippingList = new ArrayList<>(); orderManagementDetailList.forEach(k -> { + if (k.getStatus() == MesExtEnumUtil.SHIPPING_ORDER_DETAIL_SHIPPING_STATUS.SKIP.getValue()) { + return; + } MesJisShipping jisShipping = new MesJisShipping(); BeanUtils.copyProperties(orderManagement, jisShipping, MesPcnExtConstWords.BASE_BEAN_FIELDS); BeanUtils.copyProperties(k, jisShipping, MesPcnExtConstWords.BASE_BEAN_FIELDS); From f55139b42e7874f9ad42b8a3ae2a5e94f8a2665f Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 27 Feb 2025 15:33:36 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BE=99=E5=85=B4?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 index 9cbd260..c189975 100644 --- 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 @@ -954,10 +954,10 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer Date currentTime = DateUtil.parse(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, nowTime), DateUtil.SHORT_FORMAT_HOUR); if (!configTime.after(currentTime)) { startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getInterStartShift(); - endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, 1)) + " " + cfg.getCustStartShift(); + endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, 1)) + " " + cfg.getInterStartShift(); } else { //小于配置时间,如凌晨1点则跨天,需将当前时间减一天 - startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, -1)) + " " + cfg.getCustStartShift(); + startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, -1)) + " " + cfg.getInterStartShift(); endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getInterStartShift(); } @@ -1015,10 +1015,10 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer Date currentTime = DateUtil.parse(DateUtil.formatDate(DateUtil.SHORT_FORMAT_HOUR, nowTime), DateUtil.SHORT_FORMAT_HOUR); if (!configTime.after(currentTime)) { startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getInterStartShift(); - endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, 1)) + " " + cfg.getCustStartShift(); + endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, 1)) + " " + cfg.getInterStartShift(); } else { //小于配置时间,如凌晨1点则跨天,需将当前时间减一天 - startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, -1)) + " " + cfg.getCustStartShift(); + startDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, DateUtil.addDays(nowTime, -1)) + " " + cfg.getInterStartShift(); endDateTime = DateUtil.formatDate(DateUtil.SHORT_FORMAT, nowTime) + " " + cfg.getInterStartShift(); }