领用管理

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();
/**设备ID*/
private Long devId;
/**工程名称*/
private String proName;
/**杆塔编号*/
@ -101,4 +103,7 @@ public class BraceletParamsDto {
private String lyTime;
/**归还时间*/
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 Date lyTime = new Date();
}
@Length(max = 255, message = "备注字符长度不能超过255")
@ -76,4 +72,9 @@ public class EquipmentReqDataVo {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
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) {
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")
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
*/
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 javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
/**
* @className:EquipmentReqServiceImpl
@ -37,14 +34,14 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
@Override
public List<EquipmentReqVo> getEquipmentReqLists(BraceletParamsDto dto) {
List<EquipmentReqVo> list= new ArrayList<>();
List<EquipmentReqVo> list = new ArrayList<>();
try {
list = mapper.getEquipmentReqLists(dto);
for (EquipmentReqVo vo : list) {
vo.setLeaderPhone(Sm4Utils.decode(vo.getLeaderPhone()));
}
} catch (Exception e) {
log.error(e.toString(),e);
log.error(e.toString(), e);
}
return list;
}
@ -53,16 +50,22 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
@Transactional(rollbackFor = Exception.class)
public AjaxResult addData(EquipmentReqDataVo vo) {
try {
if(CollectionUtils.isEmpty(vo.getList())){
if (CollectionUtils.isEmpty(vo.getList())) {
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()) {
// 判断设备是否已经归还
Integer result = result = mapper.isHasUseDevice(equipment);
if(result > 0){
if (result > 0) {
return AjaxResult.error("领用设备中包含未归还设备,请先归还后,方可再次领用");
}
}
// 添加设备领用数据设备领用详情数据
mapper.addDevUseData(vo);
mapper.addDevUseDetailData(vo);
@ -74,7 +77,7 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
}
return AjaxResult.success();
} catch (Exception e) {
log.error(e.toString(),e);
log.error(e.toString(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error();
}
@ -82,12 +85,29 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
@Override
public AjaxResult getUseDevices(BraceletParamsDto dto) {
List<Map<String,Object>> list = new ArrayList<>();
List<Map<String, Object>> list = new ArrayList<>();
try {
list = mapper.getUseDevices(dto);
} catch (Exception e) {
log.error(e.toString(),e);
log.error(e.toString(), e);
}
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
<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>
</insert>
@ -44,6 +44,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
<!--更新手环箱状态-->
<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">
@ -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
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.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 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
@ -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
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.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
SELECT tsb.id AS devId,tsb.box_code AS devCode,tsb.box_name AS devName,'shx' AS devType
FROM tb_sh_box tsb