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.sch.point.dao.SchBasePoint;
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.storage_manage.database.service.IBstIvtBoxinfoService;
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.wms.ext.acs.service.WmsToAcsService;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
@@ -32,7 +39,7 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
* 入空载具服务
*/
@Autowired
private InVehicleManageService inVehicleManageService;
private IschBaseTaskService ischBaseTaskService;
/**
* 入空木箱服务
@@ -186,6 +193,17 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
String bill_type = whereJson.getString("bill_type");
whereJson.put("material_barcode", whereJson.getString("box_no"));
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")) {
whereJson.put("bill_type", IOSEnum.IN_TYPE.code("返检入库"));
} else if (bill_type.equals("2")) {

View File

@@ -1,5 +1,6 @@
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.extension.plugins.pagination.Page;
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<JSONObject> getStructInfoBySZLS();
}

View File

@@ -110,6 +110,9 @@
</if>
ORDER BY box_group
</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>

View File

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

View File

@@ -770,5 +770,9 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
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);
if (ObjectUtil.isEmpty(taskArrAll)) {
taskArrAll = wo_Task
.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);
return;
// taskArrAll = wo_Task
// .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输送出库任务

View File

@@ -4,8 +4,12 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
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.modules.wql.WQL;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@@ -26,6 +35,8 @@ public class LmsToBigScreenServiceImpl implements LmsToBigScreenService {
@Autowired
private final WmsToAcsService wmsToAcsService;
@Autowired
private IpdmBiSubpackagerelationService ipdmBiSubpackagerelationService;
@Override
public JSONObject getDeviceInfo(JSONObject jo) {
@@ -59,50 +70,50 @@ public class LmsToBigScreenServiceImpl implements LmsToBigScreenService {
@Override
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();
for (int i = 0; i < rows.size(); i++) {
JSONObject row = rows.getJSONObject(i);
JSONObject json = new JSONObject();
String struct_code = row.getString("struct_code");
json.put("struct_code", struct_code);
json.put("struct_status", "0");
String storagevehicle_code = row.getString("storagevehicle_code");
if (StrUtil.isNotEmpty(storagevehicle_code)) {
json.put("storagevehicle_code", storagevehicle_code);
if (storagevehicle_code.startsWith("KTP")) {
json.put("struct_status", "1");
}
String struct_id = row.getString("struct_id");
JSONArray array = WQL
.getWO("QST_STRUCTATTR")
.addParamMap(MapOf.of("struct_id", struct_id, "flag", "1"))
.process()
.getResultJSONArray(0);
// 计算合计
JSONObject object = array.getJSONObject(0);
if (ObjectUtil.isNotEmpty(object.getString("net_weight"))) {
BigDecimal container_weight = array.stream().map(info -> ((JSONObject) info).getBigDecimal("net_weight")).reduce(BigDecimal.ZERO, BigDecimal::add);
json.put("container_weight", container_weight);
json.put("product_description", object.getString("product_description"));
json.put("sale_order_name", object.getString("sale_order_name"));
json.put("quanlity_in_box", object.getString("quanlity_in_box"));
json.put("box_weight", object.getString("box_weight"));
json.put("struct_status", "2");
JSONArray detail = new JSONArray();
for (int j = 0; j < array.size(); j++) {
JSONObject dtl = array.getJSONObject(j);
String container_name = dtl.getString("container_name");
String net_weight = dtl.getString("net_weight");
JSONObject jsonObject = new JSONObject();
jsonObject.put("container_name", container_name);
jsonObject.put("net_weight", net_weight);
detail.add(jsonObject);
}
json.put("detail", detail);
}
List<String> boxs = new ArrayList<>();
for (JSONObject row : rows) {
String box = row.getString("storagevehicle_code");
if (!StringUtils.isEmpty(box) && box.contains("MX")){
boxs.add(box);
}
}
List<PdmBiSubpackagerelation> list = ipdmBiSubpackagerelationService.list(new QueryWrapper<PdmBiSubpackagerelation>()
.in("package_box_sn", boxs)
.select("package_box_sn","container_name","product_description", "sale_order_name", "quanlity_in_box","box_weight", "net_weight"));
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++) {
JSONObject row = rows.get(i);
String box = row.getString("storagevehicle_code");
if (!StringUtils.isEmpty(box)){
JSONObject item = new JSONObject();
item.put("storagevehicle_code", box);
if (box.startsWith("KTP")) {
item.put("struct_status", "1");
}else {
List<PdmBiSubpackagerelation> subs = collect.get(box);
if (!CollectionUtils.isEmpty(subs) && StringUtils.isNotEmpty(subs.get(0).getNet_weight())){
BigDecimal container_weight = subs.stream().map(info -> new BigDecimal(info.getNet_weight()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
item.put("container_weight", container_weight);
item.put("product_description", subs.get(0).getProduct_description());
item.put("sale_order_name", subs.get(0).getSale_order_name());
item.put("quanlity_in_box", subs.get(0).getQuanlity_in_box());
item.put("box_weight", subs.get(0).getBox_weight());
item.put("struct_status", "2");
JSONArray detail = new JSONArray();
for (PdmBiSubpackagerelation dtl : subs) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("container_name", dtl.getContainer_name());
jsonObject.put("net_weight", dtl.getNet_weight());
detail.add(jsonObject);
}
item.put("detail", detail);
}
}
data.add(item);
}
data.add(json);
}
return data;
}