add:增加料箱/托盘称重检测功能。
This commit is contained in:
@@ -577,6 +577,9 @@ public class MdGruopDickServiceImpl extends ServiceImpl<MdGruopDickMapper, MdGru
|
|||||||
k3CloudApi
|
k3CloudApi
|
||||||
);
|
);
|
||||||
if (materialInfo == null) {
|
if (materialInfo == null) {
|
||||||
|
log.error(item.get(0).getVehicle_code()
|
||||||
|
+ "上的物料:" + r.getMaterial_code()
|
||||||
|
+ "在ERP系统上检索不到相关物料信息,请检查!");
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"weightError-载具" + item.get(0).getVehicle_code()
|
"weightError-载具" + item.get(0).getVehicle_code()
|
||||||
+ "上的物料:" + r.getMaterial_code()
|
+ "上的物料:" + r.getMaterial_code()
|
||||||
@@ -584,6 +587,7 @@ public class MdGruopDickServiceImpl extends ServiceImpl<MdGruopDickMapper, MdGru
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
r.setSingle_weight(materialInfo.getNet_weight());
|
r.setSingle_weight(materialInfo.getNet_weight());
|
||||||
|
r.setAssist_unit_id(materialInfo.getAssist_unit_id());
|
||||||
}
|
}
|
||||||
//过滤出需要称重校验的物料(单重 > 0)
|
//过滤出需要称重校验的物料(单重 > 0)
|
||||||
List<MdPbVehicleMaterVo> validItems = item.stream()
|
List<MdPbVehicleMaterVo> validItems = item.stream()
|
||||||
@@ -597,6 +601,9 @@ public class MdGruopDickServiceImpl extends ServiceImpl<MdGruopDickMapper, MdGru
|
|||||||
try {
|
try {
|
||||||
actualWeightKg = new BigDecimal(w.trim());
|
actualWeightKg = new BigDecimal(w.trim());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error(item.get(0).getVehicle_code()
|
||||||
|
+ "在称重站点上:" + deviceCode + w
|
||||||
|
+ "称重数据格式非法,请检查!");
|
||||||
throw new BadRequestException("weightError-称重数据格式非法:" + deviceCode + w);
|
throw new BadRequestException("weightError-称重数据格式非法:" + deviceCode + w);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -619,10 +626,13 @@ public class MdGruopDickServiceImpl extends ServiceImpl<MdGruopDickMapper, MdGru
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("获取称重失败" + deviceCode + ex.getMessage());
|
log.error(item.get(0).getVehicle_code() + ":获取称重失败" + deviceCode + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (actualWeightKg.compareTo(BigDecimal.ZERO) <= 0) {
|
if (actualWeightKg.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
log.error(item.get(0).getVehicle_code()
|
||||||
|
+ "在称重站点上:" + deviceCode + w
|
||||||
|
+ "反馈称重为0,称重异常,请检查。");
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
String.format("weightError-该点位:%s,反馈称重为0,称重异常,请检查。", deviceCode)
|
String.format("weightError-该点位:%s,反馈称重为0,称重异常,请检查。", deviceCode)
|
||||||
);
|
);
|
||||||
@@ -630,6 +640,8 @@ public class MdGruopDickServiceImpl extends ServiceImpl<MdGruopDickMapper, MdGru
|
|||||||
//查询出入库配置规则
|
//查询出入库配置规则
|
||||||
Param byCode = iSysParamService.findByCode(item.get(0).getVehicle_code().contains("T") ? "tp_range" : "lx_range");
|
Param byCode = iSysParamService.findByCode(item.get(0).getVehicle_code().contains("T") ? "tp_range" : "lx_range");
|
||||||
if (byCode == null || StringUtils.isEmpty(byCode.getValue())) {
|
if (byCode == null || StringUtils.isEmpty(byCode.getValue())) {
|
||||||
|
log.error(item.get(0).getVehicle_code()
|
||||||
|
+ "未配置托盘或料箱的误差值,请检查。");
|
||||||
throw new BadRequestException("weightError-未配置托盘或料箱的误差值,请检查。");
|
throw new BadRequestException("weightError-未配置托盘或料箱的误差值,请检查。");
|
||||||
}
|
}
|
||||||
// 误差值
|
// 误差值
|
||||||
@@ -650,8 +662,9 @@ public class MdGruopDickServiceImpl extends ServiceImpl<MdGruopDickMapper, MdGru
|
|||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
//实际称重换算克
|
//实际称重换算克
|
||||||
BigDecimal actualWeightG = actualWeightKg.multiply(BigDecimal.valueOf(1000));
|
BigDecimal actualWeightG = actualWeightKg.multiply(BigDecimal.valueOf(1000));
|
||||||
|
BigDecimal netWeight = BigDecimal.ZERO;
|
||||||
// 净重 = 实际称重 - 载具皮重
|
// 净重 = 实际称重 - 载具皮重
|
||||||
BigDecimal netWeight = actualWeightG.subtract(BigDecimal.valueOf(weight));
|
netWeight = actualWeightG.subtract(BigDecimal.valueOf(weight));
|
||||||
if (netWeight.compareTo(BigDecimal.ZERO) < 0) {
|
if (netWeight.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
netWeight = BigDecimal.ZERO;
|
netWeight = BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
@@ -660,9 +673,10 @@ public class MdGruopDickServiceImpl extends ServiceImpl<MdGruopDickMapper, MdGru
|
|||||||
.subtract(materialWeight)
|
.subtract(materialWeight)
|
||||||
.abs();
|
.abs();
|
||||||
if (diffWeight.compareTo(relativeError) > 0) {
|
if (diffWeight.compareTo(relativeError) > 0) {
|
||||||
|
log.error(item.get(0).getVehicle_code()+ "的物料数量为:" + validItems.get(0).getQty()
|
||||||
|
+ ",上报重量为:" + actualWeightKg + ",载具重量为:" + weight + ",去皮重量为:" + netWeight + ",与物料实际重量:" + materialWeight + ",进行对比已超过误差值" + diffWeight + ",不允许入库,请检查。");
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
String.format("weightError-该载具:%s,称重重量为%s,与物料实际重量:%s,进行对比已超过误差值:%sg,不允许入库,请检查。",
|
(item.get(0).getVehicle_code() + "的物料数量为:" + validItems.get(0).getQty() + ",上报重量为:" + actualWeightKg + "kg,载具重量为:" + weight + "g" + ",物料单重为:" + validItems.get(0).getSingle_weight() + validItems.get(0).getAssist_unit_id() +",去皮重量为:" + netWeight + "g,与物料实际重量:" + materialWeight + "g,进行对比已超过误差值" + diffWeight + "g,不允许入库,请检查。")
|
||||||
item.get(0).getVehicle_code(), netWeight, materialWeight, diffWeight)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -437,17 +437,13 @@ public class SyncErpBillsScheduleService {
|
|||||||
if (ObjectUtils.isNotEmpty(formDataList)) {
|
if (ObjectUtils.isNotEmpty(formDataList)) {
|
||||||
String assistUint = "0";
|
String assistUint = "0";
|
||||||
String netWeight = "0";
|
String netWeight = "0";
|
||||||
JSONArray uintJsonArray = JSONObject.parseObject(JSON.toJSONString(r)).getJSONArray("MaterialStock");
|
|
||||||
if (ObjectUtils.isNotEmpty(uintJsonArray)) {
|
|
||||||
JSONObject u1 = JSONObject.parseObject(JSON.toJSONString(uintJsonArray.get(0)));
|
|
||||||
JSONObject u2 = u1.getJSONObject("AuxUnitID");
|
|
||||||
assistUint = u2 != null ? u2.getString("Number") : "0";
|
|
||||||
}
|
|
||||||
JSONArray netWeightArray = JSONObject.parseObject(JSON.toJSONString(r)).getJSONArray("MaterialBase");
|
JSONArray netWeightArray = JSONObject.parseObject(JSON.toJSONString(r)).getJSONArray("MaterialBase");
|
||||||
if (ObjectUtils.isNotEmpty(netWeightArray)) {
|
if (ObjectUtils.isNotEmpty(netWeightArray)) {
|
||||||
JSONObject u1 = JSONObject.parseObject(JSON.toJSONString(netWeightArray.get(0)));
|
JSONObject u1 = JSONObject.parseObject(JSON.toJSONString(netWeightArray.get(0)));
|
||||||
String u2 = u1.getString("NETWEIGHT");
|
String u2 = u1.getString("NETWEIGHT");
|
||||||
netWeight = StringUtils.isNotBlank(u2) ? u2 : "0";
|
netWeight = StringUtils.isNotBlank(u2) ? u2 : "0";
|
||||||
|
JSONObject u3 = u1.getJSONObject("WEIGHTUNITID");
|
||||||
|
assistUint = u3 != null ? "kg".equals(u3.getString("Number"))||"MX041".equals(u3.getString("Number"))?"kg":"g" : "g";
|
||||||
}
|
}
|
||||||
PmFormData mainFormData = formDataList.stream().filter(rs1 -> "BD_MATERIAL".equals(rs1.getForm_type())).collect(Collectors.toList()).get(0);
|
PmFormData mainFormData = formDataList.stream().filter(rs1 -> "BD_MATERIAL".equals(rs1.getForm_type())).collect(Collectors.toList()).get(0);
|
||||||
JSONObject object = mainFormData.getForm_data();
|
JSONObject object = mainFormData.getForm_data();
|
||||||
@@ -464,15 +460,8 @@ public class SyncErpBillsScheduleService {
|
|||||||
materialBase.setQty_unit_id(m_unit);
|
materialBase.setQty_unit_id(m_unit);
|
||||||
materialBase.setAssist_unit_id(assistUint);
|
materialBase.setAssist_unit_id(assistUint);
|
||||||
BigDecimal netWeightGet = new BigDecimal(netWeight);
|
BigDecimal netWeightGet = new BigDecimal(netWeight);
|
||||||
//辅助单位净重为kg
|
materialBase.setNet_weight(netWeightGet);
|
||||||
if (netWeightGet.compareTo(BigDecimal.ZERO) > 0 && assistUint.contains("kg")) {
|
materialBase.setNearby_weight(netWeightGet);
|
||||||
BigDecimal newWeightGet = netWeightGet.multiply(new BigDecimal(1000));
|
|
||||||
materialBase.setNet_weight(newWeightGet);
|
|
||||||
materialBase.setNearby_weight(newWeightGet);
|
|
||||||
} else {
|
|
||||||
materialBase.setNet_weight(netWeightGet);
|
|
||||||
materialBase.setNearby_weight(netWeightGet);
|
|
||||||
}
|
|
||||||
materialBase.setPrint_no(formData.getPcsn());
|
materialBase.setPrint_no(formData.getPcsn());
|
||||||
if (materialInfo != null) {
|
if (materialInfo != null) {
|
||||||
iMdMeMaterialbaseService.update(new LambdaUpdateWrapper<MdMeMaterialbase>()
|
iMdMeMaterialbaseService.update(new LambdaUpdateWrapper<MdMeMaterialbase>()
|
||||||
|
|||||||
Reference in New Issue
Block a user