Merge remote-tracking branch 'origin/master'

This commit is contained in:
jjLv 2024-11-25 09:29:30 +08:00
commit 842c064c41
9 changed files with 393 additions and 151 deletions

View File

@ -0,0 +1,25 @@
package com.bonus.common.biz.enums;
import lombok.Getter;
/**
* @author : xsheng
* @time : 2024-11-23 12:50
* @Description: 维修类型
*/
@Getter
public enum RepairTypeEnum {
PASS(0, "合格"),
INNER_REPAIR(1, "内部维修"),
RETURN_FACTORY(2, "返厂维修"),
TO_SCRAP(3, "待报废");
private final Integer typeId;
private final String typeName;
RepairTypeEnum(Integer typeId, String typeName) {
this.typeId = typeId;
this.typeName = typeName;
}
}

View File

@ -10,7 +10,7 @@ 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;
import com.bonus.system.api.domain.SysUser;
@ -73,14 +73,14 @@ public class RepairController extends BaseController {
/**
* 获取维修任务物资设备列表--不分页
*/
@ApiOperation(value = "获取维修物资设备列表---分页")
@GetMapping("/getRepairMaTypeList")
// @RequiresPermissions("repair:manage:preview")
public TableDataInfo getRepairMaTypeList(RepairTaskDetails bean) {
startPage();
List<RepairDeviceListVo> list = service.getRepairMaTypeList(bean);
return getDataTable(list);
}
// @ApiOperation(value = "获取维修物资设备列表---分页")
// @GetMapping("/getRepairMaTypeList")
//// @RequiresPermissions("repair:manage:preview")
// public TableDataInfo getRepairMaTypeList(RepairTaskDetails bean) {
// startPage();
// List<RepairDeviceListVo> list = service.getRepairMaTypeList(bean);
// return getDataTable(list);
// }
/**
* 获取维修任务机具列表--级页面详情列表
@ -88,7 +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);
return AjaxResult.success(list);
}
@ -96,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);
}
/**

View File

@ -0,0 +1,69 @@
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;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@EqualsAndHashCode(callSuper = false)
@Data
public class RepairDeviceSummaryVo extends BaseVO {
@ApiModelProperty(value = "id")
private Long[] ids;
@ApiModelProperty(value = "任务ID")
private Long taskId;
@ApiModelProperty(value = "类型id")
private Long typeNameId;
@ApiModelProperty(value = "设备编码")
private String code;
@ApiModelProperty(value = "类型名称")
private String typeName;
@ApiModelProperty(value = "规格型号id")
private Long typeId;
@ApiModelProperty(value = "规格型号")
private String type;
@ApiModelProperty(value = "设备单位")
private String unitName;
@ApiModelProperty(value = "管理模式")
private Integer manageType;
@ApiModelProperty(value = "设备表主键id")
private Long[] maIds;
@ApiModelProperty(value = "维修人员")
private String[] repairers;
@ApiModelProperty(value = "维修总量")
private int typeRepairNum;
@ApiModelProperty(value = "已修数量")
private int typeRepairedNum;
@ApiModelProperty(value = "维修报废数量")
private int typeScrapNum;
// @ApiModelProperty(value = "维修费用记录条数")
// private Integer typeCostRecords;
@ApiModelProperty(value = "维修费用合计")
private BigDecimal typeCost;
@ApiModelProperty(value = "内层物资类型集合")
private List<RepairDeviceVO> repairDeviceList = new ArrayList<>();
@ApiModelProperty(value = "报废附件")
private List<BmFileInfo> fileList;
}

View File

@ -1,11 +1,11 @@
package com.bonus.material.repair.domain.vo;
import com.bonus.material.repair.domain.RepairPart;
import com.bonus.material.basic.domain.BmFileInfo;
import com.bonus.material.repair.domain.RepairPartDetails;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@ -40,6 +40,12 @@ public class RepairDeviceVO {
@ApiModelProperty(value = "设备编码")
private String code;
@ApiModelProperty(value = "设备单位")
private String unitName;
@ApiModelProperty(value = "管理模式")
private Integer manageType;
@ApiModelProperty(value = "状态")
private String status;
@ -52,9 +58,6 @@ public class RepairDeviceVO {
@ApiModelProperty(value = "维修人员")
private String repairer;
@ApiModelProperty(value = "管理模式")
private Integer manageType;
@ApiModelProperty(value = "附件")
private String fileUrl;
@ -67,6 +70,12 @@ public class RepairDeviceVO {
@ApiModelProperty(value = "维修报废数量")
private int scrapNum;
@ApiModelProperty(value = "维修费用记录条数")
private Integer totalCostRecords;
@ApiModelProperty(value = "维修费用小计计")
private BigDecimal totalCost;
@ApiModelProperty(value = "编码--内部维修配件集合")
private List<RepairPartDetails> codeInRepairPartList;
@ -85,6 +94,9 @@ public class RepairDeviceVO {
@ApiModelProperty(value = "数量--报废维修配件集合")
private List<RepairPartDetails> numberScrapRepairPartList;
@ApiModelProperty(value = "报废附件")
private List<BmFileInfo> fileList;
// 手动覆盖 getter 方法确保 List 始终被初始化
public List<RepairPartDetails> getCodeInRepairPartList() {
if (this.codeInRepairPartList == null) {this.codeInRepairPartList = new ArrayList<>();}

View File

@ -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;
}
}

View File

@ -5,6 +5,7 @@ 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.RepairDeviceVO;
import com.bonus.system.api.domain.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -30,11 +31,13 @@ public interface RepairMapper {
*/
RepairTask getRepairTaskInfoByTaskId(Long taskId);
List<RepairDeviceVO> getRepairDeviceList(RepairTaskDetails bean);
/**
* 获取维修详细列表
* @param bean 维修任务详情--查询条件
*/
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean);
// List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean);
/**
* 新增维修记录
@ -57,6 +60,18 @@ public interface RepairMapper {
*/
int updateRepairedNum(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("repairer") Long repairer, @Param("userId") Long userId);
int updateRepairedNumAndStatus(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("status") int status, @Param("repairer") Long repairer, @Param("userId") Long userId);
/**
* 修改维修数量
* @param id 主键 key
* @param repairNum 维修数量
* @param userid 用户id
*/
int updateRepairedNumTwo(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("userId") Long userid);
int updateRepairedNumTwoAndStatus(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("status") int status, @Param("userId") Long userid);
/**
* 修改报废数量
* @param id 主键key
@ -65,6 +80,8 @@ public interface RepairMapper {
*/
int updateScrapNum(@Param("id") Long id, @Param("scrapNum") int scrapNum, @Param("userId") Long userId);
int updateScrapNumAndStatus(@Param("id") Long id, @Param("scrapNum") int scrapNum, @Param("status") int status, @Param("userId") Long userId);
/**
* 新增配件维修记录
* @param partDetails 配件详情
@ -108,14 +125,6 @@ public interface RepairMapper {
*/
int createAgreementTask(RepairTask task);
/**
* 修改维修数量
* @param id 主键 key
* @param repairNum 维修数量
* @param userid 用户id
*/
int updateRepairedNumTwo(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("userId") Long userid);
/**
* 查询是否存在未完成维修的
* @param task 任务信息

View File

@ -6,10 +6,9 @@ import com.bonus.material.repair.domain.RepairApplyRecord;
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.system.api.domain.SysUser;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
@ -30,16 +29,20 @@ public interface RepairService {
/**
* 获取维修详细列表
*/
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup);
// List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean, boolean isGroup);
default List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean) {
return getRepairMaTypeList(bean, true);
}
List<RepairDeviceSummaryVo> getRepairDeviceSummary(RepairTaskDetails bean);
// default List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean) {
// return getRepairMaTypeList(bean, true);
// }
/**
* 查询维修单
*/
AjaxResult getRepairTicketInfo(@NotBlank(message = "TaskId参数不能为空") String taskId);
AjaxResult getRepairDocumentInfo(@NotBlank(message = "TaskId参数不能为空") String taskId);
/**
* 提交维修记录

View File

@ -3,7 +3,9 @@ package com.bonus.material.repair.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.NumberUtil;
import com.bonus.common.biz.enums.MaTypeManageTypeEnum;
import com.bonus.common.biz.enums.RepairTaskStatusEnum;
import com.bonus.common.biz.enums.RepairTypeEnum;
import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.web.domain.AjaxResult;
@ -11,7 +13,7 @@ import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.basic.domain.BmFileInfo;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.repair.domain.*;
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.domain.vo.RepairTicketVo;
import com.bonus.material.repair.mapper.RepairAuditDetailsMapper;
@ -24,9 +26,7 @@ import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@ -54,10 +54,9 @@ public class RepairServiceImpl implements RepairService {
private RepairAuditDetailsMapper repairAuditDetailsMapper;
// 1:内部维修 2:外部返厂维修 3:报废
private final int inRepairType = 1, outRepairType = 2, scrapRepairType = 3;
// 维修管理方式--0编码管理 1数量管理
private final int manageTypeByCode = 0, manageTypeByNumber = 1;
private final int INNER_REPAIR = 1; // 需要严格匹配枚举值 RepairTypeEnum.INNER_REPAIR.getTypeId();
private final int RETURN_FACTORY = 2; // 需要严格匹配枚举值 RepairTypeEnum.RETURN_FACTORY.getTypeId();
private final int TO_SCRAP = 3; // 需要严格匹配枚举值 RepairTypeEnum.TO_SCRAP.getTypeId();
@Override
public List<RepairTask> getRepairTaskList(RepairTask bean) {
@ -70,53 +69,92 @@ public class RepairServiceImpl implements RepairService {
}
@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);
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));
for (Long key : map.keySet()) {
List<RepairDeviceVO> tempList = map.get(key);
if (CollectionUtil.isNotEmpty(tempList)) {
RepairDeviceSummaryVo vo = new RepairDeviceSummaryVo();
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);
vo.setRepairDeviceList(tempList);
vo.setIds(ids);
vo.setTypeRepairNum(repairNumSum);
vo.setTypeRepairedNum(repairedNumSum);
//vo.setTypeCost(typeCostSum);
vo.setTaskId(tempList.get(0).getTaskId());
vo.setCode(tempList.get(0).getCode());
vo.setTypeName(tempList.get(0).getTypeName());
vo.setTypeId(tempList.get(0).getTypeId());
vo.setType(tempList.get(0).getType());
vo.setUnitName(tempList.get(0).getUnitName());
vo.setManageType(tempList.get(0).getManageType());
repairDeviceSummaryVoList.add(vo);
}
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;
});
});
return new ArrayList<>(resultMap.values());
}
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());
// }
/**
* 查询维修单
* @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参数非数字类型,参数类型错误");
}
@ -128,12 +166,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);
@ -143,7 +192,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);
@ -205,19 +254,19 @@ public class RepairServiceImpl implements RepairService {
// 根据维修类型更新维修数量报废数量
switch (bean.getRepairType()) {
case inRepairType: {
case INNER_REPAIR: {
int repairNum = verifyRepairNum(bean, details);
// 更新维修数量并修改维修人员
repairMapper.updateRepairedNum(bean.getId(), repairNum, loginUser.getUserid(), loginUser.getUserid());
break;
}
case outRepairType: {
case RETURN_FACTORY: {
int repairNum = verifyRepairNum(bean, details);
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
break;
}
case scrapRepairType: {
case TO_SCRAP: {
int scrapNum = details.getScrapNum() + bean.getScrapNum();
int num = scrapNum + details.getRepairedNum();
if (num > details.getRepairNum()) {
@ -234,7 +283,7 @@ public class RepairServiceImpl implements RepairService {
// 判断配件列表是否为空
if (CollectionUtil.isNotEmpty(partList)) {
// 内部维修
if (Objects.equals(inRepairType, bean.getRepairType())) {
if (Objects.equals(RepairTypeEnum.INNER_REPAIR.getTypeId(), bean.getRepairType())) {
// 遍历配件列表判断配件类型收费还是不收费
for (RepairPartDetails partDetails : partList) {
if (partDetails.getPartId() != null) {
@ -270,7 +319,7 @@ public class RepairServiceImpl implements RepairService {
}
// 返厂维修
if (outRepairType == bean.getRepairType()) {
if (RepairTypeEnum.RETURN_FACTORY.getTypeId().equals(bean.getRepairType())) {
bean.setPartName(partList.get(0).getPartName());
bean.setPartType(partList.get(0).getPartType());
bean.setRepairContent(partList.get(0).getRepairContent());
@ -340,7 +389,7 @@ public class RepairServiceImpl implements RepairService {
repairRecord.setTypeId(Long.valueOf(bean.getTypeId()));
repairRecord.setRepairNum(repairedNum);
// 快捷维修设置为内部维修
repairRecord.setRepairType(inRepairType);
repairRecord.setRepairType(RepairTypeEnum.INNER_REPAIR.getTypeId());
repairRecord.setCreateBy(String.valueOf(loginUser.getUserid()));
repairRecord.setCompanyId(bean.getCompanyId());
repairMapper.addRecord(repairRecord);
@ -366,30 +415,30 @@ public class RepairServiceImpl implements RepairService {
if (bean.getManageType() == null) {
throw new ServiceException("请选择物资管理方式");
}
if (Objects.equals(manageTypeByCode, bean.getManageType())) {
if (Objects.equals(MaTypeManageTypeEnum.CODE_DEVICE.getTypeId(), bean.getManageType())) {
// 物资管理方式--编码管理
if (bean.getRepairType() == null) {
continue;
}
// 根据维修方式更新维修数量报废数量
switch (bean.getRepairType()) {
case inRepairType: {
case INNER_REPAIR: {
partList = bean.getCodeInRepairPartList();
// 更新维修数量并修改维修人员
repairMapper.updateRepairedNum(bean.getId(), 1, loginUser.getUserid(), loginUser.getUserid());
repairMapper.updateRepairedNumAndStatus(bean.getId(), 1, 1, loginUser.getUserid(), loginUser.getUserid());
break;
}
case outRepairType: {
case RETURN_FACTORY: {
partList = bean.getCodeOutRepairPartList();
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwo(bean.getId(), 1, loginUser.getUserid());
repairMapper.updateRepairedNumTwoAndStatus(bean.getId(), 1, 1, loginUser.getUserid());
break;
}
case scrapRepairType: {
case TO_SCRAP: {
// 报废无需上传配件直接初始化空集合
partList = bean.getCodeScrapRepairPartList();
// 更新报废数量
repairMapper.updateScrapNum(bean.getId(), 1, loginUser.getUserid());
repairMapper.updateScrapNumAndStatus(bean.getId(), 1, 1, loginUser.getUserid());
break;
}
default:
@ -399,7 +448,7 @@ public class RepairServiceImpl implements RepairService {
// 统一处理配件集合数据
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
} else if (Objects.equals(manageTypeByNumber, bean.getManageType())) {
} else if (Objects.equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId(), bean.getManageType())) {
// 物资管理方式--数量管理
if (bean.getId() == null) {
throw new ServiceException("请完善参数维修详情ID为空!");
@ -471,7 +520,7 @@ public class RepairServiceImpl implements RepairService {
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
for (RepairPartDetails repairPartDetails : partList) {
repairApplyRecord.setId(bean.getId()).setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(outRepairType).setRepairNum(repairPartDetails.getRepairNum()).setScrapNum(0)
.setRepairType(RepairTypeEnum.RETURN_FACTORY.getTypeId()).setRepairNum(repairPartDetails.getRepairNum()).setScrapNum(0)
.setPartName(repairPartDetails.getPartName()).setPartType(repairPartDetails.getPartType())
.setRepairContent(repairPartDetails.getRepairContent()).setSupplierId(repairPartDetails.getSupplierId())
.setPartNum(repairPartDetails.getPartNum()).setRepairer(loginUser.getUsername())
@ -524,7 +573,7 @@ public class RepairServiceImpl implements RepairService {
// 维修记录表信息
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(scrapRepairType).setStatus(0L).setIsSlt(0L).setPartNum(0)
.setRepairType(RepairTypeEnum.TO_SCRAP.getTypeId()).setStatus(0L).setIsSlt(0L).setPartNum(0)
.setFileIds(fileInfo.getId() == null ? "" : String.valueOf(fileInfo.getId()))
.setRepairNum(0).setScrapNum(bean.getNumberScrapRepairPartList().get(0).getScrapNum())
.setScrapReason(bean.getNumberScrapRepairPartList().get(0).getScrapReason())
@ -539,7 +588,7 @@ public class RepairServiceImpl implements RepairService {
// 维修记录表信息
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(scrapRepairType).setStatus(0L).setIsSlt(0L).setPartNum(0)
.setRepairType(RepairTypeEnum.TO_SCRAP.getTypeId()).setStatus(0L).setIsSlt(0L).setPartNum(0)
.setRepairNum(0).setScrapNum(bean.getNumberScrapRepairPartList().get(0).getScrapNum())
.setScrapReason(bean.getNumberScrapRepairPartList().get(0).getScrapReason())
.setScrapType(bean.getNumberScrapRepairPartList().get(0).getScrapType())
@ -589,8 +638,8 @@ public class RepairServiceImpl implements RepairService {
throw new ServiceException("请选择物资管理方式");
}
// 如果是数量管理那么默认为内部维修
if (bean.getRepairType() == null && manageType == manageTypeByNumber) {
bean.setRepairType(inRepairType);
if (bean.getRepairType() == null && MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId().equals(manageType)) {
bean.setRepairType(RepairTypeEnum.INNER_REPAIR.getTypeId());
}
// 再检查还是null的话直接结束任务
if (bean.getRepairType() == null) {
@ -598,17 +647,17 @@ public class RepairServiceImpl implements RepairService {
}
// 内部维修
if (bean.getRepairType() == inRepairType) {
if (RepairTypeEnum.INNER_REPAIR.getTypeId().equals(bean.getRepairType())) {
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
// 遍历配件列表判断配件类型收费还是不收费
for (RepairPartDetails partDetails : partList) {
// 维修记录表信息
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId()).setRepairType(inRepairType);
if (manageType == manageTypeByCode) {
repairApplyRecord.setRepairNum(scrapRepairType != bean.getRepairType() ? 1 : 0);
repairApplyRecord.setScrapNum(scrapRepairType == bean.getRepairType() ? 1 : 0);
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId()).setRepairType(RepairTypeEnum.INNER_REPAIR.getTypeId());
if (MaTypeManageTypeEnum.CODE_DEVICE.getTypeId().equals(manageType)) {
repairApplyRecord.setRepairNum(!RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0);
repairApplyRecord.setScrapNum(RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0);
}
if (manageType == manageTypeByNumber) {
if (MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId().equals(manageType)) {
repairApplyRecord.setRepairNum(partDetails.getRepairNum());
}
repairApplyRecord.setCreateBy(loginUser.getUsername());
@ -650,7 +699,7 @@ public class RepairServiceImpl implements RepairService {
}
// 外部维修
if (bean.getRepairType() == outRepairType) {
if (RepairTypeEnum.RETURN_FACTORY.getTypeId().equals(bean.getRepairType())) {
// ---------------校验维修数量-----------------
// 统计已维修数量 + 本次维修数量
int repairNum = OptionalInt.of(bean.getRepairedNum()).orElse(0) + bean.getRepairNum();
@ -664,7 +713,7 @@ public class RepairServiceImpl implements RepairService {
// 编码管理--外部返厂维修
RepairApplyRecord repairApplyRecord = new RepairApplyRecord().setId(bean.getId()).setTaskId(bean.getTaskId()).setMaId(bean.getMaId())
.setTypeId(bean.getTypeId()).setRepairType(outRepairType)
.setTypeId(bean.getTypeId()).setRepairType(RepairTypeEnum.RETURN_FACTORY.getTypeId())
.setPartName(partList.get(0).getPartName())
.setPartType(partList.get(0).getPartType())
.setRepairContent(partList.get(0).getRepairContent()).setPartNum(partList.get(0).getPartNum());
@ -686,7 +735,7 @@ public class RepairServiceImpl implements RepairService {
}
// 如果是报废类型进行上传附件相关处理
if (scrapRepairType == bean.getRepairType()) {
if (RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType())) {
if (CollectionUtil.isNotEmpty(partList.get(0).getFileList())) {
for (BmFileInfo fileInfo : partList.get(0).getFileList()) {
fileInfo.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId())
@ -698,8 +747,8 @@ public class RepairServiceImpl implements RepairService {
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(bean.getRepairType()).setStatus(0L).setFileIds(String.valueOf(fileInfo.getId()))
.setRepairNum(bean.getRepairType() != scrapRepairType ? 1 : 0)
.setScrapNum(bean.getRepairType() == scrapRepairType ? 1 : 0)
.setRepairNum(!RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0)
.setScrapNum(RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0)
.setCreateBy(loginUser.getUsername());
// 不选维修配件时, 只添加维修记录表
@ -710,8 +759,8 @@ public class RepairServiceImpl implements RepairService {
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(bean.getRepairType()).setStatus(0L)
.setRepairNum(bean.getRepairType() != scrapRepairType ? 1 : 0)
.setScrapNum(bean.getRepairType() == scrapRepairType ? 1 : 0)
.setRepairNum(!RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0)
.setScrapNum(RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0)
.setCreateBy(loginUser.getUsername());
// 不选维修配件时, 只添加维修记录表
@ -724,8 +773,8 @@ public class RepairServiceImpl implements RepairService {
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(bean.getRepairType()).setStatus(0L)
.setRepairNum(bean.getRepairType() != scrapRepairType ? 1 : 0)
.setScrapNum(bean.getRepairType() == scrapRepairType ? 1 : 0)
.setRepairNum(!RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0)
.setScrapNum(RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0)
.setCreateBy(loginUser.getUsername());
// 不选维修配件时, 只添加维修记录表

View File

@ -42,6 +42,33 @@
where id = #{id}
</update>
<update id="updateRepairedNumAndStatus">
update repair_apply_details
set repaired_num = #{repairNum},
status = #{status},
repairer = #{repairer},
update_by = #{userId},
update_time = now()
where id = #{id}
</update>
<update id="updateRepairedNumTwo">
update repair_apply_details
set repaired_num = #{repairNum},
update_by = #{userId},
update_time = now()
where id = #{id}
</update>
<update id="updateRepairedNumTwoAndStatus">
update repair_apply_details
set repaired_num = #{repairNum},
status = #{status},
update_by = #{userId},
update_time = now()
where id = #{id}
</update>
<update id="updateScrapNum">
update repair_apply_details
set scrap_num = #{scrapNum},
@ -50,6 +77,15 @@
where id = #{id}
</update>
<update id="updateScrapNumAndStatus">
update repair_apply_details
set scrap_num = #{scrapNum},
status = #{status},
update_by = #{userId},
update_time = now()
where id = #{id}
</update>
<update id="completeRepair">
update repair_apply_details
set status = '1',
@ -72,14 +108,6 @@
</foreach>
</update>
<update id="updateRepairedNumTwo">
update repair_apply_details
set repaired_num = #{repairNum},
update_by = #{userId},
update_time = now()
where id = #{id}
</update>
<select id="getRepairTaskInfoByTaskId" resultType="com.bonus.material.repair.domain.RepairTask">
SELECT
rd.task_id as taskId,
@ -228,27 +256,27 @@
tt.create_time DESC
</select>
<select id="getRepairMaTypeList" resultType="com.bonus.material.repair.domain.vo.RepairDeviceListVo">
<select id="getRepairDeviceList" resultType="com.bonus.material.repair.domain.vo.RepairDeviceVO">
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
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
@ -275,6 +303,53 @@
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,
rad.repair_num as repairNum,