rev:修改任务下发字段与acs反馈统一;add
This commit is contained in:
@@ -33,6 +33,11 @@ public class TableDataInfo<T> implements Serializable {
|
||||
*/
|
||||
private List<T> content;
|
||||
|
||||
/**
|
||||
* 反馈数据
|
||||
*/
|
||||
private Object data;
|
||||
|
||||
/**
|
||||
* 消息状态码
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.dispatch_manage.task.service.TaskScheduleService;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -16,7 +17,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.nl.wms.dispatch_manage.task.service.dto.SchBaseTaskQuery;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,9 @@ import java.util.Set;
|
||||
@RequestMapping("api/schBaseTask")
|
||||
public class SchBaseTaskController {
|
||||
@Autowired
|
||||
private ISchBaseTaskService schBaseTaskService;
|
||||
private ISchBaseTaskService iSchBaseTaskService;
|
||||
@Autowired
|
||||
private TaskScheduleService taskScheduleService;
|
||||
|
||||
|
||||
|
||||
@@ -40,37 +42,43 @@ public class SchBaseTaskController {
|
||||
if (CollectionUtils.isEmpty(param)){
|
||||
throw new BadRequestException("参数不能为空");
|
||||
}
|
||||
return new ResponseEntity<>(schBaseTaskService.getByVehicle(param.getString("vehicle_code")), HttpStatus.OK);
|
||||
return new ResponseEntity<>(iSchBaseTaskService.getByVehicle(param.getString("vehicle_code")), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Object> query(SchBaseTaskQuery whereJson, PageQuery page){
|
||||
return new ResponseEntity<>(TableDataInfo.build(schBaseTaskService.queryAll(whereJson,page)), HttpStatus.OK);
|
||||
return new ResponseEntity<>(TableDataInfo.build(iSchBaseTaskService.queryAll(whereJson,page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SchBaseTask entity){
|
||||
schBaseTaskService.create(entity);
|
||||
iSchBaseTaskService.create(entity);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SchBaseTask entity){
|
||||
schBaseTaskService.update(entity);
|
||||
iSchBaseTaskService.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
schBaseTaskService.deleteAll(ids);
|
||||
iSchBaseTaskService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/operation")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject map) {
|
||||
schBaseTaskService.operation(map);
|
||||
iSchBaseTaskService.operation(map);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/taskSchedule")
|
||||
public ResponseEntity<Object> taskSchedule() {
|
||||
taskScheduleService.taskPublish();
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
package org.nl.wms.dispatch_manage.task.service;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.external_system.acs.service.WmsToAcsService;
|
||||
@@ -42,11 +49,23 @@ public class TaskScheduleService {
|
||||
List<SchBaseTask> list = taskService.list(new QueryWrapper<SchBaseTask>().eq("is_send", true)
|
||||
.eq("status", StatusEnum.FORM_STATUS.code("生成")));
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
wmsToAcsService.interationToExt(list,"createTask");
|
||||
TableDataInfo response = wmsToAcsService.interationToExt(list, "createTask");
|
||||
if (response.getCode().equals(String.valueOf(HttpStatus.HTTP_BAD_REQUEST))){
|
||||
JSONArray results = (JSONArray)JSON.toJSON(response.getData());
|
||||
if (!CollectionUtils.isEmpty(results)){
|
||||
for (Object result : results) {
|
||||
Map resultM = (Map) result;
|
||||
taskService.update(new UpdateWrapper<SchBaseTask>()
|
||||
.eq("task_code",resultM.get("task_code"))
|
||||
.set("status",StatusEnum.FORM_STATUS.code("暂停"))
|
||||
.set("update_time", DateUtil.now()).set("remark",resultM.get("error")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}finally {
|
||||
if (islock){
|
||||
if (lock.isLocked() && lock.isHeldByCurrentThread()){
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
|
||||
@Override
|
||||
public void operation(JSONObject param) {
|
||||
String task_code = param.getString("task_code");
|
||||
String task_code = param.getString("taskCode");
|
||||
SchBaseTask task = this.getOne(new QueryWrapper<SchBaseTask>().eq("task_code", task_code));
|
||||
if (task.getStatus().equals(StatusEnum.FORM_STATUS.code("完成"))){
|
||||
throw new BadRequestException("当前任务已完成");
|
||||
}
|
||||
this.update(new UpdateWrapper<SchBaseTask>()
|
||||
.set("status",param.getString("method_name"))
|
||||
.set("status",param.getString("status"))
|
||||
.eq("task_code", task_code));
|
||||
if (param.getString("method_name").equals(StatusEnum.FORM_STATUS.code("完成"))){
|
||||
MdPbVehicleMater vehicleMater = iMdPbVehicleMaterService.getOne(new QueryWrapper<MdPbVehicleMater>()
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.nl.wms.external_system;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.external_system.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.external_system.dto.InteracteDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -15,17 +18,20 @@ public class GateWayService {
|
||||
@Autowired
|
||||
private AcsToWmsService acsToWmsService;
|
||||
|
||||
@Autowired
|
||||
private ISchBaseTaskService iSchBaseTaskService;
|
||||
|
||||
|
||||
public void apply(InteracteDto param){
|
||||
//处理日志相关
|
||||
String service = param.getService();
|
||||
String type = param.getType();
|
||||
//根据服务拆分不同的业务
|
||||
acsToWmsService.applyTask(param.getService(), type, param.getData());
|
||||
|
||||
if (service.equals("InStorage")){
|
||||
acsToWmsService.applyTask(param.getService(), type, (JSONObject) JSON.toJSON(param.getData()));
|
||||
}
|
||||
if (service.equals("Task")){
|
||||
iSchBaseTaskService.operation((JSONObject) JSON.toJSON(param.getData()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.nl.wms.external_system.acs.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.InterationUtil;
|
||||
import org.nl.common.utils.SpringContextHolder;
|
||||
import org.nl.wms.dispatch_manage.task.handler.AbstractTask;
|
||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.external_system.dto.InteracteDto;
|
||||
import org.nl.wms.flow_manage.flow.framework.process.nodeType.source.impl.MappingSourceDataTypeHandler;
|
||||
import org.nl.wms.sync_manage.service.form_mapping.ISyncFormMappingService;
|
||||
import org.nl.wms.sync_manage.service.form_mapping.dao.SyncFormMapping;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2024/5/6 14:53
|
||||
*/
|
||||
@Service
|
||||
public class AcsToWmsService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private Map<String, AbstractTask> applyTaskMap;
|
||||
@Autowired
|
||||
private ISchBaseTaskService iSchBaseTaskService;
|
||||
|
||||
public void applyTask(String service,String type,JSONObject data){
|
||||
if (service.equals("InStorage")){
|
||||
/*
|
||||
{
|
||||
"service": "ZPInStorage",
|
||||
"ip": "ip_7va9w",
|
||||
"request_time": "request_time_pbi5u",
|
||||
"trace_id": "trace_id_xl8dk",
|
||||
"data": {
|
||||
"D00018": "start001"
|
||||
}
|
||||
}
|
||||
* */
|
||||
applyTaskMap.get(type).createTask(data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void updateTAsk(String type,JSONObject data){
|
||||
String task_code = data.getString("task_code");
|
||||
SchBaseTask task = iSchBaseTaskService.getOne(new QueryWrapper<SchBaseTask>().eq("task_code", task_code)
|
||||
.lt("status", StatusEnum.FORM_STATUS.code("完成")));
|
||||
if (task == null){
|
||||
throw new BadRequestException("更新失败:当前执行中的任务不存在");
|
||||
}
|
||||
applyTaskMap.get(task.getTask_type()).updateStatus(data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.nl.wms.external_system.dto;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -17,15 +18,16 @@ import java.util.List;
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InteracteDto {
|
||||
|
||||
String service;
|
||||
String type;
|
||||
String ip = IPUtil.getLocalIp();
|
||||
String request_time = DateUtil.now();
|
||||
String trace_id;
|
||||
private String service;
|
||||
private String type;
|
||||
private String ip;
|
||||
private String request_time;
|
||||
private String trace_id;
|
||||
/**
|
||||
* 要么JSONArray要么JSONObject
|
||||
*/
|
||||
Object data;
|
||||
private Object data;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ExecuteFlowActivityBehavior extends FlowNodeActivityBehavior<JSONOb
|
||||
ActHiExecution one = actHiExecutionService.getOne(new QueryWrapper<ActHiExecution>()
|
||||
.eq("activity_id", source_data)
|
||||
.eq("proc_inst_id", entity.getProc_inst_id()));
|
||||
executeFlow.getDataSource()
|
||||
executeFlow.getDataSource();
|
||||
//处理流程线:将结果值封装
|
||||
super.execute(entity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user