rev:task
This commit is contained in:
@@ -59,7 +59,7 @@ public class CodeGenerator {
|
||||
dsc.setUrl("jdbc:mysql://localhost:3306/wms?serverTimezone=GMT&setUnicode=true&characterEncoding=utf8");
|
||||
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||
dsc.setUsername("root");
|
||||
dsc.setPassword("123456");
|
||||
dsc.setPassword("password");
|
||||
mpg.setDataSource(dsc);
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
package org.nl.wms.dispatch_manage.task.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.dispatch_manage.task.service.dto.TaskQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -23,9 +14,10 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.nl.wms.dispatch_manage.task.service.dto.SchBaseTaskQuery;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -38,67 +30,48 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequestMapping("api/schBaseTask")
|
||||
public class SchBaseTaskController {
|
||||
|
||||
@Autowired
|
||||
private ISchBaseTaskService iSchBaseTaskService;
|
||||
private ISchBaseTaskService schBaseTaskService;
|
||||
|
||||
|
||||
|
||||
@PostMapping("getVehicleTask")
|
||||
public ResponseEntity<Object> getVehicleTask(@RequestBody JSONObject param) {
|
||||
if (CollectionUtils.isEmpty(param)){
|
||||
throw new BadRequestException("参数不能为空");
|
||||
}
|
||||
return new ResponseEntity<>(iSchBaseTaskService.getByVehicle(param.getString("vehicle_code")), HttpStatus.OK);
|
||||
return new ResponseEntity<>(schBaseTaskService.getByVehicle(param.getString("vehicle_code")), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping
|
||||
@Log("查询任务")
|
||||
public ResponseEntity<Object> query(TaskQuery query, PageQuery pageQuery) {
|
||||
Page<SchBaseTask> page = iSchBaseTaskService.page(pageQuery.build(), query.build());
|
||||
return new ResponseEntity<>(TableDataInfo.build(page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/undo")
|
||||
@Log("查询任务")
|
||||
public ResponseEntity<Object> undo() {
|
||||
int count = iSchBaseTaskService.count(new QueryWrapper<SchBaseTask>()
|
||||
.lt("task_status", StatusEnum.FORM_STATUS.code("完成")));
|
||||
return new ResponseEntity<>(count, HttpStatus.OK);
|
||||
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(@RequestBody JSONObject task) {
|
||||
SchBaseTask schBaseTask = task.toJavaObject(SchBaseTask.class);
|
||||
schBaseTask.setId(IdUtil.getStringId());
|
||||
schBaseTask.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
schBaseTask.setCreate_time(DateUtil.now());
|
||||
iSchBaseTaskService.save(schBaseTask);
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SchBaseTask entity){
|
||||
schBaseTaskService.create(entity);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改任务")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody JSONObject task) {
|
||||
iSchBaseTaskService.updateById(task.toJavaObject(SchBaseTask.class));
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SchBaseTask entity){
|
||||
schBaseTaskService.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除任务")
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
if (ids!=null && ids.length>0){
|
||||
iSchBaseTaskService.removeByIds(Arrays.asList(ids));
|
||||
}
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
schBaseTaskService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/operation")
|
||||
@Log("任务操作")
|
||||
public ResponseEntity<Object> taskOperation(@RequestBody JSONObject map) {
|
||||
iSchBaseTaskService.operation(map);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
@PutMapping("/operation")
|
||||
public ResponseEntity<Object> update(@RequestBody Map<String, Object> map) {
|
||||
schBaseTaskService.operation(map);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class StackingTaskHandler implements TaskHandler {
|
||||
task.setVehicle_code(vehicle_code);
|
||||
task.setPoint_code1(start_point);
|
||||
task.setPoint_code2(struct_code);
|
||||
taskService.createTask(task);
|
||||
taskService.create(task);
|
||||
Boolean isSend = param.getBoolean("is_send");
|
||||
if (isSend){
|
||||
//参数封装,调acs接口
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package org.nl.wms.dispatch_manage.task.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.wms.dispatch_manage.task.service.dto.SchBaseTaskQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -18,11 +21,43 @@ import java.util.Map;
|
||||
*/
|
||||
public interface ISchBaseTaskService extends IService<SchBaseTask> {
|
||||
|
||||
void createTask(SchBaseTask task);
|
||||
|
||||
void operation(JSONObject param);
|
||||
|
||||
|
||||
List<Map> getByVehicle(String vehicle_code);
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* 任务操作
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void operation(Map<String, Object> param);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package org.nl.wms.dispatch_manage.task.service.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.wms.dispatch_manage.task.service.dto.SchBaseTaskQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -16,6 +21,7 @@ import java.util.Map;
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
public interface SchBaseTaskMapper extends BaseMapper<SchBaseTask> {
|
||||
IPage<SchBaseTask> selectPageLeftJoin(IPage<SchBaseTask> pages, @Param("whereJson") SchBaseTaskQuery whereJson, @Param("collect") List<String> collect);
|
||||
|
||||
@Select("SELECT\n" +
|
||||
"\tsch_base_task.*, md_pb_vehicleMater.*,md_me_materialbase.material_code,md_me_materialbase.material_name,md_me_materialbase.material_spec\n" +
|
||||
|
||||
@@ -1,5 +1,41 @@
|
||||
<?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.dispatch_manage.task.service.dao.mapper.SchBaseTaskMapper">
|
||||
|
||||
<select id="selectPageLeftJoin" resultType="org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask">
|
||||
SELECT
|
||||
t.*
|
||||
FROM
|
||||
`sch_base_task` t
|
||||
<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,23 @@
|
||||
package org.nl.wms.dispatch_manage.task.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-05-15
|
||||
**/
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -1,21 +1,26 @@
|
||||
package org.nl.wms.dispatch_manage.task.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.ListOf;
|
||||
import org.nl.wms.dispatch_manage.task.handler.TaskHandler;
|
||||
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.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.mapper.SchBaseTaskMapper;
|
||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.wms.external_system.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.dispatch_manage.task.service.dto.SchBaseTaskQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -29,13 +34,27 @@ import java.util.Map;
|
||||
public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBaseTask> implements ISchBaseTaskService {
|
||||
|
||||
@Autowired
|
||||
private WmsToAcsService wmsToAcsService;
|
||||
private SchBaseTaskMapper schBaseTaskMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void createTask(SchBaseTask task) {
|
||||
this.save(task);
|
||||
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("")) {
|
||||
collect = null;
|
||||
whereJson.setUnFinished(StatusEnum.FORM_STATUS.code("执行中"));
|
||||
}
|
||||
}
|
||||
IPage<SchBaseTask> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
pages = schBaseTaskMapper.selectPageLeftJoin(pages, whereJson, collect);
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Map> getByVehicle(String vehicle_code) {
|
||||
if (StringUtils.isEmpty(vehicle_code)){
|
||||
@@ -45,7 +64,42 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operation(JSONObject param) {
|
||||
public void update(SchBaseTask entity) {
|
||||
SchBaseTask dto = schBaseTaskMapper.selectById(entity.getTask_code());
|
||||
if (dto == null) throw new BadRequestException("任务信息不存在");
|
||||
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
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 nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
Assert.notNull(entity.getTask_status(), "任务状态不能为空!");
|
||||
|
||||
entity.setId(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
entity.setTask_code(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
entity.setCreate_name(nickName);
|
||||
entity.setCreate_time(now);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
schBaseTaskMapper.insert(entity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operation(Map<String, Object> param) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:123456}
|
||||
password: ${DB_PWD:password}
|
||||
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
|
||||
Reference in New Issue
Block a user