rev 部分bug修复、不跳过困料区以及工单确认信号下发不到电气

This commit is contained in:
2023-04-15 22:46:58 +08:00
parent 6f8881f8cb
commit bb7cf6ddb2
15 changed files with 473 additions and 226 deletions

View File

@@ -388,6 +388,7 @@ public class HfStationDeviceDriver extends AbstractOpcDeviceDriver implements De
produceshiftorderService.update(dto);
this.setRequireSucess(true);
this.writing(8);
this.writing(8);
logServer.deviceInfo("人工排产确认", this.getDevice_code(), "人工排产确认成功!");
}
return true;

View File

@@ -2,7 +2,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
jackson:
time-zone: GMT+8
data:

View File

@@ -293,7 +293,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
put("vehicle_type", "1");
put("vehicle_code", barcode.toString());
}};
log.info("混碾机满盅入库申请任务时,设备号:{},扫到的载具号为:{}", point_code, barcode);
WQLObject.getWQLObject("sch_base_point")
.update(vehicle, "point_code = '" + point_code + "'");
WQLObject.getWQLObject("st_ivt_structivt")
@@ -333,8 +333,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String device_code = whereJson.getString("device_code");
//条码
StringBuilder barcodeBuilder = new StringBuilder(StrUtil.isBlank(whereJson.getString("barcode")) ? "" : whereJson.getString("barcode"));
//是否是第一个工位
String is_first = whereJson.getString("is_first");
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
WQLObject wo_ivt = WQLObject.getWQLObject("ST_IVT_StructIvt");
MaterialbaseDto materialbaseDto = null;
@@ -396,59 +394,59 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
pointJson.put("update_time", DateUtil.now());
wo.update(pointJson);
//如果是第一个工位的条码变化 则需要更新困料区等的库存信息 因为第一个是从困料区过来的
if (StrUtil.equals(is_first, "true")) {
//获取困料区的缓存信息
LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
if (ll.size() == 0) ll = structivtService.reload();
Boolean isHasGoods = false;
JSONObject jsonObject = wo.query("is_used = '1' and is_delete = '0' and lock_type = '2' and region_code = '" + RegionTypeEnum.GT1.getCode() + "'").uniqueResult(0);
JSONObject ivtJsonObject = new JSONObject();
if (ObjectUtil.isNotEmpty(jsonObject)) {
ivtJsonObject = wo_ivt.query("point_code = '" + jsonObject.getString("point_code") + "' and (vehicle_code <> '' or vehicle_code is not null)").uniqueResult(0);
if (ObjectUtil.isNotEmpty(ivtJsonObject)) {
isHasGoods = true;
}
}
if (ll.size() == (HcwNumEnum.KLZCQ.getNum() + HcwNumEnum.GT2.getNum()) && isHasGoods) {
ll.removeFirst();
materialbaseDto = materialbaseService.findById(ivtJsonObject.getLong("material_id"));
JSONObject map = new JSONObject();
map.put("vehicle_type", ivtJsonObject.getString("vehicle_type"));
map.put("vehicle_code", ivtJsonObject.getString("vehicle_code"));
if (ObjectUtil.isNotEmpty(materialbaseDto)) {
map.put("material_code", materialbaseDto.getMaterial_code());
}
map.put("ivt_qty", ivtJsonObject.getString("ivt_qty"));
boolean flag = klzhcwUtil.judge(ll, map);
if (flag) {
jsonObject.put("lock_type", "1");
jsonObject.put("task_id", "");
jsonObject.put("point_status", "1");
jsonObject.put("update_time", DateUtil.now());
wo.update(jsonObject);
JSONObject ivtJson = wo_ivt.query("point_code = '" + jsonObject.getString("point_code") + "'").uniqueResult(0);
ivtJson.put("vehicle_type", "");
ivtJson.put("vehicle_code", "");
ivtJson.put("material_id", "");
ivtJson.put("ivt_qty", "0");
wo_ivt.update(ivtJson);
}
} else if (ll.size() == (HcwNumEnum.KLZCQ.getNum() + HcwNumEnum.GT2.getNum()) && !isHasGoods) {
ll.removeFirst();
klzhcwUtil.lessThan25(ll);
JSONObject jsonGT2 = wo_ivt.query("region_code = '" + RegionTypeEnum.GT2.getCode() + "'").uniqueResult(0);
jsonGT2.put("vehicle_code", "");
jsonGT2.put("vehicle_type", "");
jsonGT2.put("material_id", "");
jsonGT2.put("ivt_qty", "0");
wo_ivt.update(jsonGT2);
JSONObject jsonObject2 = wo.query("point_code = '" + jsonGT2.getString("point_code") + "'").uniqueResult(0);
jsonObject2.put("point_status", "1");
jsonObject2.put("update_time", DateUtil.now());
wo.update(jsonObject2);
}
}
// //如果是第一个工位的条码变化 则需要更新困料区等的库存信息 因为第一个是从困料区过来的
// if (StrUtil.equals(is_first, "true")) {
// //获取困料区的缓存信息
// LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
// if (ll.size() == 0) ll = structivtService.reload();
// Boolean isHasGoods = false;
// JSONObject jsonObject = wo.query("is_used = '1' and is_delete = '0' and lock_type = '2' and region_code = '" + RegionTypeEnum.GT1.getCode() + "'").uniqueResult(0);
// JSONObject ivtJsonObject = new JSONObject();
// if (ObjectUtil.isNotEmpty(jsonObject)) {
// ivtJsonObject = wo_ivt.query("point_code = '" + jsonObject.getString("point_code") + "' and (vehicle_code <> '' or vehicle_code is not null)").uniqueResult(0);
// if (ObjectUtil.isNotEmpty(ivtJsonObject)) {
// isHasGoods = true;
// }
// }
// if (ll.size() == (HcwNumEnum.KLZCQ.getNum() + HcwNumEnum.GT2.getNum()) && isHasGoods) {
// ll.removeFirst();
// materialbaseDto = materialbaseService.findById(ivtJsonObject.getLong("material_id"));
// JSONObject map = new JSONObject();
// map.put("vehicle_type", ivtJsonObject.getString("vehicle_type"));
// map.put("vehicle_code", ivtJsonObject.getString("vehicle_code"));
// if (ObjectUtil.isNotEmpty(materialbaseDto)) {
// map.put("material_code", materialbaseDto.getMaterial_code());
// }
// map.put("ivt_qty", ivtJsonObject.getString("ivt_qty"));
// boolean flag = klzhcwUtil.judge(ll, map);
// if (flag) {
// jsonObject.put("lock_type", "1");
// jsonObject.put("task_id", "");
// jsonObject.put("point_status", "1");
// jsonObject.put("update_time", DateUtil.now());
// wo.update(jsonObject);
// JSONObject ivtJson = wo_ivt.query("point_code = '" + jsonObject.getString("point_code") + "'").uniqueResult(0);
// ivtJson.put("vehicle_type", "");
// ivtJson.put("vehicle_code", "");
// ivtJson.put("material_id", "");
// ivtJson.put("ivt_qty", "0");
// wo_ivt.update(ivtJson);
// }
// } else if (ll.size() == (HcwNumEnum.KLZCQ.getNum() + HcwNumEnum.GT2.getNum()) && !isHasGoods) {
// ll.removeFirst();
// klzhcwUtil.lessThan25(ll);
// JSONObject jsonGT2 = wo_ivt.query("region_code = '" + RegionTypeEnum.GT2.getCode() + "'").uniqueResult(0);
// jsonGT2.put("vehicle_code", "");
// jsonGT2.put("vehicle_type", "");
// jsonGT2.put("material_id", "");
// jsonGT2.put("ivt_qty", "0");
// wo_ivt.update(jsonGT2);
// JSONObject jsonObject2 = wo.query("point_code = '" + jsonGT2.getString("point_code") + "'").uniqueResult(0);
// jsonObject2.put("point_status", "1");
// jsonObject2.put("update_time", DateUtil.now());
// wo.update(jsonObject2);
// }
// }
JSONObject resp = new JSONObject();
resp.put("status", "200");
resp.put("message", "申请成功");

View File

@@ -112,6 +112,15 @@ public class HandlingTaskServiceImpl implements HandlingTaskService {
return result;
}
}
if (RegionTypeEnum.MLZZCQ.getCode().equals(start_region_code) && RegionTypeEnum.MLZZCQ.getCode().equals(next_region_code)) {
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
JSONObject jsonStart = pointTab.query("point_code = '" + start_point_code + "'").uniqueResult(0);
if (jsonStart.getString("point_status").equals("3")) {
result.put("code", "0");
result.put("desc", "起点:'" + start_point_code + "'有货,不允许搬运此任务!");
return result;
}
}
HandlingTask taskBean = SpringContextHolder.getBean(HandlingTask.class);
taskBean.createTask(whereJson);
result.put("code", "1");

View File

@@ -1,5 +1,6 @@
package org.nl.wms.pda.inStruct.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
@@ -9,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RedisUtils;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.basedata.service.MaterialbaseService;
import org.nl.wms.basedata.service.VehicleService;
import org.nl.wms.basedata.service.dto.MaterialbaseDto;
@@ -17,10 +19,13 @@ import org.nl.wms.ext.acs.service.AcsToWmsService;
import org.nl.wms.pda.inStruct.service.InStructService;
import org.nl.wms.pda.scanGroup.KlzhcwUtil;
import org.nl.wms.pda.scanGroup.MyLinkedListService;
import org.nl.wms.st.structivt.service.KlhcqIvt;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
@Service
@RequiredArgsConstructor
@@ -62,9 +67,12 @@ public class InStructServiceImpl implements InStructService {
if (ObjectUtil.isEmpty(vehicle)) {
throw new BadRequestException("载具号不存在");
}
JSONObject map = new JSONObject();
String vehicle_type = vehicle.getVehicle_type();
// JSONObject map = new JSONObject();
// String vehicle_type = vehicle.getVehicle_type();
String type = param.getString("type");
Map<String, String> ivtMap = new HashMap<>();
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
JSONObject ivtEnd = ivtTab.query("point_code = 'GT01'").uniqueResult(0);
if ("2".equals(type)) {
String material_code = param.getString("material_code");
if (StrUtil.isBlank(material_code)) {
@@ -77,16 +85,38 @@ public class InStructServiceImpl implements InStructService {
redisUtils.set(vehicle_code, material.getMaterial_id().toString());
redisUtils.set(vehicle_code + "-ivt_qty", "1");
log.info("手持入库确认type2,往redis中存储载具信息,载具号:{},物料信息:{},物料数量:{}", vehicle_code, material.getMaterial_id(), "1");
map.put("material_code", material_code);
// map.put("material_code", material_code);
ivtMap.put(vehicle_code, ObjectUtil.isEmpty(material.getMaterial_id()) ? "" : material.getMaterial_id().toString());
try {
KlhcqIvt.add(ivtMap);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("手持入库确认更新困料区库存出现异常!" + e.getMessage());
}
ivtEnd.put("vehicle_type", vehicle.getVehicle_type());
ivtEnd.put("vehicle_code", vehicle.getVehicle_code());
ivtEnd.put("material_id", material.getMaterial_id().toString());
ivtTab.update(ivtEnd);
} else {
String material_code = param.getString("material_code");
if (StrUtil.isNotBlank(material_code)) {
throw new BadRequestException("空盅不能选择物料编码");
}
redisUtils.set(vehicle_code, "");
redisUtils.set(vehicle_code + "-ivt_qty", "1");
log.info("手持入库确认type1,往redis中存储载具信息,载具号:{},物料信息:{},物料数量:{}", vehicle_code, "", "1");
ivtMap.put(vehicle_code, "");
try {
KlhcqIvt.add(ivtMap);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("手持入库确认更新困料区库存出现异常!" + e.getMessage());
}
ivtEnd.put("vehicle_type", vehicle.getVehicle_type());
ivtEnd.put("vehicle_code", vehicle.getVehicle_code());
ivtEnd.put("material_id", "");
ivtTab.update(ivtEnd);
}
map.put("vehicle_code", vehicle_code);
map.put("vehicle_type", vehicle_type);
LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
klzhcwUtil.judge(ll, map);
JSONObject result = new JSONObject();
result.put("code", "1");
result.put("desc", "入库成功");

View File

@@ -11,6 +11,8 @@ import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.basedata.service.VehicleService;
import org.nl.wms.basedata.service.dto.VehicleDto;
import org.nl.wms.pda.outStruct.service.OutStructService;
import org.nl.wms.sch.tasks.RegionTypeEnum;
import org.nl.wms.st.structivt.service.KlhcqIvt;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -39,7 +41,7 @@ public class OutStructServiceImpl implements OutStructService {
log.info("手持出库确认,从redis中删除对应的载具号:{},物料信息:{}", vehicle_code, redisUtils.get(vehicle_code));
redisUtils.del(vehicle_code);
redisUtils.del(vehicle_code + "-ivt_qty");
JSONObject jsonObject = wo.query("vehicle_code = '" + vehicle + "'").uniqueResult(0);
JSONObject jsonObject = wo.query("vehicle_code = '" + vehicle_code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonObject)) {
jsonObject.put("vehicle_type", "");
jsonObject.put("vehicle_code", "");
@@ -54,6 +56,10 @@ public class OutStructServiceImpl implements OutStructService {
jsonObject1.put("vehicle_type", "");
jsonObject1.put("vehicle_code", "");
wo_point.update(jsonObject1);
if (jsonObject.getString("region_code").equals(RegionTypeEnum.KLZCQ.getCode())
|| (jsonObject.getString("region_code").equals(RegionTypeEnum.GT1.getCode()))) {
KlhcqIvt.clear();
}
}
JSONObject result = new JSONObject();
result.put("code", "1");

View File

@@ -65,7 +65,7 @@ public class PointServiceImpl implements PointService {
if (!ObjectUtil.isEmpty(point_status)) {
JSONObject statusArr = new JSONObject();
String[] split = point_status_explain.split("");
for ( int j = 0; j < split.length; j++) {
for (int j = 0; j < split.length; j++) {
String[] status = split[j].split("-");
statusArr.put(status[0], status[1]);
}
@@ -75,7 +75,7 @@ public class PointServiceImpl implements PointService {
if (!ObjectUtil.isEmpty(point_type)) {
JSONObject typeArr = new JSONObject();
String[] split = point_type_explain.split("");
for ( int j = 0; j < split.length; j++) {
for (int j = 0; j < split.length; j++) {
String[] types = split[j].split("-");
typeArr.put(types[0], types[1]);
}
@@ -148,6 +148,7 @@ public class PointServiceImpl implements PointService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(PointDto dto) {
log.info("修改点位信息,参数:{}", JSON.toJSONString(dto));
PointDto entity = this.findById(dto.getPoint_id());
if (entity == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
@@ -275,7 +276,7 @@ public class PointServiceImpl implements PointService {
WQLObject wo = WQLObject.getWQLObject("sch_base_Point");
JSONArray data = jsonObject.getJSONArray("data");
String used = jsonObject.getString("used");
for ( int i = 0; i < data.size(); i++ ) {
for (int i = 0; i < data.size(); i++) {
JSONObject object = data.getJSONObject(i);
if (used.equals("1")) object.put("is_used", 1);
else object.put("is_used", 0);
@@ -293,7 +294,7 @@ public class PointServiceImpl implements PointService {
WQLObject wo = WQLObject.getWQLObject("sch_base_Point");
JSONArray data = jsonObject.getJSONArray("data");
String lock = jsonObject.getString("lock_type");
for ( int i = 0; i < data.size(); i++ ) {
for (int i = 0; i < data.size(); i++) {
JSONObject object = data.getJSONObject(i);
if (lock.equals("1")) object.put("lock_type", 1);
else object.put("lock_type", 2);

View File

@@ -12,7 +12,6 @@ import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.ext.acs.service.impl.AcsToWmsServiceImpl;
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
import org.nl.wms.sch.SchTaskDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
@@ -68,10 +67,12 @@ public class HnjCallEmpVehicleTask extends AbstractAcsTask {
taskTab.update(taskObj);
//解锁起点
jsonStart.put("lock_type", "1");
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
if (ObjectUtil.isNotEmpty(jsonStart)) {
jsonStart.put("lock_type", "1");
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
}
}
// 更新任务状态为执行中
@@ -94,6 +95,7 @@ public class HnjCallEmpVehicleTask extends AbstractAcsTask {
JSONObject ivtStart = ivtTab.query("point_code = '" + point_code1 + "'").uniqueResult(0);
JSONObject ivtEnd = ivtTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
//修改终点库存
ivtEnd.put("vehicle_type", jsonTask.getString("vehicle_type"));
ivtEnd.put("vehicle_code", jsonTask.getString("vehicle_code"));
@@ -110,6 +112,7 @@ public class HnjCallEmpVehicleTask extends AbstractAcsTask {
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("混碾机叫空盅任务完成,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
//修改起点库存
ivtStart.put("vehicle_type", "");
@@ -127,6 +130,7 @@ public class HnjCallEmpVehicleTask extends AbstractAcsTask {
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("混碾机叫空盅任务完成,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
}
}

View File

@@ -66,10 +66,12 @@ public class YljCallMaterialTask extends AbstractAcsTask {
taskTab.update(taskObj);
// 点位解锁
jsonStart.put("lock_type", "1");
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
if (ObjectUtil.isNotEmpty(jsonStart)){
jsonStart.put("lock_type", "1");
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
}
}
if (StrUtil.equals(status, TaskStatusEnum.EXECUTING.getCode())) {
@@ -120,6 +122,7 @@ public class YljCallMaterialTask extends AbstractAcsTask {
// jsonStart.put("material_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("压力机叫料任务完成,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
//修改终点库存 即空盅对接位因为压力机叫完料 放到空盅对接位才上报放货完成 此时需要修改空盅对接位的库存 即
JSONObject ivtEnd = ivtTab.query("region_code = '" + RegionTypeEnum.GT4.getCode() + "'").uniqueResult(0);

View File

@@ -23,14 +23,12 @@ import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.tasks.AcsTaskDto;
import org.nl.wms.sch.tasks.RegionTypeEnum;
import org.nl.wms.st.structivt.service.KlhcqIvt;
import org.nl.wms.util.IdUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service
@RequiredArgsConstructor
@@ -69,14 +67,17 @@ public class HandlingTask extends AbstractAcsTask {
jsonTask.put("remark", "已取消");
taskTab.update(jsonTask);
jsonStart.put("lock_type", "1");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
jsonEnd.put("lock_type", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
if (ObjectUtil.isNotEmpty(jsonStart)){
jsonStart.put("lock_type", "1");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
}
if (ObjectUtil.isNotEmpty(jsonEnd)){
jsonEnd.put("lock_type", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
}
}
// 更新任务状态为执行中
@@ -93,38 +94,42 @@ public class HandlingTask extends AbstractAcsTask {
jsonTask.put("update_optname", "acs");
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
//更新起点终点的库存
JSONObject ivtStart = ivtTab.query("point_code = '" + point_code1 + "'").uniqueResult(0);
JSONObject ivtEnd = ivtTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
if (StrUtil.equals(region_codeS, RegionTypeEnum.HNJQ.getCode())) {
MaterialbaseServiceImpl materialbaseService = SpringContextHolder.getBean(MaterialbaseServiceImpl.class);
KlzhcwUtil klzhcwUtil = SpringContextHolder.getBean(KlzhcwUtil.class);
//更新终点的库存
//如果终点不是空料盅缓存区 则终点肯定是GT01
if (!StrUtil.equals(region_codeE, RegionTypeEnum.KLZHCQ.getCode())) {
MaterialbaseDto materialbaseDto = materialbaseService.findById(jsonTask.getLong("material_id"));
LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
JSONObject param = new JSONObject();
param.put("vehicle_type", jsonTask.getString("vehicle_type"));
param.put("vehicle_code", jsonTask.getString("vehicle_code"));
if (ObjectUtil.isNotEmpty(materialbaseDto)) {
param.put("material_code", materialbaseDto.getMaterial_code());
}
redisUtils.set(jsonTask.getString("vehicle_code"), StrUtil.isEmpty(jsonTask.getString("material_id")) ? "" : jsonTask.getString("material_id"));
redisUtils.set(jsonTask.getString("vehicle_code") + "-ivt_qty", "1");
log.info("手持创建任务,任务号:{},往redis中存储载具信息,载具号:{},物料信息:{},物料个数:{}", jsonTask.getString("task_code"), jsonTask.getString("vehicle_code"), jsonTask.getLong("material_id"), "1");
boolean flag = klzhcwUtil.judge(ll, param);
if (flag) {
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("手持任务完成,从混碾机到一号接驳位,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
Map<String, String> ivtMap = new HashMap<>();
ivtMap.put(taskObj.getString("vehicle_code"), taskObj.getString("material_id"));
try {
KlhcqIvt.add(ivtMap);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("手持任务完成,从混碾机到一号接驳位更新困料区库存出现异常!" + e.getMessage());
}
//修改终点库存
ivtEnd.put("vehicle_type", taskObj.getString("vehicle_type"));
ivtEnd.put("vehicle_code", taskObj.getString("vehicle_code"));
ivtEnd.put("material_id", taskObj.getString("material_id"));
ivtEnd.put("instorage_time", DateUtil.now());
ivtTab.update(ivtEnd);
} else {
JSONObject jsonObject = ivtTab.query("point_code = '" + jsonEnd.getString("point_code") + "'").uniqueResult(0);
//修改终点库存信息
@@ -139,35 +144,53 @@ public class HandlingTask extends AbstractAcsTask {
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("手持任务完成,从混碾机到空盅暂存区,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
}
} else if (StrUtil.equals(region_codeS, RegionTypeEnum.KLZHCQ.getCode()) && StrUtil.equals(region_codeE, RegionTypeEnum.GT1.getCode())) {
MaterialbaseServiceImpl materialbaseService = SpringContextHolder.getBean(MaterialbaseServiceImpl.class);
KlzhcwUtil klzhcwUtil = SpringContextHolder.getBean(KlzhcwUtil.class);
jsonStart.put("vehicle_type", "");
jsonStart.put("vehicle_code", "");
jsonStart.put("material_id", "");
jsonStart.put("point_status", "1");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
JSONObject jsonObject = ivtTab.query("point_code = '" + jsonStart.getString("point_code") + "'").uniqueResult(0);
//修改终点库存信息
jsonObject.put("vehicle_type", "");
jsonObject.put("vehicle_code", "");
jsonObject.put("material_id", "");
jsonObject.put("instorage_time", DateUtil.now());
ivtTab.update(jsonObject);
} else if (StrUtil.equals(region_codeS, RegionTypeEnum.KLZHCQ.getCode()) && StrUtil.equals(region_codeE, RegionTypeEnum.GT1.getCode())) {
MaterialbaseDto materialbaseDto = materialbaseService.findById(jsonTask.getLong("material_id"));
LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
JSONObject param = new JSONObject();
param.put("vehicle_type", jsonTask.getString("vehicle_type"));
param.put("vehicle_code", jsonTask.getString("vehicle_code"));
if (ObjectUtil.isNotEmpty(materialbaseDto)) {
param.put("material_code", materialbaseDto.getMaterial_code());
}
redisUtils.set(jsonTask.getString("vehicle_code"), StrUtil.isEmpty(jsonTask.getString("material_id")) ? "" : jsonTask.getString("material_id"));
redisUtils.set(jsonTask.getString("vehicle_code") + "-ivt_qty", "1");
log.info("手持创建任务,任务号:{},往redis中存储载具信息,载具号:{},物料信息:{},物料个数:{}", jsonTask.getString("task_code"), jsonTask.getString("vehicle_code"), jsonTask.getLong("material_id"), "1");
boolean flag = klzhcwUtil.judge(ll, param);
if (flag) {
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("手持任务完成,从空盅缓存区到一号接驳位,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
Map<String, String> ivtMap = new HashMap<>();
ivtMap.put(taskObj.getString("vehicle_code"), taskObj.getString("material_id"));
try {
KlhcqIvt.add(ivtMap);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("手持任务完成,从空盅缓存区到一号接驳位更新困料区库存出现异常!" + e.getMessage());
}
//修改终点库存
ivtEnd.put("vehicle_type", taskObj.getString("vehicle_type"));
ivtEnd.put("vehicle_code", taskObj.getString("vehicle_code"));
ivtEnd.put("material_id", taskObj.getString("material_id"));
ivtEnd.put("instorage_time", DateUtil.now());
ivtTab.update(ivtEnd);
//修改起点库存
ivtStart.put("vehicle_type", "");
ivtStart.put("vehicle_code", "");
@@ -183,6 +206,8 @@ public class HandlingTask extends AbstractAcsTask {
jsonStart.put("material_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("手持任务完成,从空盅缓存区到一号接驳位,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
} else if (StrUtil.equals(region_codeE, RegionTypeEnum.YLJQ.getCode())) {
//修改起点库存
ivtStart.put("vehicle_type", "");
@@ -200,6 +225,7 @@ public class HandlingTask extends AbstractAcsTask {
jsonStart.put("material_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("手持任务完成,从满料盅区到压力机区,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
//修改终点库存 即空盅对接位因为压力机叫完料 放到空盅对接位才上报放货完成 此时需要修改空盅对接位的库存 即
ivtEnd.put("vehicle_type", jsonTask.getString("vehicle_type"));
@@ -218,6 +244,12 @@ public class HandlingTask extends AbstractAcsTask {
ivtEnd.put("instorage_time", DateUtil.now());
ivtTab.update(ivtEnd);
//解锁终点
jsonEnd.put("point_status", "2");
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
//修改起点库存
ivtStart.put("vehicle_type", "");
ivtStart.put("vehicle_code", "");
@@ -234,6 +266,8 @@ public class HandlingTask extends AbstractAcsTask {
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("手持任务完成,到混碾区,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
} else if (StrUtil.equals(region_codeS, RegionTypeEnum.GT4.getCode())) {
log.info("手持创建任务,从redis删除对应的载具信息,载具号:{},物料信息:{}", jsonTask.getString("vehicle_code"), redisUtils.get(jsonTask.getString("vehicle_code")));
redisUtils.del(jsonTask.getString("vehicle_code"));
@@ -254,7 +288,7 @@ public class HandlingTask extends AbstractAcsTask {
jsonEnd.put("point_status", "2");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("手持任务完成,起点为GT04,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
//修改起点库存
ivtStart.put("vehicle_type", "");
ivtStart.put("vehicle_code", "");
@@ -270,6 +304,7 @@ public class HandlingTask extends AbstractAcsTask {
jsonStart.put("point_status", "1");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("手持任务完成,起点为GT04,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
} else if (StrUtil.equals(RegionTypeEnum.GT4.getCode(), region_codeE)
&& StrUtil.equals(RegionTypeEnum.MLZZCQ.getCode(), region_codeS)) {
//修改终点库存
@@ -288,7 +323,7 @@ public class HandlingTask extends AbstractAcsTask {
jsonEnd.put("point_status", "2");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("手持任务完成,从满料盅到GT04,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
//修改起点库存
// ivtStart.put("vehicle_type", "");
// ivtStart.put("vehicle_code", "");
@@ -304,6 +339,7 @@ public class HandlingTask extends AbstractAcsTask {
// jsonStart.put("point_status", "1");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("手持任务完成,从满料盅到GT04,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
}
}
}

View File

@@ -16,19 +16,18 @@ import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
import org.nl.wms.pda.scanGroup.KlzhcwUtil;
import org.nl.wms.pda.scanGroup.MyLinkedListService;
import org.nl.wms.sch.SchTaskDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.tasks.AcsTaskDto;
import org.nl.wms.sch.tasks.RegionTypeEnum;
import org.nl.wms.st.structivt.service.KlhcqIvt;
import org.nl.wms.util.IdUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -66,10 +65,12 @@ public class KzdjwSendEmpVehicleTask extends AbstractAcsTask {
taskTab.update(taskObj);
//解锁终点
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
if (ObjectUtil.isNotEmpty(jsonEnd)) {
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
}
}
if (StrUtil.equals(status, TaskStatusEnum.EXECUTING.getCode())) {
@@ -100,22 +101,31 @@ public class KzdjwSendEmpVehicleTask extends AbstractAcsTask {
JSONObject ivtStart = ivtTab.query("point_code = '" + point_code1 + "'").uniqueResult(0);
if ("GT01".equals(point_code2)) {
LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
JSONObject param = new JSONObject();
param.put("vehicle_type", taskObj.getString("vehicle_type"));
param.put("vehicle_code", taskObj.getString("vehicle_code"));
param.put("ivt_qty", taskObj.getString("qty"));
boolean flag = SpringContextHolder.getBean(KlzhcwUtil.class).judge(ll, param);
if (flag) {
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("空盅对接位任务完成,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
Map<String, String> ivtMap = new HashMap<>();
ivtMap.put(taskObj.getString("vehicle_code"), "");
try {
KlhcqIvt.add(ivtMap);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("空盅对接位送空盅到GT01更新困料区库存出现异常!" + e.getMessage());
}
JSONObject ivtEnd = ivtTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
//修改终点库存
ivtEnd.put("vehicle_type", taskObj.getString("vehicle_type"));
ivtEnd.put("vehicle_code", taskObj.getString("vehicle_code"));
ivtEnd.put("material_id", "");
ivtEnd.put("instorage_time", DateUtil.now());
ivtTab.update(ivtEnd);
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
redisUtils.set(taskObj.getString("vehicle_code"), StrUtil.isEmpty(taskObj.getString("material_id")) ? "" : taskObj.getString("material_id"));
redisUtils.set(taskObj.getString("vehicle_code") + "-ivt_qty", "1");
@@ -139,6 +149,7 @@ public class KzdjwSendEmpVehicleTask extends AbstractAcsTask {
jsonEnd.put("point_status", "2");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("空盅对接位任务完成,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
}
//修改起点库存
@@ -156,6 +167,7 @@ public class KzdjwSendEmpVehicleTask extends AbstractAcsTask {
jsonStart.put("point_status", "1");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("空盅对接位任务完成,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
}
}

View File

@@ -13,24 +13,21 @@ import org.nl.modules.common.utils.RedisUtils;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.basedata.service.dto.MaterialbaseDto;
import org.nl.wms.basedata.service.impl.MaterialbaseServiceImpl;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
import org.nl.wms.pda.scanGroup.KlzhcwUtil;
import org.nl.wms.pda.scanGroup.MyLinkedListService;
import org.nl.wms.sch.SchTaskDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.tasks.AcsTaskDto;
import org.nl.wms.sch.tasks.RegionTypeEnum;
import org.nl.wms.st.structivt.service.KlhcqIvt;
import org.nl.wms.util.IdUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -75,18 +72,22 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
//取空任务取消
if (StrUtil.equals(sort_seq, "1")) {
//解锁起点
jsonStart.put("lock_type", "1");
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
if (ObjectUtil.isNotEmpty(jsonStart)){
jsonStart.put("lock_type", "1");
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
}
}
//取满任务取消
if (StrUtil.equals(sort_seq, "2")) {
//解锁终点
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
if (ObjectUtil.isNotEmpty(jsonEnd)){
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
}
}
}
@@ -137,6 +138,7 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("混碾机双任务之取空任务完成,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
//修改起点库存
ivtStart.put("vehicle_type", "");
@@ -154,6 +156,7 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("混碾机双任务之取空任务完成,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
}
//取满任务完成
@@ -168,32 +171,33 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
return;
}
MaterialbaseServiceImpl materialbaseService = SpringContextHolder.getBean(MaterialbaseServiceImpl.class);
KlzhcwUtil klzhcwUtil = SpringContextHolder.getBean(KlzhcwUtil.class);
//更新终点的库存
String region_code = jsonEnd.getString("region_code");
if (!StrUtil.equals(region_code, RegionTypeEnum.KLZHCQ.getCode())) {
MaterialbaseDto materialbaseDto = materialbaseService.findById(Long.parseLong(taskObj.getString("material_id")));
LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
JSONObject param = new JSONObject();
param.put("vehicle_type", taskObj.getString("vehicle_type"));
param.put("vehicle_code", taskObj.getString("vehicle_code"));
if (ObjectUtil.isNotEmpty(materialbaseDto)) {
param.put("material_code", materialbaseDto.getMaterial_code());
}
param.put("ivt_qty", taskObj.getString("qty"));
boolean flag = klzhcwUtil.judge(ll, param);
if (flag) {
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("混碾机双任务之取满任务完成,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
JSONObject ivtEnd = ivtTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
Map<String, String> ivtMap = new HashMap<>();
ivtMap.put(taskObj.getString("vehicle_code"), taskObj.getString("material_id"));
try {
KlhcqIvt.add(ivtMap);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("混碾机双任务之取满任务完成更新困料区库存出现异常!" + e.getMessage());
}
//修改终点库存
ivtEnd.put("vehicle_type", taskObj.getString("vehicle_type"));
ivtEnd.put("vehicle_code", taskObj.getString("vehicle_code"));
ivtEnd.put("material_id", taskObj.getString("material_id"));
ivtEnd.put("instorage_time", DateUtil.now());
ivtTab.update(ivtEnd);
} else {
JSONObject jsonObject = ivtTab.query("point_code = '" + jsonEnd.getString("point_code") + "'").uniqueResult(0);
//修改终点库存信息
@@ -209,6 +213,7 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("混碾机双任务之取满任务完成,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
}
}
}
@@ -230,9 +235,13 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
JSONObject taskObj2 = taskTab.query("handle_class = '" + THIS_CLASS + "'and task_group_id = '" + task_group_id + "' and is_delete = '0' and task_status = '" + TaskStatusEnum.SURE_START.getCode() + "'").uniqueResult(0);
//1、查询未锁定,空料盅,空盅位暂存区的起始点位 如果有取空的点位 再判断取满时 是否有放货位
JSONObject json1 = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '2' AND region_code = '" + RegionTypeEnum.KLZHCQ.getCode() + "'").uniqueResult(0);
// 取空任务查询到有起点
if (ObjectUtil.isNotEmpty(json1)) {
JSONObject gt01Status = SpringContextHolder.getBean(WmsToAcsService.class).queryGT01Status();
//查询GT01是否锁定
JSONObject json2 = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '1' AND region_code = '" + RegionTypeEnum.GT1.getCode() + "'").uniqueResult(0);
//如果GT01未锁定并且GT01允许放货
if (ObjectUtil.isNotEmpty(json2) && gt01Status.getBooleanValue("GT01")) {
//锁定取空任务的起点
json1.put("lock_type", "2");
@@ -265,7 +274,9 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
taskTab.update(taskObj2);
} else {
//如果GTO1未锁定但是GT01不允许放货 就去查询空料盅位是否有空位
JSONObject json3 = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '1' AND region_code = '" + RegionTypeEnum.KLZHCQ.getCode() + "' and point_code <> 'KLZHC12'").uniqueResult(0);
//如果有空位
if (ObjectUtil.isNotEmpty(json3)) {
//锁定取空任务的起点
json1.put("lock_type", "2");
@@ -289,7 +300,7 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
taskTab.update(taskObj);
//更改取满任务中的载具信息 任务状态
JSONObject ivtJson3 = ivtTab.query("point_code = '" + json3.getString("point_code") + "'").uniqueResult(0);
JSONObject ivtJson3 = ivtTab.query("point_code = '" + taskObj2.getString("point_code1") + "'").uniqueResult(0);
taskObj2.put("point_code2", json3.getString("point_code"));
taskObj2.put("vehicle_code", ivtJson3.getString("vehicle_code"));
taskObj2.put("vehicle_type", ivtJson3.getString("vehicle_type"));

View File

@@ -9,26 +9,24 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RedisUtils;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.basedata.service.dto.MaterialbaseDto;
import org.nl.wms.basedata.service.impl.MaterialbaseServiceImpl;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
import org.nl.wms.pda.scanGroup.KlzhcwUtil;
import org.nl.wms.pda.scanGroup.MyLinkedListService;
import org.nl.wms.sch.SchTaskDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.tasks.AcsTaskDto;
import org.nl.wms.sch.tasks.RegionTypeEnum;
import org.nl.wms.st.structivt.service.KlhcqIvt;
import org.nl.wms.util.IdUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -73,16 +71,20 @@ public class TimingSendMaterialTask extends AbstractAcsTask {
taskTab.update(taskObj);
//解锁起点
jsonStart.put("lock_type", "1");
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
if (ObjectUtil.isNotEmpty(jsonStart)){
jsonStart.put("lock_type", "1");
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
}
//解锁起点
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
if (ObjectUtil.isNotEmpty(jsonEnd)){
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
}
}
// 更新任务状态为执行中
@@ -110,27 +112,38 @@ public class TimingSendMaterialTask extends AbstractAcsTask {
jsonTask.put("finished_type", finished_type);
taskTab.update(jsonTask);
MaterialbaseServiceImpl materialbaseService = SpringContextHolder.getBean(MaterialbaseServiceImpl.class);
KlzhcwUtil klzhcwUtil = SpringContextHolder.getBean(KlzhcwUtil.class);
MaterialbaseDto materialbaseDto = materialbaseService.findById(jsonTask.getLong("material_id"));
LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
JSONObject param = new JSONObject();
param.put("vehicle_type", jsonTask.getString("vehicle_type"));
param.put("vehicle_code", jsonTask.getString("vehicle_code"));
if (ObjectUtil.isNotEmpty(materialbaseDto)) {
param.put("material_code", materialbaseDto.getMaterial_code());
}
boolean flag = klzhcwUtil.judge(ll, param);
if (flag) {
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
if (jsonEnd.getString("region_code").equals(RegionTypeEnum.GT1.getCode())) {
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
redisUtils.set(taskObj.getString("vehicle_code"), StrUtil.isEmpty(taskObj.getString("material_id")) ? "" : taskObj.getString("material_id"));
redisUtils.set(taskObj.getString("vehicle_code") + "-ivt_qty", "1");
log.info("定时任务到GT01,往redis中存载具信息:载具号:{},物料信息:{}", taskObj.getString("vehicle_code"), taskObj.getString("material_id"));
Map<String, String> ivtMap = new HashMap<>();
ivtMap.put(taskObj.getString("vehicle_code"), taskObj.getString("material_id"));
try {
KlhcqIvt.add(ivtMap);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("定时任务完成更新困料区库存出现异常!" + e.getMessage());
}
//修改终点库存
JSONObject ivtEnd = ivtTab.query("point_code = '" + jsonEnd.getString("point_code") + "'").uniqueResult(0);
ivtEnd.put("vehicle_type", taskObj.getString("vehicle_type"));
ivtEnd.put("vehicle_code", taskObj.getString("vehicle_code"));
ivtEnd.put("material_id", taskObj.getString("material_id"));
ivtEnd.put("instorage_time", DateUtil.now());
ivtTab.update(ivtEnd);
}
jsonEnd.put("lock_type", "1");
jsonEnd.put("task_id", "");
jsonEnd.put("vehicle_type", "");
jsonEnd.put("vehicle_code", "");
jsonEnd.put("material_id", "");
jsonEnd.put("point_status", "1");
jsonEnd.put("update_time", DateUtil.now());
pointTab.update(jsonEnd);
log.info("定时任务完成,终点解锁成功,任务号:{}", taskObj.getString("task_code"));
//更新起点库存
JSONObject ivtStart = ivtTab.query("point_code = '" + jsonStart.getString("point_code") + "'").uniqueResult(0);
ivtStart.put("vehicle_type", "");
@@ -147,6 +160,7 @@ public class TimingSendMaterialTask extends AbstractAcsTask {
jsonStart.put("task_id", "");
jsonStart.put("update_time", DateUtil.now());
pointTab.update(jsonStart);
log.info("定时任务完成,起点解锁成功,任务号:{}", taskObj.getString("task_code"));
}
}

View File

@@ -0,0 +1,118 @@
package org.nl.wms.st.structivt.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.sch.tasks.RegionTypeEnum;
import org.nl.wms.st.structivt.service.dto.StructivtDto;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.stream.Collectors;
/**
* @author: geng by
* @createDate: 2023/4/12
*/
public class KlhcqIvt {
private static ArrayBlockingQueue<Map<String, String>> ivtQueue = new ArrayBlockingQueue<>(27);
//困料区+1号滚筒接驳机数量
private static final Integer MAX_NUM = 27;
private static final Integer MIN_NUM = 0;
/**
* 向队列中添加入到GT01的信息
*
* @param ivtMap
* @throws InterruptedException
*/
public static void add(Map<String, String> ivtMap) throws InterruptedException {
if (ivtQueue.size() == MIN_NUM) {
WQLObject wo = WQLObject.getWQLObject("st_ivt_structivt");
JSONArray resultJSONArray = wo.query("region_code = '" + RegionTypeEnum.KLZCQ.getCode() + "'", "point_code").getResultJSONArray(0);
List<StructivtDto> structivtDtos = resultJSONArray.toJavaList(StructivtDto.class);
Map<String, String> ivt;
for (int i = 0; i < structivtDtos.size(); i++) {
StructivtDto structivtDto = structivtDtos.get(i);
ivt = new HashMap<>();
ivt.put(structivtDto.getVehicle_code(), ObjectUtil.isEmpty(structivtDto.getMaterial_id()) ? "" : structivtDto.getMaterial_id().toString());
ivtQueue.put(ivt);
}
JSONObject resultJson = wo.query("region_code = '" + RegionTypeEnum.GT1.getCode() + "'", "point_code").uniqueResult(0);
StructivtDto structivtDto = resultJson.toJavaObject(StructivtDto.class);
ivt = new HashMap<>();
ivt.put(structivtDto.getVehicle_code(), ObjectUtil.isEmpty(structivtDto.getMaterial_id()) ? "" : structivtDto.getMaterial_id().toString());
ivtQueue.put(ivt);
}
updateHasEmptyInMiddle();
if (ivtQueue.size() == MAX_NUM) {
ivtQueue.take();
}
ivtQueue.put(ivtMap);
updateIvt();
}
/**
* 根据队列中的信息修改困料区库存
*/
public static void updateIvt() {
WQLObject wo = WQLObject.getWQLObject("st_ivt_structivt");
JSONArray resultJSONArray = wo.query("region_code = '" + RegionTypeEnum.KLZCQ.getCode() + "'", "point_code").getResultJSONArray(0);
List<StructivtDto> structivtDtos = resultJSONArray.toJavaList(StructivtDto.class);
List<Map<String, String>> ivtList = ivtQueue.stream().collect(Collectors.toList());
for (int i = 0; i < ivtList.size() - 1; i++) {
Map<String, String> ivt = ivtList.get(i);
for (Map.Entry<String, String> ivtEntry : ivt.entrySet()) {
String vehicle_code = ivtEntry.getKey();
String material_id = ivtEntry.getValue();
StructivtDto structivtDto = structivtDtos.get(i);
JSONObject structivtJson = new JSONObject();
if (!StrUtil.isEmpty(vehicle_code)) {
structivtJson.put("vehicle_type", "1");
} else {
structivtJson.put("vehicle_type", "");
}
structivtJson.put("vehicle_code", vehicle_code);
structivtJson.put("update_time", DateUtil.now());
structivtJson.put("update_optname", SecurityUtils.getCurrentNickName() == null ? "入库修改" : SecurityUtils.getCurrentNickName());
structivtJson.put("material_id", StrUtil.isEmpty(material_id) ? "" : material_id);
wo.update(structivtJson, "stockrecord_id = '" + structivtDto.getStockrecord_id() + "'");
}
}
}
/**
* 如果困料区26包括到GT01包括修改队列中的信息
* 比如 困料区03中手动调出来了 此时困料区03中队列信息未载具号为空 此刻再入库GT01
* 困料区03到困料区26的库存不应该更新 而困料区03的信息应该修改为困料区02的
* 困料区02的应该修改为困料区01的 以此类推
*/
public static void updateHasEmptyInMiddle() {
List<Map<String, String>> ivtList = ivtQueue.stream().collect(Collectors.toList());
Collections.reverse(ivtList);
Iterator<Map<String, String>> iterator = ivtList.iterator();
out:
while (iterator.hasNext()) {
Map<String, String> ivtMap = iterator.next();
in:
for (Map.Entry<String, String> entry : ivtMap.entrySet()) {
if (StrUtil.isEmpty(entry.getKey())) {
iterator.remove();
break out;
}
}
}
Collections.reverse(ivtList);
clear();
ivtQueue.addAll(ivtList);
}
public static void clear() {
ivtQueue.clear();
}
}

View File

@@ -15,6 +15,7 @@ import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.RegionService;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.wms.sch.tasks.RegionTypeEnum;
import org.nl.wms.st.structivt.service.KlhcqIvt;
import org.nl.wms.st.structivt.service.StructivtService;
import org.nl.wms.st.structivt.service.dto.StructivtDto;
import org.springframework.stereotype.Service;
@@ -163,6 +164,9 @@ public class StructivtServiceImpl implements StructivtService {
// redisUtils.del(dto.getVehicle_code() + "-ivt_qty");
// }
}
if (structivtDto.getRegion_code().equals(RegionTypeEnum.KLZCQ.getCode()) || structivtDto.getRegion_code().equals(RegionTypeEnum.GT1.getCode())) {
KlhcqIvt.clear();
}
WQLObject wo_point = WQLObject.getWQLObject("sch_base_point");
// 找主表获取之前的数据
@@ -274,9 +278,9 @@ public class StructivtServiceImpl implements StructivtService {
jsonObject.put("update_time", DateUtil.now());
wo_point.update(jsonObject);
if (StrUtil.equals(region_code, RegionTypeEnum.KLZCQ.getCode()) || StrUtil.equals(region_code, RegionTypeEnum.GT2.getCode())) {
this.reload();
}
// if (StrUtil.equals(region_code, RegionTypeEnum.KLZCQ.getCode()) || StrUtil.equals(region_code, RegionTypeEnum.GT2.getCode())) {
// this.reload();
// }
}