施工管控
This commit is contained in:
parent
c3f2b8464e
commit
7e4d462382
|
|
@ -0,0 +1,40 @@
|
|||
package com.bonus.common.entity.bracelet;
|
||||
|
||||
import com.bonus.common.entity.bracelet.vo.BallTreeVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @className:BuildTreeUtil
|
||||
* @author:cwchen
|
||||
* @date:2024-08-08-16:15
|
||||
* @version:1.0
|
||||
* @description:构建树
|
||||
*/
|
||||
public class BuildTreeUtil {
|
||||
|
||||
public static List<BallTreeVo> ballListToChildren(List<BallTreeVo> list) {
|
||||
Map<String, BallTreeVo> map = new HashMap<>();
|
||||
List<BallTreeVo> result = new ArrayList<>();
|
||||
// 第一次遍历,将所有节点存储到map中
|
||||
for (BallTreeVo node : list) {
|
||||
map.put(node.getId() + "", node);
|
||||
}
|
||||
// 第二次遍历,构建Children关系
|
||||
for (BallTreeVo node : list) {
|
||||
BallTreeVo parent = map.get(node.getParentId());
|
||||
if (parent != null) {
|
||||
if (parent.getChildren() == null) {
|
||||
parent.setChildren(new ArrayList<>());
|
||||
}
|
||||
parent.getChildren().add(node);
|
||||
} else {
|
||||
result.add(node);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.common.entity.bracelet.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -14,11 +15,16 @@ import java.util.List;
|
|||
@Data
|
||||
public class BallTreeVo {
|
||||
|
||||
/**id*/
|
||||
private Long id;
|
||||
|
||||
/**名称*/
|
||||
private String label;
|
||||
/**设备编码*/
|
||||
private String devCode;
|
||||
/**设备下标*/
|
||||
private String devIndex;
|
||||
|
||||
private String puid;
|
||||
private Long parentId;
|
||||
|
||||
private List<BallTreeVo> children;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,10 @@ public class AppEquipmentReqServiceImpl implements IAppEquipmentReqService {
|
|||
if(Objects.equals(equipment.getDevType(), BusinessConstants.SHX)){
|
||||
// 绑定手环箱
|
||||
mapper.updateDeviceData(vo,equipment,1);
|
||||
}else if(!Objects.equals(equipment.getDevType(), BusinessConstants.SHX) && !Objects.equals(equipment.getDevType(), BusinessConstants.AQM)){
|
||||
}else if(Objects.equals(equipment.getDevType(), BusinessConstants.AQM)){
|
||||
// 绑定安全帽
|
||||
mapper.updateDeviceData(vo,equipment,3);
|
||||
}else{
|
||||
// 绑定除安全帽和手环箱以外的设备(绑定人为班组长)
|
||||
mapper.updateDeviceData(vo,equipment,2);
|
||||
}
|
||||
|
|
@ -125,12 +128,13 @@ public class AppEquipmentReqServiceImpl implements IAppEquipmentReqService {
|
|||
mapper.updateReturnDeviceData(dto,1);
|
||||
}else if(Objects.equals(dto.getDevType(), BusinessConstants.AQM)){
|
||||
// 设备类型为安全帽时,判断是否全部归还
|
||||
int result = mapper.isAllDeviceReturn(dto,2);
|
||||
int result = mapper.isAllDeviceReturn(dto,1);
|
||||
if(result > 0){
|
||||
return AjaxResult.error("班组人员未归还安全帽设备");
|
||||
}
|
||||
mapper.updateReturnDeviceData(dto,2);
|
||||
}else{
|
||||
// 解绑除手环箱、安全帽以外的设备
|
||||
// 解绑除手环箱以外的设备
|
||||
mapper.updateReturnDeviceData(dto,2);
|
||||
}
|
||||
mapper.returnDevice(dto);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="type == 2">
|
||||
UPDATE tb_dev_ly SET pro_id = #{vo.proId},team_id = #{vo.teamId},ly_user = #{vo.teamLeaderId},ly_status = 0,ly_time = #{vo.lyTime},user_type = #{vo.userType},gt_id = #{vo.powerId} WHERE dev_id = #{equipment.devId}
|
||||
</if>
|
||||
<if test="type == 3">
|
||||
UPDATE tb_dev_ly SET pro_id = #{vo.proId},team_id = #{vo.teamId},gt_id = #{vo.powerId} WHERE dev_id = #{equipment.devId}
|
||||
</if>
|
||||
</update>
|
||||
<!--更新1.手环箱/2.其他设备状态-->
|
||||
<update id="updateReturnDeviceData">
|
||||
|
|
@ -152,7 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND a.departId = #{departId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.ghTime ASC,a.lyTime DESC
|
||||
ORDER BY IFNULL(a.ghTime,now()) DESC,a.lyTime DESC
|
||||
</select>
|
||||
|
||||
<!--判断设备是否已经归还-->
|
||||
|
|
@ -164,8 +167,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="devType!='' and devType!=null and devType!='shx'">
|
||||
SELECT td.id AS devId,td.dev_code AS devCode,td.dev_name AS devName,td.dev_type AS devType
|
||||
FROM tb_device td
|
||||
LEFT JOIN tb_dev_use_bid tdub ON td.id = tdub.dev_id AND td.dev_type = tdub.dev_type
|
||||
WHERE (tdub.id IS NULL OR tdub.gh_time IS NOT NULL) AND td.dev_type = #{devType} AND td.del_flag = 0
|
||||
LEFT JOIN tb_dev_ly tdl ON td.id = tdl.dev_id
|
||||
WHERE tdl.team_id IS NULL AND tdl.ly_user IS NULL AND td.dev_type = #{devType} AND td.del_flag = 0
|
||||
</if>
|
||||
<if test="devType!='' and devType!=null and devType=='shx'">
|
||||
SELECT tsb.id AS devId,tsb.box_code AS devCode,tsb.box_name AS devName,'shx' AS devType
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</insert>
|
||||
<!--更新设备表领用状态-->
|
||||
<update id="updateDevLyStatus">
|
||||
UPDATE tb_dev_ly SET pro_id = #{proId},team_id = #{teamId},ly_user = #{bidId},ly_status = 0,ly_time = #{bidTime},user_type = 0,gt_id = #{gtId} WHERE dev_id = #{devId}
|
||||
UPDATE tb_dev_ly SET ly_user = #{bidId},ly_status = 0,ly_time = #{bidTime},user_type = 0 WHERE dev_id = #{devId}
|
||||
</update>
|
||||
<!--更新人员领用的归还状态-->
|
||||
<update id="returnHelmet">
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package com.bonus.bracelet.mapper;
|
||||
|
||||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import com.bonus.common.entity.bracelet.vo.BallTreeVo;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className:ConsControlMapper
|
||||
* @author:cwchen
|
||||
|
|
@ -11,4 +15,12 @@ import org.springframework.stereotype.Repository;
|
|||
*/
|
||||
@Repository(value = "ConsControlMapper")
|
||||
public interface ConsControlMapper {
|
||||
/**
|
||||
* 获取球机设备列表
|
||||
* @param dto
|
||||
* @return List<BallTreeVo>
|
||||
* @author cwchen
|
||||
* @date 2024/8/8 11:24
|
||||
*/
|
||||
List<BallTreeVo> getBallDeviceLists(BraceletParamsDto dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,18 @@ package com.bonus.bracelet.service.impl;
|
|||
|
||||
import com.bonus.bracelet.mapper.ConsControlMapper;
|
||||
import com.bonus.bracelet.service.IConsControlService;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import com.bonus.common.entity.bracelet.BuildTreeUtil;
|
||||
import com.bonus.common.entity.bracelet.vo.BallTreeVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className:ConsControlServiceImpl
|
||||
|
|
@ -26,9 +32,18 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
@Override
|
||||
public AjaxResult getBallDeviceLists(BraceletParamsDto dto) {
|
||||
try {
|
||||
return null;
|
||||
List<BallTreeVo> list = new ArrayList<>();
|
||||
list = mapper.getBallDeviceLists(dto);
|
||||
for (BallTreeVo vo : list) {
|
||||
String[] valArr = vo.getLabel().split("-");
|
||||
if (StringUtils.isNotEmpty(valArr[1])) {
|
||||
vo.setLabel(valArr[0] + "-" + Sm4Utils.decode(valArr[1]));
|
||||
}
|
||||
}
|
||||
List<BallTreeVo> handleList = BuildTreeUtil.ballListToChildren(list);
|
||||
return AjaxResult.success(handleList);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(),e);
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
|
|||
return AjaxResult.error("领用设备中有重复设备,请仔细检查");
|
||||
}
|
||||
for (EquipmentReqDataVo.Equipment equipment : vo.getList()) {
|
||||
// 判断设备是否已经归还
|
||||
// 判断领用设备是否已经归还
|
||||
Integer result = result = mapper.isHasUseDevice(equipment);
|
||||
if (result > 0) {
|
||||
return AjaxResult.error("领用设备中包含未归还设备,请先归还后,方可再次领用");
|
||||
|
|
@ -80,7 +80,10 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
|
|||
if(Objects.equals(equipment.getDevType(), BusinessConstants.SHX)){
|
||||
// 绑定手环箱
|
||||
mapper.updateDeviceData(vo,equipment,1);
|
||||
}else if(!Objects.equals(equipment.getDevType(), BusinessConstants.SHX) && !Objects.equals(equipment.getDevType(), BusinessConstants.AQM)){
|
||||
}else if(Objects.equals(equipment.getDevType(), BusinessConstants.AQM)){
|
||||
// 绑定安全帽
|
||||
mapper.updateDeviceData(vo,equipment,3);
|
||||
}else{
|
||||
// 绑定除安全帽和手环箱以外的设备(绑定人为班组长)
|
||||
mapper.updateDeviceData(vo,equipment,2);
|
||||
}
|
||||
|
|
@ -124,12 +127,13 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
|
|||
mapper.updateReturnDeviceData(dto,1);
|
||||
}else if(Objects.equals(dto.getDevType(), BusinessConstants.AQM)){
|
||||
// 设备类型为安全帽时,判断是否全部归还
|
||||
int result = mapper.isAllDeviceReturn(dto,2);
|
||||
int result = mapper.isAllDeviceReturn(dto,1);
|
||||
if(result > 0){
|
||||
return AjaxResult.error("班组人员未归还安全帽设备");
|
||||
}
|
||||
mapper.updateReturnDeviceData(dto,2);
|
||||
}else{
|
||||
// 解绑除手环箱、安全帽以外的设备
|
||||
// 解绑除手环箱以外的设备
|
||||
mapper.updateReturnDeviceData(dto,2);
|
||||
}
|
||||
mapper.returnDevice(dto);
|
||||
|
|
|
|||
|
|
@ -4,4 +4,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.bracelet.mapper.ConsControlMapper">
|
||||
|
||||
<!--获取球机设备列表-->
|
||||
<select id="getBallDeviceLists" resultType="com.bonus.common.entity.bracelet.vo.BallTreeVo">
|
||||
SELECT * FROM (
|
||||
SELECT tp.id,
|
||||
tp.pro_name AS label,
|
||||
'0' AS devCode,
|
||||
'0' AS devIndex,
|
||||
0 AS parentId,
|
||||
tp.depart_id AS departId
|
||||
FROM tb_project tp
|
||||
WHERE tp.del_flag = 0
|
||||
UNION ALL
|
||||
SELECT
|
||||
tdu.id,
|
||||
CONCAT(tpe.name,'-',tpe.phone) AS label,
|
||||
td.dev_code AS devCode,
|
||||
td.dev_index AS devIndex,
|
||||
tdu.pro_id AS parentId,
|
||||
tp.depart_id AS departId
|
||||
FROM tb_dev_use tdu
|
||||
LEFT JOIN tb_dev_use_bid tdub ON tdu.id = tdub.id
|
||||
LEFT JOIN tb_project tp ON tp.id = tdu.pro_id AND tp.del_flag = 0
|
||||
LEFT JOIN tb_device td ON tdub.dev_id = td.id AND td.del_flag = 0
|
||||
LEFT JOIN tb_dev_ly tdl ON tdub.dev_id = tdl.dev_id
|
||||
LEFT JOIN tb_people tpe ON tpe.id = tdl.ly_user AND tpe.del_flag = 0
|
||||
WHERE tdub.dev_type = 'ball' AND tdu.del_flag = 0 AND tdub.gh_time IS NULL
|
||||
) a
|
||||
<where>
|
||||
<if test="roleCode!='administrators' and roleCode!='depart'">
|
||||
a.id = -1
|
||||
</if>
|
||||
<if test="roleCode=='depart'">
|
||||
a.departId = #{departId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -48,6 +48,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="type == 2">
|
||||
UPDATE tb_dev_ly SET pro_id = #{vo.proId},team_id = #{vo.teamId},ly_user = #{vo.teamLeaderId},ly_status = 0,ly_time = #{vo.lyTime},user_type = #{vo.userType},gt_id = #{vo.powerId} WHERE dev_id = #{equipment.devId}
|
||||
</if>
|
||||
<if test="type == 3">
|
||||
UPDATE tb_dev_ly SET pro_id = #{vo.proId},team_id = #{vo.teamId},gt_id = #{vo.powerId} WHERE dev_id = #{equipment.devId}
|
||||
</if>
|
||||
</update>
|
||||
<!--更新1.手环箱/2.其他设备状态-->
|
||||
<update id="updateReturnDeviceData">
|
||||
|
|
@ -153,7 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND a.departId = #{departId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.ghTime ASC,a.lyTime DESC
|
||||
ORDER BY IFNULL(a.ghTime,now()) DESC,a.lyTime DESC
|
||||
</select>
|
||||
<!--判断设备是否已经归还-->
|
||||
<select id="isHasUseDevice" resultType="java.lang.Integer">
|
||||
|
|
@ -164,8 +167,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="devType!='' and devType!=null and devType!='shx'">
|
||||
SELECT td.id AS devId,td.dev_code AS devCode,td.dev_name AS devName,td.dev_type AS devType
|
||||
FROM tb_device td
|
||||
LEFT JOIN tb_dev_use_bid tdub ON td.id = tdub.dev_id AND td.dev_type = tdub.dev_type
|
||||
WHERE (tdub.id IS NULL OR tdub.gh_time IS NOT NULL) AND td.dev_type = #{devType} AND td.del_flag = 0
|
||||
LEFT JOIN tb_dev_ly tdl ON td.id = tdl.dev_id
|
||||
WHERE tdl.team_id IS NULL AND tdl.ly_user IS NULL AND td.dev_type = #{devType} AND td.del_flag = 0
|
||||
</if>
|
||||
<if test="devType!='' and devType!=null and devType=='shx'">
|
||||
SELECT tsb.id AS devId,tsb.box_code AS devCode,tsb.box_name AS devName,'shx' AS devType
|
||||
|
|
|
|||
Loading…
Reference in New Issue