维修拆分
This commit is contained in:
parent
cf65ca7a08
commit
10cc6c2cde
|
|
@ -232,19 +232,4 @@ public class RepairController extends BaseController {
|
||||||
return js;
|
return js;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
|
||||||
// String url = "http://10.138.55.102:10000/api_gqj/pre";
|
|
||||||
// JSONObject js = null;
|
|
||||||
// try {
|
|
||||||
// OCRBean o = new OCRBean();
|
|
||||||
// String jsonStr = JSONObject.toJSONString(o);
|
|
||||||
// String data = "{\"code\": \"fack_code\"}"; //HttpHelper.sendHttpPostForToken(url, jsonStr);
|
|
||||||
// js = JSONObject.parseObject(data);
|
|
||||||
// System.out.println(js);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,12 @@ public class RepairTask {
|
||||||
@ApiModelProperty(value = "任务当月序号 例如:1 插入及查询时请携带任务类型")
|
@ApiModelProperty(value = "任务当月序号 例如:1 插入及查询时请携带任务类型")
|
||||||
private Integer monthOrder;
|
private Integer monthOrder;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修拆分层级")
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修拆分父级id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修单号
|
* 维修单号
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,13 @@ public class RepairTaskDetails extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "任务ID")
|
@ApiModelProperty(value = "任务ID")
|
||||||
private Long taskId;
|
private Long taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前任务ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "前任务ID")
|
||||||
|
private Long preTaskId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机具ID
|
* 机具ID
|
||||||
*/
|
*/
|
||||||
|
|
@ -114,6 +121,30 @@ public class RepairTaskDetails extends BaseEntity {
|
||||||
@ApiModelProperty(value = "维修任务编码")
|
@ApiModelProperty(value = "维修任务编码")
|
||||||
private String taskCode;
|
private String taskCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修拆分层级")
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修拆分父级id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维修前总量
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "维修前总量")
|
||||||
|
private BigDecimal preRepairNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维修前合格总量
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "维修前合格总量")
|
||||||
|
private BigDecimal preRepairedNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维修前报废总量
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "维修前报废总量")
|
||||||
|
private BigDecimal preScrapNum;
|
||||||
|
|
||||||
public RepairTaskDetails(Long taskId) {
|
public RepairTaskDetails(Long taskId) {
|
||||||
this.taskId = taskId;
|
this.taskId = taskId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ public class RepairDeviceVO {
|
||||||
@ApiModelProperty(value = "任务ID")
|
@ApiModelProperty(value = "任务ID")
|
||||||
private Long taskId;
|
private Long taskId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "任务ID")
|
||||||
|
private Long newTaskId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "设备表主键id")
|
@ApiModelProperty(value = "设备表主键id")
|
||||||
private Long maId;
|
private Long maId;
|
||||||
|
|
||||||
|
|
@ -110,6 +113,14 @@ public class RepairDeviceVO {
|
||||||
@ApiModelProperty(value = "报废附件")
|
@ApiModelProperty(value = "报废附件")
|
||||||
private List<BmFileInfo> fileList;
|
private List<BmFileInfo> fileList;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修拆分层级")
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "维修拆分父级id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
// 手动覆盖 getter 方法,确保 List 始终被初始化
|
// 手动覆盖 getter 方法,确保 List 始终被初始化
|
||||||
public List<RepairPartDetails> getCodeInRepairPartList() {
|
public List<RepairPartDetails> getCodeInRepairPartList() {
|
||||||
if (this.codeInRepairPartList == null) {this.codeInRepairPartList = new ArrayList<>();}
|
if (this.codeInRepairPartList == null) {this.codeInRepairPartList = new ArrayList<>();}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.bonus.material.repair.mapper;
|
package com.bonus.material.repair.mapper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.material.repair.domain.RepairApplyDetails;
|
import com.bonus.material.repair.domain.RepairApplyDetails;
|
||||||
|
import com.bonus.material.repair.domain.RepairAuditDetails;
|
||||||
import com.bonus.material.repair.domain.RepairTaskDetails;
|
import com.bonus.material.repair.domain.RepairTaskDetails;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|
@ -75,7 +77,21 @@ public interface RepairApplyDetailsMapper {
|
||||||
* @param repairId
|
* @param repairId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String selectById(Long repairId);
|
RepairAuditDetails selectById(Long repairId);
|
||||||
|
|
||||||
int updateStatus(@Param("repairId") Long repairId, @Param("status") Integer status);
|
int updateStatus(@Param("repairId") Long repairId, @Param("status") Integer status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取维修任务详情
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RepairTaskDetails> getList(@Param("list") ArrayList<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据旧维修任务ID获取维修任务详情
|
||||||
|
* @param oldWxTaskId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RepairTaskDetails> getRepairDetails(Long oldWxTaskId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,4 +212,25 @@ public interface RepairMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<RepairTaskDetails> getAuditDetailsById(RepairTaskDetails details);
|
List<RepairTaskDetails> getAuditDetailsById(RepairTaskDetails details);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增维修任务明细
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int insertRepaired(RepairDeviceVO bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询维修任务明细
|
||||||
|
* @param taskList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RepairTask> getRepairTaskDetails(@Param("list") List<RepairTask> taskList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询维修任务明细
|
||||||
|
* @param details
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RepairTaskDetails> getRepairDetailsById(RepairTaskDetails details);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -515,7 +515,8 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
// 查询维修审核明细
|
// 查询维修审核明细
|
||||||
final List<RepairAuditDetails> repairAuditDetailList = repairAuditDetailsMapper.selectRepairAuditDetailsByTaskIds(Collections.singletonList(repairAuditDetail.getTaskId()));
|
final List<RepairAuditDetails> repairAuditDetailList = repairAuditDetailsMapper.selectRepairAuditDetailsByTaskIds(Collections.singletonList(repairAuditDetail.getTaskId()));
|
||||||
// 批量插入维修入库明细
|
// 批量插入维修入库明细
|
||||||
batchInsertRepairInputDetails(repairAuditDetailList, agreementId);
|
List<ScrapApplyDetails> scrapApplyDetails = new ArrayList<>();
|
||||||
|
batchInsertRepairInputDetails(scrapApplyDetails, repairAuditDetailList, agreementId);
|
||||||
// 更新任务状态
|
// 更新任务状态
|
||||||
taskMapper.updateTaskStatus(String.valueOf(repairAuditDetail.getTaskId()), RepairTaskStatusEnum.TASK_STATUS_REVIEW.getStatus());
|
taskMapper.updateTaskStatus(String.valueOf(repairAuditDetail.getTaskId()), RepairTaskStatusEnum.TASK_STATUS_REVIEW.getStatus());
|
||||||
}
|
}
|
||||||
|
|
@ -577,11 +578,13 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
final RepairAuditDetails auditDetails1 = repairAuditDetails.get(0);
|
final RepairAuditDetails auditDetails1 = repairAuditDetails.get(0);
|
||||||
final String status = auditDetails1.getStatus(); // 1通过 2驳回
|
final String status = auditDetails1.getStatus(); // 1通过 2驳回
|
||||||
// 根据repairId查询前任务id
|
// 根据repairId查询前任务id
|
||||||
String preTaskId = repairApplyDetailsMapper.selectById(auditDetails1.getRepairId());
|
RepairAuditDetails dto = repairApplyDetailsMapper.selectById(auditDetails1.getRepairId());
|
||||||
|
// 查询报废详情
|
||||||
|
final List<ScrapApplyDetails> scrapApplyDetails = scrapApplyDetailsMapper.selectScrapByTaskId(dto);
|
||||||
if ("1".equals(status)) {
|
if ("1".equals(status)) {
|
||||||
//根据任务id查询协议id
|
//根据任务id查询协议id
|
||||||
final Long agreementId = taskAgreementMapper.selectAgreementIdByTaskId(auditDetails1.getTaskId());
|
final Long agreementId = taskAgreementMapper.selectAgreementIdByTaskId(auditDetails1.getTaskId());
|
||||||
batchInsertRepairInputDetails(repairAuditDetails, agreementId);
|
batchInsertRepairInputDetails(scrapApplyDetails,repairAuditDetails, agreementId);
|
||||||
} else if ("2".equals(status)) {
|
} else if ("2".equals(status)) {
|
||||||
for (final RepairAuditDetails auditDetails : repairAuditDetails) {
|
for (final RepairAuditDetails auditDetails : repairAuditDetails) {
|
||||||
repairApplyDetailsMapper.updateRepairApplyDetailsAfterReject(
|
repairApplyDetailsMapper.updateRepairApplyDetailsAfterReject(
|
||||||
|
|
@ -589,7 +592,7 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
ObjectUtils.defaultIfNull(auditDetails.getScrapNum(),0).longValue(), auditDetails.getRepairId());
|
ObjectUtils.defaultIfNull(auditDetails.getScrapNum(),0).longValue(), auditDetails.getRepairId());
|
||||||
repairApplyDetailsMapper.updateStatus(auditDetails.getRepairId(), RepairTaskStatusEnum.TASK_STATUS_PROCESSING.getStatus());
|
repairApplyDetailsMapper.updateStatus(auditDetails.getRepairId(), RepairTaskStatusEnum.TASK_STATUS_PROCESSING.getStatus());
|
||||||
}
|
}
|
||||||
taskMapper.updateTaskStatus(preTaskId, RepairTaskStatusEnum.TASK_STATUS_PROCESSING.getStatus());
|
taskMapper.updateTaskStatus(dto.getTaskId().toString(), RepairTaskStatusEnum.TASK_STATUS_PROCESSING.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -630,7 +633,7 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
// System.out.println(b);
|
// System.out.println(b);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void batchInsertRepairInputDetails(List<RepairAuditDetails> repairAuditDetailsByQuery, Long agreementId) {
|
private void batchInsertRepairInputDetails(List<ScrapApplyDetails> scrapApplyDetailList, List<RepairAuditDetails> repairAuditDetailsByQuery, Long agreementId) {
|
||||||
boolean inputFlag = false;
|
boolean inputFlag = false;
|
||||||
boolean scrapFlag = false;
|
boolean scrapFlag = false;
|
||||||
for (RepairAuditDetails repairAuditDetails : repairAuditDetailsByQuery) {
|
for (RepairAuditDetails repairAuditDetails : repairAuditDetailsByQuery) {
|
||||||
|
|
@ -659,6 +662,8 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
}
|
}
|
||||||
final List<RepairInputDetails> inputList = new ArrayList<>();
|
final List<RepairInputDetails> inputList = new ArrayList<>();
|
||||||
for (final RepairAuditDetails details : repairAuditDetailsByQuery) {
|
for (final RepairAuditDetails details : repairAuditDetailsByQuery) {
|
||||||
|
RepairAuditDetails dto = repairApplyDetailsMapper.selectById(details.getRepairId());
|
||||||
|
List<ScrapApplyDetails> list = scrapApplyDetailsMapper.selectScrapByTaskId(dto);
|
||||||
//修改机具状态
|
//修改机具状态
|
||||||
if (null != details.getMaId()) {
|
if (null != details.getMaId()) {
|
||||||
repairAuditDetailsMapper.updateMachine(details);
|
repairAuditDetailsMapper.updateMachine(details);
|
||||||
|
|
@ -674,6 +679,13 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
inputList.add(inputVo);
|
inputList.add(inputVo);
|
||||||
}
|
}
|
||||||
if (details.getScrapNum().compareTo(BigDecimal.ZERO) > 0) {
|
if (details.getScrapNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
ScrapApplyDetails bean = null;
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
bean = list.get(0);
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(scrapApplyDetailList)) {
|
||||||
|
bean = scrapApplyDetailList.get(0);
|
||||||
|
}
|
||||||
ScrapApplyDetails scrapApplyDetails = new ScrapApplyDetails();
|
ScrapApplyDetails scrapApplyDetails = new ScrapApplyDetails();
|
||||||
scrapApplyDetails.setTaskId(newScrapTaskId);
|
scrapApplyDetails.setTaskId(newScrapTaskId);
|
||||||
scrapApplyDetails.setTypeId(details.getTypeId());
|
scrapApplyDetails.setTypeId(details.getTypeId());
|
||||||
|
|
@ -684,6 +696,10 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
scrapApplyDetails.setParentId(details.getId());
|
scrapApplyDetails.setParentId(details.getId());
|
||||||
scrapApplyDetails.setCreateBy(SecurityUtils.getUsername());
|
scrapApplyDetails.setCreateBy(SecurityUtils.getUsername());
|
||||||
scrapApplyDetails.setCreateTime(new Date());
|
scrapApplyDetails.setCreateTime(new Date());
|
||||||
|
if (bean != null) {
|
||||||
|
scrapApplyDetails.setScrapReason(bean.getScrapReason() == null ? "" : bean.getScrapReason());
|
||||||
|
scrapApplyDetails.setScrapType(bean.getScrapType() == null ? null : bean.getScrapType());
|
||||||
|
}
|
||||||
scrapApplyDetailsMapper.insertScrapApplyDetails(scrapApplyDetails);
|
scrapApplyDetailsMapper.insertScrapApplyDetails(scrapApplyDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ 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.settlement.mapper.SltAgreementInfoMapper;
|
import com.bonus.material.settlement.mapper.SltAgreementInfoMapper;
|
||||||
import com.bonus.material.task.domain.TmTask;
|
import com.bonus.material.task.domain.TmTask;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAgreement;
|
||||||
|
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
|
||||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||||
import com.bonus.system.api.domain.SysUser;
|
import com.bonus.system.api.domain.SysUser;
|
||||||
import com.bonus.system.api.model.LoginUser;
|
import com.bonus.system.api.model.LoginUser;
|
||||||
|
|
@ -70,6 +72,9 @@ public class RepairServiceImpl implements RepairService {
|
||||||
@Resource
|
@Resource
|
||||||
private SltAgreementInfoMapper sltAgreementInfoMapper;
|
private SltAgreementInfoMapper sltAgreementInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TmTaskAgreementMapper taskAgreementMapper;
|
||||||
|
|
||||||
// 1:内部维修 2:外部返厂维修 3:报废
|
// 1:内部维修 2:外部返厂维修 3:报废
|
||||||
private final int INNER_REPAIR = 1; // 需要严格匹配枚举值 RepairTypeEnum.INNER_REPAIR.getTypeId();
|
private final int INNER_REPAIR = 1; // 需要严格匹配枚举值 RepairTypeEnum.INNER_REPAIR.getTypeId();
|
||||||
private final int RETURN_FACTORY = 2; // 需要严格匹配枚举值 RepairTypeEnum.RETURN_FACTORY.getTypeId();
|
private final int RETURN_FACTORY = 2; // 需要严格匹配枚举值 RepairTypeEnum.RETURN_FACTORY.getTypeId();
|
||||||
|
|
@ -455,6 +460,9 @@ public class RepairServiceImpl implements RepairService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult batchRepairApply(@NotNull List<RepairDeviceVO> repairDeviceVOList) {
|
public AjaxResult batchRepairApply(@NotNull List<RepairDeviceVO> repairDeviceVOList) {
|
||||||
|
BigDecimal innerNum = BigDecimal.ZERO;
|
||||||
|
BigDecimal outerNum = BigDecimal.ZERO;
|
||||||
|
BigDecimal scrapRepairNum = BigDecimal.ZERO;
|
||||||
// 准备业务逻辑数据
|
// 准备业务逻辑数据
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
// 配件集合
|
// 配件集合
|
||||||
|
|
@ -462,7 +470,77 @@ public class RepairServiceImpl implements RepairService {
|
||||||
|
|
||||||
// 校验参数,过滤空数据
|
// 校验参数,过滤空数据
|
||||||
repairDeviceVOList.removeIf(Objects::isNull);
|
repairDeviceVOList.removeIf(Objects::isNull);
|
||||||
|
// 先根据任务id查询维修任务详情,判断是否需要维修拆分
|
||||||
|
boolean isNeedSplit = false;
|
||||||
|
// 过滤出repairType不为null的RepairDeviceVO,并获取它们的id组成一个集合
|
||||||
|
List<Long> idList = repairDeviceVOList.stream()
|
||||||
|
.filter(device -> device.getRepairType() != null)
|
||||||
|
.map(RepairDeviceVO::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<RepairTaskDetails> detailsList = repairApplyDetailsMapper.getRepairDetailsWhichNotSent(repairDeviceVOList.get(0).getTaskId());
|
||||||
|
if (!CollectionUtils.isEmpty(detailsList)) {
|
||||||
|
for (RepairTaskDetails bean : detailsList) {
|
||||||
|
for (RepairDeviceVO repairDeviceVO : repairDeviceVOList) {
|
||||||
|
if (Objects.equals(MaTypeManageTypeEnum.CODE_DEVICE.getTypeId(), repairDeviceVO.getManageType())) {
|
||||||
|
if (!idList.contains(bean.getId()) && "0".equals(bean.getStatus())) {
|
||||||
|
isNeedSplit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (Objects.equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId(), repairDeviceVO.getManageType())) {
|
||||||
|
if (!idList.contains(bean.getId()) && "0".equals(bean.getStatus())) {
|
||||||
|
isNeedSplit = true;
|
||||||
|
} else if (idList.contains(bean.getId())) {
|
||||||
|
if (Objects.equals(bean.getTypeId(), repairDeviceVO.getTypeId().toString())) {
|
||||||
|
if (CollectionUtil.isNotEmpty(repairDeviceVO.getNumberInRepairPartList())) {
|
||||||
|
partList = repairDeviceVO.getNumberInRepairPartList();
|
||||||
|
if (null != partList.get(0).getRepairNum() && 0 < partList.get(0).getRepairNum().compareTo(BigDecimal.ZERO)) {
|
||||||
|
// 分拆维修单, 准备数据
|
||||||
|
innerNum = partList.get(0).getRepairNum();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(repairDeviceVO.getNumberOutRepairPartList())) {
|
||||||
|
partList = repairDeviceVO.getNumberOutRepairPartList();
|
||||||
|
if (null != partList.get(0).getRepairNum() && partList.get(0).getRepairNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
// 分拆维修单, 准备数据
|
||||||
|
outerNum = partList.get(0).getRepairNum();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理配件集合数据 -- 数量管理--报废维修
|
||||||
|
if (CollectionUtil.isNotEmpty(repairDeviceVO.getNumberScrapRepairPartList())) {
|
||||||
|
// 判断报废数量是否为空
|
||||||
|
if (repairDeviceVO.getNumberScrapRepairPartList().get(0).getScrapNum() != null && repairDeviceVO.getNumberScrapRepairPartList().get(0).getScrapNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
// 获取维修详情表中的维修详情记录:待维修、已维修、已报废的数量
|
||||||
|
RepairTaskDetails details = repairMapper.getById(bean.getId());
|
||||||
|
if (Objects.isNull(details)) {
|
||||||
|
throw new ServiceException("此维修记录不存在,请检查后提交!");
|
||||||
|
}
|
||||||
|
// 分拆维修单, 准备数据
|
||||||
|
scrapRepairNum = repairDeviceVO.getNumberScrapRepairPartList().get(0).getScrapNum();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BigDecimal add = innerNum.add(outerNum).add(scrapRepairNum);
|
||||||
|
BigDecimal subtract = bean.getRepairNum().subtract(bean.getRepairedNum()).subtract(bean.getScrapNum());
|
||||||
|
if (add.compareTo(subtract) < 0) {
|
||||||
|
isNeedSplit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Long newTaskId = null;
|
||||||
|
if (isNeedSplit) {
|
||||||
|
// 查询协议ID
|
||||||
|
Long agreementId = taskAgreementMapper.selectAgreementIdByTaskId(repairDeviceVOList.get(0).getTaskId());
|
||||||
|
// 插入任务表
|
||||||
|
newTaskId = insertTt(SecurityUtils.getUsername());
|
||||||
|
// 插入协议任务表
|
||||||
|
int res = insertTta(newTaskId, agreementId);
|
||||||
|
if (res <= 0) {
|
||||||
|
throw new ServiceException("协议任务表插入失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
for (RepairDeviceVO bean : repairDeviceVOList) {
|
for (RepairDeviceVO bean : repairDeviceVOList) {
|
||||||
if (null == bean.getManageType()) {throw new ServiceException("请选择物资管理方式");}
|
if (null == bean.getManageType()) {throw new ServiceException("请选择物资管理方式");}
|
||||||
if (Objects.equals(MaTypeManageTypeEnum.CODE_DEVICE.getTypeId(), bean.getManageType())) {
|
if (Objects.equals(MaTypeManageTypeEnum.CODE_DEVICE.getTypeId(), bean.getManageType())) {
|
||||||
|
|
@ -475,12 +553,29 @@ public class RepairServiceImpl implements RepairService {
|
||||||
partList = bean.getCodeInRepairPartList();
|
partList = bean.getCodeInRepairPartList();
|
||||||
// 更新维修数量、并修改维修人员
|
// 更新维修数量、并修改维修人员
|
||||||
repairMapper.updateRepairedNumAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUsername(), loginUser.getUserid());
|
repairMapper.updateRepairedNumAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUsername(), loginUser.getUserid());
|
||||||
|
if (isNeedSplit) {
|
||||||
|
bean.setNewTaskId(newTaskId);
|
||||||
|
bean.setRepairer(loginUser.getUsername());
|
||||||
|
bean.setRepairedNum(bean.getRepairNum());
|
||||||
|
bean.setParentId(bean.getId());
|
||||||
|
bean.setLevel((StringUtils.isNotBlank(bean.getLevel())) ? String.valueOf(Integer.parseInt(bean.getLevel()) + 1) : "1");
|
||||||
|
bean.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
repairMapper.insertRepaired(bean);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RETURN_FACTORY: {
|
case RETURN_FACTORY: {
|
||||||
partList = bean.getCodeOutRepairPartList();
|
partList = bean.getCodeOutRepairPartList();
|
||||||
// 更新维修数量、维修人员不变
|
// 更新维修数量、维修人员不变
|
||||||
repairMapper.updateRepairedNumTwoAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUserid());
|
repairMapper.updateRepairedNumTwoAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUserid());
|
||||||
|
if (isNeedSplit) {
|
||||||
|
bean.setNewTaskId(newTaskId);
|
||||||
|
bean.setRepairedNum(bean.getRepairNum());
|
||||||
|
bean.setParentId(bean.getId());
|
||||||
|
bean.setLevel((StringUtils.isNotBlank(bean.getLevel())) ? String.valueOf(Integer.parseInt(bean.getLevel()) + 1) : "1");
|
||||||
|
bean.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
repairMapper.insertRepaired(bean);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TO_SCRAP: {
|
case TO_SCRAP: {
|
||||||
|
|
@ -488,6 +583,14 @@ public class RepairServiceImpl implements RepairService {
|
||||||
partList = bean.getCodeScrapRepairPartList();
|
partList = bean.getCodeScrapRepairPartList();
|
||||||
// 更新报废数量
|
// 更新报废数量
|
||||||
repairMapper.updateScrapNumAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUserid());
|
repairMapper.updateScrapNumAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUserid());
|
||||||
|
if (isNeedSplit) {
|
||||||
|
bean.setNewTaskId(newTaskId);
|
||||||
|
bean.setScrapNum(bean.getRepairNum());
|
||||||
|
bean.setParentId(bean.getId());
|
||||||
|
bean.setLevel((StringUtils.isNotBlank(bean.getLevel())) ? String.valueOf(Integer.parseInt(bean.getLevel()) + 1) : "1");
|
||||||
|
bean.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
repairMapper.insertRepaired(bean);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -504,7 +607,7 @@ public class RepairServiceImpl implements RepairService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 统一处理配件集合数据
|
// 统一处理配件集合数据
|
||||||
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
|
copeNumberManageInList(bean, partList, loginUser, bean.getManageType(), isNeedSplit, newTaskId);
|
||||||
|
|
||||||
} else if (Objects.equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId(), bean.getManageType())) {
|
} else if (Objects.equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId(), bean.getManageType())) {
|
||||||
// 物资管理方式--数量管理
|
// 物资管理方式--数量管理
|
||||||
|
|
@ -547,7 +650,7 @@ public class RepairServiceImpl implements RepairService {
|
||||||
// 分拆维修单, 准备数据
|
// 分拆维修单, 准备数据
|
||||||
innerRepairNum = partList.get(0).getRepairNum();
|
innerRepairNum = partList.get(0).getRepairNum();
|
||||||
// 处理配件集合数据
|
// 处理配件集合数据
|
||||||
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
|
copeNumberManageInList(bean, partList, loginUser, bean.getManageType(), isNeedSplit, newTaskId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -627,6 +730,10 @@ public class RepairServiceImpl implements RepairService {
|
||||||
|
|
||||||
// 因报废操作无需配件, 只添加【维修记录表】
|
// 因报废操作无需配件, 只添加【维修记录表】
|
||||||
repairMapper.addRecord(repairApplyRecord);
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
if (isNeedSplit) {
|
||||||
|
repairApplyRecord.setTaskId(newTaskId);
|
||||||
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 报废类型无需配件,所以配件为空,添加【维修记录表】
|
// 报废类型无需配件,所以配件为空,添加【维修记录表】
|
||||||
|
|
@ -641,13 +748,28 @@ public class RepairServiceImpl implements RepairService {
|
||||||
|
|
||||||
// 因报废操作无需配件, 只添加【维修记录表】
|
// 因报废操作无需配件, 只添加【维修记录表】
|
||||||
repairMapper.addRecord(repairApplyRecord);
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
if (isNeedSplit) {
|
||||||
|
repairApplyRecord.setTaskId(newTaskId);
|
||||||
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 拆分维修单
|
// 拆分维修单
|
||||||
splitRepairDetailsToMultiple(bean, innerRepairNum, outerRepairNum, scrapNum, loginUser);
|
splitRepairDetailsToMultiple(bean, innerRepairNum, outerRepairNum, scrapNum, loginUser);
|
||||||
|
if (isNeedSplit) {
|
||||||
|
// 维修单拆分合并
|
||||||
|
bean.setNewTaskId(newTaskId);
|
||||||
|
bean.setRepairNum(innerRepairNum.add(outerRepairNum).add(scrapNum));
|
||||||
|
bean.setRepairedNum(innerRepairNum.add(outerRepairNum));
|
||||||
|
bean.setScrapNum(scrapNum);
|
||||||
|
bean.setStatus("1");
|
||||||
|
bean.setParentId(bean.getId());
|
||||||
|
bean.setLevel((StringUtils.isNotBlank(bean.getLevel())) ? String.valueOf(Integer.parseInt(bean.getLevel()) + 1) : "1");
|
||||||
|
bean.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
repairMapper.insertRepaired(bean);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceException("请选择正确的维修类型");
|
throw new ServiceException("请选择正确的维修类型");
|
||||||
}
|
}
|
||||||
|
|
@ -656,6 +778,44 @@ public class RepairServiceImpl implements RepairService {
|
||||||
return AjaxResult.success("维修完成");
|
return AjaxResult.success("维修完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拆分维修单,生成任务协议表
|
||||||
|
* @param newTaskId
|
||||||
|
* @param agreementId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int insertTta(Long newTaskId, Long agreementId) {
|
||||||
|
int res;
|
||||||
|
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(newTaskId, agreementId);
|
||||||
|
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||||
|
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
res = taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成任务表
|
||||||
|
* @param createBy
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Long insertTt(String createBy) {
|
||||||
|
Long newTask = null;
|
||||||
|
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId());
|
||||||
|
// 生成维修单号
|
||||||
|
String code = genderWxTaskCode(thisMonthMaxOrder);
|
||||||
|
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId(), RepairTaskStatusEnum.TASK_STATUS_PROCESSING.getStatus(),
|
||||||
|
null,thisMonthMaxOrder + 1, code);
|
||||||
|
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||||
|
tmTask.setCreateBy(createBy);
|
||||||
|
// 插入任务
|
||||||
|
int taskId = taskMapper.insertTmTask(tmTask);
|
||||||
|
// 如果插入成功且返回的 taskId 大于 0
|
||||||
|
if (taskId > 0 && tmTask.getTaskId() > 0) {
|
||||||
|
newTask = tmTask.getTaskId();
|
||||||
|
}
|
||||||
|
return newTask;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将维修详情拆分到多个类别
|
* 将维修详情拆分到多个类别
|
||||||
* 此方法用于根据内修、外修和报废数量更新维修记录,
|
* 此方法用于根据内修、外修和报废数量更新维修记录,
|
||||||
|
|
@ -714,7 +874,7 @@ public class RepairServiceImpl implements RepairService {
|
||||||
* @param loginUser 当前登录用户
|
* @param loginUser 当前登录用户
|
||||||
* @param manageType 管理方式:0编码管理 1数量管理
|
* @param manageType 管理方式:0编码管理 1数量管理
|
||||||
*/
|
*/
|
||||||
private void copeNumberManageInList(RepairDeviceVO bean, List<RepairPartDetails> partList, LoginUser loginUser, Integer manageType) {
|
private void copeNumberManageInList(RepairDeviceVO bean, List<RepairPartDetails> partList, LoginUser loginUser, Integer manageType, Boolean isNeedSplit, Long newTaskId) {
|
||||||
if (CollectionUtil.isNotEmpty(partList)) {
|
if (CollectionUtil.isNotEmpty(partList)) {
|
||||||
if (null == bean.getManageType()) {
|
if (null == bean.getManageType()) {
|
||||||
throw new ServiceException("请选择物资管理方式");
|
throw new ServiceException("请选择物资管理方式");
|
||||||
|
|
@ -839,9 +999,14 @@ public class RepairServiceImpl implements RepairService {
|
||||||
.setRepairNum(BigDecimal.valueOf(!RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0))
|
.setRepairNum(BigDecimal.valueOf(!RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0))
|
||||||
.setScrapNum(BigDecimal.valueOf(RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0))
|
.setScrapNum(BigDecimal.valueOf(RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0))
|
||||||
.setCreateBy(loginUser.getUsername());
|
.setCreateBy(loginUser.getUsername());
|
||||||
|
repairApplyRecord.setScrapType(partList.get(0).getScrapType());
|
||||||
|
repairApplyRecord.setScrapReason(partList.get(0).getScrapReason());
|
||||||
// 不选维修配件时, 只添加【维修记录表】
|
// 不选维修配件时, 只添加【维修记录表】
|
||||||
repairMapper.addRecord(repairApplyRecord);
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
if (isNeedSplit) {
|
||||||
|
repairApplyRecord.setTaskId(newTaskId);
|
||||||
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 配件为空,添加【维修记录表】
|
// 配件为空,添加【维修记录表】
|
||||||
|
|
@ -851,9 +1016,14 @@ public class RepairServiceImpl implements RepairService {
|
||||||
.setRepairNum(BigDecimal.valueOf(!RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0))
|
.setRepairNum(BigDecimal.valueOf(!RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0))
|
||||||
.setScrapNum(BigDecimal.valueOf(RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0))
|
.setScrapNum(BigDecimal.valueOf(RepairTypeEnum.TO_SCRAP.getTypeId().equals(bean.getRepairType()) ? 1 : 0))
|
||||||
.setCreateBy(loginUser.getUsername());
|
.setCreateBy(loginUser.getUsername());
|
||||||
|
repairApplyRecord.setScrapType(partList.get(0).getScrapType());
|
||||||
|
repairApplyRecord.setScrapReason(partList.get(0).getScrapReason());
|
||||||
// 不选维修配件时, 只添加【维修记录表】
|
// 不选维修配件时, 只添加【维修记录表】
|
||||||
repairMapper.addRecord(repairApplyRecord);
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
if (isNeedSplit) {
|
||||||
|
repairApplyRecord.setTaskId(newTaskId);
|
||||||
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -884,23 +1054,37 @@ public class RepairServiceImpl implements RepairService {
|
||||||
throw new ServiceException("任务" + task.getTaskId() + "还有未完成维修的数据,请先完成维修");
|
throw new ServiceException("任务" + task.getTaskId() + "还有未完成维修的数据,请先完成维修");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 根据taskId去查询维修任务详情,按照level进行重新排序,确保维修拆分顺利进行
|
||||||
|
List<RepairTask> list = repairMapper.getRepairTaskDetails(taskList);
|
||||||
|
// 根据查询的list集合,根据level进行从大到小级别排序
|
||||||
|
list.sort(Comparator.comparing(RepairTask::getLevel).reversed());
|
||||||
// 3.业务逻辑处理
|
// 3.业务逻辑处理
|
||||||
for (RepairTask task : taskList) {
|
for (RepairTask task : list) {
|
||||||
// 查询维修任务的详情表
|
// 查询维修任务的详情表
|
||||||
Long oldWxTaskId = task.getTaskId();
|
Long oldWxTaskId = task.getTaskId();
|
||||||
|
List<RepairTaskDetails> preDetailsList = null;
|
||||||
List<RepairTaskDetails> detailsList = repairApplyDetailsMapper.getRepairDetailsWhichNotSent(oldWxTaskId);
|
List<RepairTaskDetails> detailsList = repairApplyDetailsMapper.getRepairDetailsWhichNotSent(oldWxTaskId);
|
||||||
BigDecimal thisRepairedNum = detailsList.stream().map(RepairTaskDetails::getRepairedNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
BigDecimal thisRepairedNum = detailsList.stream().map(RepairTaskDetails::getRepairedNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
BigDecimal thisScrapNum = detailsList.stream().map(RepairTaskDetails::getScrapNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
BigDecimal thisScrapNum = detailsList.stream().map(RepairTaskDetails::getScrapNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
if (!CollectionUtils.isEmpty(detailsList) && 0 < (thisRepairedNum.add(thisScrapNum)).compareTo(BigDecimal.ZERO)) {
|
if (!CollectionUtils.isEmpty(detailsList) && 0 < (thisRepairedNum.add(thisScrapNum)).compareTo(BigDecimal.ZERO)) {
|
||||||
|
if (StringUtils.isNotBlank(detailsList.get(0).getLevel()) && Integer.parseInt(detailsList.get(0).getLevel()) > 1){
|
||||||
|
preDetailsList = repairApplyDetailsMapper.getRepairDetails(oldWxTaskId);
|
||||||
|
if (!CollectionUtils.isEmpty(preDetailsList)) {
|
||||||
|
for (RepairTaskDetails repairTaskDetails : preDetailsList) {
|
||||||
|
if (repairTaskDetails.getParentId() != null && repairTaskDetails.getParentId() != 0) {
|
||||||
|
preDetailsList = getPreDetailsForTask(repairTaskDetails);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
task.setCreateBy(loginUser.getUserid());
|
task.setCreateBy(loginUser.getUserid());
|
||||||
Long agreementId = repairMapper.getAgreementId(task);
|
Long agreementId = repairMapper.getAgreementId(task);
|
||||||
// 新增tm_task表数据、修饰审核任务、状态是待审核
|
// 新增tm_task表数据、修饰审核任务、状态是待审核
|
||||||
task.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR_AUDIT.getTaskTypeId());
|
task.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR_AUDIT.getTaskTypeId());
|
||||||
task.setTaskStatus(RepairTaskStatusEnum.TASK_STATUS_TO_EXAM.getStatus());
|
task.setTaskStatus(RepairTaskStatusEnum.TASK_STATUS_TO_EXAM.getStatus());
|
||||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR_AUDIT.getTaskTypeId());
|
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR_AUDIT.getTaskTypeId());
|
||||||
// 生成维修单号
|
// 生成维修审核单号
|
||||||
String code = genderWxTaskCode(thisMonthMaxOrder);
|
String code = genderWsTaskCode(thisMonthMaxOrder);
|
||||||
task.setRepairCode(code);
|
task.setRepairCode(code);
|
||||||
task.setMonthOrder(thisMonthMaxOrder + 1);
|
task.setMonthOrder(thisMonthMaxOrder + 1);
|
||||||
// 插入之前的维修任务id标记前置任务
|
// 插入之前的维修任务id标记前置任务
|
||||||
|
|
@ -913,16 +1097,49 @@ public class RepairServiceImpl implements RepairService {
|
||||||
|
|
||||||
// 新增审计记录
|
// 新增审计记录
|
||||||
for (RepairTaskDetails details : detailsList) {
|
for (RepairTaskDetails details : detailsList) {
|
||||||
RepairApplyDetails repairApplyDetails = createRepairDetailsCope(details);
|
/*RepairApplyDetails repairApplyDetails = createRepairDetailsCope(details);
|
||||||
repairApplyDetailsMapper.updateRepairApplyDetails(repairApplyDetails);
|
repairApplyDetailsMapper.updateRepairApplyDetails(repairApplyDetails);*/
|
||||||
details.setCreateBy(String.valueOf(loginUser.getUserid()));
|
details.setCreateBy(String.valueOf(loginUser.getUserid()));
|
||||||
details.setTaskId(task.getTaskId());
|
details.setTaskId(task.getTaskId());
|
||||||
details.setRepairNum(details.getRepairNum());
|
/*details.setRepairNum(details.getRepairNum());
|
||||||
details.setRepairedNum(details.getRepairedNum());
|
details.setRepairedNum(details.getRepairedNum());
|
||||||
details.setScrapNum(details.getScrapNum());
|
details.setScrapNum(details.getScrapNum());*/
|
||||||
// 先根据id查询审核表中是否存在数据,存在则不用重复插入
|
// 先根据id查询审核表中是否存在数据,存在则不用重复插入
|
||||||
if (CollectionUtils.isEmpty(repairMapper.getAuditDetailsById(details))) {
|
if (StringUtils.isNotBlank(details.getMaId())) {
|
||||||
repairMapper.addAuditDetails(details);
|
List<RepairTaskDetails> taskDetails = repairMapper.getRepairDetailsById(details);
|
||||||
|
if (CollectionUtils.isEmpty(taskDetails)) {
|
||||||
|
repairMapper.addAuditDetails(details);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
List<RepairTaskDetails> taskDetails = repairMapper.getRepairDetailsById(details);
|
||||||
|
if (!CollectionUtils.isEmpty(taskDetails) && taskDetails.size() > 0) {
|
||||||
|
for (RepairTaskDetails taskDetail : taskDetails) {
|
||||||
|
if (!CollectionUtils.isEmpty(preDetailsList) && preDetailsList.size() > 0) {
|
||||||
|
//获取到preDetailsList中的typeId和taskDetail相同的数据
|
||||||
|
for (RepairTaskDetails preDetails : preDetailsList) {
|
||||||
|
if (preDetails.getTypeId().equals(taskDetail.getTypeId())) {
|
||||||
|
if (taskDetail.getRepairNum().compareTo(preDetails.getPreRepairNum()) < 0) {
|
||||||
|
details.setRepairNum(preDetails.getPreRepairNum().subtract(taskDetail.getRepairNum()));
|
||||||
|
details.setScrapNum(preDetails.getPreScrapNum().subtract(taskDetail.getScrapNum()).compareTo(BigDecimal.ZERO) > 0 ? preDetails.getPreScrapNum().subtract(taskDetail.getScrapNum()) : BigDecimal.ZERO);
|
||||||
|
details.setRepairedNum(preDetails.getPreRepairedNum().subtract(taskDetail.getRepairedNum()).compareTo(BigDecimal.ZERO) > 0 ? preDetails.getPreRepairedNum().subtract(taskDetail.getRepairedNum()) : BigDecimal.ZERO);
|
||||||
|
repairMapper.addAuditDetails(details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (taskDetail.getTypeId().equals(details.getTypeId())) {
|
||||||
|
if (taskDetail.getRepairNum().compareTo(details.getRepairNum()) < 0) {
|
||||||
|
details.setRepairNum(details.getRepairNum().subtract(taskDetail.getRepairNum()));
|
||||||
|
details.setScrapNum(details.getScrapNum().subtract(taskDetail.getScrapNum()).compareTo(BigDecimal.ZERO) > 0 ? details.getScrapNum().subtract(taskDetail.getScrapNum()) : BigDecimal.ZERO);
|
||||||
|
details.setRepairedNum(details.getRepairedNum().subtract(taskDetail.getRepairedNum()).compareTo(BigDecimal.ZERO) > 0 ? details.getRepairedNum().subtract(taskDetail.getRepairedNum()) : BigDecimal.ZERO);
|
||||||
|
repairMapper.addAuditDetails(details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
repairMapper.addAuditDetails(details);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -930,6 +1147,33 @@ public class RepairServiceImpl implements RepairService {
|
||||||
return AjaxResult.success("执行完毕");
|
return AjaxResult.success("执行完毕");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取前置任务详情
|
||||||
|
* @param repairTaskDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<RepairTaskDetails> getPreDetailsForTask(RepairTaskDetails repairTaskDetails) {
|
||||||
|
// 如果 parentId 为 0,表示达到了根任务,返回当前任务列表
|
||||||
|
if (repairTaskDetails.getParentId() == 0) {
|
||||||
|
return Collections.singletonList(repairTaskDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 否则,继续递归查询上一个任务
|
||||||
|
List<RepairTaskDetails> preDetailsList = repairApplyDetailsMapper.getRepairDetails(repairTaskDetails.getPreTaskId());
|
||||||
|
if (!CollectionUtils.isEmpty(preDetailsList)) {
|
||||||
|
for (RepairTaskDetails preRepairTaskDetails : preDetailsList) {
|
||||||
|
if (preRepairTaskDetails.getParentId() != null && preRepairTaskDetails.getParentId() != 0) {
|
||||||
|
// 递归查询父任务
|
||||||
|
return getPreDetailsForTask(preRepairTaskDetails);
|
||||||
|
} else {
|
||||||
|
// 找到 parentId 为 0 的任务,返回该任务
|
||||||
|
return Collections.singletonList(preRepairTaskDetails);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.emptyList(); // 如果没有找到,返回空列表
|
||||||
|
}
|
||||||
|
|
||||||
private static RepairApplyDetails createRepairDetailsCope(RepairTaskDetails details) {
|
private static RepairApplyDetails createRepairDetailsCope(RepairTaskDetails details) {
|
||||||
RepairApplyDetails repairApplyDetails = new RepairApplyDetails();
|
RepairApplyDetails repairApplyDetails = new RepairApplyDetails();
|
||||||
repairApplyDetails.setId(details.getId());
|
repairApplyDetails.setId(details.getId());
|
||||||
|
|
@ -941,15 +1185,28 @@ public class RepairServiceImpl implements RepairService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成维修单号
|
* 生成维修审核单号
|
||||||
* @param thisMonthMaxOrder 当前月最大序号
|
* @param thisMonthMaxOrder 当前月最大序号
|
||||||
*/
|
*/
|
||||||
|
private String genderWsTaskCode(int thisMonthMaxOrder) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
|
String format = dateFormat.format(nowDate);
|
||||||
|
String result = format.replace("-", "");
|
||||||
|
return MaterialConstants.REPAIR_AUDIT_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成维修单号
|
||||||
|
* @param thisMonthMaxOrder
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private String genderWxTaskCode(int thisMonthMaxOrder) {
|
private String genderWxTaskCode(int thisMonthMaxOrder) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
Date nowDate = DateUtils.getNowDate();
|
Date nowDate = DateUtils.getNowDate();
|
||||||
String format = dateFormat.format(nowDate);
|
String format = dateFormat.format(nowDate);
|
||||||
String result = format.replace("-", "");
|
String result = format.replace("-", "");
|
||||||
return MaterialConstants.REPAIR_AUDIT_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
return MaterialConstants.REPAIR_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1017,8 +1274,59 @@ public class RepairServiceImpl implements RepairService {
|
||||||
* 维修明细--批量合格--更新明细status,以及repairedNum
|
* 维修明细--批量合格--更新明细status,以及repairedNum
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int batchQualified(ArrayList<Long> ids) {
|
public int batchQualified(ArrayList<Long> ids) {
|
||||||
return repairMapper.batchQualified(ids, SecurityUtils.getLoginUser().getUserid());
|
int result = 0;
|
||||||
|
try {
|
||||||
|
// 根据id查询任务状态
|
||||||
|
RepairAuditDetails dto = repairApplyDetailsMapper.selectById(ids.get(0));
|
||||||
|
List<RepairTaskDetails> detailsList = repairApplyDetailsMapper.getRepairDetailsWhichNotSent(dto.getTaskId());
|
||||||
|
if (!CollectionUtils.isEmpty(detailsList)) {
|
||||||
|
Set<Long> idsSet = new HashSet<>(ids);
|
||||||
|
// 如果detailsList中的status除了ids中的数据,其余皆为已完成,则不需要创建新的维修单
|
||||||
|
boolean hasStatus = false;
|
||||||
|
for (RepairTaskDetails details : detailsList) {
|
||||||
|
if (!idsSet.contains(details.getId()) && "0".equals(details.getStatus())) {
|
||||||
|
hasStatus = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasStatus) {
|
||||||
|
// 查询协议ID
|
||||||
|
Long agreementId = taskAgreementMapper.selectAgreementIdByTaskId(dto.getTaskId());
|
||||||
|
// 插入任务表
|
||||||
|
Long newTaskId = insertTt(SecurityUtils.getUsername());
|
||||||
|
// 插入协议任务表
|
||||||
|
int res = insertTta(newTaskId, agreementId);
|
||||||
|
if (res <= 0) {
|
||||||
|
throw new ServiceException("协议任务表插入失败");
|
||||||
|
}
|
||||||
|
List<RepairTaskDetails> list = repairApplyDetailsMapper.getList(ids);
|
||||||
|
for (RepairTaskDetails details : list) {
|
||||||
|
RepairDeviceVO bean = new RepairDeviceVO();
|
||||||
|
bean.setTaskId(newTaskId);
|
||||||
|
bean.setMaId(details.getMaId() == null ? null :Long.valueOf(details.getMaId()));
|
||||||
|
bean.setTypeId(Long.valueOf(details.getTypeId()));
|
||||||
|
bean.setRepairNum(details.getRepairNum().subtract(details.getRepairedNum() == null ? BigDecimal.ZERO : details.getRepairedNum()));
|
||||||
|
bean.setRepairedNum(details.getRepairNum().subtract(details.getRepairedNum() == null ? BigDecimal.ZERO : details.getRepairedNum()));
|
||||||
|
bean.setStatus("1");
|
||||||
|
bean.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
bean.setBackId(details.getBackId());
|
||||||
|
bean.setParentId(details.getId());
|
||||||
|
bean.setLevel((StringUtils.isNotBlank(details.getLevel())) ? String.valueOf(Integer.parseInt(details.getLevel()) + 1) : "1");
|
||||||
|
if ("0".equals(details.getStatus())) {
|
||||||
|
repairMapper.insertRepaired(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result += repairMapper.batchQualified(ids, SecurityUtils.getLoginUser().getUserid());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="getRepairDetailsWhichNotSent" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
|
<select id="getRepairDetailsWhichNotSent" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
|
||||||
select rad.id,
|
select rad.id as id,
|
||||||
rad.ma_id as maId,
|
rad.ma_id as maId,
|
||||||
rad.type_id as typeId,
|
rad.type_id as typeId,
|
||||||
rad.repair_num as repairNum,
|
rad.repair_num as repairNum,
|
||||||
|
|
@ -138,15 +138,71 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
rad.this_scrap_num as thisScrapNum,
|
rad.this_scrap_num as thisScrapNum,
|
||||||
rad.company_id as companyId,
|
rad.company_id as companyId,
|
||||||
tt.task_id as taskId,
|
tt.task_id as taskId,
|
||||||
tt.code as taskCode
|
tt.code as taskCode,
|
||||||
|
rad.back_id as backId,
|
||||||
|
rad.status as status,
|
||||||
|
rad.level as level
|
||||||
from repair_apply_details rad
|
from repair_apply_details rad
|
||||||
left join tm_task tt on rad.task_id = tt.task_id
|
left join tm_task tt on rad.task_id = tt.task_id
|
||||||
where rad.task_id = #{taskId}
|
where rad.task_id = #{taskId}
|
||||||
<!-- and rad.status = '0'-->
|
<!-- and rad.status = '0'-->
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectById" resultType="java.lang.String">
|
<select id="getList" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
|
||||||
select task_id from repair_apply_details where id = #{repairId}
|
select rad.id,
|
||||||
|
rad.ma_id as maId,
|
||||||
|
rad.type_id as typeId,
|
||||||
|
rad.repair_num as repairNum,
|
||||||
|
rad.repaired_num as repairedNum,
|
||||||
|
rad.this_repaired_num as thisRepairedNum,
|
||||||
|
rad.scrap_num as scrapNum,
|
||||||
|
rad.this_scrap_num as thisScrapNum,
|
||||||
|
rad.company_id as companyId,
|
||||||
|
rad.back_id as backId,
|
||||||
|
rad.status as status,
|
||||||
|
rad.level as level,
|
||||||
|
rad.parent_id as parentId
|
||||||
|
from repair_apply_details rad
|
||||||
|
where rad.id in
|
||||||
|
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getRepairDetails" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
|
||||||
|
SELECT
|
||||||
|
rad.id AS id,
|
||||||
|
rad.ma_id AS maId,
|
||||||
|
rad.type_id AS typeId,
|
||||||
|
rad.repair_num AS repairNum,
|
||||||
|
rad.this_repaired_num,
|
||||||
|
rad.this_scrap_num,
|
||||||
|
rad.repaired_num AS repairedNum,
|
||||||
|
rad.this_repaired_num AS thisRepairedNum,
|
||||||
|
rad.scrap_num AS scrapNum,
|
||||||
|
rad.this_scrap_num AS thisScrapNum,
|
||||||
|
rad.company_id AS companyId,
|
||||||
|
rad.back_id AS backId,
|
||||||
|
rad.STATUS AS STATUS ,
|
||||||
|
rad.`level` as level,
|
||||||
|
rd.repair_num as preRepairNum,
|
||||||
|
rd.repaired_num as preRepairedNum,
|
||||||
|
rd.scrap_num as preScrapNum,
|
||||||
|
rd.parent_id as parentId,
|
||||||
|
rd.task_id as preTaskId
|
||||||
|
FROM
|
||||||
|
repair_apply_details rad
|
||||||
|
LEFT JOIN repair_apply_details rd on rad.parent_id = rd.id
|
||||||
|
WHERE
|
||||||
|
rad.task_id = #{oldWxTaskId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectById" resultType="com.bonus.material.repair.domain.RepairAuditDetails">
|
||||||
|
select task_id as taskId,
|
||||||
|
type_id as typeId,
|
||||||
|
ma_id as maId
|
||||||
|
from repair_apply_details
|
||||||
|
where id = #{repairId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleteRepairApplyDetailsById" parameterType="Long">
|
<delete id="deleteRepairApplyDetailsById" parameterType="Long">
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
<insert id="addAuditDetails">
|
<insert id="addAuditDetails">
|
||||||
insert into repair_audit_details (task_id,repair_id,ma_id,type_id,repair_num,repaired_num,scrap_num,status,
|
insert into repair_audit_details (task_id,repair_id,ma_id,type_id,repair_num,repaired_num,scrap_num,status,
|
||||||
create_by,create_time,company_id)
|
create_by,create_time,company_id, back_id)
|
||||||
values (#{taskId},#{id},#{maId},#{typeId},#{repairNum},#{repairedNum},#{scrapNum},'0',#{createBy},now(),
|
values (#{taskId},#{id},#{maId},#{typeId},#{repairNum},#{repairedNum},#{scrapNum},'0',#{createBy},now(),
|
||||||
#{companyId});
|
#{companyId}, #{backId});
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="addRepairCost">
|
<insert id="addRepairCost">
|
||||||
|
|
@ -33,6 +33,88 @@
|
||||||
values (#{bean.taskId},#{bean.id},#{bean.typeId},#{bean.maId},#{bean.repairNum},#{costs},#{partType},'0',#{bean.repairType});
|
values (#{bean.taskId},#{bean.id},#{bean.typeId},#{bean.maId},#{bean.repairNum},#{costs},#{partType},'0',#{bean.repairType});
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertRepaired">
|
||||||
|
insert into repair_apply_details
|
||||||
|
(
|
||||||
|
<if test="newTaskId != null">
|
||||||
|
task_id,
|
||||||
|
</if>
|
||||||
|
<if test="maId != null">
|
||||||
|
ma_id,
|
||||||
|
</if>
|
||||||
|
<if test="typeId != null">
|
||||||
|
type_id,
|
||||||
|
</if>
|
||||||
|
<if test="repairNum != null">
|
||||||
|
repair_num,
|
||||||
|
</if>
|
||||||
|
<if test="repairedNum != null">
|
||||||
|
repaired_num,
|
||||||
|
</if>
|
||||||
|
<if test="scrapNum != null">
|
||||||
|
scrap_num,
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
status,
|
||||||
|
</if>
|
||||||
|
<if test="createBy != null and createBy != ''">
|
||||||
|
create_by,
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
remark,
|
||||||
|
</if>
|
||||||
|
<if test="backId != null">
|
||||||
|
back_id,
|
||||||
|
</if>
|
||||||
|
<if test="level != null and level != ''">
|
||||||
|
level,
|
||||||
|
</if>
|
||||||
|
<if test="parentId != null">
|
||||||
|
parent_id,
|
||||||
|
</if>
|
||||||
|
create_time
|
||||||
|
)
|
||||||
|
values (
|
||||||
|
<if test="newTaskId != null">
|
||||||
|
#{newTaskId},
|
||||||
|
</if>
|
||||||
|
<if test="maId != null">
|
||||||
|
#{maId},
|
||||||
|
</if>
|
||||||
|
<if test="typeId != null">
|
||||||
|
#{typeId},
|
||||||
|
</if>
|
||||||
|
<if test="repairNum != null">
|
||||||
|
#{repairNum},
|
||||||
|
</if>
|
||||||
|
<if test="repairedNum != null">
|
||||||
|
#{repairedNum},
|
||||||
|
</if>
|
||||||
|
<if test="scrapNum != null">
|
||||||
|
#{scrapNum},
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
#{status},
|
||||||
|
</if>
|
||||||
|
<if test="createBy != null and createBy != ''">
|
||||||
|
#{createBy},
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
#{remark},
|
||||||
|
</if>
|
||||||
|
<if test="backId != null">
|
||||||
|
#{backId},
|
||||||
|
</if>
|
||||||
|
<if test="level != null and level != ''">
|
||||||
|
#{level},
|
||||||
|
</if>
|
||||||
|
<if test="parentId != null">
|
||||||
|
#{parentId},
|
||||||
|
</if>
|
||||||
|
NOW()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateRepairedNum">
|
<update id="updateRepairedNum">
|
||||||
update repair_apply_details
|
update repair_apply_details
|
||||||
set repaired_num = #{repairNum},
|
set repaired_num = #{repairNum},
|
||||||
|
|
@ -300,6 +382,8 @@
|
||||||
rad.update_time as updateTime,
|
rad.update_time as updateTime,
|
||||||
rad.type_id as typeId,
|
rad.type_id as typeId,
|
||||||
rad.back_id as backId,
|
rad.back_id as backId,
|
||||||
|
rad.level as level,
|
||||||
|
rad.parent_id as parentId,
|
||||||
rad.create_time,
|
rad.create_time,
|
||||||
bai.CODE AS backCode,
|
bai.CODE AS backCode,
|
||||||
( SELECT COUNT(*) FROM repair_cost rc WHERE rc.repair_id = rad.id ) AS totalCostRecords,
|
( SELECT COUNT(*) FROM repair_cost rc WHERE rc.repair_id = rad.id ) AS totalCostRecords,
|
||||||
|
|
@ -553,18 +637,60 @@
|
||||||
|
|
||||||
<select id="getAuditDetailsById" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
|
<select id="getAuditDetailsById" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
|
||||||
SELECT
|
SELECT
|
||||||
rad.id,
|
rad.id,
|
||||||
|
rad.ma_id AS maId,
|
||||||
|
rad.type_id AS typeId,
|
||||||
|
sum(rad.repair_num) AS repairNum,
|
||||||
|
sum(rad.repaired_num) AS repairedNum,
|
||||||
|
sum(rad.scrap_num) AS scrapNum,
|
||||||
|
rad.company_id AS companyId
|
||||||
|
FROM
|
||||||
|
repair_audit_details rad
|
||||||
|
WHERE
|
||||||
|
rad.`status` != '2'
|
||||||
|
AND rad.back_id = #{backId} AND rad.type_id = #{typeId}
|
||||||
|
<if test="maId != null">
|
||||||
|
AND rad.ma_id = #{maId}
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
rad.ma_id, rad.type_id, rad.company_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getRepairTaskDetails" resultType="com.bonus.material.repair.domain.RepairTask">
|
||||||
|
select
|
||||||
|
rad.task_id as taskId,
|
||||||
|
rad.status as status,
|
||||||
|
rad.level as level,
|
||||||
|
rad.parent_id as parentId
|
||||||
|
from repair_apply_details rad
|
||||||
|
where rad.task_id in (
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
#{item.taskId}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
GROUP BY rad.task_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getRepairDetailsById" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
|
||||||
|
SELECT
|
||||||
|
rad.id AS id,
|
||||||
rad.ma_id AS maId,
|
rad.ma_id AS maId,
|
||||||
rad.type_id AS typeId,
|
rad.type_id AS typeId,
|
||||||
rad.repair_num AS repairNum,
|
sum( rad.repair_num ) AS repairNum,
|
||||||
rad.repaired_num AS repairedNum,
|
sum( rad.repaired_num ) AS repairedNum,
|
||||||
rad.scrap_num AS scrapNum,
|
sum( rad.scrap_num ) AS scrapNum,
|
||||||
rad.company_id AS companyId
|
tt.task_id AS taskId,
|
||||||
|
tt.CODE AS taskCode,
|
||||||
|
rad.back_id AS backId,
|
||||||
|
rad.STATUS AS STATUS,
|
||||||
|
rad.LEVEL AS LEVEL
|
||||||
FROM
|
FROM
|
||||||
repair_audit_details rad
|
repair_apply_details rad
|
||||||
|
LEFT JOIN tm_task tt ON rad.task_id = tt.task_id
|
||||||
WHERE
|
WHERE
|
||||||
rad.repair_id = #{id}
|
rad.parent_id = #{id}
|
||||||
AND rad.`status` != '2'
|
GROUP BY
|
||||||
|
rad.ma_id, rad.type_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateRepairedAndScrapNum">
|
<update id="updateRepairedAndScrapNum">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue