diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 87af6e5..4ddda96 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -626,6 +626,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override @Transactional(rollbackFor = Exception.class) public void finish(String id) { + Instruction entity = this.findById(id); // if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); String currentUsername = SecurityUtils.getCurrentUsername(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java index 9b37cfc..5f07e77 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java @@ -115,6 +115,14 @@ public class TaskController { return new ResponseEntity<>(HttpStatus.OK); } + @Log("强制完成任务") + @ApiOperation("强制完成任务") + @PostMapping(value = "/forceFinish/{id}") + public ResponseEntity forceFinish(@RequestBody String id) throws Exception { + taskService.forceFinish(id); + return new ResponseEntity<>(HttpStatus.OK); + } + @Log("取消任务") @ApiOperation("取消任务") @PostMapping(value = "/cancel/{id}") diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java index 42f8584..0c87d93 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java @@ -180,6 +180,14 @@ public interface TaskService { */ void finish(String ids); + /** + * 强制完成任务 + * + * @param ids + */ + void forceFinish(String ids) throws Exception; + + /** * 取消任务 * diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 8bed9b3..3354d8c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.Synchronized; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; import org.nl.acs.AcsConfig; import org.nl.acs.agv.server.XianGongAgvService; import org.nl.acs.auto.initial.ApplicationAutoInitial; @@ -100,6 +101,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } } + @Override public synchronized void reload() { List list = this.queryAll("task_status <2 and is_delete =0 order by create_time"); @@ -373,6 +375,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return list; } + @Override public List queryTaskByStartAndIntStatus(String head_start_device_code) { List list = new ArrayList<>(); Iterator iterator = tasks.iterator(); @@ -393,6 +396,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return list; } + @Override public List queryTaskByNextAndIntStatus(String back_start_device_code) { List list = new ArrayList<>(); Iterator iterator = tasks.iterator(); @@ -732,10 +736,14 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { @Transactional(rollbackFor = Exception.class) public void finish(String id) { TaskDto entity = this.findById(id); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); - if (instdto != null) throw new BadRequestException("有指令未完成!"); + if (instdto != null) { + throw new BadRequestException("有指令未完成!"); + } String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); entity.setUpdate_time(now); @@ -782,6 +790,161 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } } + + public void finish1(String id) { + TaskDto entity = this.findById(id); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); + if (instdto != null) { + throw new BadRequestException("有指令未完成!"); + } + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setTask_status("2"); + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + removeByCodeFromCache(entity.getTask_code()); + // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS +// String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); +// if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { +// TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); +// System.out.println(feefbackdto == null); +// JSONObject feed_jo = new JSONObject(); +// feed_jo.put("task_id", entity.getTask_id()); +// feed_jo.put("task_code", entity.getTask_code()); +// feed_jo.put("task_status", entity.getTask_status()); +// JSONArray ja = new JSONArray(); +// ja.add(feed_jo); +// +// try { +// JSONObject request1 = new JSONObject(); +// request1.put("REQCODE", entity.getExt_task_id()); +// request1.put("TASKCODE", entity.getTask_code()); +// request1.put("PODCODE", entity.getVehicle_code()); +// request1.put("TASKTYPE", entity.getTask_type()); +// request1.put("METHOD", "3"); +// request1.put("REQTIME", DateUtil.now()); +// log.info("atrAgvCallback 请求参数:" + request1.toString()); +// String str1 = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request1.toJSONString()); +// log.info("atrAgvCallback 返回参数:" + str1); +// +// JSONObject request = new JSONObject(); +// request.put("REQCODE", entity.getExt_task_id()); +// request.put("TASKCODE", entity.getTask_code()); +// request.put("PODCODE", entity.getVehicle_code()); +// request.put("TASKTYPE", entity.getTask_type()); +// request.put("METHOD", "5"); +// request.put("REQTIME", DateUtil.now()); +// log.info("atrAgvCallback 请求参数:" + request.toString()); +// String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); +// log.info("atrAgvCallback 返回参数:" + str); +// } catch (Exception e) { +// e.printStackTrace(); +// throw new BadRequestException(e.getMessage()); +// } +// } + // 如果属于先知AGV,关闭运单序列 + if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { + try { + agvService.markComplete(entity.getTask_code()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @Override + public void forceFinish(String ids) throws Exception { + TaskDto dto = this.findById(ids); + if (dto == null) { + throw new BadRequestException("权限不足,操作失败"); + } + Instruction entity = instructionService.findByTaskid(ids, "instruction_status <2 "); + if (entity != null) { + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setInstruction_status("2"); + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + removeByCodeFromCache(entity.getInstruction_code()); + } + + String instnextdevice = dto.getNext_device_code(); + WQLObject taskwo = WQLObject.getWQLObject("acs_task"); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device startdevice = appService.findDeviceByCode(entity.getStart_device_code()); + if (ObjectUtils.isEmpty(startdevice)) { + log.debug("地址对应设备未找到"); + throw new BadRequestException("地址对应设备未找到"); + } + if (instnextdevice.indexOf(".") != -1) { + instnextdevice = instnextdevice.substring(0, instnextdevice.indexOf(".")); + } + Device device = appService.findDeviceByCode(instnextdevice); + if (device == null) { + log.debug("地址对应设备未找到"); + throw new BadRequestException("地址对应设备未找到"); + } + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + + JSONObject jo1 = new JSONObject(); + jo1.put("device_code", instnextdevice); + + String start_device_code = entity.getStart_device_code(); + + Device deviceByCode = deviceAppService.findDeviceByCode(start_device_code); + if (deviceByCode == null) { + log.debug("地址对应设备未找到"); + throw new BadRequestException("地址对应设备未找到"); + } + + jo1.put("hasGoodStatus", "1"); + jo1.put("material_type", startdevice.getMaterial_type()); + + jo1.put("quantity", startdevice.getQuantity()); + jo1.put("remark", startdevice.getRemark()); + jo1.put("batch", startdevice.getBatch()); + jo1.put("vehicle_code", entity.getVehicle_code()); + jo1.put("islock", "0"); + jo1.put("barrels_code", startdevice.getBarrels_code()); + jo1.put("cooperate_code", startdevice.getCooperate_code()); + jo1.put("powder_name", startdevice.getPowder_name()); + jo1.put("barrels_status", startdevice.getBarrels_status()); + deviceService.changeDeviceStatus(jo1); + // 如果是无光电的设备 指令完成变更起点、终点状态 + JSONObject jo = new JSONObject(); + jo.put("device_code", entity.getStart_device_code()); + jo.put("hasGoodStatus", "0"); + jo.put("material_type", ""); + jo.put("quantity", ""); + jo.put("remark", ""); + jo.put("batch", ""); + jo.put("islock", "0"); + deviceService.changeDeviceStatus(jo); + + + JSONObject taskjson = taskwo.query("task_id ='" + ids + "'").uniqueResult(0); + TaskDto obj = taskjson.toJavaObject(TaskDto.class); + // =0 则不用再次请求 + if (StrUtil.equals(obj.getRequest_again(), "0")) { + if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) { + this.finish1(obj.getTask_id()); + } else { + instructionService.finishAndCreateNextInst(entity); + } + } + } + + @Override @Transactional(rollbackFor = Exception.class) public void cancel(String id) { @@ -1164,6 +1327,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return tasks; } + @Override public TaskDto findByContainer(String container_code) { Iterator var3 = tasks.iterator(); @@ -1177,6 +1341,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return null; } + @Override public TaskDto findByCodeFromCache(String task_code) { Iterator var3 = tasks.iterator(); diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index d60d6ad..ebc8fb4 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -13,11 +13,11 @@ spring: driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy # url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:huaYan_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:huayan_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true username: ${DB_USER:root} # password: ${DB_PWD:P@ssw0rd} # password: ${DB_PWD:Root.123456} - password: ${DB_PWD:password} + password: ${DB_PWD:123456} # 初始连接数 initial-size: 5 diff --git a/acs/nladmin-system/src/main/resources/config/application.yml b/acs/nladmin-system/src/main/resources/config/application.yml index f943602..cfc52fe 100644 --- a/acs/nladmin-system/src/main/resources/config/application.yml +++ b/acs/nladmin-system/src/main/resources/config/application.yml @@ -2,7 +2,7 @@ spring: freemarker: check-template-location: false profiles: - active: dev + active: prod jackson: time-zone: GMT+8 data: diff --git a/acs/nladmin-ui/src/api/acs/task/task.js b/acs/nladmin-ui/src/api/acs/task/task.js index 8c3e7e0..f2d0bbc 100644 --- a/acs/nladmin-ui/src/api/acs/task/task.js +++ b/acs/nladmin-ui/src/api/acs/task/task.js @@ -32,6 +32,14 @@ export function finish(task_id) { }) } +export function forceFinish(task_id) { + return request({ + url: 'api/task/forceFinish/' + task_id, + method: 'post', + data: task_id + }) +} + export function cancel(task_id) { return request({ url: 'api/task/cancel/' + task_id, @@ -95,5 +103,5 @@ export function reload() { }) } -export default { add, edit, del, finish, cancel, createTaskByClick, deviceAskTask, ordinaryTaskCreate, specialTaskCreate, createInst, reload } +export default { add, edit, del, finish, cancel, createTaskByClick, deviceAskTask, ordinaryTaskCreate, specialTaskCreate, createInst, reload, forceFinish } diff --git a/acs/nladmin-ui/src/views/acs/task/index.vue b/acs/nladmin-ui/src/views/acs/task/index.vue index b5aa549..289d9c8 100644 --- a/acs/nladmin-ui/src/views/acs/task/index.vue +++ b/acs/nladmin-ui/src/views/acs/task/index.vue @@ -368,6 +368,7 @@ 完成 取消 创建指令 + 强制完成 @@ -562,6 +563,14 @@ export default { console.log(err.response.data.message) }) }, + forceFinish(index, row) { + crudTask.forceFinish(row.task_id).then(res => { + this.crud.toQuery() + this.crud.notify('强制完成成功', CRUD.NOTIFICATION_TYPE.SUCCESS) + }).catch(err => { + console.log(err.response.data.message) + }) + }, reload() { crudTask.reload().then(res => { this.crud.toQuery() @@ -588,6 +597,9 @@ export default { case 'c':// 创建指令 this.createInst(command.index, command.row) break + case 'd':// 强制完成 + this.forceFinish(command.index, command.row) + break } }, showStartStorage(val) {