fix: 优化输送线搬运任务与手持工单显示

This commit is contained in:
2024-11-04 14:57:43 +08:00
parent 849d93234a
commit 90f906c4f8
5 changed files with 48 additions and 27 deletions

View File

@@ -27,6 +27,8 @@ public class FjOrderVo {
private String material_name;
/** 物料规格 */
private String material_spec;
/** 砖型 */
private String material_model;
private String ext_data;
/** 订单号 */
private String order_no;

View File

@@ -445,7 +445,7 @@ public class PdaServiceImpl implements PdaService {
for (FjOrderVo order : orders) {
String extData = order.getExt_data();
if (ObjectUtil.isNotEmpty(extData)) {
JSONObject object = JSONObject.parseObject(extData);
JSONObject object = TaskUtils.parseObject(extData, "客户/订单信息");
order.setOrder_no(ObjectUtil.isNotEmpty(object.getString("order_no"))
? object.getString("order_no") : "-");
order.setCuster_no(ObjectUtil.isNotEmpty(object.getString("custer_no"))
@@ -505,7 +505,7 @@ public class PdaServiceImpl implements PdaService {
workorderService.updateById(order);
// 创建任务
JSONObject taskParam = new JSONObject();
taskParam.put("device_code", "RGCDW01");
taskParam.put("device_code", "RGMDW01");
taskParam.put("config_code", "RGBZTask");
taskParam.put("vehicle_code", vehicleCode);
taskParam.put("vehicle_type", vehicleType);

View File

@@ -170,6 +170,7 @@
,ma.material_name
,ma.material_code
,ma.material_spec
,ma.material_model
,ma.half_material_code
FROM pdm_bd_workorder wo
LEFT JOIN md_base_material ma ON ma.material_id = wo.material_id

View File

@@ -107,10 +107,9 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
// 如果是分拣(并且点位不是分拣输送线),就特殊处理
if (GeneralDefinition.AREA_FJ.equals(entity.getRegion_code())
&& !"6".equals(point.getPoint_type())) {
toCalculatePlannedQuantity(entity);
// 如果是分拣,就特殊处理
if (GeneralDefinition.AREA_FJ.equals(entity.getRegion_code())) {
toCalculatePlannedQuantity(entity, point);
}
pdmBdWorkorderMapper.insert(entity);
}
@@ -120,33 +119,36 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
*
* @param entity
*/
private void toCalculatePlannedQuantity(PdmBdWorkorder entity) {
// 获取物料
MdBaseMaterial material = materialService.getById(entity.getMaterial_id());
if (ObjectUtil.isEmpty(material.getPack_method()) || ObjectUtil.isEmpty(material.getPack_palletspec())) {
throw new BadRequestException("创建工单失败,物料[" + entity.getMaterial_id() + "]包装规格为空,请维护!");
private void toCalculatePlannedQuantity(PdmBdWorkorder entity, SchBasePoint point) {
// (点位不是分拣输送线)
if (!"6".equals(point.getPoint_type())) {
// 获取物料
MdBaseMaterial material = materialService.getById(entity.getMaterial_id());
if (ObjectUtil.isEmpty(material.getPack_method()) || ObjectUtil.isEmpty(material.getPack_palletspec())) {
throw new BadRequestException("创建工单失败,物料[" + entity.getMaterial_id() + "]包装规格为空,请维护!");
}
// 计划量
int orderSubnum = entity.getOrder_subnum();
// 已经包装数
int guadansum = entity.getGuadansum();
// 剩余数
int residueNum = orderSubnum - guadansum;
int multiply = TaskUtils.convertMultiply(entity.getPack_method());
// 计算需要多少木托
int ceil = (int) Math.ceil(residueNum / multiply);
// 获取此物料在库存中有多少
int inventoryQty = vehiclematerialgroupService.getInventoryQtyByMaterialId(entity.getMaterial_id());
// 查看库存能有多少托
int inventoryCeil = (int) Math.ceil(inventoryQty / multiply);
entity.setPlan_qty(ceil > inventoryCeil ? BigDecimal.valueOf(inventoryCeil) : BigDecimal.valueOf(ceil));
entity.setPlan_weight(ceil > inventoryCeil ? BigDecimal.valueOf(inventoryQty) : BigDecimal.valueOf(residueNum)); // 对于分拣就是计划钢托盘上的砖数量
entity.setProduce_order(entity.getOrder_no());
}
// 计划量
int orderSubnum = entity.getOrder_subnum();
// 已经包装数
int guadansum = entity.getGuadansum();
// 剩余数
int residueNum = orderSubnum - guadansum;
int multiply = TaskUtils.convertMultiply(entity.getPack_method());
// 计算需要多少木托
int ceil = (int) Math.ceil(residueNum / multiply);
// 获取此物料在库存中有多少
int inventoryQty = vehiclematerialgroupService.getInventoryQtyByMaterialId(entity.getMaterial_id());
// 查看库存能有多少托
int inventoryCeil = (int) Math.ceil(inventoryQty / multiply);
// 工单号和客户编码存放json
JSONObject res = new JSONObject();
res.put("order_no", entity.getOrder_no());
res.put("custer_no", entity.getCuster_no());
entity.setPlan_qty(ceil > inventoryCeil ? BigDecimal.valueOf(inventoryCeil) : BigDecimal.valueOf(ceil));
entity.setExt_data(res.toJSONString());
entity.setPlan_weight(ceil > inventoryCeil ? BigDecimal.valueOf(inventoryQty) : BigDecimal.valueOf(residueNum)); // 对于分拣就是计划钢托盘上的砖数量
entity.setProduce_order(entity.getOrder_no());
}
@Override

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.SpringContextHolder;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
@@ -223,4 +224,19 @@ public class TaskUtils {
}
return result;
}
/**
* 转换JSONObject
* @param param
* @return
*/
public static JSONObject parseObject(String param, String tip) {
JSONObject jsonObject;
try {
jsonObject = JSONObject.parseObject(param);
} catch (Exception e) {
throw new BadRequestException("转化JSON错误, " + tip + "{" + param + "}");
}
return jsonObject;
}
}