领用管理

This commit is contained in:
cwchen 2024-08-06 09:28:12 +08:00
parent df70c43f19
commit bc4cc7d8ff
7 changed files with 86 additions and 18 deletions

View File

@ -87,6 +87,8 @@ public class BraceletParamsDto {
private Long updateUser = SecurityUtils.getUserId(); private Long updateUser = SecurityUtils.getUserId();
/**设备ID*/
private Long devId;
/**工程名称*/ /**工程名称*/
private String proName; private String proName;
/**杆塔编号*/ /**杆塔编号*/
@ -101,4 +103,7 @@ public class BraceletParamsDto {
private String lyTime; private String lyTime;
/**归还时间*/ /**归还时间*/
private String ghTime; private String ghTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date backTime = new Date();
} }

View File

@ -49,10 +49,6 @@ public class EquipmentReqDataVo {
*/ */
private String devType; private String devType;
/**
* 领用时间
*/
private Date lyTime = new Date();
} }
@Length(max = 255, message = "备注字符长度不能超过255") @Length(max = 255, message = "备注字符长度不能超过255")
@ -76,4 +72,9 @@ public class EquipmentReqDataVo {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Date updateTime = new Date(); private Date updateTime = new Date();
/**
* 领用时间
*/
private Date lyTime = new Date();
} }

View File

@ -60,4 +60,11 @@ public class EquipmentReqController extends BaseController {
public AjaxResult getUseDevices(BraceletParamsDto dto) { public AjaxResult getUseDevices(BraceletParamsDto dto) {
return service.getUseDevices(dto); return service.getUseDevices(dto);
} }
// @RequiresPermissions("basic:equipmentReq:returnDevice")
@PostMapping("returnDevice")
@SysLog(title = "施工管控", businessType = OperaType.INSERT,logType = 0,module = "施工管控->设备领用",details ="归还设备")
public AjaxResult returnDevice(@RequestBody BraceletParamsDto dto) {
return service.returnDevice(dto);
}
} }

View File

@ -79,4 +79,22 @@ public interface EquipmentReqMapper {
*/ */
@MapKey("devId") @MapKey("devId")
List<Map<String, Object>> getUseDevices(BraceletParamsDto dto); List<Map<String, Object>> getUseDevices(BraceletParamsDto dto);
/**
* 更新手环箱状态
* @param dto
* @return void
* @author cwchen
* @date 2024/8/6 9:16
*/
void updateshBoxData(BraceletParamsDto dto);
/**
* 更新设备归还状态
* @param dto
* @return void
* @author cwchen
* @date 2024/8/6 9:19
*/
void returnDevice(BraceletParamsDto dto);
} }

View File

@ -42,4 +42,13 @@ public interface IEquipmentReqService {
* @date 2024/8/5 18:06 * @date 2024/8/5 18:06
*/ */
AjaxResult getUseDevices(BraceletParamsDto dto); AjaxResult getUseDevices(BraceletParamsDto dto);
/**
* 归还设备
* @param dto
* @return AjaxResult
* @author cwchen
* @date 2024/8/6 9:14
*/
AjaxResult returnDevice(BraceletParamsDto dto);
} }

View File

@ -16,10 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** /**
* @className:EquipmentReqServiceImpl * @className:EquipmentReqServiceImpl
@ -56,6 +53,11 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
if (CollectionUtils.isEmpty(vo.getList())) { if (CollectionUtils.isEmpty(vo.getList())) {
return AjaxResult.error("领用设备不能为空"); return AjaxResult.error("领用设备不能为空");
} }
// 判断是否添加重复设备
Set<EquipmentReqDataVo.Equipment> setList = new HashSet<>(vo.getList());
if (setList.size() != vo.getList().size()) {
return AjaxResult.error("领用设备中有重复设备,请仔细检查");
}
for (EquipmentReqDataVo.Equipment equipment : vo.getList()) { for (EquipmentReqDataVo.Equipment equipment : vo.getList()) {
// 判断设备是否已经归还 // 判断设备是否已经归还
Integer result = result = mapper.isHasUseDevice(equipment); Integer result = result = mapper.isHasUseDevice(equipment);
@ -63,6 +65,7 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
return AjaxResult.error("领用设备中包含未归还设备,请先归还后,方可再次领用"); return AjaxResult.error("领用设备中包含未归还设备,请先归还后,方可再次领用");
} }
} }
// 添加设备领用数据设备领用详情数据 // 添加设备领用数据设备领用详情数据
mapper.addDevUseData(vo); mapper.addDevUseData(vo);
mapper.addDevUseDetailData(vo); mapper.addDevUseDetailData(vo);
@ -90,4 +93,21 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
} }
return AjaxResult.success(list); return AjaxResult.success(list);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult returnDevice(BraceletParamsDto dto) {
try {
if(Objects.equals(dto.getDevType(), BusinessConstants.SHX)){
// 设备类型为手环箱更新手环箱状态
mapper.updateshBoxData(dto);
}
mapper.returnDevice(dto);
return AjaxResult.success();
} catch (Exception e) {
log.error(e.toString(),e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error();
}
}
} }

View File

@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
INSERT INTO tb_dev_use_bid(id,dev_id,dev_name,dev_code,dev_type,ly_time) VALUES INSERT INTO tb_dev_use_bid(id,dev_id,dev_name,dev_code,dev_type,ly_time) VALUES
<foreach collection="list" separator="," item="item"> <foreach collection="list" separator="," item="item">
( (
#{id},#{item.devId},#{item.devName},#{item.devCode},#{item.devType},#{item.lyTime} #{id},#{item.devId},#{item.devName},#{item.devCode},#{item.devType},#{lyTime}
) )
</foreach> </foreach>
</insert> </insert>
@ -44,6 +44,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateShBoxData"> <update id="updateShBoxData">
UPDATE tb_sh_box SET team_id = #{vo.teamId},pro_id = #{vo.proId},gt_id = #{vo.powerId} WHERE id = #{equipment.devId} UPDATE tb_sh_box SET team_id = #{vo.teamId},pro_id = #{vo.proId},gt_id = #{vo.powerId} WHERE id = #{equipment.devId}
</update> </update>
<!--更新手环箱状态-->
<update id="updateshBoxData">
UPDATE tb_sh_box SET team_id = null,pro_id = null,gt_id = null WHERE id = #{devId}
</update>
<!--更新设备归还状态-->
<update id="returnDevice">
UPDATE tb_dev_use_bid SET gh_time = #{backTime} WHERE id = #{id} AND dev_id = #{devId} AND dev_type = #{devType} AND dev_code = #{devCode}
</update>
<!--设备领用列表--> <!--设备领用列表-->
<select id="getEquipmentReqLists" resultType="com.bonus.common.entity.bracelet.vo.EquipmentReqVo"> <select id="getEquipmentReqLists" resultType="com.bonus.common.entity.bracelet.vo.EquipmentReqVo">
@ -133,7 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT td.id AS devId,td.dev_code AS devCode,td.dev_name AS devName,td.dev_type AS devType SELECT td.id AS devId,td.dev_code AS devCode,td.dev_name AS devName,td.dev_type AS devType
FROM tb_device td FROM tb_device td
LEFT JOIN tb_dev_use_bid tdub ON td.id = tdub.dev_id AND td.dev_type = tdub.dev_type 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.del_flag = 0 WHERE (tdub.id IS NULL OR tdub.gh_time IS NOT NULL) AND td.dev_type = #{devType} AND td.del_flag = 0
</if> </if>
<if test="devType!='' and devType!=null and devType=='shx'"> <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 SELECT tsb.id AS devId,tsb.box_code AS devCode,tsb.box_name AS devName,'shx' AS devType
@ -144,7 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT td.id AS devId,td.dev_code AS devCode,td.dev_name AS devName,td.dev_type AS devType SELECT td.id AS devId,td.dev_code AS devCode,td.dev_name AS devName,td.dev_type AS devType
FROM tb_device td FROM tb_device td
LEFT JOIN tb_dev_use_bid tdub ON td.id = tdub.dev_id AND td.dev_type = tdub.dev_type 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.del_flag = 0 WHERE (tdub.id IS NULL OR tdub.gh_time IS NOT NULL) AND td.dev_type = #{devType} AND td.del_flag = 0
UNION ALL UNION ALL
SELECT tsb.id AS devId,tsb.box_code AS devCode,tsb.box_name AS devName,'shx' AS devType SELECT tsb.id AS devId,tsb.box_code AS devCode,tsb.box_name AS devName,'shx' AS devType
FROM tb_sh_box tsb FROM tb_sh_box tsb