装备配置管理
This commit is contained in:
parent
d8e36ba0bd
commit
b6e3fe369e
|
|
@ -13,16 +13,14 @@ import com.bonus.material.equipment.service.ISysDeptService;
|
||||||
import com.bonus.system.api.domain.SysDept;
|
import com.bonus.system.api.domain.SysDept;
|
||||||
import com.bonus.system.api.domain.SysUser;
|
import com.bonus.system.api.domain.SysUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dept")
|
@RequestMapping("/dept")
|
||||||
public class SysDeptController extends BaseController {
|
public class SysDeptController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDeptService service;
|
private ISysDeptService service;
|
||||||
|
|
@ -43,7 +41,7 @@ public class SysDeptController extends BaseController {
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@SysLog(title = "装备列表", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "查询装备列表")
|
@SysLog(title = "装备列表", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "查询装备列表")
|
||||||
public TableDataInfo list(DeptEquipmentConfig user) {
|
public TableDataInfo list(DeptEquipmentConfig user) {
|
||||||
try {
|
try {
|
||||||
startPage();
|
startPage();
|
||||||
List<SysUser> list = service.selectUserList(user);
|
List<SysUser> list = service.selectUserList(user);
|
||||||
|
|
@ -53,4 +51,9 @@ public class SysDeptController extends BaseController {
|
||||||
}
|
}
|
||||||
return getDataTableError(new ArrayList<>());
|
return getDataTableError(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/selectConfigList")
|
||||||
|
public AjaxResult selectConfigList(@RequestBody DeptEquipmentConfig user) {
|
||||||
|
return service.selectConfigList(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.bonus.material.equipment.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ConfigEntity {
|
||||||
|
|
||||||
|
private String basicConfig;
|
||||||
|
|
||||||
|
private String configurationType;
|
||||||
|
|
||||||
|
private String configurationRate;
|
||||||
|
|
||||||
|
private String configurationDescription;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -4,15 +4,19 @@ import com.bonus.common.core.annotation.Excel;
|
||||||
import com.bonus.common.core.web.domain.BaseEntity;
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class DeptEquipmentConfig extends BaseEntity {
|
public class DeptEquipmentConfig extends BaseEntity {
|
||||||
private Long id;
|
private Long id;
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
private String typeId;
|
private String typeId;
|
||||||
private String equipmentName;
|
private String equipmentName;
|
||||||
private String equipmenttype;
|
private String equipmenttype;
|
||||||
private String basicConfig; //基础配置信息
|
private String basicConfig; //基础配置信息
|
||||||
private String equipmentId;
|
private String equipmentId;
|
||||||
|
private List<ConfigEntity> configs;
|
||||||
|
private String configStatus;
|
||||||
|
|
||||||
@Excel(name = "配置值")
|
@Excel(name = "配置值")
|
||||||
private String configValue;
|
private String configValue;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.material.equipment.mapper;
|
package com.bonus.material.equipment.mapper;
|
||||||
|
|
||||||
|
import com.bonus.material.equipment.domain.ConfigEntity;
|
||||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||||
import com.bonus.material.equipment.domain.SysDept;
|
import com.bonus.material.equipment.domain.SysDept;
|
||||||
import com.bonus.system.api.domain.SysUser;
|
import com.bonus.system.api.domain.SysUser;
|
||||||
|
|
@ -12,4 +13,7 @@ public interface SysDeptMapper {
|
||||||
List<com.bonus.system.api.domain.SysDept> selectDeptList(com.bonus.system.api.domain.SysDept dept);
|
List<com.bonus.system.api.domain.SysDept> selectDeptList(com.bonus.system.api.domain.SysDept dept);
|
||||||
|
|
||||||
List<SysUser> selectUserList(DeptEquipmentConfig user);
|
List<SysUser> selectUserList(DeptEquipmentConfig user);
|
||||||
|
|
||||||
|
|
||||||
|
List<ConfigEntity> selectConfigList(DeptEquipmentConfig user);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.bonus.material.equipment.service;
|
package com.bonus.material.equipment.service;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.material.equipment.domain.ConfigEntity;
|
||||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||||
import com.bonus.material.equipment.domain.DeptTreeSelect;
|
import com.bonus.material.equipment.domain.DeptTreeSelect;
|
||||||
import com.bonus.system.api.domain.SysDept;
|
import com.bonus.system.api.domain.SysDept;
|
||||||
|
|
@ -12,4 +14,7 @@ public interface ISysDeptService {
|
||||||
public List<DeptTreeSelect> selectDeptTreeList(SysDept dept);
|
public List<DeptTreeSelect> selectDeptTreeList(SysDept dept);
|
||||||
|
|
||||||
List<SysUser> selectUserList(DeptEquipmentConfig user);
|
List<SysUser> selectUserList(DeptEquipmentConfig user);
|
||||||
|
|
||||||
|
|
||||||
|
AjaxResult selectConfigList(DeptEquipmentConfig user);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,21 @@ package com.bonus.material.equipment.service.impl;
|
||||||
|
|
||||||
import com.bonus.common.core.utils.SpringUtils;
|
import com.bonus.common.core.utils.SpringUtils;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.core.web.domain.BaseEntity;
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
import com.bonus.common.datascope.annotation.DataScope;
|
import com.bonus.common.datascope.annotation.DataScope;
|
||||||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
|
import com.bonus.material.equipment.domain.ConfigEntity;
|
||||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||||
import com.bonus.material.equipment.domain.DeptTreeSelect;
|
import com.bonus.material.equipment.domain.DeptTreeSelect;
|
||||||
import com.bonus.material.equipment.mapper.SysDeptMapper;
|
import com.bonus.material.equipment.mapper.SysDeptMapper;
|
||||||
import com.bonus.material.equipment.service.ISysDeptService;
|
import com.bonus.material.equipment.service.ISysDeptService;
|
||||||
import com.bonus.system.api.domain.SysDept;
|
import com.bonus.system.api.domain.SysDept;
|
||||||
import com.bonus.system.api.domain.SysUser;
|
import com.bonus.system.api.domain.SysUser;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -25,22 +30,33 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
public class SysDeptServiceImpl implements ISysDeptService {
|
public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(SysDeptServiceImpl.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysDeptMapper mapper;
|
private SysDeptMapper mapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeptTreeSelect> selectDeptTreeList(SysDept dept)
|
public List<DeptTreeSelect> selectDeptTreeList(SysDept dept) {
|
||||||
{
|
|
||||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||||
return buildDeptTreeSelect(depts);
|
return buildDeptTreeSelect(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysUser> selectUserList(DeptEquipmentConfig user) {
|
public List<SysUser> selectUserList(DeptEquipmentConfig user) {
|
||||||
List<SysUser> sysUsers = mapper.selectUserList(user);
|
List<SysUser> sysUsers = mapper.selectUserList(user);
|
||||||
return sysUsers;
|
return sysUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult selectConfigList(DeptEquipmentConfig user) {
|
||||||
|
try {
|
||||||
|
List<ConfigEntity> configEntities = mapper.selectConfigList(user);
|
||||||
|
return ObjectUtils.isNotEmpty(configEntities) ? AjaxResult.success(configEntities) : AjaxResult.success();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
*
|
*
|
||||||
|
|
@ -48,8 +64,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
* @return 部门信息集合
|
* @return 部门信息集合
|
||||||
*/
|
*/
|
||||||
@DataScope(deptAlias = "d")
|
@DataScope(deptAlias = "d")
|
||||||
public List<SysDept> selectDeptList(SysDept dept)
|
public List<SysDept> selectDeptList(SysDept dept) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
BaseEntity entity = CommonDataPermissionInfo.backMissionInfo(dept.getParams().get("dataScope").toString());
|
BaseEntity entity = CommonDataPermissionInfo.backMissionInfo(dept.getParams().get("dataScope").toString());
|
||||||
BeanUtils.copyProperties(entity, dept);
|
BeanUtils.copyProperties(entity, dept);
|
||||||
|
|
@ -64,63 +79,51 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
return mapper.selectDeptList(dept);
|
return mapper.selectDeptList(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DeptTreeSelect> buildDeptTreeSelect(List<SysDept> depts)
|
public List<DeptTreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
|
||||||
{
|
|
||||||
List<SysDept> deptTrees = buildDeptTree(depts);
|
List<SysDept> deptTrees = buildDeptTree(depts);
|
||||||
return deptTrees.stream().map(DeptTreeSelect::new).collect(Collectors.toList());
|
return deptTrees.stream().map(DeptTreeSelect::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SysDept> buildDeptTree(List<SysDept> depts)
|
public List<SysDept> buildDeptTree(List<SysDept> depts) {
|
||||||
{
|
|
||||||
List<SysDept> returnList = new ArrayList<SysDept>();
|
List<SysDept> returnList = new ArrayList<SysDept>();
|
||||||
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
||||||
for (SysDept dept : depts)
|
for (SysDept dept : depts) {
|
||||||
{
|
|
||||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||||
if (!tempList.contains(dept.getParentId()))
|
if (!tempList.contains(dept.getParentId())) {
|
||||||
{
|
|
||||||
recursionFn(depts, dept);
|
recursionFn(depts, dept);
|
||||||
returnList.add(dept);
|
returnList.add(dept);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (returnList.isEmpty())
|
if (returnList.isEmpty()) {
|
||||||
{
|
|
||||||
returnList = depts;
|
returnList = depts;
|
||||||
}
|
}
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recursionFn(List<SysDept> list, SysDept t)
|
private void recursionFn(List<SysDept> list, SysDept t) {
|
||||||
{
|
|
||||||
// 得到子节点列表
|
// 得到子节点列表
|
||||||
List<SysDept> childList = getChildList(list, t);
|
List<SysDept> childList = getChildList(list, t);
|
||||||
t.setChildren(childList);
|
t.setChildren(childList);
|
||||||
for (SysDept tChild : childList)
|
for (SysDept tChild : childList) {
|
||||||
{
|
if (hasChild(list, tChild)) {
|
||||||
if (hasChild(list, tChild))
|
|
||||||
{
|
|
||||||
recursionFn(list, tChild);
|
recursionFn(list, tChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SysDept> getChildList(List<SysDept> list, SysDept t)
|
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
|
||||||
{
|
|
||||||
List<SysDept> tlist = new ArrayList<SysDept>();
|
List<SysDept> tlist = new ArrayList<SysDept>();
|
||||||
Iterator<SysDept> it = list.iterator();
|
Iterator<SysDept> it = list.iterator();
|
||||||
while (it.hasNext())
|
while (it.hasNext()) {
|
||||||
{
|
|
||||||
SysDept n = (SysDept) it.next();
|
SysDept n = (SysDept) it.next();
|
||||||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
|
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
|
||||||
{
|
|
||||||
tlist.add(n);
|
tlist.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tlist;
|
return tlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasChild(List<SysDept> list, SysDept t)
|
private boolean hasChild(List<SysDept> list, SysDept t) {
|
||||||
{
|
|
||||||
return getChildList(list, t).size() > 0 ? true : false;
|
return getChildList(list, t).size() > 0 ? true : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,33 @@
|
||||||
<select id="selectConfig" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig"></select>
|
<select id="selectConfig" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig"></select>
|
||||||
|
|
||||||
<insert id="insertOrUpdateBatch" parameterType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
<insert id="insertOrUpdateBatch" parameterType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||||
INSERT INTO ma_dept_config (dept_id, type_id, config_value, remark)
|
INSERT INTO ma_dept_config (
|
||||||
VALUES (#{deptId}, #{typeId}, #{configValue}, #{remark})
|
dept_id,
|
||||||
ON DUPLICATE KEY UPDATE
|
type_id,
|
||||||
config_value = VALUES(config_value),
|
config_type,
|
||||||
remark = VALUES(remark)
|
config_value,
|
||||||
|
config_rate,
|
||||||
|
config_description,
|
||||||
|
remark
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="configs" item="item" separator=",">
|
||||||
|
(
|
||||||
|
#{deptId},
|
||||||
|
#{equipmentId},
|
||||||
|
#{item.configurationType},
|
||||||
|
#{item.basicConfig},
|
||||||
|
#{item.configurationRate},
|
||||||
|
#{item.configurationDescription},
|
||||||
|
#{remark}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
config_value = VALUES(config_value),
|
||||||
|
config_rate = VALUES(config_rate),
|
||||||
|
config_description = VALUES(config_description),
|
||||||
|
remark = VALUES(remark),
|
||||||
|
update_time = CURRENT_TIMESTAMP
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -60,27 +60,33 @@
|
||||||
mt.type_id AS equipmentId,
|
mt.type_id AS equipmentId,
|
||||||
mt2.type_name AS equipmentName,
|
mt2.type_name AS equipmentName,
|
||||||
mt.type_name AS equipmenttype,
|
mt.type_name AS equipmenttype,
|
||||||
mt.type_id,
|
CASE
|
||||||
mdc.config_value AS basicConfig
|
WHEN MAX(mdc.config_value) IS NOT NULL AND MAX(mdc.config_value) != '' THEN '已配置'
|
||||||
FROM
|
ELSE '未配置'
|
||||||
ma_type mt
|
END AS configStatus
|
||||||
|
FROM ma_type mt
|
||||||
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||||
LEFT JOIN ma_dept_config mdc
|
LEFT JOIN ma_dept_config mdc
|
||||||
ON mdc.type_id = mt.type_id
|
ON mdc.type_id = mt.type_id
|
||||||
<if test="deptId != null">
|
AND mdc.dept_id = #{deptId}
|
||||||
AND mdc.dept_id = #{deptId}
|
WHERE mt.level = 3
|
||||||
</if>
|
|
||||||
<if test="deptId == null">
|
|
||||||
AND 1=0
|
|
||||||
</if>
|
|
||||||
WHERE
|
|
||||||
mt.LEVEL = 3
|
|
||||||
<if test="equipmentName != null and equipmentName != ''">
|
<if test="equipmentName != null and equipmentName != ''">
|
||||||
AND mt.type_name LIKE CONCAT('%', #{equipmentName}, '%')
|
AND mt.type_name LIKE CONCAT('%', #{equipmentName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="equipmenttype != null and equipmenttype != ''">
|
<if test="equipmenttype != null and equipmenttype != ''">
|
||||||
AND mt2.type_name LIKE CONCAT('%', #{equipmenttype}, '%')
|
AND mt2.type_name LIKE CONCAT('%', #{equipmenttype}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
GROUP BY mt.type_id, mt2.type_name, mt.type_name
|
||||||
|
</select>
|
||||||
|
<select id="selectConfigList" resultType="com.bonus.material.equipment.domain.ConfigEntity">
|
||||||
|
SELECT
|
||||||
|
config_value AS basicConfig,
|
||||||
|
config_type AS configurationType,
|
||||||
|
config_rate AS configurationRate,
|
||||||
|
config_description AS configurationDescription
|
||||||
|
FROM ma_dept_config
|
||||||
|
WHERE dept_id = #{deptId}
|
||||||
|
AND type_id = #{typeId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue