领用管理

This commit is contained in:
cwchen 2024-08-06 14:11:18 +08:00
parent c1dac23723
commit d3c8488051
3 changed files with 34 additions and 20 deletions

View File

@ -81,7 +81,7 @@ public interface EquipmentReqMapper {
List<Map<String, Object>> getUseDevices(BraceletParamsDto dto);
/**
* 更新手环箱状态
* 更新手环箱/手环箱状态
* @param dto
* @return void
* @author cwchen
@ -97,4 +97,14 @@ public interface EquipmentReqMapper {
* @date 2024/8/6 9:19
*/
void returnDevice(BraceletParamsDto dto);
/**
* 判断设备是否全部归还
* @param dto
* @return int
* @author cwchen
* @date 2024/8/6 11:10
*/
int isAllDeviceReturn(@Param("params") BraceletParamsDto dto,@Param("type") int type);
}

View File

@ -11,6 +11,7 @@ import com.bonus.common.entity.bracelet.vo.EquipmentReqDataVo;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
@ -65,17 +66,13 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
return AjaxResult.error("领用设备中包含未归还设备,请先归还后,方可再次领用");
}
}
// 添加设备领用数据设备领用详情数据
mapper.addDevUseData(vo);
mapper.addDevUseDetailData(vo);
for (EquipmentReqDataVo.Equipment equipment : vo.getList()) {
if(Objects.equals(equipment.getDevType(), BusinessConstants.SHX)){
// 更新手环箱状态
// 绑定手环箱
mapper.updateDeviceData(vo,equipment,1);
}else{
// 更新其他设备状态
mapper.updateDeviceData(vo,equipment,2);
}
}
return AjaxResult.success();
@ -90,7 +87,9 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
public AjaxResult getUseDevices(BraceletParamsDto dto) {
List<Map<String, Object>> list = new ArrayList<>();
try {
list = mapper.getUseDevices(dto);
if(StringUtils.isNotBlank(dto.getDevType())){
list = mapper.getUseDevices(dto);
}
} catch (Exception e) {
log.error(e.toString(), e);
}
@ -102,11 +101,19 @@ public class EquipmentReqServiceImpl implements IEquipmentReqService {
public AjaxResult returnDevice(BraceletParamsDto dto) {
try {
if(Objects.equals(dto.getDevType(), BusinessConstants.SHX)){
// 设备类型为手环箱更新手环箱状态
// 设备类型为手环箱时判断手环设备是否全部归还
int result = mapper.isAllDeviceReturn(dto,1);
if(result > 0){
return AjaxResult.error("该手环箱中包含的手环设备未全部归还");
}
// 解绑手环箱
mapper.updateReturnDeviceData(dto,1);
}else{
// 设备类型为其他设备更新设备状态
mapper.updateReturnDeviceData(dto,2);
// 设备类型为其他设备时判断是否全部归还
int result = mapper.isAllDeviceReturn(dto,2);
if(result > 0){
return AjaxResult.error("班组人员未归还设");
}
}
mapper.returnDevice(dto);
return AjaxResult.success();

View File

@ -158,15 +158,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM tb_sh_box tsb
WHERE team_id IS NULL AND tsb.del_flag = 0
</if>
<if test="devType == '' or devType==null">
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
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
WHERE team_id IS NULL AND tsb.del_flag = 0
</if>
</select>
<!--判断设备是否全部归还-->
<select id="isAllDeviceReturn" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM tb_dev_use_bid tdub
LEFT JOIN tb_sh_use tsu ON tdub.id = tsu.use_id AND tsu.bid_type = #{type}
WHERE tdub.id = #{params.id} AND tdub.dev_id = #{params.devId} AND tdub.dev_type = #{params.devType} AND tdub.dev_code = #{params.devCode} AND tsu.time_type = 1
</select>
</mapper>