From b64b216e2305028e83d85f4dbe19896771b80343 Mon Sep 17 00:00:00 2001 From: liuxy Date: Mon, 8 Jul 2024 08:47:32 +0800 Subject: [PATCH] =?UTF-8?q?rev=EF=BC=9A=E6=9C=A8=E7=AE=B1=E9=87=8D?= =?UTF-8?q?=E9=87=8F=E5=BC=82=E5=B8=B8=E9=80=9A=E7=9F=A5=E9=A3=9E=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProductInstorServiceImpl.java | 84 ++++++++++++++++++- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java index 7bc6ddc23..85ed3e8b8 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java @@ -21,6 +21,7 @@ import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl; import org.nl.wms.ext.acs.service.WmsToAcsService; import org.nl.wms.ext.acs.service.impl.AcsToWmsServiceImpl; import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl; +import org.nl.wms.ext.mes.service.LmsToMesService; import org.nl.wms.pda.st.service.ProductInstorService; import org.nl.wms.sch.tasks.CutConveyorTask; import org.nl.wms.st.inbill.service.RawAssistIStorService; @@ -31,6 +32,7 @@ import org.redisson.api.RedissonClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -59,6 +61,8 @@ public class ProductInstorServiceImpl implements ProductInstorService { private final WmsToAcsService wmsToAcsService; + private final LmsToMesService lmsToMesService; + @Override public JSONObject boxQuery(JSONObject whereJson) { String box_no = whereJson.getString("box_no"); @@ -194,6 +198,25 @@ public class ProductInstorServiceImpl implements ProductInstorService { throw new BadRequestException("二期仓库木箱,请进行虚拟入库!"); } + // 重量阈值系统参数 + double weight_sys = Double.parseDouble(SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("weight_sys").getValue()); + // 木箱系统重量 + double box_weight = sub_jo.getDoubleValue("box_weight"); + // 木箱实称重重量 + double real_weight = sub_jo.getDoubleValue("real_weight"); + + if (ObjectUtil.isEmpty(sub_jo.getString("real_weight"))) { + throw new BadRequestException("请先进行木箱称重校验!"); + } + + // 判断木箱毛重是否超标 + if (NumberUtil.sub(box_weight, weight_sys) <= real_weight && NumberUtil.add(box_weight, weight_sys) >= real_weight) { + } else { + // 将木箱重量告知飞书 + notifyMes(sub_jo); + throw new BadRequestException("重量不合格!系统重量浮动超过"+weight_sys+"KG,当前木称重重量:"+real_weight); + } + //判断是该包装计划是否存在长宽高 Double box_length = sub_jo.getDoubleValue("box_length"); Double box_width = sub_jo.getDoubleValue("box_width"); @@ -292,6 +315,7 @@ public class ProductInstorServiceImpl implements ProductInstorService { throw new BadRequestException("请扫描内包间入库点位!"); } } + //创建二楼去一楼的任务 JSONObject form = new JSONObject(); form.put("point_code1", point_code); @@ -574,19 +598,71 @@ public class ProductInstorServiceImpl implements ProductInstorService { JSONObject data = jsonObject.getJSONArray("data").getJSONObject(0); double weight_now = NumberUtil.div(data.getDoubleValue("weight"), 10); - // 获取系统参数 + // 获取系统参数1 double weight_sys = Double.parseDouble(SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("weight_sys").getValue()); + // 获取系统参数2 + double weight_sys_2 = Double.parseDouble(SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("weight_sys_2").getValue()); // 查询子卷包装关系 JSONObject jsonSub = subTab.query("package_box_sn = '" + box_no + "'").uniqueResult(0); double box_weight = jsonSub.getDoubleValue("box_weight"); if (NumberUtil.sub(box_weight, weight_sys) <= weight_now && NumberUtil.add(box_weight, weight_sys) >= weight_now) { - jo.put("message", "重量合格!当前称重重量:"+weight_now); + // 校验重量上下付浮动是否超过2 + if (NumberUtil.sub(box_weight, weight_sys_2) <= weight_now && NumberUtil.add(box_weight, weight_sys_2) >= weight_now) { + jo.put("message", "重量合格!当前称重重量:"+weight_now); + } else { + jo.put("message", "重量警告!系统重量浮动超过"+weight_sys_2+"KG,当前称重重量:"+weight_now); + } } else { - jo.put("message", "重量不合格!当前称重重量:"+weight_now); - } + jo.put("message", "重量不合格!系统重量浮动超过"+weight_sys+"KG,当前称重重量:"+weight_now); + } + // 更新当前木箱实际重量 + JSONObject json = new JSONObject(); + json.put("real_weight",weight_now); + subTab.update(json,"package_box_sn = '"+box_no+"'"); return jo; } + + /** + * 生成输送任务时通知木箱重量不合格 + * @param sub_jo {子卷包装关系对象} + */ + private void notifyMes(JSONObject sub_jo) { + JSONObject param = new JSONObject(); + + // 飞书用户集合 + JSONArray UserList = new JSONArray(); + // 系统参数 + String userList = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("USER_LIST_FEISHU_2").getValue(); + + String[] split = userList.split(","); + if (split.length > 0) { + for (String s : split) { + JSONObject jo = new JSONObject(); + jo.put("User", s); + UserList.add(jo); + } + } else { + JSONObject jo = new JSONObject(); + jo.put("User", ""); + UserList.add(jo); + } + param.put("UserList", UserList); + // 标签code + param.put("Code", "ctp_AA65DNXr3svo"); + + // 组织标签内容 + JSONObject content = new JSONObject(); + double box_weight = NumberUtil.round(sub_jo.getDoubleValue("box_weight"), 2).doubleValue(); + double real_weight = NumberUtil.round(sub_jo.getDoubleValue("real_weight"), 2).doubleValue(); + + content.put("title", "【LMS通知】木箱超重警告"); + content.put("Message", "木箱号:"+sub_jo.getString("package_box_sn")+",系统木箱重量:"+box_weight+"KG,实际木箱重量:"+real_weight+"KG"); + param.put("card", content); + + // 调用mes接口 + lmsToMesService.proudDayData(param); + } }