opt:RK1004任务冲突;fix:出库AGV并发问题;opt:数字孪生sql优化

This commit is contained in:
zhangzq
2025-03-18 11:04:52 +08:00
parent a8878b77a0
commit 3a20cf0c92
7 changed files with 92 additions and 46 deletions

View File

@@ -9,6 +9,8 @@ import org.apache.commons.lang3.StringUtils;
import org.nl.b_lms.pda.service.VehicleTwoService; import org.nl.b_lms.pda.service.VehicleTwoService;
import org.nl.b_lms.sch.point.dao.SchBasePoint; import org.nl.b_lms.sch.point.dao.SchBasePoint;
import org.nl.b_lms.sch.point.service.IschBasePointService; import org.nl.b_lms.sch.point.service.IschBasePointService;
import org.nl.b_lms.sch.task.dao.SchBaseTask;
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
import org.nl.b_lms.sch.tasks.TwoInEmpExcepTask; import org.nl.b_lms.sch.tasks.TwoInEmpExcepTask;
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxinfoService; import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxinfoService;
import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxinfo; import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxinfo;
@@ -20,9 +22,14 @@ import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.ext.acs.service.WmsToAcsService; import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.mes.service.LmsToMesService; import org.nl.wms.ext.mes.service.LmsToMesService;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@@ -32,7 +39,7 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
* 入空载具服务 * 入空载具服务
*/ */
@Autowired @Autowired
private InVehicleManageService inVehicleManageService; private IschBaseTaskService ischBaseTaskService;
/** /**
* 入空木箱服务 * 入空木箱服务
@@ -186,6 +193,17 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
String bill_type = whereJson.getString("bill_type"); String bill_type = whereJson.getString("bill_type");
whereJson.put("material_barcode", whereJson.getString("box_no")); whereJson.put("material_barcode", whereJson.getString("box_no"));
whereJson.put("device_code", whereJson.getString("point_code")); whereJson.put("device_code", whereJson.getString("point_code"));
if ("RK1002".equals(whereJson.getString("point_code"))){
List<SchBaseTask> list = ischBaseTaskService.list(new QueryWrapper<SchBaseTask>()
.select("task_id")
.eq("point_code2", "RK1004")
.eq("task_type", "010706")
.eq("is_delete", "0")
.lt("task_status", TaskStatusEnum.FINISHED.getCode()));
if (!CollectionUtils.isEmpty(list)){
throw new BadRequestException("稍后再试,异常口存在正在执行的任务"+ list.stream().map(SchBaseTask::getTask_id).collect(Collectors.joining(",")));
}
}
if (bill_type.equals("1")) { if (bill_type.equals("1")) {
whereJson.put("bill_type", IOSEnum.IN_TYPE.code("返检入库")); whereJson.put("bill_type", IOSEnum.IN_TYPE.code("返检入库"));
} else if (bill_type.equals("2")) { } else if (bill_type.equals("2")) {

View File

@@ -1,5 +1,6 @@
package org.nl.b_lms.pdm.subpackagerelation.dao.mapper; package org.nl.b_lms.pdm.subpackagerelation.dao.mapper;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -31,4 +32,6 @@ public interface PdmBiSubpackagerelationMapper extends BaseMapper<PdmBiSubpackag
List<PdmBiSubpackagerelationDto> queryContainerNameBySaleOrder(@Param("sale_order_name") String sale_order_name, @Param("container_name") String container_name); List<PdmBiSubpackagerelationDto> queryContainerNameBySaleOrder(@Param("sale_order_name") String sale_order_name, @Param("container_name") String container_name);
List<JSONObject> getStructInfoBySZLS();
} }

View File

@@ -110,6 +110,9 @@
</if> </if>
ORDER BY box_group ORDER BY box_group
</select> </select>
<select id="getStructInfoBySZLS" resultType="com.alibaba.fastjson.JSONObject">
select struct_code,storagevehicle_code from st_ivt_structattr where sect_code IN ('ZC01','KTP01','ZZ01','PD01')
</select>
</mapper> </mapper>

View File

@@ -121,6 +121,12 @@ public interface IpdmBiSubpackagerelationService extends IService<PdmBiSubpackag
*/ */
Map toEndSubpackagerelation(String code); Map toEndSubpackagerelation(String code);
/**
* 数字孪生用
* @return
*/
List<JSONObject> getStructInfoBySZLS();
} }

View File

@@ -770,5 +770,9 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
return result; return result;
} }
@Override
public List<JSONObject> getStructInfoBySZLS() {
return this.baseMapper.getStructInfoBySZLS();
}
} }

View File

@@ -319,9 +319,10 @@ public class TwoOutHeapTask extends AbstractAcsTask {
.getResultJSONArray(0).toJavaList(JSONObject.class); .getResultJSONArray(0).toJavaList(JSONObject.class);
if (ObjectUtil.isEmpty(taskArrAll)) { if (ObjectUtil.isEmpty(taskArrAll)) {
taskArrAll = wo_Task return;
.query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0' ORDER BY create_time") // taskArrAll = wo_Task
.getResultJSONArray(0).toJavaList(JSONObject.class); // .query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0' ORDER BY create_time")
// .getResultJSONArray(0).toJavaList(JSONObject.class);
} }
// 是否下发多个AGV输送出库任务 // 是否下发多个AGV输送出库任务

View File

@@ -4,8 +4,12 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.b_lms.pdm.subpackagerelation.dao.PdmBiSubpackagerelation;
import org.nl.b_lms.pdm.subpackagerelation.service.IpdmBiSubpackagerelationService;
import org.nl.common.utils.MapOf; import org.nl.common.utils.MapOf;
import org.nl.modules.wql.WQL; import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.core.bean.WQLObject;
@@ -16,8 +20,13 @@ import org.nl.wms.sch.manage.AutoQueryProudDayData;
import org.nl.wms.sch.tasks.URLEnum; import org.nl.wms.sch.tasks.URLEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@@ -26,6 +35,8 @@ public class LmsToBigScreenServiceImpl implements LmsToBigScreenService {
@Autowired @Autowired
private final WmsToAcsService wmsToAcsService; private final WmsToAcsService wmsToAcsService;
@Autowired
private IpdmBiSubpackagerelationService ipdmBiSubpackagerelationService;
@Override @Override
public JSONObject getDeviceInfo(JSONObject jo) { public JSONObject getDeviceInfo(JSONObject jo) {
@@ -59,50 +70,50 @@ public class LmsToBigScreenServiceImpl implements LmsToBigScreenService {
@Override @Override
public JSONArray getStructInfo(JSONObject jo) { public JSONArray getStructInfo(JSONObject jo) {
JSONArray rows = WQLObject.getWQLObject("st_ivt_structattr").query("sect_code IN ('ZC01','KTP01','ZZ01','PD01')").getResultJSONArray(0); List<JSONObject> rows = ipdmBiSubpackagerelationService.getStructInfoBySZLS();
JSONArray data = new JSONArray(); JSONArray data = new JSONArray();
for (int i = 0; i < rows.size(); i++) { List<String> boxs = new ArrayList<>();
JSONObject row = rows.getJSONObject(i); for (JSONObject row : rows) {
JSONObject json = new JSONObject(); String box = row.getString("storagevehicle_code");
String struct_code = row.getString("struct_code"); if (!StringUtils.isEmpty(box) && box.contains("MX")){
json.put("struct_code", struct_code); boxs.add(box);
json.put("struct_status", "0"); }
String storagevehicle_code = row.getString("storagevehicle_code"); }
if (StrUtil.isNotEmpty(storagevehicle_code)) { List<PdmBiSubpackagerelation> list = ipdmBiSubpackagerelationService.list(new QueryWrapper<PdmBiSubpackagerelation>()
json.put("storagevehicle_code", storagevehicle_code); .in("package_box_sn", boxs)
if (storagevehicle_code.startsWith("KTP")) { .select("package_box_sn","container_name","product_description", "sale_order_name", "quanlity_in_box","box_weight", "net_weight"));
json.put("struct_status", "1"); Map<String, List<PdmBiSubpackagerelation>> collect = list.stream().filter(a->StringUtils.isNotEmpty(a.getPackage_box_sn())).collect(Collectors.groupingBy(item -> item.getPackage_box_sn()));
} for (int i = 0; i < rows.size(); i++) {
String struct_id = row.getString("struct_id"); JSONObject row = rows.get(i);
JSONArray array = WQL String box = row.getString("storagevehicle_code");
.getWO("QST_STRUCTATTR") if (!StringUtils.isEmpty(box)){
.addParamMap(MapOf.of("struct_id", struct_id, "flag", "1")) JSONObject item = new JSONObject();
.process() item.put("storagevehicle_code", box);
.getResultJSONArray(0); if (box.startsWith("KTP")) {
// 计算合计 item.put("struct_status", "1");
JSONObject object = array.getJSONObject(0); }else {
if (ObjectUtil.isNotEmpty(object.getString("net_weight"))) { List<PdmBiSubpackagerelation> subs = collect.get(box);
BigDecimal container_weight = array.stream().map(info -> ((JSONObject) info).getBigDecimal("net_weight")).reduce(BigDecimal.ZERO, BigDecimal::add); if (!CollectionUtils.isEmpty(subs) && StringUtils.isNotEmpty(subs.get(0).getNet_weight())){
json.put("container_weight", container_weight); BigDecimal container_weight = subs.stream().map(info -> new BigDecimal(info.getNet_weight()))
json.put("product_description", object.getString("product_description")); .reduce(BigDecimal.ZERO, BigDecimal::add);
json.put("sale_order_name", object.getString("sale_order_name")); item.put("container_weight", container_weight);
json.put("quanlity_in_box", object.getString("quanlity_in_box")); item.put("product_description", subs.get(0).getProduct_description());
json.put("box_weight", object.getString("box_weight")); item.put("sale_order_name", subs.get(0).getSale_order_name());
json.put("struct_status", "2"); item.put("quanlity_in_box", subs.get(0).getQuanlity_in_box());
JSONArray detail = new JSONArray(); item.put("box_weight", subs.get(0).getBox_weight());
for (int j = 0; j < array.size(); j++) { item.put("struct_status", "2");
JSONObject dtl = array.getJSONObject(j); JSONArray detail = new JSONArray();
String container_name = dtl.getString("container_name"); for (PdmBiSubpackagerelation dtl : subs) {
String net_weight = dtl.getString("net_weight"); JSONObject jsonObject = new JSONObject();
JSONObject jsonObject = new JSONObject(); jsonObject.put("container_name", dtl.getContainer_name());
jsonObject.put("container_name", container_name); jsonObject.put("net_weight", dtl.getNet_weight());
jsonObject.put("net_weight", net_weight); detail.add(jsonObject);
detail.add(jsonObject); }
} item.put("detail", detail);
json.put("detail", detail); }
} }
data.add(item);
} }
data.add(json);
} }
return data; return data;
} }