维修管理优化维修单
This commit is contained in:
parent
1704d1f761
commit
d288936a57
|
|
@ -1,7 +1,6 @@
|
||||||
package com.bonus.material.repair.controller;
|
package com.bonus.material.repair.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import com.bonus.common.core.web.domain.BaseEntity;
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,6 +21,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
@ToString
|
||||||
|
@Accessors(chain = true)
|
||||||
public class RepairAuditDetails extends BaseEntity {
|
public class RepairAuditDetails extends BaseEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8752731235584328836L;
|
private static final long serialVersionUID = -8752731235584328836L;
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,15 @@ public class RepairPart {
|
||||||
/**
|
/**
|
||||||
* 规格ID
|
* 规格ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "规格ID")
|
@ApiModelProperty(value = "规格型号ID")
|
||||||
private String typeId;
|
private Long typeId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格型号名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机具类型名称")
|
||||||
|
private String maTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配件ID
|
* 配件ID
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,12 +48,12 @@ public class RepairPart {
|
||||||
* 返厂id
|
* 返厂id
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "返厂id")
|
@ApiModelProperty(value = "返厂id")
|
||||||
private String supplierId;
|
private Long supplierId;
|
||||||
/**
|
/**
|
||||||
* 配件数量
|
* 配件数量
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "配件数量")
|
@ApiModelProperty(value = "配件数量")
|
||||||
private int partNum;
|
private Integer partNum;
|
||||||
/**
|
/**
|
||||||
* 配件费用
|
* 配件费用
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.material.repair.domain.vo;
|
package com.bonus.material.repair.domain.vo;
|
||||||
|
|
||||||
|
import com.bonus.material.repair.domain.RepairPart;
|
||||||
import com.bonus.material.repair.domain.RepairTask;
|
import com.bonus.material.repair.domain.RepairTask;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
@ -27,6 +28,9 @@ public class RepairTicketVo {
|
||||||
@ApiModelProperty(value = "维修物资列表")
|
@ApiModelProperty(value = "维修物资列表")
|
||||||
private List<RepairDeviceListVo> repairDeviceArray;
|
private List<RepairDeviceListVo> repairDeviceArray;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修内容集合")
|
||||||
|
private List<RepairPart> repairPartArray;
|
||||||
|
|
||||||
// 覆盖默认get方法,防止空指针异常
|
// 覆盖默认get方法,防止空指针异常
|
||||||
public List<RepairDeviceListVo> getRepairDeviceList() {
|
public List<RepairDeviceListVo> getRepairDeviceList() {
|
||||||
if (this.repairDeviceArray == null) {return new ArrayList<>();}
|
if (this.repairDeviceArray == null) {return new ArrayList<>();}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ public interface RepairAuditDetailsMapper {
|
||||||
|
|
||||||
List<RepairPart> getPartRecord(RepairAuditDetails bean);
|
List<RepairPart> getPartRecord(RepairAuditDetails bean);
|
||||||
|
|
||||||
|
List<RepairPart> getPartDetailsByTaskId(RepairAuditDetails repairAuditDetails);
|
||||||
|
|
||||||
List<RepairRecord> getRepairRecord(RepairAuditDetails repairAuditDetails);
|
List<RepairRecord> getRepairRecord(RepairAuditDetails repairAuditDetails);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,11 @@ public interface RepairService {
|
||||||
/**
|
/**
|
||||||
* 获取维修详细列表
|
* 获取维修详细列表
|
||||||
*/
|
*/
|
||||||
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean);
|
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup);
|
||||||
|
|
||||||
|
default List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean) {
|
||||||
|
return getRepairMaTypeList(bean, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询维修单
|
* 查询维修单
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import com.bonus.material.repair.domain.*;
|
||||||
import com.bonus.material.repair.domain.vo.RepairDeviceListVo;
|
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.material.repair.domain.vo.RepairTicketVo;
|
import com.bonus.material.repair.domain.vo.RepairTicketVo;
|
||||||
|
import com.bonus.material.repair.mapper.RepairAuditDetailsMapper;
|
||||||
import com.bonus.material.repair.mapper.RepairMapper;
|
import com.bonus.material.repair.mapper.RepairMapper;
|
||||||
import com.bonus.material.repair.service.RepairService;
|
import com.bonus.material.repair.service.RepairService;
|
||||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||||
|
|
@ -22,18 +23,22 @@ import com.bonus.system.api.model.LoginUser;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author syruan
|
* @author syruan
|
||||||
*/
|
*/
|
||||||
@Service("RepairService")
|
@Service("RepairService")
|
||||||
|
@Validated
|
||||||
public class RepairServiceImpl implements RepairService {
|
public class RepairServiceImpl implements RepairService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -45,6 +50,9 @@ public class RepairServiceImpl implements RepairService {
|
||||||
@Resource
|
@Resource
|
||||||
private BmFileInfoMapper bmFileInfoMapper;
|
private BmFileInfoMapper bmFileInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RepairAuditDetailsMapper repairAuditDetailsMapper;
|
||||||
|
|
||||||
// 1:内部维修 2:外部返厂维修 3:报废
|
// 1:内部维修 2:外部返厂维修 3:报废
|
||||||
private final int inRepairType = 1, outRepairType = 2, scrapRepairType = 3;
|
private final int inRepairType = 1, outRepairType = 2, scrapRepairType = 3;
|
||||||
|
|
||||||
|
|
@ -62,11 +70,11 @@ public class RepairServiceImpl implements RepairService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean) {
|
public List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup) {
|
||||||
bean.setCompanyId(null);
|
bean.setCompanyId(null);
|
||||||
List<RepairDeviceListVo> repairMaTypeList = repairMapper.getRepairMaTypeList(bean);
|
List<RepairDeviceListVo> repairMaTypeList = repairMapper.getRepairMaTypeList(bean);
|
||||||
|
|
||||||
if (repairMaTypeList.isEmpty()) {
|
if (repairMaTypeList.isEmpty() || !isGroup) {
|
||||||
return repairMaTypeList;
|
return repairMaTypeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,18 +118,18 @@ public class RepairServiceImpl implements RepairService {
|
||||||
long thisTaskId = Long.parseLong(taskId);
|
long thisTaskId = Long.parseLong(taskId);
|
||||||
// 查询维修任务信息
|
// 查询维修任务信息
|
||||||
RepairTask repairTaskInfo = repairMapper.getRepairTaskInfoByTaskId(thisTaskId);
|
RepairTask repairTaskInfo = repairMapper.getRepairTaskInfoByTaskId(thisTaskId);
|
||||||
// 查询维修任务详情
|
|
||||||
List<RepairDeviceListVo> repairMaTypeList = getRepairMaTypeList(new RepairTaskDetails(taskId));
|
|
||||||
// TODO: 待完善--查询维修配件信息
|
|
||||||
List<RepairPartDetails> partList = new ArrayList<>();
|
|
||||||
if (Objects.isNull(repairTaskInfo)) {
|
if (Objects.isNull(repairTaskInfo)) {
|
||||||
return AjaxResult.error("未查询到维修任务信息");
|
return AjaxResult.error("未查询到维修任务信息");
|
||||||
}
|
}
|
||||||
|
// 查询维修任务详情
|
||||||
|
List<RepairDeviceListVo> repairMaTypeGroupList = getRepairMaTypeList(new RepairTaskDetails(taskId), true);
|
||||||
|
List<RepairPart> repairPartList = repairAuditDetailsMapper.getPartDetailsByTaskId(new RepairAuditDetails().setTaskId(thisTaskId));
|
||||||
|
repairPartList = mergePartsNum(repairPartList);
|
||||||
|
|
||||||
// 组装result返回对象
|
|
||||||
RepairTicketVo result = new RepairTicketVo()
|
RepairTicketVo result = new RepairTicketVo()
|
||||||
.setRepairTaskInfo(repairTaskInfo)
|
.setRepairTaskInfo(repairTaskInfo)
|
||||||
.setRepairDeviceArray(repairMaTypeList);
|
.setRepairDeviceArray(repairMaTypeGroupList)
|
||||||
|
.setRepairPartArray(Optional.of(repairPartList).orElse(new ArrayList<>()));
|
||||||
|
|
||||||
return AjaxResult.success(result);
|
return AjaxResult.success(result);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
@ -133,6 +141,22 @@ public class RepairServiceImpl implements RepairService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<RepairPart> mergePartsNum(@NotNull List<RepairPart> devices) {
|
||||||
|
try {
|
||||||
|
Map<String, RepairPart> map = devices.stream().filter(Objects::nonNull).collect(Collectors.toConcurrentMap(
|
||||||
|
device -> device.getTypeId() + ":" + device.getPartCost() + ":" + device.getPartName(),
|
||||||
|
device -> device, (existing, recently) -> {
|
||||||
|
existing.setPartNum(existing.getPartNum() + recently.getPartNum());
|
||||||
|
return existing;
|
||||||
|
},
|
||||||
|
ConcurrentHashMap::new
|
||||||
|
));
|
||||||
|
return new ArrayList<>(map.values());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("Error merging parts" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交维修记录
|
* 提交维修记录
|
||||||
* @param bean repairApplyRecord
|
* @param bean repairApplyRecord
|
||||||
|
|
|
||||||
|
|
@ -483,4 +483,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="getPartDetailsByTaskId" resultType="com.bonus.material.repair.domain.RepairPart">
|
||||||
|
select
|
||||||
|
mpt.pa_name as partName,
|
||||||
|
rpd.part_num as partNum,
|
||||||
|
rpd.part_cost as partCost,
|
||||||
|
rpd.part_type as partType,
|
||||||
|
rpd.type_id as typeId,
|
||||||
|
mt.type_name as typeName,
|
||||||
|
mt1.type_name as maTypeName,
|
||||||
|
rpd.remark as remark,
|
||||||
|
rpd.repair_content as repairContent
|
||||||
|
from
|
||||||
|
repair_part_details rpd
|
||||||
|
left join ma_part_type mpt on mpt.pa_id = rpd.part_id
|
||||||
|
left join ma_type mt on rpd.type_id = mt.type_id and mt.del_flag = 0
|
||||||
|
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = 0
|
||||||
|
<where>
|
||||||
|
<if test="taskId != null and taskId != ''">
|
||||||
|
and rpd.task_id = #{taskId}
|
||||||
|
</if>
|
||||||
|
<if test="maId != null and maId != ''">
|
||||||
|
and rpd.ma_id = #{maId}
|
||||||
|
</if>
|
||||||
|
<if test="typeId != null and typeId != ''">
|
||||||
|
and rpd.type_id = #{typeId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue