维修管理优化 增加维修单小计费用
This commit is contained in:
parent
d288936a57
commit
8aead27cfb
|
|
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -60,6 +61,12 @@ public class RepairDeviceListVo extends BaseVO {
|
||||||
@ApiModelProperty(value = "维修报废数量")
|
@ApiModelProperty(value = "维修报废数量")
|
||||||
private int scrapNum;
|
private int scrapNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修费用记录条数")
|
||||||
|
private Integer totalCostRecords;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修费用合计")
|
||||||
|
private BigDecimal totalCost;
|
||||||
|
|
||||||
@ApiModelProperty(value = "内层物资类型集合")
|
@ApiModelProperty(value = "内层物资类型集合")
|
||||||
private List<RepairDeviceVO> repairDeviceList = new ArrayList<>();
|
private List<RepairDeviceVO> repairDeviceList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ import com.bonus.material.repair.domain.vo.RepairDeviceListVo;
|
||||||
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
|
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
|
||||||
import com.bonus.system.api.domain.SysUser;
|
import com.bonus.system.api.domain.SysUser;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -36,19 +39,19 @@ public interface RepairService {
|
||||||
/**
|
/**
|
||||||
* 查询维修单
|
* 查询维修单
|
||||||
*/
|
*/
|
||||||
AjaxResult getRepairTicketInfo(String taskId);
|
AjaxResult getRepairTicketInfo(@NotBlank(message = "TaskId参数不能为空") String taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交维修记录
|
* 提交维修记录
|
||||||
*/
|
*/
|
||||||
AjaxResult submitRepairApply(RepairApplyRecord bean);
|
AjaxResult submitRepairApply(@NotNull(message = "参数不能为空") RepairApplyRecord bean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 快捷维修记录
|
* 快捷维修记录
|
||||||
*/
|
*/
|
||||||
AjaxResult fastRepairApply(List<RepairTaskDetails> list);
|
AjaxResult fastRepairApply(List<RepairTaskDetails> list);
|
||||||
|
|
||||||
AjaxResult batchRepairApply(List<RepairDeviceVO> repairDeviceVOList);
|
AjaxResult batchRepairApply(@NotNull List<RepairDeviceVO> repairDeviceVOList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修明细--批量审核--更新明细status
|
* 维修明细--批量审核--更新明细status
|
||||||
|
|
@ -64,9 +67,9 @@ public interface RepairService {
|
||||||
* 提交审核
|
* 提交审核
|
||||||
* @param taskList 任务信息集合
|
* @param taskList 任务信息集合
|
||||||
*/
|
*/
|
||||||
AjaxResult endRepairTask(List<RepairTask> taskList);
|
AjaxResult endRepairTask(@NotNull List<RepairTask> taskList);
|
||||||
|
|
||||||
AjaxResult rejectRepair(List<Long> taskList);
|
AjaxResult rejectRepair(@NotNull List<Long> taskList);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -71,13 +71,16 @@ public class RepairServiceImpl implements RepairService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup) {
|
public List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup) {
|
||||||
|
if (Objects.isNull(bean)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
bean.setCompanyId(null);
|
bean.setCompanyId(null);
|
||||||
List<RepairDeviceListVo> repairMaTypeList = repairMapper.getRepairMaTypeList(bean);
|
List<RepairDeviceListVo> repairMaTypeList = repairMapper.getRepairMaTypeList(bean);
|
||||||
|
|
||||||
if (repairMaTypeList.isEmpty() || !isGroup) {
|
if (repairMaTypeList.isEmpty() || !isGroup) {
|
||||||
return repairMaTypeList;
|
return repairMaTypeList;
|
||||||
}
|
}
|
||||||
|
repairMaTypeList.removeIf(Objects::isNull);
|
||||||
// 创建Map集合,用于快速分组,使用 ConcurrentHashMap 保证线程安全
|
// 创建Map集合,用于快速分组,使用 ConcurrentHashMap 保证线程安全
|
||||||
Map<Long, RepairDeviceListVo> resultMap = new ConcurrentHashMap<>();
|
Map<Long, RepairDeviceListVo> resultMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
@ -92,16 +95,18 @@ public class RepairServiceImpl implements RepairService {
|
||||||
System.err.println("复制属性时发生错误: {}" + e.getMessage());
|
System.err.println("复制属性时发生错误: {}" + e.getMessage());
|
||||||
throw new RuntimeException("复制属性时发生错误", e);
|
throw new RuntimeException("复制属性时发生错误", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getTypeNameId() == null) {
|
if (item.getTypeNameId() == null) {
|
||||||
// 处理 typeNameId 为空的情况
|
// 处理 typeNameId 为空的情况
|
||||||
System.err.println("typeNameId 为空,跳过当前项: " + item);
|
System.err.println("typeNameId 为空,跳过当前项: " + item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
resultMap.computeIfAbsent(item.getTypeNameId(), origin -> item).getRepairDeviceList().add(repairDeviceVO);
|
||||||
// 使用 computeIfAbsent 方法,如果 key 不存在,则创建一个新对象,并添加到 resultMap 中
|
resultMap.computeIfPresent(item.getTypeNameId(), (origin, novel) -> {
|
||||||
resultMap.computeIfAbsent(item.getTypeNameId(), k -> item).getRepairDeviceList().add(repairDeviceVO);
|
novel.setTotalCost(novel.getTotalCost().add(Optional.ofNullable(item.getTotalCost()).orElse(BigDecimal.ZERO)));
|
||||||
|
return novel;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return new ArrayList<>(resultMap.values());
|
return new ArrayList<>(resultMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,6 +128,7 @@ public class RepairServiceImpl implements RepairService {
|
||||||
}
|
}
|
||||||
// 查询维修任务详情
|
// 查询维修任务详情
|
||||||
List<RepairDeviceListVo> repairMaTypeGroupList = getRepairMaTypeList(new RepairTaskDetails(taskId), true);
|
List<RepairDeviceListVo> repairMaTypeGroupList = getRepairMaTypeList(new RepairTaskDetails(taskId), true);
|
||||||
|
|
||||||
List<RepairPart> repairPartList = repairAuditDetailsMapper.getPartDetailsByTaskId(new RepairAuditDetails().setTaskId(thisTaskId));
|
List<RepairPart> repairPartList = repairAuditDetailsMapper.getPartDetailsByTaskId(new RepairAuditDetails().setTaskId(thisTaskId));
|
||||||
repairPartList = mergePartsNum(repairPartList);
|
repairPartList = mergePartsNum(repairPartList);
|
||||||
|
|
||||||
|
|
@ -143,14 +149,13 @@ public class RepairServiceImpl implements RepairService {
|
||||||
|
|
||||||
public static List<RepairPart> mergePartsNum(@NotNull List<RepairPart> devices) {
|
public static List<RepairPart> mergePartsNum(@NotNull List<RepairPart> devices) {
|
||||||
try {
|
try {
|
||||||
Map<String, RepairPart> map = devices.stream().filter(Objects::nonNull).collect(Collectors.toConcurrentMap(
|
Map<String, RepairPart> map = devices.stream().filter(Objects::nonNull).collect(
|
||||||
device -> device.getTypeId() + ":" + device.getPartCost() + ":" + device.getPartName(),
|
Collectors.toConcurrentMap(device -> device.getTypeId() + ":" + device.getPartCost() + ":" + device.getPartName(),
|
||||||
device -> device, (existing, recently) -> {
|
device -> device, (existing, recently) -> {
|
||||||
existing.setPartNum(existing.getPartNum() + recently.getPartNum());
|
existing.setPartNum(existing.getPartNum() + recently.getPartNum());
|
||||||
return existing;
|
return existing;
|
||||||
},
|
}, ConcurrentHashMap::new)
|
||||||
ConcurrentHashMap::new
|
);
|
||||||
));
|
|
||||||
return new ArrayList<>(map.values());
|
return new ArrayList<>(map.values());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException("Error merging parts" + e.getMessage());
|
throw new ServiceException("Error merging parts" + e.getMessage());
|
||||||
|
|
@ -286,6 +291,9 @@ public class RepairServiceImpl implements RepairService {
|
||||||
* 校验维修数量
|
* 校验维修数量
|
||||||
*/
|
*/
|
||||||
private static int verifyRepairNum(RepairApplyRecord bean, RepairTaskDetails details) {
|
private static int verifyRepairNum(RepairApplyRecord bean, RepairTaskDetails details) {
|
||||||
|
if (bean == null || bean.getRepairNum() == null) {
|
||||||
|
throw new ServiceException("维修数量不能为空");
|
||||||
|
}
|
||||||
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getRepairNum();
|
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getRepairNum();
|
||||||
if (repairNum + OptionalInt.of(details.getScrapNum()).orElse(0) > details.getRepairNum()) {
|
if (repairNum + OptionalInt.of(details.getScrapNum()).orElse(0) > details.getRepairNum()) {
|
||||||
throw new ServiceException("维修数量大于维修总量");
|
throw new ServiceException("维修数量大于维修总量");
|
||||||
|
|
|
||||||
|
|
@ -245,12 +245,16 @@
|
||||||
rad.status as status,
|
rad.status as status,
|
||||||
su.nick_name as repairer,
|
su.nick_name as repairer,
|
||||||
rad.update_time as updateTime,
|
rad.update_time as updateTime,
|
||||||
rad.type_id as typeId
|
rad.type_id as typeId,
|
||||||
|
rad.create_time,
|
||||||
|
count(rc.id) AS totalCostRecords,
|
||||||
|
sum(rc.costs) AS totalCost
|
||||||
from repair_apply_details rad
|
from repair_apply_details rad
|
||||||
left join ma_type mt on rad.type_id = mt.type_id
|
left join ma_type mt on rad.type_id = mt.type_id
|
||||||
left join ma_machine mm on mm.ma_id = rad.ma_id
|
left join ma_machine mm on mm.ma_id = rad.ma_id
|
||||||
left join sys_user su on rad.repairer = su.user_id
|
left join sys_user su on rad.repairer = su.user_id
|
||||||
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
||||||
|
left join repair_cost rc ON rad.id = rc.repair_id
|
||||||
where rad.task_id = #{taskId}
|
where rad.task_id = #{taskId}
|
||||||
<if test="companyId != null and companyId != ''">
|
<if test="companyId != null and companyId != ''">
|
||||||
and rad.company_id = #{companyId}
|
and rad.company_id = #{companyId}
|
||||||
|
|
@ -267,6 +271,7 @@
|
||||||
<if test="typeName != null and typeName != ''">
|
<if test="typeName != null and typeName != ''">
|
||||||
AND mt2.type_id = #{typeName}
|
AND mt2.type_id = #{typeName}
|
||||||
</if>
|
</if>
|
||||||
|
GROUP BY rad.id
|
||||||
order by rad.create_time desc
|
order by rad.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue