This commit is contained in:
hayu 2025-11-16 16:19:33 +08:00
parent 8396c4158f
commit 0fa6e15bae
4 changed files with 154 additions and 5 deletions

View File

@ -81,10 +81,13 @@ public class ToBeRepair {
*/ */
private String isScrap; private String isScrap;
private Integer isScrapFilter;
/** /**
* 创建人 * 创建人
*/ */
private String createUser; private String createUser;
private String createBy;
/** /**
* 维修时间 * 维修时间

View File

@ -79,4 +79,32 @@ public interface RepairMapper {
* @return * @return
*/ */
List<ToBeRepair> getDetailsList(ToBeRepair toBeRepair); List<ToBeRepair> getDetailsList(ToBeRepair toBeRepair);
/**
* 根据设备类型和编号查询
* @param toBeRepair
* @return
*/
ToBeRepair selectByTypeIdAndCode(ToBeRepair toBeRepair);
/**
* 新增设备生命周期数据
* @param bean2
* @return
*/
int addToolLifecycleByRepair(ToBeRepair bean2);
/**
* 更新台账信息
* @param bean2
* @return
*/
int updateToolLifecycle(ToBeRepair bean2);
/**
* 更新设备信息
* @param toBeRepair
* @return
*/
int updateMaDevInfo(ToBeRepair toBeRepair);
} }

View File

@ -180,15 +180,54 @@ public class RepairServiceImpl implements RepairService {
return AjaxResult.error("请选择审核数据"); return AjaxResult.error("请选择审核数据");
} }
String username = SecurityUtils.getLoginUser().getSysUser().getNickName(); String username = SecurityUtils.getLoginUser().getSysUser().getNickName();
Long userId = SecurityUtils.getLoginUser().getUserid();
for (ToBeRepair toBeRepair : bean.getToBeRepairList()) { for (ToBeRepair toBeRepair : bean.getToBeRepairList()) {
toBeRepair.setCreateUser(username); if (!StringHelper.isNullOrEmptyString(toBeRepair.getAuditStatus())){
int res = mapper.auditData(toBeRepair); toBeRepair.setCreateUser(username);
if (res <= 0) { int res = mapper.auditData(toBeRepair);
throw new Exception("审核数据失败"); if (res <= 0) {
throw new Exception("审核数据失败");
}
//如果是审核通过需要增加周期表数据以及更新台账信息
if ("1".equals(toBeRepair.getAuditStatus())){
if ("工具".equals(toBeRepair.getType())){
//根据typeId和code查询台账信息
ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair);
if (bean1 != null && bean1.getId() > 0){
//1添加周期表数据
ToBeRepair bean2 = new ToBeRepair();
bean2.setId(bean1.getId());
bean2.setCreateBy(userId+"");
bean2.setCreateUser(username);
bean2.setCode(toBeRepair.getCode());
bean2.setRepairNum(toBeRepair.getRepairNum());
bean2.setIsScrap(toBeRepair.getIsScrap());
bean2.setIsScrapFilter(Integer.valueOf(toBeRepair.getIsScrap()));
int re = mapper.addToolLifecycleByRepair(bean2);
if (re <= 0) {
throw new Exception("添加周期表数据失败");
}
//2更新台账信息
int re2 = mapper.updateToolLifecycle(bean2);
if (re2 <= 0) {
throw new Exception("更新台账信息失败");
}
}
} else if ("装备".equals(toBeRepair.getType())){
//更新台账信息
toBeRepair.setCreateBy(userId+"");
toBeRepair.setIsScrapFilter(Integer.valueOf(toBeRepair.getIsScrap()));
int re3 = mapper.updateMaDevInfo(toBeRepair);
if (re3<=0){
throw new Exception("更新台账信息失败");
}
}
}
} else {
throw new Exception("缺少审核状态");
} }
} }
return AjaxResult.success("审核成功"); return AjaxResult.success("审核成功");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

View File

@ -41,6 +41,32 @@
NOW() NOW()
) )
</insert> </insert>
<insert id="addToolLifecycleByRepair">
insert into tool_lifecycle(
ledger_id,
<if test="code != null and code!=''">tool_code,</if>
action_type,
<if test="repairNum != null">change_num,</if>
status_before,
status_after,
<if test="createBy != null">operator_id,</if>
<if test="createUser != null">operator_name,</if>
operate_time,
create_time
)
values (
#{id},
<if test="code != null and code!=''">#{code},</if>
'维修',
<if test="repairNum != null">#{repairNum},</if>
'维修',
'在库',
<if test="createBy != null">#{createBy},</if>
<if test="createUser != null">#{createUser},</if>
NOW(),
NOW()
)
</insert>
<update id="deleteChangeInfo"> <update id="deleteChangeInfo">
update cs_device_change set del_flag = '1' where id = #{id} update cs_device_change set del_flag = '1' where id = #{id}
@ -55,6 +81,40 @@
review_time=NOW() review_time=NOW()
where id = #{id} where id = #{id}
</update> </update>
<update id="updateToolLifecycle">
update tool_ledger
set
repair_num=repair_num-#{repairNum},
<if test="isScrapFilter != null">
<if test="isScrapFilter==0">
available_num=available_num+#{repairNum},
status='0',
</if>
<if test="isScrapFilter==1">
scrap_num=scrap_num+#{repairNum},
status='3',
</if>
</if>
update_time=NOW()
where id = #{id}
</update>
<update id="updateMaDevInfo">
update ma_dev_info
set
<if test="isScrapFilter != null">
<if test="isScrapFilter==0">
ma_status='1',
</if>
<if test="isScrapFilter==1">
ma_status='99',
</if>
</if>
<if test="createBy != null">
update_by=#{createBy},
</if>
update_time=NOW()
where type_id = #{typeId} and code=#{code}
</update>
<select id="selectToBeRepairList" resultType="com.bonus.material.repair.domain.ToBeRepair"> <select id="selectToBeRepairList" resultType="com.bonus.material.repair.domain.ToBeRepair">
SELECT SELECT
@ -164,6 +224,7 @@
CONCAT(tt2.type_name, '/', tt3.type_name, '/', tt4.type_name) AS groupName, CONCAT(tt2.type_name, '/', tt3.type_name, '/', tt4.type_name) AS groupName,
tt4.type_name as typeName, tt4.type_name as typeName,
tt5.type_name as typeModelName, tt5.type_name as typeModelName,
cdcd.dev_type_id as typeId,
CASE CASE
WHEN cdcd.dev_code is null THEN WHEN cdcd.dev_code is null THEN
'数量管理' '数量管理'
@ -208,6 +269,7 @@
CONCAT(mt2.type_name, '/', mt3.type_name, '/', mt4.type_name) AS groupName, CONCAT(mt2.type_name, '/', mt3.type_name, '/', mt4.type_name) AS groupName,
mdi.device_name as typeName, mdi.device_name as typeName,
mdi.item_type_model as typeModelName, mdi.item_type_model as typeModelName,
cdcd.dev_type_id as typeId,
CASE CASE
WHEN cdcd.dev_code is null THEN WHEN cdcd.dev_code is null THEN
'数量管理' '数量管理'
@ -253,4 +315,21 @@
WHERE WHERE
change_id=#{id} change_id=#{id}
</select> </select>
<select id="selectByTypeIdAndCode" resultType="com.bonus.material.repair.domain.ToBeRepair">
SELECT
tl.id,
CASE tl.manage_mode
WHEN 0 THEN
'编码管理'
WHEN 1 THEN
'数量管理'
END manageMode
FROM
tool_ledger tl
WHERE
tl.type_id=#{typeId}
<if test="code != null and code!=''">
and tl.tool_code=#{code}
</if>
</select>
</mapper> </mapper>