维修模块优化
This commit is contained in:
parent
6a4ea4dc68
commit
0f25724852
|
|
@ -10,7 +10,6 @@ import com.bonus.material.repair.domain.RepairApplyRecord;
|
|||
import com.bonus.material.repair.domain.RepairPartDetails;
|
||||
import com.bonus.material.repair.domain.RepairTask;
|
||||
import com.bonus.material.repair.domain.RepairTaskDetails;
|
||||
import com.bonus.material.repair.domain.vo.RepairDeviceListVo;
|
||||
import com.bonus.material.repair.domain.vo.RepairDeviceSummaryVo;
|
||||
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
|
||||
import com.bonus.material.repair.service.RepairService;
|
||||
|
|
@ -89,8 +88,7 @@ public class RepairController extends BaseController {
|
|||
@ApiOperation(value = "获取维修物资设备列表---不分页")
|
||||
@GetMapping("/getAppRepairMaTypeList")
|
||||
public AjaxResult getAppRepairMaTypeList(RepairTaskDetails bean) {
|
||||
//List<RepairDeviceListVo> list = service.getRepairMaTypeList(bean);
|
||||
List<RepairDeviceSummaryVo> list = service.getRepairDeviceSummary(bean, true);
|
||||
List<RepairDeviceSummaryVo> list = service.getRepairDeviceSummary(bean);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
|
@ -98,9 +96,9 @@ public class RepairController extends BaseController {
|
|||
* 查询维修单
|
||||
*/
|
||||
@ApiOperation(value = "获取维修单详情")
|
||||
@GetMapping("/getRepairTicketInfo")
|
||||
public AjaxResult getRepairTicketInfo(@NotBlank(message = "TaskId参数不能为空") String taskId) {
|
||||
return service.getRepairTicketInfo(taskId);
|
||||
@GetMapping("/getRepairDocumentInfo")
|
||||
public AjaxResult getRepairDocumentInfo(@NotBlank(message = "TaskId参数不能为空") String taskId) {
|
||||
return service.getRepairDocumentInfo(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.material.repair.domain.vo;
|
||||
|
||||
import com.bonus.common.biz.domain.BaseVO;
|
||||
import com.bonus.material.basic.domain.BmFileInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
|
@ -62,4 +63,7 @@ public class RepairDeviceSummaryVo extends BaseVO {
|
|||
|
||||
@ApiModelProperty(value = "内层物资类型集合")
|
||||
private List<RepairDeviceVO> repairDeviceList = new ArrayList<>();
|
||||
|
||||
@ApiModelProperty(value = "报废附件")
|
||||
private List<BmFileInfo> fileList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,15 +26,15 @@ public class RepairTicketVo {
|
|||
private RepairTask repairTaskInfo;
|
||||
|
||||
@ApiModelProperty(value = "维修物资列表")
|
||||
private List<RepairDeviceListVo> repairDeviceArray;
|
||||
private List<RepairDeviceSummaryVo> repairDeviceSummaryList;
|
||||
|
||||
@ApiModelProperty(value = "维修内容集合")
|
||||
private List<RepairPart> repairPartArray;
|
||||
|
||||
// 覆盖默认get方法,防止空指针异常
|
||||
public List<RepairDeviceListVo> getRepairDeviceList() {
|
||||
if (this.repairDeviceArray == null) {return new ArrayList<>();}
|
||||
return this.repairDeviceArray;
|
||||
public List<RepairDeviceSummaryVo> getRepairDeviceSummaryList() {
|
||||
if (this.repairDeviceSummaryList == null) {return new ArrayList<>();}
|
||||
return this.repairDeviceSummaryList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public interface RepairMapper {
|
|||
* 获取维修详细列表
|
||||
* @param bean 维修任务详情--查询条件
|
||||
*/
|
||||
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean);
|
||||
// List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean);
|
||||
|
||||
/**
|
||||
* 新增维修记录
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ public interface RepairService {
|
|||
/**
|
||||
* 获取维修详细列表
|
||||
*/
|
||||
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup);
|
||||
// List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup);
|
||||
|
||||
|
||||
List<RepairDeviceSummaryVo> getRepairDeviceSummary(RepairTaskDetails bean, boolean isGroup);
|
||||
List<RepairDeviceSummaryVo> getRepairDeviceSummary(RepairTaskDetails bean);
|
||||
|
||||
|
||||
// default List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean) {
|
||||
|
|
@ -42,7 +42,7 @@ public interface RepairService {
|
|||
/**
|
||||
* 查询维修单
|
||||
*/
|
||||
AjaxResult getRepairTicketInfo(@NotBlank(message = "TaskId参数不能为空") String taskId);
|
||||
AjaxResult getRepairDocumentInfo(@NotBlank(message = "TaskId参数不能为空") String taskId);
|
||||
|
||||
/**
|
||||
* 提交维修记录
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<RepairDeviceSummaryVo> getRepairDeviceSummary(RepairTaskDetails bean, boolean isGroup) {
|
||||
public List<RepairDeviceSummaryVo> getRepairDeviceSummary(RepairTaskDetails bean) {
|
||||
List<RepairDeviceSummaryVo> repairDeviceSummaryVoList = new ArrayList<>();
|
||||
List<RepairDeviceVO> repairDeviceList = repairMapper.getRepairDeviceList(bean);
|
||||
Map<Long, List<RepairDeviceVO>> map = repairDeviceList.stream().collect(Collectors.groupingBy(RepairDeviceVO::getTypeId));
|
||||
|
|
@ -81,12 +81,12 @@ public class RepairServiceImpl implements RepairService {
|
|||
Long[] ids = tempList.stream().map(RepairDeviceVO::getId).toArray(Long[]::new);
|
||||
int repairNumSum = tempList.stream().mapToInt(RepairDeviceVO::getRepairNum).sum();
|
||||
int repairedNumSum = tempList.stream().mapToInt(RepairDeviceVO::getRepairedNum).sum();
|
||||
BigDecimal typeCostSum = tempList.stream().map(RepairDeviceVO::getTotalCost).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
//BigDecimal typeCostSum = tempList.stream().map(RepairDeviceVO::getTotalCost).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setRepairDeviceList(tempList);
|
||||
vo.setIds(ids);
|
||||
vo.setTypeRepairNum(repairNumSum);
|
||||
vo.setTypeRepairedNum(repairedNumSum);
|
||||
vo.setTypeCost(typeCostSum);
|
||||
//vo.setTypeCost(typeCostSum);
|
||||
vo.setTaskId(tempList.get(0).getTaskId());
|
||||
vo.setCode(tempList.get(0).getCode());
|
||||
vo.setTypeName(tempList.get(0).getTypeName());
|
||||
|
|
@ -100,62 +100,62 @@ public class RepairServiceImpl implements RepairService {
|
|||
return repairDeviceSummaryVoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup) {
|
||||
if (Objects.isNull(bean)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
bean.setCompanyId(null);
|
||||
List<RepairDeviceListVo> repairMaTypeList = repairMapper.getRepairMaTypeList(bean);
|
||||
|
||||
if (repairMaTypeList.isEmpty() || !isGroup) {
|
||||
return repairMaTypeList;
|
||||
}
|
||||
repairMaTypeList.removeIf(Objects::isNull);
|
||||
// 创建Map集合,用于快速分组,使用 ConcurrentHashMap 保证线程安全
|
||||
Map<Long, RepairDeviceListVo> resultMap = new ConcurrentHashMap<>();
|
||||
|
||||
// 遍历处理,把相同的父级对象,拆分到子集合中
|
||||
repairMaTypeList.forEach(item -> {
|
||||
// 创建对象,并复制字段value
|
||||
RepairDeviceVO repairDeviceVO = new RepairDeviceVO();
|
||||
try {
|
||||
BeanUtil.copyProperties(item, repairDeviceVO);
|
||||
} catch (Exception e) {
|
||||
System.err.println("复制属性时发生错误: {}" + e.getMessage());
|
||||
throw new RuntimeException("复制属性时发生错误", e);
|
||||
}
|
||||
if (item.getTypeNameId() == null) {
|
||||
System.err.println("typeNameId 为空,跳过当前项: " + item);
|
||||
return;
|
||||
}
|
||||
resultMap.computeIfAbsent(item.getTypeNameId(), origin -> item).getRepairDeviceList().add(repairDeviceVO);
|
||||
|
||||
resultMap.computeIfPresent(item.getTypeNameId(), (origin, novel) -> {
|
||||
novel.setTotalCost(Optional.ofNullable(novel.getTotalCost()).orElse(BigDecimal.ZERO)
|
||||
.add(Optional.ofNullable(item.getTotalCost()).orElse(BigDecimal.ZERO))
|
||||
);
|
||||
return novel;
|
||||
});
|
||||
});
|
||||
|
||||
for (Long key : resultMap.keySet()) {
|
||||
RepairDeviceListVo vo = resultMap.get(key);
|
||||
if (MaTypeManageTypeEnum.CODE_DEVICE.getTypeId().equals(vo.getManageType())) {
|
||||
vo.setRepairNum((int) vo.getRepairDeviceList().stream().filter(o -> o.getRepairNum() > 0).count());
|
||||
vo.setRepairedNum((int) vo.getRepairDeviceList().stream().filter(o -> o.getRepairedNum() > 0).count());
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<>(resultMap.values());
|
||||
}
|
||||
// @Override
|
||||
// public List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup) {
|
||||
// if (Objects.isNull(bean)) {
|
||||
// return new ArrayList<>();
|
||||
// }
|
||||
// bean.setCompanyId(null);
|
||||
// List<RepairDeviceListVo> repairMaTypeList = repairMapper.getRepairMaTypeList(bean);
|
||||
//
|
||||
// if (repairMaTypeList.isEmpty() || !isGroup) {
|
||||
// return repairMaTypeList;
|
||||
// }
|
||||
// repairMaTypeList.removeIf(Objects::isNull);
|
||||
// // 创建Map集合,用于快速分组,使用 ConcurrentHashMap 保证线程安全
|
||||
// Map<Long, RepairDeviceListVo> resultMap = new ConcurrentHashMap<>();
|
||||
//
|
||||
// // 遍历处理,把相同的父级对象,拆分到子集合中
|
||||
// repairMaTypeList.forEach(item -> {
|
||||
// // 创建对象,并复制字段value
|
||||
// RepairDeviceVO repairDeviceVO = new RepairDeviceVO();
|
||||
// try {
|
||||
// BeanUtil.copyProperties(item, repairDeviceVO);
|
||||
// } catch (Exception e) {
|
||||
// System.err.println("复制属性时发生错误: {}" + e.getMessage());
|
||||
// throw new RuntimeException("复制属性时发生错误", e);
|
||||
// }
|
||||
// if (item.getTypeNameId() == null) {
|
||||
// System.err.println("typeNameId 为空,跳过当前项: " + item);
|
||||
// return;
|
||||
// }
|
||||
// resultMap.computeIfAbsent(item.getTypeNameId(), origin -> item).getRepairDeviceList().add(repairDeviceVO);
|
||||
//
|
||||
// resultMap.computeIfPresent(item.getTypeNameId(), (origin, novel) -> {
|
||||
// novel.setTotalCost(Optional.ofNullable(novel.getTotalCost()).orElse(BigDecimal.ZERO)
|
||||
// .add(Optional.ofNullable(item.getTotalCost()).orElse(BigDecimal.ZERO))
|
||||
// );
|
||||
// return novel;
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// for (Long key : resultMap.keySet()) {
|
||||
// RepairDeviceListVo vo = resultMap.get(key);
|
||||
// if (MaTypeManageTypeEnum.CODE_DEVICE.getTypeId().equals(vo.getManageType())) {
|
||||
// vo.setRepairNum((int) vo.getRepairDeviceList().stream().filter(o -> o.getRepairNum() > 0).count());
|
||||
// vo.setRepairedNum((int) vo.getRepairDeviceList().stream().filter(o -> o.getRepairedNum() > 0).count());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return new ArrayList<>(resultMap.values());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询维修单
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getRepairTicketInfo(@NotBlank(message = "TaskId参数不能为空") String taskId) {
|
||||
public AjaxResult getRepairDocumentInfo(@NotBlank(message = "TaskId参数不能为空") String taskId) {
|
||||
if (!NumberUtil.isNumber(taskId)) {
|
||||
return AjaxResult.error("TaskId参数非数字类型,参数类型错误");
|
||||
}
|
||||
|
|
@ -167,12 +167,23 @@ public class RepairServiceImpl implements RepairService {
|
|||
return AjaxResult.error("未查询到维修任务信息");
|
||||
}
|
||||
// 查询维修任务详情
|
||||
List<RepairDeviceListVo> repairMaTypeGroupList = getRepairMaTypeList(new RepairTaskDetails(taskId), true);
|
||||
repairMaTypeGroupList.removeIf(Objects::isNull);
|
||||
repairMaTypeGroupList.forEach(repairDevice -> {
|
||||
// List<RepairDeviceListVo> repairMaTypeGroupList = getRepairMaTypeList(new RepairTaskDetails(taskId), true);
|
||||
// repairMaTypeGroupList.removeIf(Objects::isNull);
|
||||
// repairMaTypeGroupList.forEach(repairDevice -> {
|
||||
// List<BmFileInfo> fileInfos = bmFileInfoMapper.selectBmFileInfoList(new BmFileInfo()
|
||||
// .setTaskId(OptionalLong.of(thisTaskId).orElse(0L))
|
||||
// .setModelId(Optional.ofNullable(repairDevice.getId()).orElse(0L))
|
||||
// .setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId())
|
||||
// );
|
||||
// repairDevice.setFileList(fileInfos);
|
||||
// });
|
||||
|
||||
List<RepairDeviceSummaryVo> repairDeviceSummaryList = getRepairDeviceSummary(new RepairTaskDetails(taskId));
|
||||
repairDeviceSummaryList.removeIf(Objects::isNull);
|
||||
repairDeviceSummaryList.forEach(repairDevice -> {
|
||||
List<BmFileInfo> fileInfos = bmFileInfoMapper.selectBmFileInfoList(new BmFileInfo()
|
||||
.setTaskId(OptionalLong.of(thisTaskId).orElse(0L))
|
||||
.setModelId(Optional.ofNullable(repairDevice.getId()).orElse(0L))
|
||||
.setModelId(Optional.ofNullable(repairDevice.getIds()[0]).orElse(0L))
|
||||
.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId())
|
||||
);
|
||||
repairDevice.setFileList(fileInfos);
|
||||
|
|
@ -182,7 +193,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
repairPartList = mergePartsNum(repairPartList);
|
||||
RepairTicketVo result = new RepairTicketVo()
|
||||
.setRepairTaskInfo(repairTaskInfo)
|
||||
.setRepairDeviceArray(repairMaTypeGroupList)
|
||||
.setRepairDeviceSummaryList(repairDeviceSummaryList)
|
||||
.setRepairPartArray(Optional.of(repairPartList).orElse(new ArrayList<>()));
|
||||
|
||||
return AjaxResult.success(result);
|
||||
|
|
|
|||
|
|
@ -303,52 +303,52 @@
|
|||
order by rad.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="getRepairMaTypeList" resultType="com.bonus.material.repair.domain.vo.RepairDeviceListVo">
|
||||
select
|
||||
rad.id as id,
|
||||
rad.task_id as taskId,
|
||||
rad.ma_id as maId,
|
||||
mt2.type_name as typeName,
|
||||
mt2.type_id as typeNameId,
|
||||
mt.type_name as type,
|
||||
mt.unit_name as unitName,
|
||||
mt.manage_type as manageType,
|
||||
mm.ma_code as code,
|
||||
rad.repair_num as repairNum,
|
||||
rad.repaired_num as repairedNum,
|
||||
rad.scrap_num as scrapNum,
|
||||
rad.status as status,
|
||||
su.nick_name as repairer,
|
||||
rad.update_time as updateTime,
|
||||
rad.type_id as typeId,
|
||||
rad.create_time,
|
||||
count(rc.id) AS totalCostRecords,
|
||||
sum(rc.costs) AS totalCost
|
||||
from repair_apply_details rad
|
||||
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 sys_user su on rad.repairer = su.user_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}
|
||||
<if test="companyId != null and companyId != ''">
|
||||
and rad.company_id = #{companyId}
|
||||
</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (locate(#{keyword}, mm.ma_code) > 0
|
||||
or locate(#{keyword}, su.nick_name) > 0
|
||||
or locate(#{keyword}, mt2.type_name) > 0
|
||||
or locate(#{keyword}, mt.type_name) > 0)
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
AND mt.type_id = #{type}
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
AND mt2.type_id = #{typeName}
|
||||
</if>
|
||||
GROUP BY rad.id
|
||||
order by rad.create_time desc
|
||||
</select>
|
||||
<!-- <select id="getRepairMaTypeList" resultType="com.bonus.material.repair.domain.vo.RepairDeviceListVo">-->
|
||||
<!-- select-->
|
||||
<!-- rad.id as id,-->
|
||||
<!-- rad.task_id as taskId,-->
|
||||
<!-- rad.ma_id as maId,-->
|
||||
<!-- mt2.type_name as typeName,-->
|
||||
<!-- mt2.type_id as typeNameId,-->
|
||||
<!-- mt.type_name as type,-->
|
||||
<!-- mt.unit_name as unitName,-->
|
||||
<!-- mt.manage_type as manageType,-->
|
||||
<!-- mm.ma_code as code,-->
|
||||
<!-- rad.repair_num as repairNum,-->
|
||||
<!-- rad.repaired_num as repairedNum,-->
|
||||
<!-- rad.scrap_num as scrapNum,-->
|
||||
<!-- rad.status as status,-->
|
||||
<!-- su.nick_name as repairer,-->
|
||||
<!-- rad.update_time as updateTime,-->
|
||||
<!-- rad.type_id as typeId,-->
|
||||
<!-- rad.create_time,-->
|
||||
<!-- count(rc.id) AS totalCostRecords,-->
|
||||
<!-- sum(rc.costs) AS totalCost-->
|
||||
<!-- from repair_apply_details rad-->
|
||||
<!-- 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 sys_user su on rad.repairer = su.user_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}-->
|
||||
<!-- <if test="companyId != null and companyId != ''">-->
|
||||
<!-- and rad.company_id = #{companyId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="keyword != null and keyword != ''">-->
|
||||
<!-- AND (locate(#{keyword}, mm.ma_code) > 0-->
|
||||
<!-- or locate(#{keyword}, su.nick_name) > 0-->
|
||||
<!-- or locate(#{keyword}, mt2.type_name) > 0-->
|
||||
<!-- or locate(#{keyword}, mt.type_name) > 0)-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="type != null and type != ''">-->
|
||||
<!-- AND mt.type_id = #{type}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="typeName != null and typeName != ''">-->
|
||||
<!-- AND mt2.type_id = #{typeName}-->
|
||||
<!-- </if>-->
|
||||
<!-- GROUP BY rad.id-->
|
||||
<!-- order by rad.create_time desc-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="getById" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
|
||||
select rad.id as id,
|
||||
|
|
|
|||
Loading…
Reference in New Issue