rev:部门树修改

This commit is contained in:
2023-09-05 10:50:35 +08:00
parent e65153e68e
commit a4f0e49a3c
11 changed files with 185 additions and 165 deletions

View File

@@ -25,6 +25,7 @@ import org.nl.wms.device_manage.repair.service.dto.DevicerepairmstDto;
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtBsrealstorattrService;
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtBsrealstorattr;
import org.nl.wms.masterdata_manage.备份master.service.ClassstandardService;
import org.nl.wms.system_manage.service.dept.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -48,6 +49,9 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
// private final StorattrService storattrService;
// private final SparePartOutServiceImpl sparePartOutService;
@Autowired
private ISysDeptService deptService;
@Autowired
private IStIvtBsrealstorattrService storattrService; // 仓库服务
@@ -1097,7 +1101,6 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
@Override
public Map<String, Object> query5(Map whereJson, Pageable page) {
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
String device_code = MapUtil.getStr(whereJson, "device_code");
String repair_code = MapUtil.getStr(whereJson, "repair_code");
@@ -1128,8 +1131,8 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
// 归属部门
String dept_id = MapUtil.getStr(whereJson, "dept_id");
if (!StrUtil.isEmpty(dept_id)) {
// String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
// map.put("deptIds", deptIds);
String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
map.put("deptIds", deptIds);
}
JSONObject json = WQL.getWO("EM_BI_DEVICEREPAIR_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "mst.input_time DESC");
return json;

View File

@@ -21,6 +21,7 @@ import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.device_manage.repair.service.DevicerepairrequestService;
import org.nl.wms.device_manage.repair.service.dto.DevicerepairrequestDto;
import org.nl.wms.masterdata_manage.备份master.service.ClassstandardService;
import org.nl.wms.system_manage.service.dept.ISysDeptService;
import org.nl.wms.system_manage.service.user.ISysUserService;
import org.nl.wms.system_manage.service.user.dao.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,6 +47,9 @@ public class DevicerepairrequestServiceImpl implements DevicerepairrequestServic
@Autowired
private ISysUserService iSysUserService;
@Autowired
private ISysDeptService deptService;
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
@@ -78,8 +82,6 @@ public class DevicerepairrequestServiceImpl implements DevicerepairrequestServic
@Override
public Map<String, Object> query2(Map whereJson, Pageable page) {
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
String device_code = MapUtil.getStr(whereJson, "device_code");
String request_code = MapUtil.getStr(whereJson, "request_code");
@@ -107,14 +109,14 @@ public class DevicerepairrequestServiceImpl implements DevicerepairrequestServic
// 归属部门
String dept_id = MapUtil.getStr(whereJson, "dept_id");
if (!StrUtil.isEmpty(dept_id)) {
// String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
// map.put("deptIds", deptIds);
String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
map.put("deptIds", deptIds);
}
// 归属部门
String use_groupid = MapUtil.getStr(whereJson, "use_groupid");
if (!StrUtil.isEmpty(use_groupid)) {
// String use_groupidIds = deptService.getChildIdStr(Long.parseLong(use_groupid));
// map.put("use_groupid", use_groupidIds);
String use_groupidIds = deptService.getChildIdStr(Long.parseLong(use_groupid));
map.put("use_groupid", use_groupidIds);
}
JSONObject json = WQL.getWO("EM_BI_DEVICEREPAIRREQUEST_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "mst.create_time DESC");
return json;
@@ -151,8 +153,6 @@ public class DevicerepairrequestServiceImpl implements DevicerepairrequestServic
@Override
@Transactional(rollbackFor = Exception.class)
public void create(DevicerepairrequestDto dto) {
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
WQLObject fileTab = WQLObject.getWQLObject("EM_BI_EquipmentFile");
WQLObject userTab = WQLObject.getWQLObject("sys_user");

View File

@@ -20,6 +20,8 @@ import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.device_manage.upkeep.service.DevicemaintenancemstService;
import org.nl.wms.device_manage.upkeep.service.dto.DevicemaintenancemstDto;
import org.nl.wms.masterdata_manage.备份master.service.ClassstandardService;
import org.nl.wms.system_manage.service.dept.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,6 +42,9 @@ import java.util.Map;
public class DevicemaintenancemstServiceImpl implements DevicemaintenancemstService {
private final ClassstandardService classstandardService;
@Autowired
private ISysDeptService deptService;
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
@@ -552,7 +557,6 @@ public class DevicemaintenancemstServiceImpl implements DevicemaintenancemstServ
@Override
public Map<String, Object> query4(Map whereJson, Pageable page) {
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
String class_idStr = MapUtil.getStr(whereJson, "class_idStr");
String device_code = MapUtil.getStr(whereJson, "device_code");
@@ -582,8 +586,8 @@ public class DevicemaintenancemstServiceImpl implements DevicemaintenancemstServ
// 归属部门
String dept_id = MapUtil.getStr(whereJson, "dept_id");
if (!StrUtil.isEmpty(dept_id)) {
// String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
// map.put("deptIds", deptIds);
String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
map.put("deptIds", deptIds);
}
JSONObject json = WQL.getWO("EM_BIDEVICEMAINTENANCE_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "mst.input_time DESC");
return json;
@@ -591,7 +595,6 @@ public class DevicemaintenancemstServiceImpl implements DevicemaintenancemstServ
@Override
public Map<String, Object> query5(Map whereJson, Pageable page) {
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
String class_idStr = MapUtil.getStr(whereJson, "class_idStr");
String device_code = MapUtil.getStr(whereJson, "device_code");
@@ -623,8 +626,8 @@ public class DevicemaintenancemstServiceImpl implements DevicemaintenancemstServ
// 归属部门
String dept_id = MapUtil.getStr(whereJson, "dept_id");
if (!StrUtil.isEmpty(dept_id)) {
// String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
// map.put("deptIds", deptIds);
String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
map.put("deptIds", deptIds);
}
JSONObject json = WQL.getWO("EM_BIDEVICEMAINTENANCE_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "input_time DESC");
return json;

View File

@@ -20,6 +20,8 @@ import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.device_manage.upkeep.service.DevicemaintenanceplanmstService;
import org.nl.wms.device_manage.upkeep.service.dto.DevicemaintenanceplanmstDto;
import org.nl.wms.masterdata_manage.备份master.service.ClassstandardService;
import org.nl.wms.system_manage.service.dept.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -39,7 +41,9 @@ import java.util.Map;
@Slf4j
public class DevicemaintenanceplanmstServiceImpl implements DevicemaintenanceplanmstService {
private final ClassstandardService classstandardService;
// private final DeptService deptService;
@Autowired
private ISysDeptService deptService;
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
@@ -247,7 +251,6 @@ public class DevicemaintenanceplanmstServiceImpl implements Devicemaintenancepla
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> queryDevice(Map whereJson, Pageable page) {
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
String device_code = MapUtil.getStr(whereJson, "device_code");
// 查询设备档案
HashMap<String, String> map = new HashMap<>();
@@ -256,14 +259,14 @@ public class DevicemaintenanceplanmstServiceImpl implements Devicemaintenancepla
String dept_id = MapUtil.getStr(whereJson, "dept_id");
if (!StrUtil.isEmpty(dept_id)) {
// String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
// map.put("deptIds", deptIds);
String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
map.put("deptIds", deptIds);
}
String use_id = MapUtil.getStr(whereJson, "use_id");
if (!StrUtil.isEmpty(use_id)) {
// String useIds = deptService.getChildIdStr(Long.parseLong(use_id));
// map.put("useIds", useIds);
String useIds = deptService.getChildIdStr(Long.parseLong(use_id));
map.put("useIds", useIds);
}
JSONObject json = WQL.getWO("EM_BIDEVICEMAINTENANCEPLAN_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "file.update_time DESC");
@@ -272,7 +275,6 @@ public class DevicemaintenanceplanmstServiceImpl implements Devicemaintenancepla
@Override
public Map<String, Object> queryDevice2(Map whereJson, Pageable page) {
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
String device_code = MapUtil.getStr(whereJson, "device_code");
// 查询设备档案
HashMap<String, String> map = new HashMap<>();
@@ -281,14 +283,14 @@ public class DevicemaintenanceplanmstServiceImpl implements Devicemaintenancepla
String dept_id = MapUtil.getStr(whereJson, "dept_id");
if (!StrUtil.isEmpty(dept_id)) {
// String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
// map.put("deptIds", deptIds);
String deptIds = deptService.getChildIdStr(Long.parseLong(dept_id));
map.put("deptIds", deptIds);
}
String use_id = MapUtil.getStr(whereJson, "use_id");
if (!StrUtil.isEmpty(use_id)) {
// String useIds = deptService.getChildIdStr(Long.parseLong(use_id));
// map.put("useIds", useIds);
String useIds = deptService.getChildIdStr(Long.parseLong(use_id));
map.put("useIds", useIds);
}
// 如果班组为空 则默认当前用户部门

View File

@@ -15,10 +15,11 @@ import org.nl.modules.common.utils.FileUtil;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.masterdata_manage.em.service.EquipmentfileService;
import org.nl.wms.masterdata_manage.备份master.service.ClassstandardService;
import org.nl.wms.system_manage.service.dept.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -31,12 +32,15 @@ import java.util.*;
@RequiredArgsConstructor
@Slf4j
public class EquipmentfileServiceImpl implements EquipmentfileService {
private final ClassstandardService classstandardService;
@Autowired
private ISysDeptService deptService;
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
HashMap<String, String> map = new HashMap<>(whereJson);
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
map.put("flag", "1");
String device_code = map.get("device_code");
if (StrUtil.isNotEmpty(device_code)) {
@@ -53,8 +57,8 @@ public class EquipmentfileServiceImpl implements EquipmentfileService {
}
String use_deptid = map.get("use_deptid");
if (!StrUtil.isEmpty(use_deptid)) {
// String deptIds = deptService.getChildIdStr(Long.parseLong(use_deptid));
// map.put("deptIds", deptIds);
String deptIds = deptService.getChildIdStr(Long.parseLong(use_deptid));
map.put("deptIds", deptIds);
}
String begin_time = map.get("begin_time");
if (StrUtil.isNotEmpty(begin_time)) {
@@ -71,7 +75,6 @@ public class EquipmentfileServiceImpl implements EquipmentfileService {
@Override
public JSONArray query(Map whereJson) {
HashMap<String, String> map = new HashMap<>(whereJson);
// DeptService deptService = SpringContextHolder.getBean(DeptService.class);
map.put("flag", "11");
String device_code = map.get("device_code");
if (StrUtil.isNotEmpty(device_code)) {
@@ -88,8 +91,8 @@ public class EquipmentfileServiceImpl implements EquipmentfileService {
}
String use_deptid = map.get("use_deptid");
if (!StrUtil.isEmpty(use_deptid)) {
// String deptIds = deptService.getChildIdStr(Long.parseLong(use_deptid));
// map.put("deptIds", deptIds);
String deptIds = deptService.getChildIdStr(Long.parseLong(use_deptid));
map.put("deptIds", deptIds);
}
String begin_time = map.get("begin_time");
if (StrUtil.isNotEmpty(begin_time)) {
@@ -108,8 +111,6 @@ public class EquipmentfileServiceImpl implements EquipmentfileService {
Long currentUserId = Long.parseLong(SecurityUtils.getCurrentUserId());
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
// JwtUserDto currentUser = (JwtUserDto) SecurityUtils.getCurrentUser();
// Long deptId = currentUser.getDeptId();
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 工艺路线主表
WQLObject EM_BI_DeviceLifeCycle = WQLObject.getWQLObject("EM_BI_DeviceLifeCycle"); // 工艺路线主表
@@ -149,8 +150,6 @@ public class EquipmentfileServiceImpl implements EquipmentfileService {
Long currentUserId = Long.parseLong(SecurityUtils.getCurrentUserId());
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
// JwtUserDto currentUser = (JwtUserDto) SecurityUtils.getCurrentUser();
// Long deptId = currentUser.getDeptId();
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 工艺路线主表
String device_code = whereJson.getString("device_code");
String devicerecord_id = whereJson.getString("devicerecord_id");

View File

@@ -67,4 +67,20 @@ public interface ISysDeptService extends IService<SysDept> {
void createDept(SysDept dept);
/**
* 获取当前节点的所有子类节点集合数据
*
* @param dept_id
* @return
*/
Set<Long> getChildIdSet(Long dept_id);
/**
* 获取当前节点的所有子类节点集合串,用于拼接SQLin
*
* @param dept_id
* @return
*/
String getChildIdStr(Long dept_id);
}

View File

@@ -1,6 +1,9 @@
package org.nl.wms.system_manage.service.dept.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -10,6 +13,7 @@ import org.nl.common.utils.CopyUtil;
import org.nl.common.utils.IdUtil;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.system_manage.service.dept.ISysDeptService;
import org.nl.wms.system_manage.service.dept.dao.SysDept;
import org.nl.wms.system_manage.service.dept.dao.mapper.SysDeptMapper;
@@ -22,6 +26,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.Collectors;
@@ -183,4 +189,44 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
sysDeptMapper.updateSubCount(dept.getPid());
}
}
@Override
public Set<Long> getChildIdSet(Long pid) {
String sql = "select dept_id from (\n" +
" select t1.dept_id,\n" +
" if(find_in_set(pid, @pids) > 0, @pids := concat(@pids, ',', dept_id), 0) as ischild\n" +
" from (\n" +
" select dept_id,pid from sys_dept t where t.is_used = 1\n" +
" ) t1,\n" +
" (select @pids :=" + pid + ") t2\n" +
" ) t3 where ischild != 0";
Set<Long> set = new HashSet<>();
//添加本级
set.add(pid);
//添加子节点
try {
List<Entity> list = Db.use((DataSource) SpringContextHolder.getBean("dataSource")).query(sql);
list.forEach(item -> {
set.add(item.getLong("dept_id"));
});
} catch (SQLException e) {
e.printStackTrace();
}
return set;
}
@Override
public String getChildIdStr(Long dept_id) {
Set<Long> set = this.getChildIdSet(dept_id);
StringBuilder sb = new StringBuilder();
set.forEach(item -> {
sb.append(",'" + item + "'");
});
String str = sb.toString();
if (StrUtil.isNotEmpty(str)) {
str = "(" + str.substring(1) + ")";
}
return str;
}
}