维修管理--代码逻辑优化、注解调整
This commit is contained in:
parent
b3a578e91b
commit
befffbc5a8
|
|
@ -18,6 +18,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -26,6 +27,7 @@ import javax.validation.constraints.NotNull;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author syruan
|
||||
|
|
@ -84,7 +86,7 @@ public class RepairController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "获取维修物资设备列表---分页")
|
||||
@GetMapping("/getRepairMaTypeList")
|
||||
@RequiresPermissions("repair:manage:preview")
|
||||
// @RequiresPermissions("repair:manage:preview")
|
||||
public TableDataInfo getRepairMaTypeList(RepairTaskDetails bean) {
|
||||
startPage();
|
||||
List<RepairDeviceListVo> list = service.getRepairMaTypeList(bean);
|
||||
|
|
@ -92,7 +94,7 @@ public class RepairController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取维修任务机具列表
|
||||
* 获取维修任务机具列表--Ⅱ级页面详情列表
|
||||
*/
|
||||
@ApiOperation(value = "获取维修物资设备列表---不分页")
|
||||
@GetMapping("/getAppRepairMaTypeList")
|
||||
|
|
@ -109,8 +111,10 @@ public class RepairController extends BaseController {
|
|||
public AjaxResult submitRepairApply(@RequestBody @NotNull RepairApplyRecord bean) {
|
||||
try {
|
||||
String partStrList = bean.getPartStrList();
|
||||
List<RepairPartDetails> repairPartDetails = objectMapper.readValue(partStrList, new TypeReference<List<RepairPartDetails>>() {});
|
||||
bean.setPartList(repairPartDetails);
|
||||
if (StringUtils.isNoneBlank(partStrList)) {
|
||||
List<RepairPartDetails> repairPartDetails = objectMapper.readValue(partStrList, new TypeReference<List<RepairPartDetails>>() {});
|
||||
bean.setPartList(Optional.ofNullable(repairPartDetails).orElse(new ArrayList<>()));
|
||||
}
|
||||
return service.submitRepairApply(bean);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new ServiceException("Jackson反序列化异常:" + e.getMessage());
|
||||
|
|
@ -118,27 +122,36 @@ public class RepairController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 快捷维修记录
|
||||
* 快捷维修 1.把维修都设置为内部维修,增加维修配件明细
|
||||
*/
|
||||
@ApiOperation(value = "快捷维修记录")
|
||||
@ApiOperation(value = "快捷维修--批量--默认内部维修")
|
||||
@PostMapping("/fastRepairApply")
|
||||
public AjaxResult fastRepairApply(@RequestBody List<RepairTaskDetails> list) {
|
||||
return service.fastRepairApply(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成维修
|
||||
* 批量维修 1.判断维修方式,增加维修配件明细
|
||||
*/
|
||||
@ApiOperation(value = "完成维修")
|
||||
@ApiOperation(value = "批量维修--批量--按照传参维修方式进行维修")
|
||||
@PostMapping("/batchRepairApply")
|
||||
public AjaxResult batchRepairApply(@RequestBody List<RepairTaskDetails> list) {
|
||||
return service.fastRepairApply(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 维修明细--批量审核--更新明细status
|
||||
*/
|
||||
@ApiOperation(value = "维修明细更新status--批量")
|
||||
@PostMapping("/completeRepair")
|
||||
public AjaxResult completeRepair(@RequestBody ArrayList<Long> ids) {
|
||||
return toAjax(service.completeRepair(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交审核
|
||||
* 任务维修完成--提交修饰审核
|
||||
*/
|
||||
@ApiOperation(value = "提交审核")
|
||||
@ApiOperation(value = "任务维修完成--提交至修饰审核")
|
||||
@PostMapping("/endRepairTask")
|
||||
public AjaxResult endRepairTask(@RequestBody ArrayList<RepairTask> taskList) {
|
||||
return service.endRepairTask(taskList);
|
||||
|
|
@ -147,7 +160,7 @@ public class RepairController extends BaseController {
|
|||
/**
|
||||
* 驳回退料--批量
|
||||
*/
|
||||
@ApiOperation(value = "驳回退料")
|
||||
@ApiOperation(value = "驳回退料--批量")
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult rejectRepair(@PathVariable Long[] ids) {
|
||||
return service.rejectRepair(Arrays.asList(ids));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,13 @@ public class RepairTask {
|
|||
*/
|
||||
@ApiModelProperty(value = "任务id")
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty(value = "任务状态")
|
||||
private Integer taskStatus;
|
||||
|
||||
@ApiModelProperty(value = "任务类型")
|
||||
private Integer taskType;
|
||||
|
||||
/**
|
||||
* 维修单号
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ package com.bonus.material.repair.domain.vo;
|
|||
|
||||
import com.bonus.material.repair.domain.RepairPart;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.List;
|
|||
* @Description: 维修设备VO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RepairDeviceVO {
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
|
|
@ -37,10 +39,77 @@ public class RepairDeviceVO {
|
|||
@ApiModelProperty(value = "维修配件信息")
|
||||
private String partInfo;
|
||||
|
||||
@ApiModelProperty(value = "维修方式: 1内部 2外部返厂 3报废")
|
||||
private Integer repairType;
|
||||
|
||||
@ApiModelProperty(value = "附件")
|
||||
private String fileUrl;
|
||||
|
||||
@ApiModelProperty(value = "维修配件集合")
|
||||
private List<RepairPart> repairPartList;
|
||||
@ApiModelProperty(value = "编码--内部维修配件集合")
|
||||
private List<RepairPart> codeInRepairPartList;
|
||||
|
||||
@ApiModelProperty(value = "编码--返厂维修配件集合")
|
||||
private List<RepairPart> codeOutRepairPartList;
|
||||
|
||||
@ApiModelProperty(value = "编码--报废维修配件集合")
|
||||
private List<RepairPart> codeScrapRepairPartList;
|
||||
|
||||
@ApiModelProperty(value = "数量--内部维修配件集合")
|
||||
private List<RepairPart> numberInRepairPartList;
|
||||
|
||||
@ApiModelProperty(value = "数量--返厂维修配件集合")
|
||||
private List<RepairPart> numberOutRepairPartList;
|
||||
|
||||
@ApiModelProperty(value = "数量--报废维修配件集合")
|
||||
private List<RepairPart> numberScrapRepairPartList;
|
||||
|
||||
// 手动覆盖 getter 方法,确保 List 始终被初始化
|
||||
public List<RepairPart> getCodeInRepairPartList() {
|
||||
if (this.codeInRepairPartList == null) {this.codeInRepairPartList = new ArrayList<>();}
|
||||
return this.codeInRepairPartList;
|
||||
}
|
||||
|
||||
public List<RepairPart> getCodeOutRepairPartList() {
|
||||
if (this.codeOutRepairPartList == null) {this.codeOutRepairPartList = new ArrayList<>();}
|
||||
return this.codeOutRepairPartList;
|
||||
}
|
||||
|
||||
public List<RepairPart> getCodeScrapRepairPartList() {
|
||||
if (this.codeScrapRepairPartList == null) {this.codeScrapRepairPartList = new ArrayList<>();}
|
||||
return this.codeScrapRepairPartList;
|
||||
}
|
||||
|
||||
public List<RepairPart> getNumberInRepairPartList() {
|
||||
if (this.numberInRepairPartList == null) {this.numberInRepairPartList = new ArrayList<>();}
|
||||
return this.numberInRepairPartList;
|
||||
}
|
||||
|
||||
public List<RepairPart> getNumberOutRepairPartList() {
|
||||
if (this.numberOutRepairPartList == null) {this.numberOutRepairPartList = new ArrayList<>();}
|
||||
return this.numberOutRepairPartList;
|
||||
}
|
||||
|
||||
public List<RepairPart> getNumberScrapRepairPartList() {
|
||||
if (this.numberScrapRepairPartList == null) {this.numberScrapRepairPartList = new ArrayList<>();}
|
||||
return this.numberScrapRepairPartList;
|
||||
}
|
||||
|
||||
// 自定义 clear 方法
|
||||
public void clear() {
|
||||
this.id = null;
|
||||
this.taskId = null;
|
||||
this.typeName = null;
|
||||
this.type = null;
|
||||
this.code = null;
|
||||
this.status = null;
|
||||
this.partInfo = null;
|
||||
this.repairType = null;
|
||||
this.fileUrl = null;
|
||||
this.codeInRepairPartList.clear();
|
||||
this.codeOutRepairPartList.clear();
|
||||
this.codeScrapRepairPartList.clear();
|
||||
this.numberInRepairPartList.clear();
|
||||
this.numberOutRepairPartList.clear();
|
||||
this.numberScrapRepairPartList.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public interface RepairMapper {
|
|||
* @param taskList 任务列表集合
|
||||
* @param userid 用户id
|
||||
*/
|
||||
int updateTaskStatus(@Param("taskList") List<RepairTask> taskList, @Param("userId") Long userid);
|
||||
int updateTaskStatus(@Param("taskList") List<RepairTask> taskList, @Param("userId") Long userid, @Param("taskStatus") Integer taskStatus);
|
||||
|
||||
/**
|
||||
* 新增任务
|
||||
|
|
@ -123,7 +123,7 @@ public interface RepairMapper {
|
|||
List<RepairTaskDetails> getDetailsListByTaskId(RepairTask task);
|
||||
|
||||
/**
|
||||
* 新增实验建议审核数据
|
||||
* 新增修饰审核审核数据
|
||||
* @param details 数据详情
|
||||
*/
|
||||
int addAuditDetails(RepairTaskDetails details);
|
||||
|
|
|
|||
|
|
@ -25,15 +25,11 @@ public interface RepairService {
|
|||
|
||||
/**
|
||||
* 获取维修详细列表
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean);
|
||||
|
||||
/**
|
||||
* 新增维修记录
|
||||
* @param bean
|
||||
* @return
|
||||
* 提交维修记录
|
||||
*/
|
||||
AjaxResult submitRepairApply(RepairApplyRecord bean);
|
||||
|
||||
|
|
@ -45,9 +41,7 @@ public interface RepairService {
|
|||
AjaxResult fastRepairApply(List<RepairTaskDetails> list);
|
||||
|
||||
/**
|
||||
* 完成维修
|
||||
* @param ids
|
||||
* @return
|
||||
* 维修明细--批量审核--更新明细status
|
||||
*/
|
||||
int completeRepair(ArrayList<Long> ids);
|
||||
|
||||
|
|
@ -59,8 +53,7 @@ public interface RepairService {
|
|||
|
||||
/**
|
||||
* 提交审核
|
||||
* @param taskList
|
||||
* @return
|
||||
* @param taskList 任务信息集合
|
||||
*/
|
||||
AjaxResult endRepairTask(List<RepairTask> taskList);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.bonus.material.repair.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.bonus.common.biz.enums.RepairTaskStatusEnum;
|
||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
|
|
@ -13,7 +15,6 @@ import com.bonus.material.repair.domain.vo.RepairDeviceListVo;
|
|||
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
|
||||
import com.bonus.material.repair.mapper.RepairMapper;
|
||||
import com.bonus.material.repair.service.RepairService;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
|
|
@ -24,12 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author syruan
|
||||
|
|
@ -40,6 +37,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
@Resource
|
||||
private RepairMapper repairMapper;
|
||||
|
||||
@Resource
|
||||
private TmTaskMapper taskMapper;
|
||||
|
||||
|
||||
|
|
@ -62,7 +60,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
return repairMaTypeList;
|
||||
}
|
||||
|
||||
// 创建Map集合,用于快速分组
|
||||
// 创建Map集合,用于快速分组,使用 ConcurrentHashMap 保证线程安全
|
||||
Map<Long, RepairDeviceListVo> resultMap = new ConcurrentHashMap<>();
|
||||
|
||||
// 遍历处理,把相同的父级对象,拆分到子集合中
|
||||
|
|
@ -83,54 +81,54 @@ public class RepairServiceImpl implements RepairService {
|
|||
return;
|
||||
}
|
||||
|
||||
// 使用 computeIfAbsent 方法,如果 key 不存在,则创建一个新对象,并添加到 resultMap 中
|
||||
resultMap.computeIfAbsent(item.getTypeNameId(), k -> {
|
||||
item.getRepairDeviceList().add(repairDeviceVO);
|
||||
return item;
|
||||
}).getRepairDeviceList().add(repairDeviceVO);
|
||||
|
||||
// 使用 computeIfAbsent 方法,如果 key 不存在,则创建一个新对象,并添加到 resultMap 中
|
||||
resultMap.computeIfAbsent(item.getTypeNameId(), k -> item).getRepairDeviceList().add(repairDeviceVO);
|
||||
});
|
||||
|
||||
return new ArrayList<>(resultMap.values());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增维修记录
|
||||
* 提交维修记录
|
||||
* @param bean repairApplyRecord
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult submitRepairApply(RepairApplyRecord bean) {
|
||||
public AjaxResult submitRepairApply(@NotNull(message = "参数不能为空") RepairApplyRecord bean) {
|
||||
// 获取维修详情记录:待维修、已维修、报废的数量
|
||||
RepairTaskDetails details = repairMapper.getById(bean.getId());
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
bean.setCreateBy(String.valueOf(loginUser.getUserid()));
|
||||
|
||||
// 获取维修配件列表
|
||||
List<RepairPartDetails> partList = bean.getPartList();
|
||||
BigDecimal sfCosts = new BigDecimal("0");
|
||||
String nbType = "1";
|
||||
String fcType = "2";
|
||||
|
||||
// 内部维修类型
|
||||
String inRepairType = "1";
|
||||
// 返厂维修类型
|
||||
String outRepairType = "2";
|
||||
// 收费配件
|
||||
String sfPart = "1";
|
||||
// 不收费配件
|
||||
String bsfPart = "0";
|
||||
if (partList != null && !partList.isEmpty()) {
|
||||
|
||||
if (CollectionUtil.isNotEmpty(partList)) {
|
||||
bean.setRepairNum(partList.get(0).getRepairNum());
|
||||
bean.setRepairer(partList.get(0).getRepairer());
|
||||
}
|
||||
|
||||
// 根据维修类型,更新维修数量、报废数量
|
||||
switch (bean.getRepairType()) {
|
||||
case "1": {
|
||||
int repairNum = details.getRepairedNum() + bean.getRepairNum();
|
||||
int num = repairNum + details.getScrapNum();
|
||||
if (num > details.getRepairNum()) {
|
||||
throw new ServiceException("维修数量大于维修总量");
|
||||
}
|
||||
int repairNum = getNum(bean, details);
|
||||
// 更新维修数量、并修改维修人员
|
||||
repairMapper.updateRepairedNum(bean.getId(), repairNum, Long.valueOf(bean.getRepairer()), loginUser.getUserid());
|
||||
break;
|
||||
}
|
||||
case "2": {
|
||||
int repairNum = details.getRepairedNum() + bean.getRepairNum();
|
||||
int num = repairNum + details.getScrapNum();
|
||||
if (num > details.getRepairNum()) {
|
||||
throw new ServiceException("维修数量大于维修总量");
|
||||
}
|
||||
int repairNum = getNum(bean, details);
|
||||
// 更新维修数量、维修人员不变
|
||||
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
|
||||
break;
|
||||
}
|
||||
|
|
@ -140,17 +138,22 @@ public class RepairServiceImpl implements RepairService {
|
|||
if (num > details.getRepairNum()) {
|
||||
throw new ServiceException("维修数量大于维修总量");
|
||||
}
|
||||
// 更新报废数量
|
||||
repairMapper.updateScrapNum(bean.getId(), scrapNum, loginUser.getUserid());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (partList != null && !partList.isEmpty()) {
|
||||
if (nbType.equals(bean.getRepairType())) {
|
||||
|
||||
// 判断配件列表是否为空
|
||||
if (CollectionUtil.isNotEmpty(partList)) {
|
||||
// 内部维修
|
||||
if (inRepairType.equals(bean.getRepairType())) {
|
||||
// 遍历配件列表,判断配件类型,收费还是不收费
|
||||
for (RepairPartDetails partDetails : partList) {
|
||||
if (partDetails.getPartId() != null) {
|
||||
// 有维修配件时
|
||||
// 有维修配件时,如果价格为空,设置为0
|
||||
if (partDetails.getPartCost() == null) {
|
||||
partDetails.setPartCost(new BigDecimal(0));
|
||||
}
|
||||
|
|
@ -159,23 +162,30 @@ public class RepairServiceImpl implements RepairService {
|
|||
partDetails.setTypeId(bean.getTypeId());
|
||||
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
|
||||
partDetails.setCompanyId(bean.getCompanyId());
|
||||
// 根据partid 找到配件单价
|
||||
|
||||
// 根据 partId 找配件单价
|
||||
BigDecimal partPrice = repairMapper.selectPartPrice(partDetails.getPartId());
|
||||
// 设置配件费用
|
||||
partDetails.setPartCost(partPrice);
|
||||
// 添加【维修配件明细表】
|
||||
repairMapper.addPart(partDetails);
|
||||
|
||||
bean.setPartPrice(partDetails.getPartCost());
|
||||
bean.setPartId((long) partDetails.getPartId().intValue());
|
||||
bean.setPartNum(partDetails.getPartNum());
|
||||
bean.setRepairContent(partDetails.getRepairContent());
|
||||
bean.setPartType(partDetails.getPartType());
|
||||
// 添加【维修记录表】
|
||||
repairMapper.addRecord(bean);
|
||||
} else {
|
||||
// 不选维修配件时
|
||||
// 不选维修配件时, 只添加【维修记录表】
|
||||
repairMapper.addRecord(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fcType.equals(bean.getRepairType())) {
|
||||
|
||||
// 返厂维修
|
||||
if (outRepairType.equals(bean.getRepairType())) {
|
||||
bean.setPartName(partList.get(0).getPartName());
|
||||
bean.setPartType(partList.get(0).getPartType());
|
||||
bean.setRepairContent(partList.get(0).getRepairContent());
|
||||
|
|
@ -190,8 +200,11 @@ public class RepairServiceImpl implements RepairService {
|
|||
bean.setPartPrice(partList.get(0).getPartPrice());
|
||||
}
|
||||
bean.setPartNum(partList.get(0).getPartNum());
|
||||
// 新增【维修记录表】
|
||||
repairMapper.addRecord(bean);
|
||||
}
|
||||
|
||||
// 配件费用计算
|
||||
for (RepairPartDetails partDetails : partList) {
|
||||
if (partDetails.getPartCost() != null) {
|
||||
BigDecimal partCost = partDetails.getPartCost();
|
||||
|
|
@ -200,64 +213,95 @@ public class RepairServiceImpl implements RepairService {
|
|||
}
|
||||
}
|
||||
|
||||
if (!"0".equals(sfCosts.toString())) {
|
||||
// 判断是否是收费配件
|
||||
if (sfPart.equals(sfCosts.toString())) {
|
||||
// SQL: 新增【维修费用记录表】
|
||||
repairMapper.addRepairCost(bean, sfCosts, sfPart);
|
||||
}
|
||||
} else {
|
||||
// 新增预报废记录
|
||||
// 新增【维修记录表--预报废】
|
||||
repairMapper.addRecord(bean);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
private static int getNum(RepairApplyRecord bean, RepairTaskDetails details) {
|
||||
int repairNum = details.getRepairedNum() + bean.getRepairNum();
|
||||
int num = repairNum + details.getScrapNum();
|
||||
if (num > details.getRepairNum()) {
|
||||
throw new ServiceException("维修数量大于维修总量");
|
||||
}
|
||||
return repairNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult fastRepairApply(List<RepairTaskDetails> list) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
||||
// 判断待维修数量是否大于0
|
||||
for (RepairTaskDetails bean : list) {
|
||||
int repairedNum = bean.getRepairNum() - bean.getRepairedNum() - bean.getScrapNum();
|
||||
if (repairedNum <= 0) {
|
||||
throw new ServiceException("选中的数据中包含待维修数量为0的机具,请重新选择");
|
||||
}
|
||||
}
|
||||
|
||||
// 执行SQL: 1.增加【维修记录表】、 2.修改【维修明细表】的维修数量
|
||||
for (RepairTaskDetails bean : list) {
|
||||
int repairedNum = bean.getRepairNum() - bean.getRepairedNum() - bean.getScrapNum();
|
||||
RepairApplyRecord partDetails = new RepairApplyRecord();
|
||||
partDetails.setTaskId(Long.valueOf(bean.getTaskId()));
|
||||
partDetails.setMaId(Long.valueOf(bean.getMaId()));
|
||||
partDetails.setTypeId(Long.valueOf(bean.getTypeId()));
|
||||
partDetails.setRepairNum(repairedNum);
|
||||
partDetails.setRepairType("1");
|
||||
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
|
||||
partDetails.setCompanyId(bean.getCompanyId());
|
||||
repairMapper.addRecord(partDetails);
|
||||
RepairApplyRecord repairRecord = new RepairApplyRecord();
|
||||
repairRecord.setTaskId(Long.valueOf(bean.getTaskId()));
|
||||
repairRecord.setMaId(Long.valueOf(bean.getMaId()));
|
||||
repairRecord.setTypeId(Long.valueOf(bean.getTypeId()));
|
||||
repairRecord.setRepairNum(repairedNum);
|
||||
// 快捷维修,设置为内部维修
|
||||
repairRecord.setRepairType("1");
|
||||
repairRecord.setCreateBy(String.valueOf(loginUser.getUserid()));
|
||||
repairRecord.setCompanyId(bean.getCompanyId());
|
||||
repairMapper.addRecord(repairRecord);
|
||||
int i = repairedNum + bean.getRepairedNum();
|
||||
repairMapper.updateRepairedNumTwo(bean.getId(), i, loginUser.getUserid());
|
||||
}
|
||||
|
||||
// 执行完毕,无异常返回至前端
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult endRepairTask(List<RepairTask> taskList) {
|
||||
public AjaxResult endRepairTask(@NotNull List<RepairTask> taskList) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
||||
// 1.查询选择任务是否还有未完成维修的数据
|
||||
for (RepairTask task : taskList) {
|
||||
int i = repairMapper.getUnFinish(task);
|
||||
if (i > 0) {
|
||||
throw new ServiceException("选中的数据中包含维修未完成的,请完成维修再进行提交审核");
|
||||
if (repairMapper.getUnFinish(task) > 0) {
|
||||
return AjaxResult.error("选中的数据中包含维修未完成的,请完成维修再进行提交审核");
|
||||
}
|
||||
}
|
||||
int i = repairMapper.updateTaskStatus(taskList, loginUser.getUserid());
|
||||
|
||||
// 2.更新tm_task任务状态
|
||||
repairMapper.updateTaskStatus(taskList, loginUser.getUserid(), RepairTaskStatusEnum.TASK_STATUS_COMPLETE.getStatus());
|
||||
|
||||
// 3.业务逻辑处理
|
||||
for (RepairTask task : taskList) {
|
||||
task.setCreateBy(loginUser.getUserid());
|
||||
// 查询任务的协议id
|
||||
Long agreementId = repairMapper.getAgreementId(task);
|
||||
// 查询维修任务的详情表
|
||||
List<RepairTaskDetails> detailsList = repairMapper.getDetailsListByTaskId(task);
|
||||
// 新增tm_task表数据、修饰审核任务、状态是待审核
|
||||
task.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR_STORAGE.getTaskTypeId());
|
||||
task.setTaskStatus(RepairTaskStatusEnum.TASK_STATUS_TO_EXAM.getStatus());
|
||||
repairMapper.addTask(task);
|
||||
|
||||
// 循环插入【修饰审核明细表】
|
||||
for (RepairTaskDetails details : detailsList) {
|
||||
details.setCreateBy(String.valueOf(loginUser.getUserid()));
|
||||
details.setTaskId(task.getTaskId());
|
||||
repairMapper.addAuditDetails(details);
|
||||
}
|
||||
// 新增协议任务表--关联修饰任务与协议
|
||||
task.setAgreementId(agreementId);
|
||||
repairMapper.createAgreementTask(task);
|
||||
}
|
||||
|
|
@ -270,12 +314,14 @@ public class RepairServiceImpl implements RepairService {
|
|||
taskList.forEach(taskId -> taskMapper.updateTmTaskStatusByTaskId(taskId, RepairTaskStatusEnum.TASK_STATUS_REJECT.getStatus()));
|
||||
} catch (DataAccessException e) {
|
||||
System.err.println(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
return AjaxResult.error("数据库SQL修改执行失败" + e.getMessage());
|
||||
}
|
||||
return AjaxResult.success("执行完成");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 维修明细--批量审核--更新明细status
|
||||
*/
|
||||
@Override
|
||||
public int completeRepair(ArrayList<Long> ids) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<insert id="addTask" useGeneratedKeys="true" keyProperty="taskId">
|
||||
insert into tm_task (task_status,task_type,code,create_by,create_time,company_id)
|
||||
values (46,45,#{repairCode},#{createBy},now(),#{companyId});
|
||||
values (#{taskStatus},#{taskType},#{repairCode},#{createBy},now(),#{companyId});
|
||||
</insert>
|
||||
|
||||
<insert id="createAgreementTask">
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
|
||||
<update id="updateTaskStatus">
|
||||
update tm_task
|
||||
set task_status = '44',
|
||||
set task_status = #{taskStatus},
|
||||
update_by = #{userId},
|
||||
update_time = now()
|
||||
where task_id in
|
||||
|
|
|
|||
Loading…
Reference in New Issue