fix: 任务配置以及基础分类三级回显失败BUG

This commit is contained in:
2024-04-09 14:56:53 +08:00
parent 48375287d9
commit 9db858ccb4
9 changed files with 196 additions and 124 deletions

View File

@@ -213,40 +213,36 @@ public class MdBaseClassstandardServiceImpl extends ServiceImpl<MdBaseClassstand
@Override
public List<MdBaseClassstandard> buildTree(ArrayList<MdBaseClassstandard> list) {
// 将获取的数据初始化状态
// 初始化数据
list.forEach(classstandard -> {
classstandard.setId(classstandard.getClass_id());
classstandard.setLabel(classstandard.getClass_name());
classstandard.setLeaf((classstandard.getSub_count() <= 0));
classstandard.setHasChildren(classstandard.getSub_count() > 0);
});
// 待返回数据
List<MdBaseClassstandard> trees = new ArrayList<>();
for (MdBaseClassstandard mdBaseClassstandard : list) {
// 筛选父类的值
if (ObjectUtil.isEmpty(mdBaseClassstandard.getParent_class_id())
|| mdBaseClassstandard.getParent_class_id().equals("0")) {
// collect获取当前对象的所有子级
List<MdBaseClassstandard> collect = list.stream().filter(t -> t.getParent_class_id()
.equals(mdBaseClassstandard.getClass_id())).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(collect)) {
// 设置参数
collect.forEach(classstandard -> {
classstandard.setId(classstandard.getClass_id());
classstandard.setLabel(classstandard.getClass_name());
classstandard.setHasChildren(classstandard.getSub_count() > 0);
});
MdBaseClassstandardTrees tObj = new MdBaseClassstandardTrees();
// 赋值一份实体可以避免vue-tree拿到children属性显示展开图标
BeanUtils.copyProperties(mdBaseClassstandard, tObj);
tObj.setChildren(collect);
trees.add(tObj);
} else {
trees.add(mdBaseClassstandard);
}
}
// 创建树结构
return list.stream()
.filter(node -> "0".equals(node.getParent_class_id()) || ObjectUtil.isEmpty(node.getParent_class_id()))
.map(node -> createTree(node, list))
.collect(Collectors.toList());
}
private MdBaseClassstandard createTree(MdBaseClassstandard node, List<MdBaseClassstandard> list) {
List<MdBaseClassstandard> children = list.stream()
.filter(child -> node.getClass_id().equals(child.getParent_class_id()))
.map(child -> createTree(child, list))
.collect(Collectors.toList());
if (!children.isEmpty()) {
MdBaseClassstandardTrees tObj = new MdBaseClassstandardTrees();
// 赋值一份实体可以避免vue-tree拿到children属性显示展开图标
BeanUtils.copyProperties(node, tObj);
tObj.setChildren(children);
return tObj;
} else {
node.setLeaf(true);
}
return trees;
return node;
}
@Override

View File

@@ -8,6 +8,7 @@ import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task.service.dto.SchBaseTaskconfigQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -30,7 +31,7 @@ public class SchBaseTaskconfigController {
@GetMapping
@Log("查询任务配置")
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page){
public ResponseEntity<Object> query(SchBaseTaskconfigQuery whereJson, PageQuery page){
return new ResponseEntity<>(TableDataInfo.build(schBaseTaskconfigService.queryAll(whereJson,page)),HttpStatus.OK);
}

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import org.nl.common.domain.query.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task.service.dto.SchBaseTaskconfigQuery;
import java.util.Map;
import java.util.Set;
@@ -21,7 +22,7 @@ public interface ISchBaseTaskconfigService extends IService<SchBaseTaskconfig> {
* @param pageable 分页参数
* @return IPage<SchBaseTaskconfig>
*/
IPage<SchBaseTaskconfig> queryAll(Map whereJson, PageQuery pageable);
IPage<SchBaseTaskconfig> queryAll(SchBaseTaskconfigQuery whereJson, PageQuery pageable);
/**
* 创建

View File

@@ -25,124 +25,128 @@ public class SchBaseTaskconfig implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "config_id", type = IdType.NONE)
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_type;
@TableField(exist = false)
private String task_type_id;
@TableField(exist = false)
private String task_type_name;
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)

View File

@@ -1,7 +1,9 @@
package org.nl.wms.sch.task.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task.service.dto.SchBaseTaskconfigQuery;
/**
* @author lyd
@@ -9,4 +11,11 @@ import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
**/
public interface SchBaseTaskconfigMapper extends BaseMapper<SchBaseTaskconfig> {
/**
* 连接查询
* @param pages 分页
* @param config 参数
* @return 任务配置数据
*/
IPage<SchBaseTaskconfig> selectPageLeftJoin(IPage<SchBaseTaskconfig> pages, SchBaseTaskconfigQuery config);
}

View File

@@ -2,4 +2,20 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.sch.task.service.dao.mapper.SchBaseTaskconfigMapper">
<select id="selectPageLeftJoin" resultType="org.nl.wms.sch.task.service.dao.SchBaseTaskconfig">
SELECT
sc.*,
mc.class_id AS task_type_id,
mc.class_name AS task_type_name
FROM
`sch_base_taskconfig` sc
LEFT JOIN md_base_classstandard mc ON mc.class_code = sc.task_type
WHERE sc.is_delete = FALSE
<if test="config.blurry != null">
AND sc.config_name LIKE '%${config.blurry}%'
</if>
<if test="config.workshop_code != null">
AND sc.workshop_code = config.workshop_code
</if>
</select>
</mapper>

View File

@@ -1,12 +1,18 @@
package org.nl.wms.sch.task.service.dto;
import lombok.Data;
import org.nl.common.domain.query.BaseQuery;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import java.io.Serializable;
/**
* @author lyd
* @date 2023-05-15
**/
public class SchBaseTaskconfigQuery extends BaseQuery<SchBaseTaskconfig> {
@Data
public class SchBaseTaskconfigQuery extends SchBaseTaskconfig {
private String blurry;
}

View File

@@ -12,9 +12,12 @@ import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.language.LangProcess;
import org.nl.wms.basedata.master.classification.service.IMdBaseClassstandardService;
import org.nl.wms.basedata.master.classification.service.dao.MdBaseClassstandard;
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task.service.dao.mapper.SchBaseTaskconfigMapper;
import org.nl.wms.sch.task.service.dto.SchBaseTaskconfigQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,32 +36,27 @@ public class SchBaseTaskconfigServiceImpl extends ServiceImpl<SchBaseTaskconfigM
@Autowired
private SchBaseTaskconfigMapper schBaseTaskconfigMapper;
@Autowired
private IMdBaseClassstandardService classstandardService;
@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)
.eq(ObjectUtil.isNotEmpty(workshop_code), SchBaseTaskconfig::getWorkshop_code, workshop_code);
public IPage<SchBaseTaskconfig> queryAll(SchBaseTaskconfigQuery whereJson, PageQuery page) {
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(",")));
}
});
pages = schBaseTaskconfigMapper.selectPageLeftJoin(pages, whereJson);
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))
if (ObjectUtil.isNotEmpty(schBaseTaskconfig)) {
throw new BadRequestException(LangProcess.msg("error_ParamExist", entity.getConfig_code()));
}
MdBaseClassstandard classstandard = classstandardService.getById(entity.getTask_type_id());
if (classstandard == null) {
throw new BadRequestException(LangProcess.msg("error_isNull", entity.getTask_type()));
}
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
@@ -71,26 +69,19 @@ public class SchBaseTaskconfigServiceImpl extends ServiceImpl<SchBaseTaskconfigM
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
entity.setTask_type(classstandard.getClass_code());
schBaseTaskconfigMapper.insert(entity);
}
@Override
public void update(SchBaseTaskconfig entity) {
SchBaseTaskconfig dto = schBaseTaskconfigMapper.selectById(entity.getConfig_id());
if (dto == null) throw new BadRequestException(LangProcess.msg("error_SystemAuthError"));
if (ObjectUtil.isAllEmpty(entity.getStart_region_strs(), entity.getNext_region_strs()))
throw new BadRequestException(LangProcess.msg("point_checkNull_1"));
if (ObjectUtil.isNotEmpty(entity.getStart_region_strs())) {
// 起点区域配置
String startRegion = String.join(",", entity.getStart_region_strs());
entity.setStart_region_str(startRegion);
if (dto == null) {
throw new BadRequestException(LangProcess.msg("error_SystemAuthError"));
}
if (ObjectUtil.isNotEmpty(entity.getNext_region_strs())) {
// 终点区域配置
String nextRegion = String.join(",", entity.getNext_region_strs());
entity.setNext_region_str(nextRegion);
MdBaseClassstandard classstandard = classstandardService.getById(entity.getTask_type_id());
if (classstandard == null) {
throw new BadRequestException(LangProcess.msg("error_isNull", entity.getTask_type()));
}
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
@@ -98,7 +89,7 @@ public class SchBaseTaskconfigServiceImpl extends ServiceImpl<SchBaseTaskconfigM
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
entity.setTask_type(classstandard.getClass_code());
schBaseTaskconfigMapper.updateById(entity);
}

View File

@@ -93,18 +93,13 @@
<el-input v-model="form.task_name" style="width: 240px;" />
</el-form-item>
<el-form-item label="任务类型">
<el-select
v-model="form.task_type"
size="mini"
placeholder="任务类型"
<treeselect
v-model="form.task_type_id"
:load-options="loadTaskType"
:options="taskTypes"
style="width: 240px;"
>
<el-option
v-for="item in dict.task_type"
:label="item.label"
:value="item.value"
/>
</el-select>
placeholder="请选择任务类型"
/>
</el-form-item>
<el-form-item label="优先级" pro="priority">
<el-input-number
@@ -197,14 +192,15 @@
</template>
</el-table-column>
<el-table-column prop="task_name" label="任务名字" :min-width="flexWidth('task_name',crud.data,'任务名字')" />
<el-table-column prop="task_type" label="任务类型" :min-width="flexWidth('task_type',crud.data,'任务类型', 20)">
<template slot-scope="scope">
{{ dict.label.task_type[scope.row.task_type] }}
</template>
</el-table-column>
<el-table-column prop="task_type_name" label="任务类型" :min-width="flexWidth('task_type_name',crud.data,'任务类型')" />
<el-table-column prop="priority" label="优先级" :min-width="flexWidth('priority',crud.data,'优先级')" />
<el-table-column prop="task_create_max_num" label="任务生成数上限" :min-width="flexWidth('task_create_max_num',crud.data,'任务生成数上限')" />
<el-table-column prop="task_issue_max_num" label="任务下发数上限" :min-width="flexWidth('task_issue_max_num',crud.data,'任务下发数上限')" />
<el-table-column prop="is_immediate_create" label="是否立即创建" :min-width="flexWidth('is_immediate_create',crud.data,'是否立即创建')">
<template slot-scope="scope">
{{ scope.row.is_immediate_create ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column prop="is_auto_issue" label="是否自动下发" :min-width="flexWidth('is_auto_issue',crud.data,'是否自动下发')">
<template slot-scope="scope">
{{ scope.row.is_auto_issue?'是':'否' }}
@@ -238,11 +234,6 @@
{{ scope.row.is_check_start_lock?'是':'否' }}
</template>
</el-table-column>
<el-table-column prop="is_immediate_create" label="是否立即创建" :min-width="flexWidth('is_immediate_create',crud.data,'是否立即创建')">
<template slot-scope="scope">
{{ scope.row.is_immediate_create?'是':'否' }}
</template>
</el-table-column>
<el-table-column v-if="false" prop="is_check_next_lock" label="是否判断终点锁" :min-width="flexWidth('is_check_next_lock',crud.data,'是否判断终点锁')">
<template slot-scope="scope">
{{ scope.row.is_check_next_lock?'是':'否' }}
@@ -306,8 +297,11 @@ import rrOperation from '@crud/RR.operation.vue'
import crudOperation from '@crud/CRUD.operation.vue'
import udOperation from '@crud/UD.operation.vue'
import pagination from '@crud/Pagination.vue'
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import crudMdBaseWorkShop from '@/views/wms/basedata/workshop/mdBaseWorkshop'
import crudSchBaseRegion from '@/views/wms/sch/region/schBaseRegion'
import crudClassstandard from '@/views/wms/basedata/master/classification/mdBaseClassstandard'
const defaultForm = {
config_id: null,
@@ -317,6 +311,7 @@ const defaultForm = {
acs_task_type: null,
task_name: null,
task_type: null,
task_type_id: null,
priority: null,
task_create_max_num: null,
task_issue_max_num: null,
@@ -350,7 +345,7 @@ const defaultForm = {
export default {
name: 'TaskConfig',
dicts: ['task_qf_type', 'acs_task_type', 'task_direction', 'task_type'],
components: { pagination, crudOperation, rrOperation, udOperation },
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
@@ -390,7 +385,8 @@ export default {
]
},
workShopList: [],
regionList: []
regionList: [],
taskTypes: []
}
},
computed: {
@@ -414,12 +410,28 @@ export default {
created() {
this.getWorkShopList()
this.getRegionList()
this.initClassType()
},
methods: {
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
},
// 新增与编辑前做的操作
[CRUD.HOOK.afterToCU](crud, form) {
// 为了初始化数据 -> 树的数据
if (form.task_type_id !== null && form.task_type_id !== '0' && form.task_type_id !== '') {
this.getSubTypes(form.task_type_id)
} else {
this.getClass()
}
},
getSubTypes(id) { // 获取当前对象与所有父类数据
crudClassstandard.getClassSuperior(id).then(res => {
this.buildTree(res)
this.taskTypes = res
})
},
getWorkShopList() { // 获取车间列表
crudMdBaseWorkShop.getWorkShopList().then(res => {
this.workShopList = res
@@ -429,6 +441,42 @@ export default {
crudSchBaseRegion.getRegionList().then(res => {
this.regionList = res
})
},
// 获取弹窗内任务类型数据
loadTaskType({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
crudClassstandard.getClass({ pid: parentNode.id }).then(res => {
parentNode.children = res.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 100)
})
}
},
initClassType() {
const param = {
parent_class_code: 'task_type'
}
crudClassstandard.getClassType(param).then(res => {
const data = res
this.buildTree(data)
this.taskTypes = data
})
},
buildTree(classes) {
classes.forEach(data => {
if (data.children) {
this.buildTree(data.children)
}
if (data.hasChildren && !data.children) {
data.children = null // 重点代码
}
})
}
}
}