add:任务管理,任务配置
This commit is contained in:
@@ -82,4 +82,10 @@ public class ClassStandardController {
|
||||
return new ResponseEntity<>(iMdPbClassstandardService.getClassName(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getClass")
|
||||
@Log("根据编码查询基础类型")
|
||||
public ResponseEntity<Object> queryClassBycode(@RequestParam Map whereJson) {
|
||||
return new ResponseEntity<>(iMdPbClassstandardService.queryClassBycode(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -71,4 +71,11 @@ public interface IMdPbClassstandardService extends IService<MdPbClassstandard> {
|
||||
* @return List<JSONObject>
|
||||
*/
|
||||
List<JSONObject> getClassName();
|
||||
|
||||
/**
|
||||
* 根据编码查询基础类型
|
||||
* @param whereJson 入参
|
||||
* @return JSONObject
|
||||
*/
|
||||
JSONObject queryClassBycode(Map whereJson);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package org.nl.wms.basedata_manage.service.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sun.xml.bind.v2.model.core.ID;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.PageUtil;
|
||||
@@ -324,6 +326,61 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl<MdPbClassstandardM
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryClassBycode(Map whereJson) {
|
||||
// 判断父节点是否存在
|
||||
String parent_class_code = MapUtil.getStr(whereJson, "parent_class_code");
|
||||
ClassstandardDto classstandardDto = null;
|
||||
if (ObjectUtil.isNotEmpty(parent_class_code)) {
|
||||
MdPbClassstandard classDao = this.getOne(
|
||||
new QueryWrapper<MdPbClassstandard>().lambda()
|
||||
.eq(MdPbClassstandard::getClass_code, parent_class_code)
|
||||
);
|
||||
classstandardDto = JSONObject.parseObject(JSONObject.toJSONString(classDao),ClassstandardDto.class);
|
||||
if (classstandardDto == null) {
|
||||
throw new BadRequestException("请输入正确的父节点编号!");
|
||||
}
|
||||
}
|
||||
|
||||
// 查询
|
||||
String class_code = MapUtil.getStr(whereJson, "class_code");
|
||||
LambdaQueryWrapper<MdPbClassstandard> lambda = new QueryWrapper<MdPbClassstandard>().lambda();
|
||||
|
||||
if (ObjectUtil.isNotEmpty(parent_class_code)) {
|
||||
lambda.eq(MdPbClassstandard::getClass_id, classstandardDto.getClass_id())
|
||||
.orderByAsc(MdPbClassstandard::getClass_id);
|
||||
} else if (ObjectUtil.isNotEmpty(class_code)) {
|
||||
lambda.in(MdPbClassstandard::getClass_code, class_code)
|
||||
.orderByAsc(MdPbClassstandard::getClass_id);
|
||||
} else if (ObjectUtil.isEmpty(parent_class_code) || parent_class_code.equals(BaseDataEnum.IS_YES_NOT.code("否"))) {
|
||||
lambda.eq(MdPbClassstandard::getParent_class_id, BaseDataEnum.IS_YES_NOT.code("否"))
|
||||
.or(item -> item.eq(MdPbClassstandard::getParent_class_id, null));
|
||||
lambda.eq(MdPbClassstandard::getIs_delete, BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
lambda.orderByAsc(MdPbClassstandard::getClass_id);
|
||||
}
|
||||
List<ClassstandardDto> classDtoList = this.list(lambda).stream()
|
||||
.map(row -> JSONObject.parseObject(JSONObject.toJSONString(row), ClassstandardDto.class))
|
||||
.collect(Collectors.toList());
|
||||
// 格式化数据
|
||||
classDtoList.forEach(row -> {
|
||||
if (Integer.parseInt(row.getSub_count()) > 0) {
|
||||
row.setHasChildren(true);
|
||||
row.setLeaf(false);
|
||||
} else {
|
||||
row.setHasChildren(false);
|
||||
row.setLeaf(true);
|
||||
}
|
||||
row.setId(row.getClass_id());
|
||||
row.setLabel(row.getClass_name());
|
||||
row.setCreate_user_name(row.getCreate_name());
|
||||
row.setUpdate_user_name(row.getUpdate_optname());
|
||||
});
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("content", classDtoList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新节点
|
||||
* @param parent_class_id 父级id
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.nl.wms.ext.service.util;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import lombok.Data;
|
||||
import org.nl.wms.ext.util.BaseResponse;
|
||||
|
||||
/**
|
||||
* @Author: Liuxy
|
||||
* @Description: 下发acs的反馈数据*new
|
||||
* @Date: 2025/05/19
|
||||
*/
|
||||
@Data
|
||||
public class AcsResponse extends BaseResponse {
|
||||
private JSONArray errArr = new JSONArray();
|
||||
private JSONArray data = new JSONArray();
|
||||
|
||||
public static AcsResponse requestRefuse(String message) {
|
||||
AcsResponse result = new AcsResponse();
|
||||
result.setCode(HttpStatus.HTTP_BAD_REQUEST);
|
||||
result.setMessage(message);
|
||||
result.setResponseDate(DateUtil.now());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static AcsResponse requestOk() {
|
||||
AcsResponse result = new AcsResponse();
|
||||
result.setCode(HttpStatus.HTTP_OK);
|
||||
result.setMessage("请求成功");
|
||||
result.setResponseDate(DateUtil.now());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package org.nl.wms.ext.util;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: Liuxy
|
||||
* @Description: ACS 响应的基础实体
|
||||
* @Date: 2025/05/19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BaseResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* 请求号
|
||||
*/
|
||||
private String requestNo;
|
||||
|
||||
/**
|
||||
* 响应时间
|
||||
*/
|
||||
private String responseDate;
|
||||
|
||||
/**
|
||||
* 结果 200成功
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
private Map<String, String> parameters = new HashMap();
|
||||
|
||||
public static BaseResponse build(String requestNo) {
|
||||
BaseResponse response = new BaseResponse();
|
||||
response.setRequestNo(requestNo);
|
||||
response.setCode(HttpStatus.HTTP_OK);
|
||||
response.setMessage("请求成功");
|
||||
response.setResponseDate(DateUtil.now());
|
||||
return response;
|
||||
}
|
||||
|
||||
public static BaseResponse responseOk(String requestNo) {
|
||||
BaseResponse response = new BaseResponse();
|
||||
response.setRequestNo(requestNo);
|
||||
response.setCode(HttpStatus.HTTP_OK);
|
||||
response.setMessage("请求成功");
|
||||
response.setResponseDate(DateUtil.now());
|
||||
return response;
|
||||
}
|
||||
|
||||
public static BaseResponse responseOk(String requestNo, String message) {
|
||||
BaseResponse response = new BaseResponse();
|
||||
response.setRequestNo(requestNo);
|
||||
response.setCode(HttpStatus.HTTP_OK);
|
||||
response.setMessage(message);
|
||||
response.setResponseDate(DateUtil.now());
|
||||
return response;
|
||||
}
|
||||
|
||||
public static BaseResponse responseOk(String requestNo, HashMap<String, String> parameters) {
|
||||
BaseResponse response = new BaseResponse();
|
||||
response.setRequestNo(requestNo);
|
||||
response.setCode(HttpStatus.HTTP_OK);
|
||||
response.setMessage("请求成功");
|
||||
response.setResponseDate(DateUtil.now());
|
||||
response.setParameters(parameters);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static BaseResponse responseError(String requestNo, String message) {
|
||||
BaseResponse response = new BaseResponse();
|
||||
response.setRequestNo(requestNo);
|
||||
response.setCode(HttpStatus.HTTP_BAD_REQUEST);
|
||||
response.setMessage(message);
|
||||
response.setResponseDate(DateUtil.now());
|
||||
return response;
|
||||
}
|
||||
|
||||
public static BaseResponse responseError(String requestNo, int code, String message) {
|
||||
BaseResponse response = new BaseResponse();
|
||||
response.setRequestNo(requestNo);
|
||||
response.setCode(code);
|
||||
response.setMessage(message);
|
||||
response.setResponseDate(DateUtil.now());
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.nl.wms.sch_manage.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch_manage.service.dto.SchBaseTaskQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
||||
@RequestMapping("/api/schBaseTask")
|
||||
public class SchBaseTaskController {
|
||||
|
||||
@Autowired
|
||||
private ISchBaseTaskService schBaseTaskService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询任务管理")
|
||||
public ResponseEntity<Object> query(SchBaseTaskQuery whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(schBaseTaskService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增任务管理")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SchBaseTask entity) {
|
||||
schBaseTaskService.create(entity);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改任务管理")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SchBaseTask entity) {
|
||||
schBaseTaskService.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除任务管理")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
schBaseTaskService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/taskStatusList")
|
||||
@Log("任务状态下拉框")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getTaskStatusList() {
|
||||
return new ResponseEntity<>(TableDataInfo.build(schBaseTaskService.getTaskStatusList()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/operation")
|
||||
@Log("任务操作")
|
||||
public ResponseEntity<Object> update(@RequestBody Map<String, Object> map) {
|
||||
schBaseTaskService.operation(map);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.nl.wms.sch_manage.controller;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTaskconfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
||||
@RequestMapping("/api/schBaseTaskconfig")
|
||||
public class SchBaseTaskconfigController {
|
||||
|
||||
@Autowired
|
||||
private ISchBaseTaskconfigService schBaseTaskconfigService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询任务配置")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(schBaseTaskconfigService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增任务配置")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SchBaseTaskconfig entity) {
|
||||
schBaseTaskconfigService.create(entity);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改任务配置")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SchBaseTaskconfig entity) {
|
||||
schBaseTaskconfigService.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除任务配置")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
schBaseTaskconfigService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getTaskConfigList")
|
||||
@Log("获取下拉框")
|
||||
public ResponseEntity<Object> getTaskConfigList() {
|
||||
return new ResponseEntity<>(schBaseTaskconfigService.getTaskConfigList(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.nl.wms.sch_manage.enums;
|
||||
|
||||
/**
|
||||
* @Author: Liuxy
|
||||
* @Description: 任务枚举
|
||||
* @Date: 2025/05/19
|
||||
*/
|
||||
public enum TaskStatus {
|
||||
/**
|
||||
* 申请
|
||||
*/
|
||||
CREATE("0", "生成", "生成"),
|
||||
/**
|
||||
* 申请
|
||||
*/
|
||||
APPLY("1", "申请", "申请"),
|
||||
/**
|
||||
* 创建完成
|
||||
*/
|
||||
CREATED("2", "创建完成", "创建完成"),
|
||||
/**
|
||||
* 下发
|
||||
*/
|
||||
ISSUED("3", "下发", "下发"),
|
||||
/**
|
||||
* 执行中
|
||||
*/
|
||||
EXECUTING("4", "执行中", "执行中"),
|
||||
/**
|
||||
* 完成
|
||||
*/
|
||||
FINISHED("5", "完成", "完成"),
|
||||
/**
|
||||
* 已取消
|
||||
*/
|
||||
CANCELED("6", "已取消", "已取消"),
|
||||
/**
|
||||
* 未完成
|
||||
*/
|
||||
UNFINISHED("7", "未完成", "未完成");
|
||||
|
||||
|
||||
TaskStatus(String code, String name, String desc) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
private String desc;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package org.nl.wms.sch_manage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch_manage.service.dto.SchBaseTaskQuery;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务接口
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
public interface ISchBaseTaskService extends IService<SchBaseTask> {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param pageable 分页参数
|
||||
* @return IPage<SchBaseTask>
|
||||
*/
|
||||
IPage<SchBaseTask> queryAll(SchBaseTaskQuery whereJson, PageQuery pageable);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param entity /
|
||||
*/
|
||||
void create(SchBaseTask entity);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param entity /
|
||||
*/
|
||||
void update(SchBaseTask entity);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 获取任务状态下拉框
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
JSONArray getTaskStatusList();
|
||||
|
||||
/**
|
||||
* 任务操作
|
||||
*
|
||||
* @param param 参数
|
||||
*/
|
||||
void operation(Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 获取任务数据
|
||||
*
|
||||
* @param taskCode 任务编码
|
||||
* @return /
|
||||
*/
|
||||
SchBaseTask getByCode(String taskCode);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.nl.wms.sch_manage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTaskconfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务接口
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
public interface ISchBaseTaskconfigService extends IService<SchBaseTaskconfig> {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param pageable 分页参数
|
||||
* @return IPage<SchBaseTaskconfig>
|
||||
*/
|
||||
IPage<SchBaseTaskconfig> queryAll(Map whereJson, PageQuery pageable);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param entity /
|
||||
*/
|
||||
void create(SchBaseTaskconfig entity);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param entity /
|
||||
*/
|
||||
void update(SchBaseTaskconfig entity);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 获取下拉框
|
||||
* @return List<SchBaseTaskconfig>
|
||||
*/
|
||||
List<SchBaseTaskconfig> getTaskConfigList();
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package org.nl.wms.sch_manage.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @description /
|
||||
* @date 2023-05-15
|
||||
**/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sch_base_task")
|
||||
public class SchBaseTask implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "task_id")
|
||||
private String task_id;
|
||||
|
||||
|
||||
private String task_code;
|
||||
|
||||
|
||||
private String task_status;
|
||||
|
||||
|
||||
private String config_code;
|
||||
|
||||
|
||||
private String point_code1;
|
||||
|
||||
|
||||
private String point_code2;
|
||||
|
||||
|
||||
private String point_code3;
|
||||
|
||||
|
||||
private String point_code4;
|
||||
|
||||
|
||||
private String group_id;
|
||||
|
||||
|
||||
private String vehicle_type;
|
||||
|
||||
|
||||
private Integer vehicle_qty;
|
||||
|
||||
|
||||
private String vehicle_code;
|
||||
|
||||
|
||||
private String vehicle_code2;
|
||||
|
||||
|
||||
private String handle_status;
|
||||
|
||||
|
||||
private String car_no;
|
||||
|
||||
|
||||
private String task_group_id;
|
||||
|
||||
|
||||
private BigDecimal task_group_seq;
|
||||
|
||||
|
||||
private String finished_type;
|
||||
|
||||
|
||||
private String create_mode;
|
||||
|
||||
|
||||
private String acs_trace_id;
|
||||
|
||||
|
||||
private String request_param;
|
||||
|
||||
|
||||
private String response_param;
|
||||
|
||||
|
||||
private String workshop_code;
|
||||
|
||||
|
||||
private String ext_group_data;
|
||||
|
||||
|
||||
private String remark;
|
||||
|
||||
|
||||
private Boolean is_delete;
|
||||
|
||||
|
||||
private String create_id;
|
||||
|
||||
|
||||
private String priority;
|
||||
|
||||
|
||||
private String create_name;
|
||||
|
||||
|
||||
private String create_time;
|
||||
|
||||
|
||||
private String update_id;
|
||||
|
||||
|
||||
private String update_name;
|
||||
|
||||
private String update_time;
|
||||
@TableField(exist = false)
|
||||
private String config_name;
|
||||
@TableField(exist = false)
|
||||
private String task_name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package org.nl.wms.sch_manage.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description /
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sch_base_taskconfig")
|
||||
public class SchBaseTaskconfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "config_id")
|
||||
|
||||
private String config_id;
|
||||
|
||||
|
||||
private String config_code;
|
||||
|
||||
|
||||
private String config_name;
|
||||
|
||||
|
||||
private String route_plan_code;
|
||||
|
||||
|
||||
private String task_qf_type;
|
||||
|
||||
|
||||
private String acs_task_type;
|
||||
|
||||
|
||||
private String task_name;
|
||||
|
||||
|
||||
private String task_type;
|
||||
|
||||
|
||||
private String task_direction;
|
||||
|
||||
|
||||
private String priority;
|
||||
|
||||
|
||||
private Integer task_create_max_num;
|
||||
|
||||
|
||||
private Integer task_issue_max_num;
|
||||
|
||||
|
||||
private Boolean is_auto_issue;
|
||||
|
||||
|
||||
private String start_region_str;
|
||||
|
||||
|
||||
private String next_region_str;
|
||||
|
||||
|
||||
private String start_point_pre;
|
||||
|
||||
|
||||
private String next_region_pre;
|
||||
|
||||
|
||||
private Boolean is_check_workorder;
|
||||
|
||||
|
||||
private Boolean is_check_start_lock;
|
||||
|
||||
|
||||
private Boolean is_immediate_create;
|
||||
|
||||
|
||||
private Boolean is_check_next_lock;
|
||||
|
||||
|
||||
private Boolean is_start_auto;
|
||||
|
||||
|
||||
private Boolean is_next_auto;
|
||||
|
||||
|
||||
private Boolean is_lock_start;
|
||||
|
||||
|
||||
private Boolean is_lock_next;
|
||||
|
||||
|
||||
private String request_param;
|
||||
|
||||
|
||||
private String response_param;
|
||||
|
||||
|
||||
private Boolean is_group_congrol_issue_seq;
|
||||
|
||||
|
||||
private BigDecimal unfinish_notify_time;
|
||||
|
||||
|
||||
private String sql_param;
|
||||
|
||||
|
||||
private String workshop_code;
|
||||
|
||||
|
||||
private String remark;
|
||||
|
||||
|
||||
private Boolean is_used;
|
||||
|
||||
|
||||
private Boolean is_delete;
|
||||
|
||||
|
||||
private String create_id;
|
||||
|
||||
|
||||
private String create_name;
|
||||
|
||||
|
||||
private String create_time;
|
||||
|
||||
|
||||
private String update_id;
|
||||
|
||||
|
||||
private String update_name;
|
||||
|
||||
|
||||
private String update_time;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> start_region_strs;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> next_region_strs;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.nl.wms.sch_manage.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch_manage.service.dto.SchBaseTaskQuery;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-05-15
|
||||
**/
|
||||
public interface SchBaseTaskMapper extends BaseMapper<SchBaseTask> {
|
||||
|
||||
int getEmptyVehicleCarryingByDevice(String deviceCode);
|
||||
|
||||
BigDecimal getCallMaterialCarryingByDevice(String deviceCode);
|
||||
|
||||
int getCarryingByDevice(String deviceCode, String taskConfig);
|
||||
|
||||
IPage<SchBaseTask> selectPageLeftJoin(IPage<SchBaseTask> pages, SchBaseTaskQuery whereJson, List<String> collect);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.sch_manage.service.dao.mapper.SchBaseTaskMapper">
|
||||
|
||||
<select id="getEmptyVehicleCarryingByDevice" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM `sch_base_task` t
|
||||
LEFT JOIN sch_base_point p1 ON p1.point_code = t.point_code4
|
||||
LEFT JOIN sch_base_point p2 ON p2.point_code = #{deviceCode}
|
||||
WHERE t.config_code = 'FJMLTask'
|
||||
AND t.point_code4 IS NOT NULL
|
||||
AND t.task_status IN ('1', '2', '3', '4')
|
||||
AND p1.parent_point_code = p2.parent_point_code
|
||||
</select>
|
||||
<select id="getCarryingByDevice" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM `sch_base_task` t
|
||||
LEFT JOIN sch_base_point p1 ON p1.point_code = t.point_code4
|
||||
LEFT JOIN sch_base_point p2 ON p2.point_code = #{deviceCode}
|
||||
WHERE t.config_code = #{taskConfig}
|
||||
AND t.point_code4 IS NOT NULL
|
||||
AND t.task_status IN ('1', '2', '3', '4')
|
||||
AND p1.parent_point_code = p2.parent_point_code
|
||||
</select>
|
||||
<select id="getCallMaterialCarryingByDevice" resultType="java.math.BigDecimal">
|
||||
SELECT COALESCE(SUM(vg.material_qty), 0) AS total_material_qty
|
||||
FROM `sch_base_task` t
|
||||
LEFT JOIN sch_base_point p1 ON p1.point_code = t.point_code2
|
||||
LEFT JOIN sch_base_point p2 ON p2.point_code = #{deviceCode}
|
||||
LEFT JOIN sch_base_vehiclematerialgroup vg ON vg.group_id = t.group_id
|
||||
WHERE t.config_code = 'FJQLTask'
|
||||
AND t.point_code2 IS NOT NULL
|
||||
AND t.task_status IN ('1', '2', '3', '4')
|
||||
AND p1.parent_point_code = p2.parent_point_code
|
||||
</select>
|
||||
<select id="selectPageLeftJoin" resultType="org.nl.wms.sch_manage.service.dao.SchBaseTask">
|
||||
SELECT
|
||||
t.*,
|
||||
tc.config_name,
|
||||
tc.task_name
|
||||
FROM
|
||||
`sch_base_task` t
|
||||
LEFT JOIN sch_base_taskconfig tc ON tc.config_code = t.config_code
|
||||
<where>
|
||||
<if test="whereJson.task_code != null">
|
||||
AND t.task_code = #{whereJson.task_code}
|
||||
</if>
|
||||
<if test="whereJson.config_code != null">
|
||||
AND t.config_code = #{whereJson.config_code}
|
||||
</if>
|
||||
<if test="whereJson.point_code != null">
|
||||
AND (t.point_code1 LIKE '%${whereJson.point_code}%'
|
||||
OR t.point_code2 LIKE '%${whereJson.point_code}%')
|
||||
</if>
|
||||
<if test="whereJson.unFinished != null">
|
||||
AND t.task_status <![CDATA[<=]]> #{whereJson.unFinished}
|
||||
</if>
|
||||
<if test="whereJson.vehicle_code != null">
|
||||
AND t.vehicle_code = #{whereJson.vehicle_code}
|
||||
</if>
|
||||
<if test="whereJson.end_time != null">
|
||||
AND t.create_time <![CDATA[<=]]> #{whereJson.end_time}
|
||||
</if>
|
||||
<if test="whereJson.begin_time != null">
|
||||
AND t.create_time <![CDATA[>=]]> #{whereJson.begin_time}
|
||||
</if>
|
||||
<if test="collect != null and collect != ''">
|
||||
AND t.task_status IN
|
||||
<foreach collection="collect" item="code" separator="," open="(" close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.wms.sch_manage.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTaskconfig;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
public interface SchBaseTaskconfigMapper extends BaseMapper<SchBaseTaskconfig> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.sch_manage.service.dao.mapper.SchBaseTaskconfigMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.wms.sch_manage.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @date 2025-05-19
|
||||
* **/
|
||||
@Data
|
||||
public class SchBaseTaskQuery implements Serializable {
|
||||
private String task_code;
|
||||
private String vehicle_code;
|
||||
private String point_code;
|
||||
private String begin_time;
|
||||
private String end_time;
|
||||
private String more_task_status;
|
||||
private String unFinished;
|
||||
|
||||
private String config_code;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package org.nl.wms.sch_manage.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.enums.BaseDataEnum;
|
||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch_manage.service.dao.mapper.SchBaseTaskMapper;
|
||||
import org.nl.wms.sch_manage.service.dto.SchBaseTaskQuery;
|
||||
import org.nl.wms.sch_manage.service.util.AbstractTask;
|
||||
import org.nl.wms.sch_manage.service.util.TaskFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务实现
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBaseTask> implements ISchBaseTaskService {
|
||||
|
||||
@Autowired
|
||||
private SchBaseTaskMapper schBaseTaskMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskFactory taskFactory;
|
||||
|
||||
@Override
|
||||
public IPage<SchBaseTask> queryAll(SchBaseTaskQuery whereJson, PageQuery page) {
|
||||
List<String> collect = ObjectUtil.isNotEmpty(whereJson.getMore_task_status())
|
||||
? Arrays.stream(whereJson.getMore_task_status().split(",")).collect(Collectors.toList()) : null;
|
||||
if (collect != null) {
|
||||
if (collect.contains(TaskStatus.UNFINISHED.getCode())) {
|
||||
collect = null;
|
||||
whereJson.setUnFinished(TaskStatus.EXECUTING.getCode());
|
||||
}
|
||||
}
|
||||
IPage<SchBaseTask> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
pages = schBaseTaskMapper.selectPageLeftJoin(pages, whereJson, collect);
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(SchBaseTask entity) {
|
||||
SchBaseTask dto = schBaseTaskMapper.selectById(entity.getTask_code());
|
||||
if (dto == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
|
||||
schBaseTaskMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Set<String> ids) {
|
||||
// 真删除
|
||||
schBaseTaskMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(SchBaseTask entity) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
Assert.notNull(entity.getTask_status(), "任务状态不能为空!");
|
||||
|
||||
entity.setTask_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
entity.setTask_code(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
entity.setCreate_id(currentUserId);
|
||||
entity.setCreate_name(nickName);
|
||||
entity.setCreate_time(now);
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
schBaseTaskMapper.insert(entity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getTaskStatusList() {
|
||||
TaskStatus[] values = TaskStatus.values();
|
||||
JSONArray arr = new JSONArray();
|
||||
for (TaskStatus value : values) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", value.getCode());
|
||||
json.put("name", value.getName());
|
||||
arr.add(json);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operation(Map<String, Object> param) {
|
||||
String task_code = ObjectUtil.isNotEmpty(param.get("task_code")) ? param.get("task_code").toString() : null;
|
||||
String method_name = ObjectUtil.isNotEmpty(param.get("method_name")) ? param.get("method_name").toString() : null;
|
||||
String config_code = ObjectUtil.isNotEmpty(param.get("config_code")) ? param.get("config_code").toString() : null;
|
||||
if (ObjectUtil.isEmpty(task_code) || ObjectUtil.isEmpty(method_name) || ObjectUtil.isEmpty(config_code)) {
|
||||
throw new BadRequestException("操作失败");
|
||||
}
|
||||
// 根据配置去工厂类获得类对象
|
||||
String processing_class = config_code;
|
||||
String message = "";
|
||||
// 根据任务类型获取对应的任务操作类
|
||||
AbstractTask abstractTask = taskFactory.getTask(processing_class);
|
||||
// 调用每个任务类的method_name()强制结束方法
|
||||
JSONObject result;
|
||||
switch (method_name) {
|
||||
case "immediateNotifyAcs":
|
||||
//
|
||||
break;
|
||||
// 强制完成
|
||||
case "forceFinish":
|
||||
abstractTask.forceFinish(task_code);
|
||||
break;
|
||||
case "cancel":
|
||||
abstractTask.cancel(task_code);
|
||||
break;
|
||||
case "back":
|
||||
abstractTask.backMes(task_code);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchBaseTask getByCode(String taskCode) {
|
||||
LambdaQueryWrapper<SchBaseTask> lam = new QueryWrapper<SchBaseTask>().lambda();
|
||||
lam.eq(SchBaseTask::getTask_code, taskCode);
|
||||
lam.eq(SchBaseTask::getIs_delete, BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
return this.getOne(lam);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package org.nl.wms.sch_manage.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTaskconfig;
|
||||
import org.nl.wms.sch_manage.service.dao.mapper.SchBaseTaskconfigMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务实现
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SchBaseTaskconfigServiceImpl extends ServiceImpl<SchBaseTaskconfigMapper, SchBaseTaskconfig> implements ISchBaseTaskconfigService {
|
||||
|
||||
@Autowired
|
||||
private SchBaseTaskconfigMapper schBaseTaskconfigMapper;
|
||||
|
||||
@Override
|
||||
public IPage<SchBaseTaskconfig> queryAll(Map whereJson, PageQuery page) {
|
||||
String blurry = ObjectUtil.isNotEmpty(whereJson.get("blurry")) ? whereJson.get("blurry").toString() : null;
|
||||
String workshop_code = ObjectUtil.isNotEmpty(whereJson.get("workshop_code")) ? whereJson.get("workshop_code").toString() : null;
|
||||
LambdaQueryWrapper<SchBaseTaskconfig> lam = new LambdaQueryWrapper<>();
|
||||
lam.like(ObjectUtil.isNotEmpty(blurry), SchBaseTaskconfig::getConfig_name, blurry)
|
||||
.or(ObjectUtil.isNotEmpty(blurry), la -> la.like( SchBaseTaskconfig::getConfig_code, blurry))
|
||||
.eq(ObjectUtil.isNotEmpty(workshop_code), SchBaseTaskconfig::getWorkshop_code, workshop_code);
|
||||
IPage<SchBaseTaskconfig> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
schBaseTaskconfigMapper.selectPage(pages, lam);
|
||||
pages.getRecords().forEach(config -> {
|
||||
if (ObjectUtil.isNotEmpty(config.getStart_region_str())) {
|
||||
config.setStart_region_strs(Arrays.asList(config.getStart_region_str().split(",")));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(config.getNext_region_str())) {
|
||||
config.setNext_region_strs(Arrays.asList(config.getNext_region_str().split(",")));
|
||||
}
|
||||
});
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(SchBaseTaskconfig entity) {
|
||||
SchBaseTaskconfig schBaseTaskconfig = schBaseTaskconfigMapper.selectOne(new LambdaQueryWrapper<SchBaseTaskconfig>().eq(SchBaseTaskconfig::getConfig_code, entity.getConfig_code()));
|
||||
if (ObjectUtil.isNotEmpty(schBaseTaskconfig)) {
|
||||
throw new BadRequestException("任务配置【" + entity.getConfig_code() + "】已存在!");
|
||||
}
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
if (ObjectUtil.isAllEmpty(entity.getStart_region_strs(), entity.getNext_region_strs())) {
|
||||
throw new BadRequestException("起点区域和终点区域不能同时为空!");
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(entity.getStart_region_strs())) {
|
||||
// 起点区域配置
|
||||
String startRegion = String.join(",", entity.getStart_region_strs());
|
||||
entity.setStart_region_str(startRegion);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(entity.getNext_region_strs())) {
|
||||
// 终点区域配置
|
||||
String nextRegion = String.join(",", entity.getNext_region_strs());
|
||||
entity.setNext_region_str(nextRegion);
|
||||
}
|
||||
|
||||
entity.setConfig_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
entity.setCreate_id(currentUserId);
|
||||
entity.setCreate_name(nickName);
|
||||
entity.setCreate_time(now);
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
schBaseTaskconfigMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(SchBaseTaskconfig entity) {
|
||||
SchBaseTaskconfig dto = schBaseTaskconfigMapper.selectById(entity.getConfig_id());
|
||||
if (dto == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
if (ObjectUtil.isAllEmpty(entity.getStart_region_strs(), entity.getNext_region_strs())) {
|
||||
throw new BadRequestException("起点区域和终点区域不能同时为空!");
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(entity.getStart_region_strs())) {
|
||||
// 起点区域配置
|
||||
String startRegion = String.join(",", entity.getStart_region_strs());
|
||||
entity.setStart_region_str(startRegion);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(entity.getNext_region_strs())) {
|
||||
// 终点区域配置
|
||||
String nextRegion = String.join(",", entity.getNext_region_strs());
|
||||
entity.setNext_region_str(nextRegion);
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
|
||||
schBaseTaskconfigMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Set<String> ids) {
|
||||
// 真删除
|
||||
schBaseTaskconfigMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchBaseTaskconfig> getTaskConfigList() {
|
||||
return this.list();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package org.nl.wms.sch_manage.service.util;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.ext.service.util.AcsResponse;
|
||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTaskconfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @version 1.0
|
||||
* @date 2025年05月19日
|
||||
* @desc 任务抽象父类,申请任务的相关率先判断以及生成,接着到子类执行任务的创建,最后统一通过定时任务去下发到ACS
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public abstract class AbstractTask {
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Autowired
|
||||
private ISchBaseTaskconfigService taskConfigService;
|
||||
/* @Autowired
|
||||
private ISchBasePointService pointService;
|
||||
@Autowired
|
||||
private WmsToAcsService wmsToAcsService;*/
|
||||
|
||||
/**
|
||||
* 任务创建
|
||||
* 根据配置生成任务
|
||||
*/
|
||||
public abstract String create(JSONObject json);
|
||||
|
||||
/**
|
||||
* 下发acs前参数整理
|
||||
* @param taskId
|
||||
*/
|
||||
public abstract AcsTaskDto sendAcsParam(String taskId);
|
||||
|
||||
/**
|
||||
* @return WCS的任务集合
|
||||
* @discription 重新下发给wcs任务
|
||||
* @author ldjun
|
||||
* @created 2020年6月12日 下午5:52:28
|
||||
*/
|
||||
protected AcsResponse renotifyAcs(SchBaseTask task) {
|
||||
Assert.notNull(task);
|
||||
List<SchBaseTask> taskList = new ArrayList<>();
|
||||
taskList.add(task);
|
||||
return this.renotifyAcs(taskList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WCS的任务集合
|
||||
* @discription 重新下发给wcs任务
|
||||
* @author ldjun
|
||||
* @created 2020年6月12日 下午5:52:28
|
||||
*/
|
||||
@SneakyThrows
|
||||
protected AcsResponse renotifyAcs(List<SchBaseTask> taskList) {
|
||||
AcsResponse resultForAcs = AcsResponse.requestOk();
|
||||
//1、获取任务
|
||||
//2、根据任务配置补全任务
|
||||
//3、下发
|
||||
List<AcsTaskDto> list = new ArrayList<>();
|
||||
for (SchBaseTask task : taskList) {
|
||||
AcsTaskDto taskDto = new AcsTaskDto();
|
||||
String responseParam = task.getResponse_param();
|
||||
if (ObjectUtil.isNotEmpty(responseParam)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(responseParam);
|
||||
taskDto.setDirection(jsonObject.getString("direction"));
|
||||
taskDto.setPut_device_code(jsonObject.getString("fmj_device"));
|
||||
}
|
||||
taskDto.setExt_task_uuid(task.getTask_id());
|
||||
taskDto.setTask_code(task.getTask_code());
|
||||
taskDto.setRoute_plan_code("normal");
|
||||
taskDto.setVehicle_code(task.getVehicle_code());
|
||||
taskDto.setVehicle_code2(task.getVehicle_code2());
|
||||
this.setTask(task.getConfig_code(), taskDto);
|
||||
list.add(taskDto);
|
||||
}
|
||||
try {
|
||||
// 创建下发对象
|
||||
// TODO resultForAcs = wmsToAcsService.renotifyAcs(list);
|
||||
} catch (Exception e) {
|
||||
log.error("任务下发异常: {}", e.getMessage());
|
||||
resultForAcs.setResponseDate(DateUtil.now());
|
||||
resultForAcs.setCode(HttpStatus.HTTP_BAD_REQUEST);
|
||||
resultForAcs.setMessage(e.getMessage());
|
||||
}
|
||||
// 如果下发完毕,就修改状态
|
||||
if (resultForAcs.getCode() == HttpStatus.HTTP_OK) {
|
||||
// 解析
|
||||
JSONArray errArr = resultForAcs.getErrArr();
|
||||
for (SchBaseTask schBaseTask : taskList) {
|
||||
schBaseTask.setTask_status(TaskStatus.ISSUED.getCode());
|
||||
// 判断是否是出错的任务
|
||||
for (int i = 0; ObjectUtil.isNotEmpty(errArr) && i < errArr.size(); i++) {
|
||||
JSONObject errObj = errArr.getJSONObject(i);
|
||||
String taskCode = errObj.getString("task_code");
|
||||
if (taskCode.equals(schBaseTask.getTask_code())) {
|
||||
// 出错的任务就设置出错信息为备注,不是出错就设置下发
|
||||
schBaseTask.setTask_status(TaskStatus.CREATED.getCode());
|
||||
schBaseTask.setRemark(errObj.getString("message"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
taskService.updateBatchById(taskList);
|
||||
}
|
||||
return resultForAcs;
|
||||
}
|
||||
|
||||
private AcsTaskDto setTask(String configCode, AcsTaskDto taskDto) {
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, configCode));
|
||||
taskDto.setPriority(taskConfig.getPriority());
|
||||
taskDto.setTask_type(taskConfig.getAcs_task_type());
|
||||
taskDto.setRoute_plan_code(taskConfig.getRoute_plan_code());
|
||||
return taskDto;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
*/
|
||||
public void schedule() {
|
||||
this.autoCreate();
|
||||
// 下发
|
||||
this.getAllFinishTask();
|
||||
}
|
||||
|
||||
public void getAllFinishTask() {
|
||||
List<SchBaseTask> list = taskService.list(new LambdaQueryWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getTask_status, TaskStatus.CREATED.getCode()));
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
// 下发
|
||||
this.renotifyAcs(list);
|
||||
}
|
||||
|
||||
public void updateTaskStatus(String taskCode, TaskStatus status) {
|
||||
this.updateStatus(taskCode, status);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自动生成任务
|
||||
*/
|
||||
protected void autoCreate() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 以下改为public会出现自动注入类出现问题
|
||||
*
|
||||
* @param task_code
|
||||
* @param status
|
||||
*/
|
||||
protected abstract void updateStatus(String task_code, TaskStatus status);
|
||||
|
||||
|
||||
/**
|
||||
* 首先组盘在下发任务
|
||||
*
|
||||
* @param param 具体参数
|
||||
*/
|
||||
public String setGroupPlate(JSONObject param) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制结束完成任务
|
||||
*
|
||||
* @param task_code
|
||||
*/
|
||||
public abstract void forceFinish(String task_code);
|
||||
|
||||
/**
|
||||
* 取消任务,货物搬回原点
|
||||
*
|
||||
* @param task_code
|
||||
*/
|
||||
public abstract void cancel(String task_code);
|
||||
|
||||
/**
|
||||
* 申请任务
|
||||
*
|
||||
* @param param
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public void apply(JSONObject param) throws BadRequestException {
|
||||
}
|
||||
|
||||
public abstract void backMes(String task_code);
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package org.nl.wms.sch_manage.service.util;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: Liuxy
|
||||
* @Description: 任务Dto
|
||||
* @Date: 2025/05/19
|
||||
*/
|
||||
@Data
|
||||
public class AcsTaskDto {
|
||||
/**
|
||||
* 任务标识
|
||||
*/
|
||||
private String ext_task_uuid;
|
||||
|
||||
/**
|
||||
* 任务编号
|
||||
*/
|
||||
private String task_code;
|
||||
|
||||
|
||||
/**
|
||||
* 取货点1
|
||||
*/
|
||||
String start_device_code;
|
||||
|
||||
/**
|
||||
* 放货点1
|
||||
*/
|
||||
String next_device_code;
|
||||
|
||||
/**
|
||||
* 取货点2
|
||||
*/
|
||||
String start_device_code2;
|
||||
|
||||
/**
|
||||
* 放货点2
|
||||
*/
|
||||
String next_device_code2;
|
||||
|
||||
/**
|
||||
* 对接位
|
||||
*/
|
||||
String put_device_code;
|
||||
|
||||
/**
|
||||
* 优先级
|
||||
*/
|
||||
String priority;
|
||||
|
||||
/**
|
||||
* 载具号
|
||||
*/
|
||||
String vehicle_code;
|
||||
|
||||
/**
|
||||
* 载具号2
|
||||
*/
|
||||
String vehicle_code2;
|
||||
|
||||
/**
|
||||
* 载具类型
|
||||
*/
|
||||
String vehicle_type;
|
||||
|
||||
/**
|
||||
* 路由方案
|
||||
*/
|
||||
String route_plan_code;
|
||||
|
||||
/**
|
||||
* 任务类型
|
||||
*/
|
||||
String task_type;
|
||||
|
||||
/**
|
||||
* 立库任务类型
|
||||
*/
|
||||
String dtl_type;
|
||||
|
||||
/**
|
||||
* Agv系统类型
|
||||
* 1:1楼叉车系统
|
||||
* 2:2楼1区域AGV系统
|
||||
* 3:2楼2区域AGV系统
|
||||
*/
|
||||
String agv_system_type;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
String remark;
|
||||
|
||||
/**
|
||||
* 烘箱时间
|
||||
*/
|
||||
String oven_time;
|
||||
|
||||
/**
|
||||
* 烘箱温度
|
||||
*/
|
||||
String temperature;
|
||||
|
||||
/**
|
||||
* agv取货高度
|
||||
*/
|
||||
private String start_height;
|
||||
|
||||
/**
|
||||
* agv放货高度
|
||||
*/
|
||||
private String next_height;
|
||||
|
||||
/**
|
||||
* 方向 1往左 2往右
|
||||
*/
|
||||
private String direction;
|
||||
|
||||
/**
|
||||
* 扩展属性
|
||||
*/
|
||||
Map<String, String> params;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.nl.wms.sch_manage.service.util;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Liuyx
|
||||
* @version 3.0
|
||||
* @date 2025年05月19日
|
||||
* @desc 2.0 采用获取注解来标识任务类型,并通过扫描和反射的方式来获取任务实例
|
||||
* 3.0 采用获取所有bean对象判断是否为AbstractTask
|
||||
*/
|
||||
@Component
|
||||
public class TaskFactory implements BeanPostProcessor {
|
||||
private final Map<String, AbstractTask> taskMap;
|
||||
|
||||
@Autowired
|
||||
public TaskFactory() {
|
||||
taskMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof AbstractTask) {
|
||||
taskMap.put(beanName, (AbstractTask) bean);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
public AbstractTask getTask(String taskType) {
|
||||
if (taskType == null) {
|
||||
return null;
|
||||
}
|
||||
return taskMap.get(taskType);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user