任务和指令加锁处理
This commit is contained in:
@@ -728,7 +728,10 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
requireSucess = true;
|
requireSucess = true;
|
||||||
applySucess = false;
|
applySucess = false;
|
||||||
} else {
|
} else {
|
||||||
|
if (jo.get("message")!=null){
|
||||||
message = jo.get("message").toString();
|
message = jo.get("message").toString();
|
||||||
|
}
|
||||||
|
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("code","to_target");
|
map.put("code","to_target");
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
package org.nl.acs.instruction.service.impl;
|
package org.nl.acs.instruction.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
@@ -64,7 +62,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author ldjun
|
* @author ldjun
|
||||||
* @description 服务实现
|
* @description 服务实现
|
||||||
* @date 2021-03-18
|
* @date 2021-03-18
|
||||||
**/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -72,18 +70,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
List<Instruction> instructions = new CopyOnWriteArrayList();
|
List<Instruction> instructions = new CopyOnWriteArrayList();
|
||||||
|
|
||||||
@Autowired
|
@Autowired DeviceAppService deviceAppService;
|
||||||
DeviceAppService deviceAppService;
|
@Autowired NDCAgvService ndcAgvService;
|
||||||
@Autowired
|
@Autowired ParamService paramService;
|
||||||
NDCAgvService ndcAgvService;
|
@Autowired RouteLineService routeLineService;
|
||||||
@Autowired
|
@Autowired TaskService taskService;
|
||||||
ParamService paramService;
|
@Autowired AcsToLiKuService acsToLiKuService;
|
||||||
@Autowired
|
|
||||||
RouteLineService routeLineService;
|
|
||||||
@Autowired
|
|
||||||
TaskService taskService;
|
|
||||||
@Autowired
|
|
||||||
AcsToLiKuService acsToLiKuService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void autoInitial() {
|
public void autoInitial() {
|
||||||
@@ -93,7 +85,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void reload() {
|
public synchronized void reload() {
|
||||||
Class var1 = TaskInstructionLock.class;
|
Class var1 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
this.instructions = this.queryAll("instruction_status <2 and is_delete =0");
|
this.instructions = this.queryAll("instruction_status <2 and is_delete =0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +95,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
/*WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
/*WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "instruction_status < 2 and is_delete =0 ", "update_time desc");
|
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "instruction_status < 2 and is_delete =0 ", "update_time desc");
|
||||||
*/
|
*/
|
||||||
// this.reload();
|
// this.reload();
|
||||||
HashMap<String, String> map = new HashMap<>();
|
HashMap<String, String> map = new HashMap<>();
|
||||||
map.put("flag", "1");
|
map.put("flag", "1");
|
||||||
String code = (String) whereJson.get("code");
|
String code = (String) whereJson.get("code");
|
||||||
@@ -135,12 +127,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
Integer currentPageNumber = page.getPageNumber() + 1;
|
Integer currentPageNumber = page.getPageNumber() + 1;
|
||||||
Integer pageMaxSize = page.getPageSize();
|
Integer pageMaxSize = page.getPageSize();
|
||||||
final JSONObject jo = WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "");
|
final JSONObject jo =
|
||||||
|
WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "");
|
||||||
JSONArray jsonArray = jo.getJSONArray("content");
|
JSONArray jsonArray = jo.getJSONArray("content");
|
||||||
List<Instruction> instructions = jsonArray.toJavaList(Instruction.class);
|
List<Instruction> instructions = jsonArray.toJavaList(Instruction.class);
|
||||||
List<Instruction> instDtoList = instructions.stream().skip((currentPageNumber - 1) * pageMaxSize).limit(pageMaxSize).collect(Collectors.toList());
|
List<Instruction> instDtoList =
|
||||||
jo.put("content",instDtoList);
|
instructions.stream()
|
||||||
jo.put("totalElements",jsonArray.size());
|
.skip((currentPageNumber - 1) * pageMaxSize)
|
||||||
|
.limit(pageMaxSize)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
jo.put("content", instDtoList);
|
||||||
|
jo.put("totalElements", jsonArray.size());
|
||||||
return jo;
|
return jo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +172,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
map.put("end_time", end_time);
|
map.put("end_time", end_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
final JSONObject jo = WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time desc");
|
final JSONObject jo =
|
||||||
|
WQL.getWO("QINST_QUERY")
|
||||||
|
.addParamMap(map)
|
||||||
|
.pageQuery(WqlUtil.getHttpContext(page), "create_time desc");
|
||||||
return jo;
|
return jo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
public Instruction findByCode(String code) {
|
public Instruction findByCode(String code) {
|
||||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||||
JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0);
|
JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0);
|
||||||
if (ObjectUtil.isEmpty(json)){
|
if (ObjectUtil.isEmpty(json)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Instruction obj = json.toJavaObject(Instruction.class);
|
final Instruction obj = json.toJavaObject(Instruction.class);
|
||||||
@@ -251,6 +251,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByTaskcodeAndStatus(String code) {
|
public Instruction findByTaskcodeAndStatus(String code) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
Iterator var3 = instructions.iterator();
|
Iterator var3 = instructions.iterator();
|
||||||
while (var3.hasNext()) {
|
while (var3.hasNext()) {
|
||||||
Instruction instruction = (Instruction) var3.next();
|
Instruction instruction = (Instruction) var3.next();
|
||||||
@@ -262,6 +263,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByTaskid(String id, String wherecaluse) {
|
public Instruction findByTaskid(String id, String wherecaluse) {
|
||||||
if (!StrUtil.isEmpty(wherecaluse)) {
|
if (!StrUtil.isEmpty(wherecaluse)) {
|
||||||
@@ -278,7 +281,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
@Override
|
@Override
|
||||||
public void create(Instruction dto) {
|
public void create(Instruction dto) {
|
||||||
Class var2 = TaskInstructionLock.class;
|
Class var2 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
dto = foramte(dto);
|
dto = foramte(dto);
|
||||||
String task_code = dto.getTask_code();
|
String task_code = dto.getTask_code();
|
||||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||||
@@ -312,17 +315,18 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
dto.setInstruction_type("3");
|
dto.setInstruction_type("3");
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询是否存在相同指令号
|
// 查询是否存在相同指令号
|
||||||
// if (!StrUtil.isEmpty(dto.getVehicle_code() )) {
|
// if (!StrUtil.isEmpty(dto.getVehicle_code() )) {
|
||||||
// Instruction inst_dto = findByContainer(dto.getVehicle_code());
|
// Instruction inst_dto = findByContainer(dto.getVehicle_code());
|
||||||
// if (inst_dto != null) {
|
// if (inst_dto != null) {
|
||||||
// log.error("存在相同载具号任务,载具号"+dto.getVehicle_code());
|
// log.error("存在相同载具号任务,载具号"+dto.getVehicle_code());
|
||||||
// throw new BadRequestException("存在相同载具号任务!");
|
// throw new BadRequestException("存在相同载具号任务!");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//起点设备与终点设备相同则为初始指令
|
// 起点设备与终点设备相同则为初始指令
|
||||||
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
||||||
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
|
if (!StrUtil.equals(dto.getCompound_inst(), "0")
|
||||||
|
&& StrUtil.equals(task.getCompound_task(), "1")) {
|
||||||
dto.setCompound_inst("1");
|
dto.setCompound_inst("1");
|
||||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||||
}
|
}
|
||||||
@@ -347,7 +351,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
|
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
|
||||||
|
|
||||||
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
hongXiangConveyorDeviceDriver =
|
||||||
|
(HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||||
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,13 +360,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
String start_device_code = dto.getStart_device_code();
|
String start_device_code = dto.getStart_device_code();
|
||||||
String next_device_code = dto.getNext_device_code();
|
String next_device_code = dto.getNext_device_code();
|
||||||
String route_plan_code = task.getRoute_plan_code();
|
String route_plan_code = task.getRoute_plan_code();
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
List<RouteLineDto> shortPathsList =
|
||||||
|
routeLineService.getShortPathLines(
|
||||||
|
start_device_code, next_device_code, route_plan_code);
|
||||||
RouteLineDto route = null;
|
RouteLineDto route = null;
|
||||||
for (int i = 0; i < shortPathsList.size(); i++) {
|
for (int i = 0; i < shortPathsList.size(); i++) {
|
||||||
RouteLineDto routeLineDto = shortPathsList.get(i);
|
RouteLineDto routeLineDto = shortPathsList.get(i);
|
||||||
String route_device = routeLineDto.getDevice_code();
|
String route_device = routeLineDto.getDevice_code();
|
||||||
String route_next_device = routeLineDto.getNext_device_code();
|
String route_next_device = routeLineDto.getNext_device_code();
|
||||||
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) {
|
if (route_device.equals(dto.getStart_device_code())
|
||||||
|
&& route_next_device.equals(dto.getNext_device_code())) {
|
||||||
route = routeLineDto;
|
route = routeLineDto;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -369,15 +377,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
if (ObjectUtil.isEmpty(route)) {
|
if (ObjectUtil.isEmpty(route)) {
|
||||||
throw new BadRequestException("未查询到相关路由!");
|
throw new BadRequestException("未查询到相关路由!");
|
||||||
}
|
}
|
||||||
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")){
|
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
|
||||||
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
|
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
|
||||||
if (!StrUtil.equals(task.getAgv_system_type(), "0") && ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
if (!StrUtil.equals(task.getAgv_system_type(), "0")
|
||||||
|
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(),dto);
|
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||||
} else {
|
} else {
|
||||||
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
||||||
Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(),dto);
|
Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(), dto);
|
||||||
if(StrUtil.equals(resp.result,"true")){
|
if (StrUtil.equals(resp.result, "true")) {
|
||||||
dto.setSend_status("1");
|
dto.setSend_status("1");
|
||||||
} else {
|
} else {
|
||||||
dto.setSend_status("2");
|
dto.setSend_status("2");
|
||||||
@@ -398,11 +407,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create2(Instruction dto) throws Exception {
|
public void create2(Instruction dto) throws Exception {
|
||||||
Class var2 = TaskInstructionLock.class;
|
Class var2 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
dto = foramte(dto);
|
dto = foramte(dto);
|
||||||
String task_code = dto.getTask_code();
|
String task_code = dto.getTask_code();
|
||||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||||
@@ -436,10 +444,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
dto.setInstruction_type("3");
|
dto.setInstruction_type("3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 起点设备与终点设备相同则为初始指令
|
||||||
//起点设备与终点设备相同则为初始指令
|
|
||||||
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
||||||
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
|
if (!StrUtil.equals(dto.getCompound_inst(), "0")
|
||||||
|
&& StrUtil.equals(task.getCompound_task(), "1")) {
|
||||||
dto.setCompound_inst("1");
|
dto.setCompound_inst("1");
|
||||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||||
}
|
}
|
||||||
@@ -464,7 +472,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
|
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
|
||||||
|
|
||||||
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
hongXiangConveyorDeviceDriver =
|
||||||
|
(HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||||
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,13 +481,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
String start_device_code = dto.getStart_device_code();
|
String start_device_code = dto.getStart_device_code();
|
||||||
String next_device_code = dto.getNext_device_code();
|
String next_device_code = dto.getNext_device_code();
|
||||||
String route_plan_code = task.getRoute_plan_code();
|
String route_plan_code = task.getRoute_plan_code();
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
List<RouteLineDto> shortPathsList =
|
||||||
|
routeLineService.getShortPathLines(
|
||||||
|
start_device_code, next_device_code, route_plan_code);
|
||||||
RouteLineDto route = null;
|
RouteLineDto route = null;
|
||||||
for (int i = 0; i < shortPathsList.size(); i++) {
|
for (int i = 0; i < shortPathsList.size(); i++) {
|
||||||
RouteLineDto routeLineDto = shortPathsList.get(i);
|
RouteLineDto routeLineDto = shortPathsList.get(i);
|
||||||
String route_device = routeLineDto.getDevice_code();
|
String route_device = routeLineDto.getDevice_code();
|
||||||
String route_next_device = routeLineDto.getNext_device_code();
|
String route_next_device = routeLineDto.getNext_device_code();
|
||||||
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) {
|
if (route_device.equals(dto.getStart_device_code())
|
||||||
|
&& route_next_device.equals(dto.getNext_device_code())) {
|
||||||
route = routeLineDto;
|
route = routeLineDto;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -486,13 +498,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
if (ObjectUtil.isEmpty(route)) {
|
if (ObjectUtil.isEmpty(route)) {
|
||||||
throw new BadRequestException("未查询到相关路由!");
|
throw new BadRequestException("未查询到相关路由!");
|
||||||
}
|
}
|
||||||
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")){
|
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
|
||||||
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
|
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
|
||||||
if (!StrUtil.equals(task.getAgv_system_type(), "0") && ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
if (!StrUtil.equals(task.getAgv_system_type(), "0")
|
||||||
|
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(),dto);
|
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||||
} else {
|
} else {
|
||||||
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -508,12 +521,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createAgain(Instruction dto) throws Exception {
|
public void createAgain(Instruction dto) throws Exception {
|
||||||
Class var2 = TaskInstructionLock.class;
|
Class var2 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
String task_code = dto.getTask_code();
|
String task_code = dto.getTask_code();
|
||||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||||
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
|
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
|
||||||
@@ -528,19 +539,34 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
if (StrUtil.isEmpty(dto.getInstruction_id())) {
|
if (StrUtil.isEmpty(dto.getInstruction_id())) {
|
||||||
dto.setInstruction_id(IdUtil.simpleUUID());
|
dto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
}
|
}
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code());
|
List<RouteLineDto> shortPathsList =
|
||||||
|
routeLineService.getShortPathLines(
|
||||||
|
dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code());
|
||||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||||
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
||||||
}
|
}
|
||||||
String type = shortPathsList.get(0).getType();
|
String type = shortPathsList.get(0).getType();
|
||||||
if (!StrUtil.equals(type, "0")) {
|
if (!StrUtil.equals(type, "0")) {
|
||||||
JSONObject instcheckjson = instwo.query(" instruction_status <3 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0);
|
JSONObject instcheckjson =
|
||||||
|
instwo
|
||||||
|
.query(
|
||||||
|
" instruction_status <3 and next_point_code= '"
|
||||||
|
+ dto.getNext_point_code()
|
||||||
|
+ "'"
|
||||||
|
+ " and start_point_code = '"
|
||||||
|
+ dto.getStart_point_code()
|
||||||
|
+ "'"
|
||||||
|
+ " and task_id = '"
|
||||||
|
+ dto.getTask_id()
|
||||||
|
+ "'")
|
||||||
|
.uniqueResult(0);
|
||||||
if (instcheckjson != null) {
|
if (instcheckjson != null) {
|
||||||
throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!");
|
throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
|
if (!StrUtil.equals(dto.getCompound_inst(), "0")
|
||||||
|
&& StrUtil.equals(task.getCompound_task(), "1")) {
|
||||||
dto.setCompound_inst("1");
|
dto.setCompound_inst("1");
|
||||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||||
}
|
}
|
||||||
@@ -555,7 +581,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
wo.insert(json);
|
wo.insert(json);
|
||||||
|
|
||||||
|
|
||||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||||
Device startdevice = appService.findDeviceByCode(dto.getStart_device_code());
|
Device startdevice = appService.findDeviceByCode(dto.getStart_device_code());
|
||||||
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
|
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
|
||||||
@@ -566,20 +591,21 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) {
|
if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) {
|
||||||
String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString();
|
String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString();
|
||||||
Device lamddevice = appService.findDeviceByCode(lamd_device);
|
Device lamddevice = appService.findDeviceByCode(lamd_device);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// != 0 为agv任务
|
// != 0 为agv任务
|
||||||
// if(!StrUtil.equals(type,"0")){
|
// if(!StrUtil.equals(type,"0")){
|
||||||
// if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1")) {
|
// if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1"))
|
||||||
// agvService.sendAgvInstToMagic(dto);
|
// {
|
||||||
// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
// agvService.sendAgvInstToMagic(dto);
|
||||||
// agvService.sendAgvInstToNDC(dto);
|
// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(),
|
||||||
// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
|
// "2")) {
|
||||||
// agvService.addOrderSequences(dto);
|
// agvService.sendAgvInstToNDC(dto);
|
||||||
// }
|
// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(),
|
||||||
// }
|
// "3")) {
|
||||||
|
// agvService.addOrderSequences(dto);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
instructions.add(dto);
|
instructions.add(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -587,8 +613,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(Instruction dto) {
|
public void update(Instruction dto) {
|
||||||
Class var2 = TaskInstructionLock.class;
|
synchronized (TaskInstructionLock.class) {
|
||||||
synchronized(TaskInstructionLock.class) {
|
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
dto.setUpdate_time(now);
|
dto.setUpdate_time(now);
|
||||||
@@ -598,16 +623,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
wo.update(json);
|
wo.update(json);
|
||||||
|
|
||||||
// Iterator<Instruction> iterator = instructions.iterator();
|
|
||||||
// while (iterator.hasNext()) {
|
|
||||||
// Instruction instruction = iterator.next();
|
|
||||||
// if (instruction.getInstruction_code().equals(dto.getInstruction_code())) {
|
|
||||||
// iterator.remove();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (StrUtil.equals(dto.getInstruction_status(), "0") || StrUtil.equals(dto.getInstruction_status(), "1")) {
|
|
||||||
// instructions.add(dto);
|
|
||||||
// }
|
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -666,7 +681,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void finish(String id) {
|
public void finish(String id) {
|
||||||
Instruction entity = this.findById(id);
|
Instruction entity = this.findById(id);
|
||||||
//if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
// if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
entity.setUpdate_time(now);
|
entity.setUpdate_time(now);
|
||||||
@@ -748,7 +763,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void finish(Instruction dto) {
|
public void finish(Instruction dto) {
|
||||||
Class var2 = TaskInstructionLock.class;
|
Class var2 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
dto.setInstruction_status("2");
|
dto.setInstruction_status("2");
|
||||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||||
@@ -777,11 +792,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 如果是无光电的设备 放货任务完成需要变更有货状态
|
// 如果是无光电的设备 放货任务完成需要变更有货状态
|
||||||
// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||||
// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver)
|
||||||
// standardOrdinarySiteDeviceDriver.setMove(2);
|
// device.getDeviceDriver();
|
||||||
// }
|
// standardOrdinarySiteDeviceDriver.setMove(2);
|
||||||
|
// }
|
||||||
|
|
||||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||||
JSONObject jo = new JSONObject();
|
JSONObject jo = new JSONObject();
|
||||||
@@ -799,20 +815,22 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
deviceService.changeDeviceStatus(jo1);
|
deviceService.changeDeviceStatus(jo1);
|
||||||
|
|
||||||
removeByCodeFromCache(dto.getInstruction_code());
|
removeByCodeFromCache(dto.getInstruction_code());
|
||||||
// this.reload();
|
// this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void finishAndCreateNextInst(Instruction dto){
|
public void finishAndCreateNextInst(Instruction dto) {
|
||||||
dto = foramte(dto);
|
dto = foramte(dto);
|
||||||
String device_code = dto.getNext_device_code();
|
String device_code = dto.getNext_device_code();
|
||||||
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
||||||
JSONObject taskjson = taskwo.query("task_id ='" + dto.getTask_id() + "'").uniqueResult(0);
|
JSONObject taskjson = taskwo.query("task_id ='" + dto.getTask_id() + "'").uniqueResult(0);
|
||||||
TaskDto acsTask = taskjson.toJavaObject(TaskDto.class);
|
TaskDto acsTask = taskjson.toJavaObject(TaskDto.class);
|
||||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
|
||||||
List<RouteLineDto> list = routeLineService.getShortPathLines(dto.getNext_device_code(), acsTask.getNext_device_code(), acsTask.getRoute_plan_code());
|
List<RouteLineDto> list =
|
||||||
|
routeLineService.getShortPathLines(
|
||||||
|
dto.getNext_device_code(), acsTask.getNext_device_code(), acsTask.getRoute_plan_code());
|
||||||
if (ObjectUtils.isEmpty(list)) {
|
if (ObjectUtils.isEmpty(list)) {
|
||||||
throw new BadRequestException("路由不通");
|
throw new BadRequestException("路由不通");
|
||||||
}
|
}
|
||||||
@@ -830,8 +848,20 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
String start_device_code = dto.getNext_device_code();
|
String start_device_code = dto.getNext_device_code();
|
||||||
String start_point_code = null;
|
String start_point_code = null;
|
||||||
String next_point_code = null;
|
String next_point_code = null;
|
||||||
String start_device = deviceAppService.findDeviceByCode(start_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
|
String start_device =
|
||||||
String next_device = deviceAppService.findDeviceByCode(next_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
|
deviceAppService
|
||||||
|
.findDeviceByCode(start_device_code)
|
||||||
|
.getDeviceDriverDefination()
|
||||||
|
.getFitDeviceTypes()
|
||||||
|
.get(0)
|
||||||
|
.name();
|
||||||
|
String next_device =
|
||||||
|
deviceAppService
|
||||||
|
.findDeviceByCode(next_device_code)
|
||||||
|
.getDeviceDriverDefination()
|
||||||
|
.getFitDeviceTypes()
|
||||||
|
.get(0)
|
||||||
|
.name();
|
||||||
if (StrUtil.equals("storage", start_device)) {
|
if (StrUtil.equals("storage", start_device)) {
|
||||||
start_point_code = start_device_code + "-" + acsTask.getFrom_y() + "-" + acsTask.getFrom_z();
|
start_point_code = start_device_code + "-" + acsTask.getFrom_y() + "-" + acsTask.getFrom_z();
|
||||||
} else {
|
} else {
|
||||||
@@ -865,15 +895,15 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
this.create(instdto);
|
this.create(instdto);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error("完成并创建下一条指令",e.getMessage());
|
log.error("完成并创建下一条指令", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel(String id) throws Exception {
|
public void cancel(String id) throws Exception {
|
||||||
Class var2 = TaskInstructionLock.class;
|
Class var2 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
//flag= true时取消指令
|
// flag= true时取消指令
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
Instruction entity = this.findById(id);
|
Instruction entity = this.findById(id);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
@@ -892,7 +922,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
flag = true;
|
flag = true;
|
||||||
|
|
||||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||||
//NDC agv指令不当场取消指令,需要等agv上报
|
// NDC agv指令不当场取消指令,需要等agv上报
|
||||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
||||||
ndcAgvService.deleteAgvInstToNDC(entity);
|
ndcAgvService.deleteAgvInstToNDC(entity);
|
||||||
} else {
|
} else {
|
||||||
@@ -900,7 +930,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")
|
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")
|
||||||
&& !StrUtil.equals(entity.getSend_status(), "2")) {
|
&& !StrUtil.equals(entity.getSend_status(), "2")) {
|
||||||
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
|
XianGongAgvService xianGongAgvService =
|
||||||
|
SpringContextHolder.getBean(XianGongAgvService.class);
|
||||||
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
|
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
|
||||||
flag = true;
|
flag = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -909,30 +940,29 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
|
|
||||||
if(StrUtil.equals(entity.getInstruction_type(),"7")){
|
if (StrUtil.equals(entity.getInstruction_type(), "7")) {
|
||||||
CancelTaskRequest cancelTaskRequest = new CancelTaskRequest();
|
CancelTaskRequest cancelTaskRequest = new CancelTaskRequest();
|
||||||
cancelTaskRequest.setOrderId(entity.getInstruction_code());
|
cancelTaskRequest.setOrderId(entity.getInstruction_code());
|
||||||
cancelTaskRequest.setPalletCode(entity.getVehicle_code());
|
cancelTaskRequest.setPalletCode(entity.getVehicle_code());
|
||||||
cancelTaskRequest.setSrcLocation(entity.getStart_point_code());
|
cancelTaskRequest.setSrcLocation(entity.getStart_point_code());
|
||||||
cancelTaskRequest.setDestLocation(entity.getNext_point_code());
|
cancelTaskRequest.setDestLocation(entity.getNext_point_code());
|
||||||
//1 入库,2 出库,3 移库,4 空托盘入库,5 空托盘出库
|
// 1 入库,2 出库,3 移库,4 空托盘入库,5 空托盘出库
|
||||||
int type = 0;
|
int type = 0;
|
||||||
if(StrUtil.equals(task.getStorage_task_type(),"1")){
|
if (StrUtil.equals(task.getStorage_task_type(), "1")) {
|
||||||
type = 1;
|
type = 1;
|
||||||
} else if (StrUtil.equals(task.getStorage_task_type(),"2")){
|
} else if (StrUtil.equals(task.getStorage_task_type(), "2")) {
|
||||||
type = 4;
|
type = 4;
|
||||||
} else if (StrUtil.equals(task.getStorage_task_type(),"3")){
|
} else if (StrUtil.equals(task.getStorage_task_type(), "3")) {
|
||||||
type = 2;
|
type = 2;
|
||||||
} else if (StrUtil.equals(task.getStorage_task_type(),"4")){
|
} else if (StrUtil.equals(task.getStorage_task_type(), "4")) {
|
||||||
type = 5;
|
type = 5;
|
||||||
} else if (StrUtil.equals(task.getStorage_task_type(),"5")){
|
} else if (StrUtil.equals(task.getStorage_task_type(), "5")) {
|
||||||
type = 3;
|
type = 3;
|
||||||
}
|
}
|
||||||
cancelTaskRequest.setTaskType(type);
|
cancelTaskRequest.setTaskType(type);
|
||||||
acsToLiKuService.cancelTask(cancelTaskRequest);
|
acsToLiKuService.cancelTask(cancelTaskRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
entity.setUpdate_time(now);
|
entity.setUpdate_time(now);
|
||||||
@@ -949,7 +979,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
jo.put("device_code", entity.getStart_device_code());
|
jo.put("device_code", entity.getStart_device_code());
|
||||||
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||||
jo.put("hasGoodStatus", "1");
|
jo.put("hasGoodStatus", "1");
|
||||||
} else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) {
|
} else if (!StrUtil.equals(entity.getMaterial(), "1")
|
||||||
|
&& !StrUtil.isEmpty(entity.getMaterial())) {
|
||||||
jo.put("hasGoodStatus", "2");
|
jo.put("hasGoodStatus", "2");
|
||||||
} else {
|
} else {
|
||||||
jo.put("hasGoodStatus", "0");
|
jo.put("hasGoodStatus", "0");
|
||||||
@@ -982,8 +1013,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
@Override
|
@Override
|
||||||
public void forceCancel(String id) throws Exception {
|
public void forceCancel(String id) throws Exception {
|
||||||
Class var2 = TaskInstructionLock.class;
|
Class var2 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
//flag= true时取消指令
|
// flag= true时取消指令
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
Instruction entity = this.findById(id);
|
Instruction entity = this.findById(id);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
@@ -1008,7 +1039,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
jo.put("device_code", entity.getStart_device_code());
|
jo.put("device_code", entity.getStart_device_code());
|
||||||
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||||
jo.put("hasGoodStatus", "1");
|
jo.put("hasGoodStatus", "1");
|
||||||
} else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) {
|
} else if (!StrUtil.equals(entity.getMaterial(), "1")
|
||||||
|
&& !StrUtil.isEmpty(entity.getMaterial())) {
|
||||||
jo.put("hasGoodStatus", "2");
|
jo.put("hasGoodStatus", "2");
|
||||||
} else {
|
} else {
|
||||||
jo.put("hasGoodStatus", "0");
|
jo.put("hasGoodStatus", "0");
|
||||||
@@ -1034,15 +1066,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
removeByCodeFromCache(entity.getInstruction_code());
|
removeByCodeFromCache(entity.getInstruction_code());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelNOSendAgv(String id) throws Exception {
|
public void cancelNOSendAgv(String id) throws Exception {
|
||||||
Class var2 = TaskInstructionLock.class;
|
Class var2 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
//flag= true时取消指令
|
// flag= true时取消指令
|
||||||
Instruction entity = this.findById(id);
|
Instruction entity = this.findById(id);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
@@ -1068,7 +1098,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
jo.put("device_code", entity.getStart_device_code());
|
jo.put("device_code", entity.getStart_device_code());
|
||||||
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||||
jo.put("hasGoodStatus", "1");
|
jo.put("hasGoodStatus", "1");
|
||||||
} else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) {
|
} else if (!StrUtil.equals(entity.getMaterial(), "1")
|
||||||
|
&& !StrUtil.isEmpty(entity.getMaterial())) {
|
||||||
jo.put("hasGoodStatus", "2");
|
jo.put("hasGoodStatus", "2");
|
||||||
} else {
|
} else {
|
||||||
jo.put("hasGoodStatus", "0");
|
jo.put("hasGoodStatus", "0");
|
||||||
@@ -1097,26 +1128,27 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByLinkNumSend(String code) {
|
public Instruction findByLinkNumSend(String code) {
|
||||||
|
synchronized (InstructionServiceImpl.class) {
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) {
|
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) {
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instruction> findByLinkNum(String code) {
|
public List<Instruction> findByLinkNum(String code) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
List<Instruction> list = new ArrayList<>();
|
List<Instruction> list = new ArrayList<>();
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) {
|
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) {
|
||||||
list.add(inst);
|
list.add(inst);
|
||||||
@@ -1125,10 +1157,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByLinkNumNoSend(String code) {
|
public Instruction findByLinkNumNoSend(String code) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) {
|
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) {
|
||||||
return inst;
|
return inst;
|
||||||
@@ -1138,10 +1174,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByCodeFromCache(String code) {
|
public Instruction findByCodeFromCache(String code) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
if (StrUtil.equals(code, inst.getInstruction_code())) {
|
if (StrUtil.equals(code, inst.getInstruction_code())) {
|
||||||
return inst;
|
return inst;
|
||||||
@@ -1151,10 +1190,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByBarcodeFromCache(String barcode) {
|
public Instruction findByBarcodeFromCache(String barcode) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
if (StrUtil.equals(barcode, inst.getVehicle_code())) {
|
if (StrUtil.equals(barcode, inst.getVehicle_code())) {
|
||||||
return inst;
|
return inst;
|
||||||
@@ -1162,11 +1204,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByIdFromCache(String id) {
|
public Instruction findByIdFromCache(String id) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
if (StrUtil.equals(id, inst.getInstruction_id())) {
|
if (StrUtil.equals(id, inst.getInstruction_id())) {
|
||||||
return inst;
|
return inst;
|
||||||
@@ -1174,6 +1218,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction foramte(Instruction inst) {
|
public Instruction foramte(Instruction inst) {
|
||||||
@@ -1200,7 +1245,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
inst.setFrom_y(start_point[1]);
|
inst.setFrom_y(start_point[1]);
|
||||||
inst.setFrom_z(start_point[2]);
|
inst.setFrom_z(start_point[2]);
|
||||||
} else {
|
} else {
|
||||||
String start_device = deviceAppService.findDeviceByCode(start_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
|
String start_device =
|
||||||
|
deviceAppService
|
||||||
|
.findDeviceByCode(start_device_code)
|
||||||
|
.getDeviceDriverDefination()
|
||||||
|
.getFitDeviceTypes()
|
||||||
|
.get(0)
|
||||||
|
.name();
|
||||||
if (StrUtil.equals("storage", start_device)) {
|
if (StrUtil.equals("storage", start_device)) {
|
||||||
String[] start_point = start_point_code.split("-");
|
String[] start_point = start_point_code.split("-");
|
||||||
inst.setFrom_x(start_point[0]);
|
inst.setFrom_x(start_point[0]);
|
||||||
@@ -1220,7 +1271,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
inst.setTo_z(next_point[2]);
|
inst.setTo_z(next_point[2]);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String next_device = deviceAppService.findDeviceByCode(next_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
|
String next_device =
|
||||||
|
deviceAppService
|
||||||
|
.findDeviceByCode(next_device_code)
|
||||||
|
.getDeviceDriverDefination()
|
||||||
|
.getFitDeviceTypes()
|
||||||
|
.get(0)
|
||||||
|
.name();
|
||||||
if (StrUtil.equals("storage", next_device)) {
|
if (StrUtil.equals("storage", next_device)) {
|
||||||
String[] next_point = start_point_code.split("-");
|
String[] next_point = start_point_code.split("-");
|
||||||
inst.setTo_x(next_point[0]);
|
inst.setTo_x(next_point[0]);
|
||||||
@@ -1236,9 +1293,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByDeviceCodeFromCache(String devicecode) {
|
public Instruction findByDeviceCodeFromCache(String devicecode) {
|
||||||
|
synchronized (InstructionServiceImpl.class) {
|
||||||
List<Instruction> instructionList = instructions;
|
List<Instruction> instructionList = instructions;
|
||||||
try {
|
|
||||||
ListUtil.sort(
|
ListUtil.sort(
|
||||||
instructionList,
|
instructionList,
|
||||||
new Comparator<Instruction>() {
|
new Comparator<Instruction>() {
|
||||||
@@ -1255,11 +1311,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("指令排序按照创建时间执执行失败!重新执行");
|
|
||||||
//失败之后重新查找指令
|
|
||||||
return findByDeviceCodeFromCache(devicecode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,14 +1321,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
return instructions;
|
return instructions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer querySameDestinationInst(String devicecode) {
|
public Integer querySameDestinationInst(String devicecode) {
|
||||||
|
synchronized (InstructionServiceImpl.class) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
//处理空盘位站点
|
// 处理空盘位站点
|
||||||
String next_code = inst.getNext_point_code();
|
String next_code = inst.getNext_point_code();
|
||||||
if (next_code.indexOf(".") != -1) {
|
if (next_code.indexOf(".") != -1) {
|
||||||
next_code = next_code.substring(0, next_code.indexOf("."));
|
next_code = next_code.substring(0, next_code.indexOf("."));
|
||||||
@@ -1287,12 +1340,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer querySameInstType(String inst_type) {
|
public Integer querySameInstType(String inst_type) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
int num = 0;
|
int num = 0;
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
if (StrUtil.equals(inst.getInstruction_type(), inst_type)) {
|
if (StrUtil.equals(inst.getInstruction_type(), inst_type)) {
|
||||||
num = num + 1;
|
num = num + 1;
|
||||||
@@ -1301,13 +1356,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer querySameOriginInst(String devicecode) {
|
public Integer querySameOriginInst(String devicecode) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
int num = 0;
|
int num = 0;
|
||||||
Iterator<Instruction> it = instructions.iterator();
|
Iterator<Instruction> it = instructions.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Instruction inst = it.next();
|
Instruction inst = it.next();
|
||||||
//处理空盘位站点
|
// 处理空盘位站点
|
||||||
String start_code = inst.getStart_point_code();
|
String start_code = inst.getStart_point_code();
|
||||||
if (start_code.indexOf(".") != -1) {
|
if (start_code.indexOf(".") != -1) {
|
||||||
start_code = start_code.substring(0, start_code.indexOf("."));
|
start_code = start_code.substring(0, start_code.indexOf("."));
|
||||||
@@ -1319,9 +1377,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeByCodeFromCache(String code) {
|
public boolean removeByCodeFromCache(String code) {
|
||||||
|
synchronized (InstructionServiceImpl.class){
|
||||||
Iterator<Instruction> iterator = instructions.iterator();
|
Iterator<Instruction> iterator = instructions.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Instruction instruction = iterator.next();
|
Instruction instruction = iterator.next();
|
||||||
@@ -1331,17 +1392,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createLkInst(String type, Instruction dto) {
|
public boolean createLkInst(String type, Instruction dto) {
|
||||||
Class var3 = TaskInstructionLock.class;
|
Class var3 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
//入库
|
// 入库
|
||||||
AcsToLiKuService acsToLiKuService = SpringContextHolder.getBean(AcsToLiKuService.class);
|
AcsToLiKuService acsToLiKuService = SpringContextHolder.getBean(AcsToLiKuService.class);
|
||||||
Resp resp = null;
|
Resp resp = null;
|
||||||
if(StrUtil.equals(type,"1")){
|
if (StrUtil.equals(type, "1")) {
|
||||||
InStoreRequest request = new InStoreRequest();
|
InStoreRequest request = new InStoreRequest();
|
||||||
request.setFloorNo(Integer.parseInt(dto.getTo_z()));
|
request.setFloorNo(Integer.parseInt(dto.getTo_z()));
|
||||||
request.setType(1);
|
request.setType(1);
|
||||||
@@ -1350,8 +1413,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
request.setSrcLocation(dto.getStart_point_code());
|
request.setSrcLocation(dto.getStart_point_code());
|
||||||
request.setDestLocation(dto.getNext_point_code());
|
request.setDestLocation(dto.getNext_point_code());
|
||||||
resp = acsToLiKuService.inStore(request);
|
resp = acsToLiKuService.inStore(request);
|
||||||
//空托入库
|
// 空托入库
|
||||||
} else if (StrUtil.equals(type,"2")){
|
} else if (StrUtil.equals(type, "2")) {
|
||||||
InStoreRequest request = new InStoreRequest();
|
InStoreRequest request = new InStoreRequest();
|
||||||
request.setFloorNo(Integer.parseInt(dto.getTo_z()));
|
request.setFloorNo(Integer.parseInt(dto.getTo_z()));
|
||||||
request.setType(2);
|
request.setType(2);
|
||||||
@@ -1360,8 +1423,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
request.setSrcLocation(dto.getStart_point_code());
|
request.setSrcLocation(dto.getStart_point_code());
|
||||||
request.setDestLocation(dto.getNext_point_code());
|
request.setDestLocation(dto.getNext_point_code());
|
||||||
resp = acsToLiKuService.inStore(request);
|
resp = acsToLiKuService.inStore(request);
|
||||||
//出库
|
// 出库
|
||||||
} else if (StrUtil.equals(type,"3")){
|
} else if (StrUtil.equals(type, "3")) {
|
||||||
OutStoreRequest outStore = new OutStoreRequest();
|
OutStoreRequest outStore = new OutStoreRequest();
|
||||||
BaseStoreRequest baseReq = new BaseStoreRequest();
|
BaseStoreRequest baseReq = new BaseStoreRequest();
|
||||||
List<BaseStoreRequest> list = new ArrayList();
|
List<BaseStoreRequest> list = new ArrayList();
|
||||||
@@ -1374,8 +1437,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
outStore.setOrderInfos(list);
|
outStore.setOrderInfos(list);
|
||||||
outStore.setGroupId(dto.getInstruction_code());
|
outStore.setGroupId(dto.getInstruction_code());
|
||||||
resp = acsToLiKuService.outStore(outStore);
|
resp = acsToLiKuService.outStore(outStore);
|
||||||
//空托出库
|
// 空托出库
|
||||||
} else if (StrUtil.equals(type,"4")) {
|
} else if (StrUtil.equals(type, "4")) {
|
||||||
EmptyVehicleOutStoreRequest emptyVehicleOutStoreRequest = new EmptyVehicleOutStoreRequest();
|
EmptyVehicleOutStoreRequest emptyVehicleOutStoreRequest = new EmptyVehicleOutStoreRequest();
|
||||||
emptyVehicleOutStoreRequest.setOrderId(dto.getInstruction_code());
|
emptyVehicleOutStoreRequest.setOrderId(dto.getInstruction_code());
|
||||||
emptyVehicleOutStoreRequest.setFloorNo(Integer.parseInt(dto.getFrom_z()));
|
emptyVehicleOutStoreRequest.setFloorNo(Integer.parseInt(dto.getFrom_z()));
|
||||||
@@ -1383,8 +1446,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
emptyVehicleOutStoreRequest.setDestLocation(dto.getNext_point_code());
|
emptyVehicleOutStoreRequest.setDestLocation(dto.getNext_point_code());
|
||||||
emptyVehicleOutStoreRequest.setPalletCode(dto.getVehicle_code());
|
emptyVehicleOutStoreRequest.setPalletCode(dto.getVehicle_code());
|
||||||
resp = acsToLiKuService.emptyVehicleOutStore(emptyVehicleOutStoreRequest);
|
resp = acsToLiKuService.emptyVehicleOutStore(emptyVehicleOutStoreRequest);
|
||||||
//转库
|
// 转库
|
||||||
} else if (StrUtil.equals(type,"5")) {
|
} else if (StrUtil.equals(type, "5")) {
|
||||||
MoveStoreRequest moveStoreRequest = new MoveStoreRequest();
|
MoveStoreRequest moveStoreRequest = new MoveStoreRequest();
|
||||||
BaseStoreRequest baseReq = new BaseStoreRequest();
|
BaseStoreRequest baseReq = new BaseStoreRequest();
|
||||||
List<BaseStoreRequest> list = new ArrayList();
|
List<BaseStoreRequest> list = new ArrayList();
|
||||||
@@ -1399,8 +1462,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
resp = acsToLiKuService.moveStore(moveStoreRequest);
|
resp = acsToLiKuService.moveStore(moveStoreRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ObjectUtil.isNotEmpty(resp)){
|
if (ObjectUtil.isNotEmpty(resp)) {
|
||||||
if(StrUtil.equals(resp.getResult(),"true")){
|
if (StrUtil.equals(resp.getResult(), "true")) {
|
||||||
dto.setSend_status("1");
|
dto.setSend_status("1");
|
||||||
} else {
|
} else {
|
||||||
dto.setSend_status("2");
|
dto.setSend_status("2");
|
||||||
@@ -1416,20 +1479,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Instruction findByContainer(String container_code) {
|
|
||||||
Iterator var3 = instructions.iterator();
|
|
||||||
|
|
||||||
while (var3.hasNext()) {
|
|
||||||
Instruction instruction = (Instruction) var3.next();
|
|
||||||
if (StrUtil.equals(instruction.getVehicle_code(), container_code)) {
|
|
||||||
return instruction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 判断是否为整数
|
* 判断是否为整数
|
||||||
* @param str 传入的字符串
|
* @param str 传入的字符串
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
package org.nl.acs.log.service.impl;
|
package org.nl.acs.log.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||||
|
import org.nl.acs.opc.OpcUtl;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -13,31 +12,29 @@ import org.springframework.stereotype.Service;
|
|||||||
* @author loujf
|
* @author loujf
|
||||||
* @description 服务实现
|
* @description 服务实现
|
||||||
* @date 2022-02-25
|
* @date 2022-02-25
|
||||||
**/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DeviceExecuteLogServiceImpl implements DeviceExecuteLogService {
|
public class DeviceExecuteLogServiceImpl implements DeviceExecuteLogService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deviceItemValue(String device_code, String key, String value) {
|
public void deviceItemValue(String device_code, String key, String value) {
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deviceExecuteLog(String device_code, String vehicle_code, String inst_code, String message) {
|
public void deviceExecuteLog(
|
||||||
|
String device_code, String vehicle_code, String inst_code, String message) {
|
||||||
try {
|
try {
|
||||||
MDC.put("device_code_log", device_code);
|
MDC.put("device_code_log", device_code);
|
||||||
log.info("{},{}", device_code, message);
|
log.info("{},{}", device_code, message);
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
} finally {
|
||||||
|
|
||||||
finally {
|
|
||||||
MDC.remove("device_code_log");
|
MDC.remove("device_code_log");
|
||||||
|
System.out.println("successNum:" + OpcUtl.successNum);
|
||||||
|
System.out.println("errNum:" + OpcUtl.errNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,12 +43,10 @@ public class DeviceExecuteLogServiceImpl implements DeviceExecuteLogService {
|
|||||||
try {
|
try {
|
||||||
MDC.put(name, name);
|
MDC.put(name, name);
|
||||||
log.info("{}", message);
|
log.info("{}", message);
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
MDC.remove(name);
|
MDC.remove(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,14 @@ import java.util.concurrent.Executors;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class OpcUtl {
|
public class OpcUtl {
|
||||||
private static int timeout = 300000;
|
private static int timeout = 1*60*1000;
|
||||||
private static String key = "rpc.socketTimeout";
|
private static String key = "rpc.socketTimeout";
|
||||||
private static int successNum=0;
|
public static int successNum=0;
|
||||||
private static int errNum=0;
|
public static int errNum=0;
|
||||||
|
|
||||||
|
static {
|
||||||
|
checkTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkTimeout() {
|
public static void checkTimeout() {
|
||||||
if (Integer.getInteger(key, 0).intValue() != timeout) {
|
if (Integer.getInteger(key, 0).intValue() != timeout) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
@Override
|
@Override
|
||||||
public void autoInitial() throws Exception {
|
public void autoInitial() throws Exception {
|
||||||
Class var1 = TaskInstructionLock.class;
|
Class var1 = TaskInstructionLock.class;
|
||||||
synchronized(TaskInstructionLock.class) {
|
synchronized (TaskInstructionLock.class) {
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,6 +138,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAllByCache(Map whereJson, Pageable page) {
|
public Map<String, Object> queryAllByCache(Map whereJson, Pageable page) {
|
||||||
|
synchronized (TaskServiceImpl.class){
|
||||||
|
|
||||||
|
|
||||||
this.reload();
|
this.reload();
|
||||||
String task_code = (String) whereJson.get("task_code");
|
String task_code = (String) whereJson.get("task_code");
|
||||||
String vehicle_code = (String) whereJson.get("vehicle_code");
|
String vehicle_code = (String) whereJson.get("vehicle_code");
|
||||||
@@ -202,6 +205,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
jo.put("totalElements", taskList.size());
|
jo.put("totalElements", taskList.size());
|
||||||
return jo;
|
return jo;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getAll(Map whereJson, Pageable page) {
|
public Map<String, Object> getAll(Map whereJson, Pageable page) {
|
||||||
@@ -288,6 +292,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskDto> queryTaskByDeviceCode(String device_code) {
|
public List<TaskDto> queryTaskByDeviceCode(String device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
List<TaskDto> list = new ArrayList<>();
|
List<TaskDto> list = new ArrayList<>();
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -299,9 +304,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskDto> queryTaskByStartDeviceCode(String start_device_code) {
|
public List<TaskDto> queryTaskByStartDeviceCode(String start_device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
List<TaskDto> list = new ArrayList<>();
|
List<TaskDto> list = new ArrayList<>();
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -317,9 +324,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskDto> queryTaskByBackDeviceCode(String back_start_device_code) {
|
public List<TaskDto> queryTaskByBackDeviceCode(String back_start_device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
List<TaskDto> list = new ArrayList<>();
|
List<TaskDto> list = new ArrayList<>();
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -334,9 +343,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code) {
|
public List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
List<TaskDto> list = new ArrayList<>();
|
List<TaskDto> list = new ArrayList<>();
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -351,8 +362,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<TaskDto> queryTaskByStartAndIntStatus(String head_start_device_code) {
|
public List<TaskDto> queryTaskByStartAndIntStatus(String head_start_device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
List<TaskDto> list = new ArrayList<>();
|
List<TaskDto> list = new ArrayList<>();
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -371,8 +384,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<TaskDto> queryTaskByNextAndIntStatus(String back_start_device_code) {
|
public List<TaskDto> queryTaskByNextAndIntStatus(String back_start_device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
List<TaskDto> list = new ArrayList<>();
|
List<TaskDto> list = new ArrayList<>();
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -390,6 +405,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskDto queryTaskByLinkNum(String link_num) {
|
public TaskDto queryTaskByLinkNum(String link_num) {
|
||||||
@@ -637,6 +653,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(TaskDto dto) {
|
public void update(TaskDto dto) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
TaskDto entity = this.findById(dto.getTask_id());
|
TaskDto entity = this.findById(dto.getTask_id());
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
@@ -751,6 +768,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -901,7 +919,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
try {
|
try {
|
||||||
Iterator<TaskDto> it = tasks.iterator();
|
Iterator<TaskDto> it = tasks.iterator();
|
||||||
// 清理缓存
|
// 清理缓存
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
TaskDto taskDto = it.next();
|
TaskDto taskDto = it.next();
|
||||||
if (taskDto.getTask_id().equals(id)) {
|
if (taskDto.getTask_id().equals(id)) {
|
||||||
tasks.remove(taskDto);
|
tasks.remove(taskDto);
|
||||||
@@ -1251,6 +1269,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeByCodeFromCache(String code) {
|
public boolean removeByCodeFromCache(String code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
TaskDto task = iterator.next();
|
TaskDto task = iterator.next();
|
||||||
@@ -1261,6 +1280,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskDto> findAllTaskFromCache() {
|
public List<TaskDto> findAllTaskFromCache() {
|
||||||
@@ -1268,6 +1288,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TaskDto findByContainer(String container_code) {
|
public TaskDto findByContainer(String container_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
Iterator var3 = tasks.iterator();
|
Iterator var3 = tasks.iterator();
|
||||||
|
|
||||||
while (var3.hasNext()) {
|
while (var3.hasNext()) {
|
||||||
@@ -1279,8 +1300,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public TaskDto findByCodeFromCache(String task_code) {
|
public TaskDto findByCodeFromCache(String task_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
Iterator var3 = tasks.iterator();
|
Iterator var3 = tasks.iterator();
|
||||||
|
|
||||||
while (var3.hasNext()) {
|
while (var3.hasNext()) {
|
||||||
@@ -1291,9 +1314,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskDto findByNextCode(String device_code) {
|
public TaskDto findByNextCode(String device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
Iterator var3 = tasks.iterator();
|
Iterator var3 = tasks.iterator();
|
||||||
|
|
||||||
while (var3.hasNext()) {
|
while (var3.hasNext()) {
|
||||||
@@ -1304,6 +1329,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskDto> findAllByNextCode(String device_code) {
|
public List<TaskDto> findAllByNextCode(String device_code) {
|
||||||
@@ -1317,6 +1343,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskDto findByStartCodeAndReady(String device_code) {
|
public TaskDto findByStartCodeAndReady(String device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
Iterator var3 = tasks.iterator();
|
Iterator var3 = tasks.iterator();
|
||||||
|
|
||||||
while (var3.hasNext()) {
|
while (var3.hasNext()) {
|
||||||
@@ -1331,9 +1358,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskDto findByStartCode(String device_code) {
|
public TaskDto findByStartCode(String device_code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
Iterator var3 = tasks.iterator();
|
Iterator var3 = tasks.iterator();
|
||||||
|
|
||||||
while (var3.hasNext()) {
|
while (var3.hasNext()) {
|
||||||
@@ -1344,6 +1373,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskDto foramte(TaskDto task) {
|
public TaskDto foramte(TaskDto task) {
|
||||||
@@ -1484,6 +1514,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByCodeFromCache(TaskDto dto) {
|
public void updateByCodeFromCache(TaskDto dto) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
TaskDto task = iterator.next();
|
TaskDto task = iterator.next();
|
||||||
@@ -1493,6 +1524,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
tasks.add(dto);
|
tasks.add(dto);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String queryAssignedByDevice(String device_code, String task_nextdeice_code) {
|
public String queryAssignedByDevice(String device_code, String task_nextdeice_code) {
|
||||||
@@ -1537,6 +1569,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer querySameDeviceReadyTask(String start_device, String next_device, String status) {
|
public Integer querySameDeviceReadyTask(String start_device, String next_device, String status) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -1550,9 +1583,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer querySameTaskByType(String taskType) {
|
public Integer querySameTaskByType(String taskType) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -1564,32 +1599,37 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer querySameOriginTask(String code) {
|
public Integer querySameOriginTask(String code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
TaskDto task = iterator.next();
|
TaskDto task = iterator.next();
|
||||||
if (StrUtil.equals(task.getStart_device_code(),code)) {
|
if (StrUtil.equals(task.getStart_device_code(), code)) {
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer querySameDestinationTask(String code) {
|
public Integer querySameDestinationTask(String code) {
|
||||||
|
synchronized (TaskServiceImpl.class) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
TaskDto task = iterator.next();
|
TaskDto task = iterator.next();
|
||||||
if (StrUtil.equals(task.getNext_device_code(),code)) {
|
if (StrUtil.equals(task.getNext_device_code(), code)) {
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user