This commit is contained in:
hayu 2025-11-16 00:52:27 +08:00
parent 5a787c9de0
commit 2ca49c4884
6 changed files with 160 additions and 34 deletions

View File

@ -84,4 +84,16 @@ public class RepairController extends BaseController {
return AjaxResult.success(list);
}
/**
* 审核
* @param bean
* @return
*/
@ApiOperation(value = "审核")
@PostMapping("/auditData")
public AjaxResult auditData(@RequestBody ToBeRepair bean) {
return service.auditData(bean);
}
}

View File

@ -128,4 +128,9 @@ public class ToBeRepair {
* 结束时间
*/
private String endTime;
/**
* 审核状态
*/
private String auditStatus;
}

View File

@ -65,4 +65,18 @@ public interface RepairMapper {
* @return
*/
List<ToBeRepair> getRepairDetailsList(ToBeRepair bean);
/**
* 审核数据
* @param toBeRepair
* @return
*/
int auditData(ToBeRepair toBeRepair);
/**
* 获取详情列表
* @param toBeRepair
* @return
*/
List<ToBeRepair> getDetailsList(ToBeRepair toBeRepair);
}

View File

@ -43,4 +43,11 @@ public interface RepairService {
* @return
*/
List<ToBeRepair> getRepairDetailsList(ToBeRepair bean);
/**
* 审核数据
* @param bean
* @return
*/
AjaxResult auditData(ToBeRepair bean);
}

View File

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -96,13 +97,49 @@ public class RepairServiceImpl implements RepairService {
@Override
public List<ToBeRepair> getRepairList(ToBeRepair bean) {
try {
return mapper.getRepairList(bean);
List<ToBeRepair> list = mapper.getRepairList(bean);
for (ToBeRepair toBeRepair : list) {
List<ToBeRepair> detailsList = mapper.getDetailsList(toBeRepair);
if (detailsList != null && !detailsList.isEmpty()) {
// 存在审核中
boolean hasZero = false;
// 是否全部驳回
boolean allTwo = true;
for (ToBeRepair detail : detailsList) {
String audit = detail.getAuditStatus();
if ("0".equals(audit)) {
hasZero = true;
}
if (!"2".equals(audit)) {
allTwo = false;
}
}
// 规则判断
if (hasZero) {
toBeRepair.setStatus("审核中");
} else if (allTwo) {
toBeRepair.setStatus("已驳回");
} else {
toBeRepair.setStatus("已审核");
}
}
}
String statusFilter = bean.getStatus();
if (statusFilter != null && !"".equals(statusFilter)) {
list = list.stream()
.filter(item -> statusFilter.equals(item.getStatus()))
.collect(Collectors.toList());
}
return list;
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<>();
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult deleteRepairList(ToBeRepair bean) {
@ -135,6 +172,30 @@ public class RepairServiceImpl implements RepairService {
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult auditData(ToBeRepair bean) {
try {
if (bean.getToBeRepairList().size() <= 0) {
return AjaxResult.error("请选择审核数据");
}
String username = SecurityUtils.getLoginUser().getSysUser().getNickName();
for (ToBeRepair toBeRepair : bean.getToBeRepairList()) {
toBeRepair.setCreateUser(username);
int res = mapper.auditData(toBeRepair);
if (res <= 0) {
throw new Exception("审核数据失败");
}
}
return AjaxResult.success("审核成功");
} catch (Exception e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("审核失败");
}
}
/**
* 生成任务编号
* @param thisMonthMaxOrder

View File

@ -20,6 +20,7 @@
<if test="scrapUrl != null and scrapUrl!=''">reason_url,</if>
<if test="isScrap != null and isScrap!=''">is_scrap,</if>
<if test="createUser != null">create_user,</if>
review_status,
create_time
)
values (
@ -36,6 +37,7 @@
<if test="scrapUrl != null and scrapUrl!=''">#{scrapUrl},</if>
<if test="isScrap != null and isScrap!=''">#{isScrap},</if>
<if test="createUser != null">#{createUser},</if>
'0',
NOW()
)
</insert>
@ -46,6 +48,13 @@
<update id="deleteChangeDetails">
update cs_device_change_details set del_flag = '1' where change_id = #{id}
</update>
<update id="auditData">
update cs_device_change_details
set review_status = #{auditStatus},
review_by = #{createUser},
review_time=NOW()
where id = #{id}
</update>
<select id="selectToBeRepairList" resultType="com.bonus.material.repair.domain.ToBeRepair">
SELECT
@ -57,7 +66,6 @@
CONCAT(tt2.type_name, '/', tt3.type_name, '/', tt4.type_name) AS groupName,
tt4.type_name as typeName,
tt5.type_name as typeModelName,
CASE tl.manage_mode
WHEN 0 THEN
'编码管理'
@ -138,20 +146,12 @@
WHEN 2 THEN cdcd.num
ELSE 0
END) as toolNum,
CASE review_status
WHEN 0 THEN '审核中'
WHEN 1 THEN '已通过'
WHEN 2 THEN '已驳回'
END as `status`,
cdc.create_user as createUser,
cdc.create_time as createTime
FROM cs_device_change cdc
LEFT JOIN cs_device_change_details cdcd ON cdcd.change_id = cdc.id
WHERE cdc.type = '4'
and cdc.del_flag='0'
<if test="status != null and status!=''">
AND cdc.review_status = #{status}
</if>
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
AND cdc.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
</if>
@ -159,27 +159,36 @@
ORDER BY cdc.create_time DESC
</select>
<select id="getRepairDetailsList" resultType="com.bonus.material.repair.domain.ToBeRepair">
SELECT '工具' as type,
CONCAT(tt2.type_name, '/', tt3.type_name, '/', tt4.type_name) AS groupName,
tt4.type_name as typeName,
tt5.type_name as typeModelName,
CASE
WHEN cdcd.dev_code is null THEN
'数量管理'
ELSE
'编码管理'
END manageMode,
cdcd.dev_code as `code`,
cdcd.num as repairNum,
cdcd.is_scrap as isScrap,
cdcd.repair_time as repairTime,
cdcd.reason_val as reasonVal,
CASE is_scrap
WHEN 0 THEN
repair_url
ELSE
reason_url
END url
SELECT DISTINCT cdcd.id,
'工具' as type,
CONCAT(tt2.type_name, '/', tt3.type_name, '/', tt4.type_name) AS groupName,
tt4.type_name as typeName,
tt5.type_name as typeModelName,
CASE
WHEN cdcd.dev_code is null THEN
'数量管理'
ELSE
'编码管理'
END manageMode,
cdcd.dev_code as `code`,
cdcd.num as repairNum,
cdcd.is_scrap as isScrap,
CASE cdcd.review_status
WHEN 0 THEN
'待审核'
WHEN 1 THEN
'通过'
WHEN 2 THEN
'驳回'
END status,
cdcd.repair_time as repairTime,
cdcd.reason_val as reasonVal,
CASE is_scrap
WHEN 0 THEN
repair_url
ELSE
reason_url
END url
FROM cs_device_change_details cdcd
LEFT JOIN tool_type tt5 on tt5.type_id = cdcd.dev_type_id
LEFT JOIN tool_type tt4 on tt4.type_id = tt5.parent_id
@ -187,14 +196,15 @@
LEFT JOIN tool_type tt2 on tt2.type_id = tt3.parent_id
WHERE cdcd.change_id = #{id}
and cdcd.dev_type = '2'
and cdcd.del_flag='0'
and cdcd.del_flag = '0'
GROUP BY cdcd.id
UNION
SELECT DISTINCT '装备' as type,
SELECT DISTINCT cdcd.id,
'装备' as type,
CONCAT(mt2.type_name, '/', mt3.type_name, '/', mt4.type_name) AS groupName,
mdi.device_name as typeName,
mdi.item_type_model as typeModelName,
@ -207,6 +217,14 @@
cdcd.dev_code as `code`,
cdcd.num as repairNum,
cdcd.is_scrap as isScrap,
CASE cdcd.review_status
WHEN 0 THEN
'待审核'
WHEN 1 THEN
'通过'
WHEN 2 THEN
'驳回'
END status,
cdcd.repair_time as repairTime,
cdcd.reason_val as reasonVal,
CASE is_scrap
@ -223,7 +241,16 @@
LEFT JOIN ma_type mt2 on mt2.type_id = mt3.parent_id
WHERE cdcd.change_id = #{id}
and cdcd.dev_type = '1'
and cdcd.del_flag='0'
and cdcd.del_flag = '0'
GROUP BY cdcd.id
</select>
<select id="getDetailsList" resultType="com.bonus.material.repair.domain.ToBeRepair">
SELECT
id,
review_status as auditStatus
FROM
cs_device_change_details
WHERE
change_id=#{id}
</select>
</mapper>