维修接口修改,逻辑优化,NULL异常修复
This commit is contained in:
parent
b169c81311
commit
e332d7f6cf
|
|
@ -3,6 +3,8 @@ package com.bonus.common.biz.domain;
|
|||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -20,7 +22,8 @@ public class TypeTreeNode {
|
|||
private long parentId;
|
||||
private int companyId;
|
||||
|
||||
private String num;
|
||||
@Digits(integer = Integer.MAX_VALUE, fraction = 3)
|
||||
private BigDecimal num;
|
||||
|
||||
private String manageType;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,17 @@ import com.bonus.material.basic.domain.BmFileInfo;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author BONUS
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public class RepairDeviceSummaryVo extends BaseVO {
|
||||
|
||||
|
|
|
|||
|
|
@ -80,27 +80,36 @@ public class RepairServiceImpl implements RepairService {
|
|||
Map<Long, List<RepairDeviceVO>> map = repairDeviceList.stream().collect(Collectors.groupingBy(RepairDeviceVO::getTypeId));
|
||||
for (Long key : map.keySet()) {
|
||||
List<RepairDeviceVO> tempList = map.get(key);
|
||||
//List<RepairDeviceVO> toRepairList = tempList.stream().filter(o -> !"1".equals(o.getStatus())).collect(Collectors.toList());
|
||||
// List<RepairDeviceVO> toRepairList = tempList.stream().filter(o -> !"1".equals(o.getStatus())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(tempList)) {
|
||||
RepairDeviceSummaryVo vo = new RepairDeviceSummaryVo();
|
||||
Long[] ids = tempList.stream().map(RepairDeviceVO::getId).toArray(Long[]::new);
|
||||
BigDecimal repairNumSum = tempList.stream().map(RepairDeviceVO::getRepairNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal repairedNumSum = tempList.stream().map(RepairDeviceVO::getRepairedNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal scrapNumSum = tempList.stream().map(RepairDeviceVO::getScrapNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
//BigDecimal typeCostSum = tempList.stream().map(RepairDeviceVO::getTotalCost).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setRepairDeviceList(tempList);
|
||||
vo.setIds(ids);
|
||||
vo.setTypeRepairNum(repairNumSum);
|
||||
vo.setTypeRepairedNum(repairedNumSum);
|
||||
vo.setTypeScrapNum(scrapNumSum);
|
||||
//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());
|
||||
BigDecimal repairNumSum = tempList.stream()
|
||||
.map(RepairDeviceVO::getRepairNum)
|
||||
.map(num -> Optional.ofNullable(num).orElse(BigDecimal.ZERO))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal repairedNumSum = tempList.stream()
|
||||
.map(RepairDeviceVO::getRepairedNum)
|
||||
.map(num -> Optional.ofNullable(num).orElse(BigDecimal.ZERO))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal scrapNumSum = tempList.stream()
|
||||
.map(RepairDeviceVO::getScrapNum)
|
||||
.map(num -> Optional.ofNullable(num).orElse(BigDecimal.ZERO))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// BigDecimal typeCostSum = tempList.stream().map(RepairDeviceVO::getTotalCost).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setRepairDeviceList(tempList)
|
||||
.setIds(ids)
|
||||
.setTypeRepairNum(repairNumSum)
|
||||
.setTypeRepairedNum(repairedNumSum)
|
||||
.setTypeScrapNum(scrapNumSum)
|
||||
.setTaskId(tempList.get(0).getTaskId())
|
||||
.setCode(tempList.get(0).getCode())
|
||||
.setTypeName(tempList.get(0).getTypeName())
|
||||
.setTypeId(tempList.get(0).getTypeId())
|
||||
.setType(tempList.get(0).getType())
|
||||
.setUnitName(tempList.get(0).getUnitName())
|
||||
.setManageType(tempList.get(0).getManageType());
|
||||
// .setTypeCost(typeCostSum);
|
||||
repairDeviceSummaryVoList.add(vo);
|
||||
}
|
||||
}
|
||||
|
|
@ -246,7 +255,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
|
||||
// 获取维修配件列表
|
||||
List<RepairPartDetails> partList = bean.getPartList();
|
||||
BigDecimal sfCosts = new BigDecimal("0");
|
||||
BigDecimal sfCosts = BigDecimal.ZERO;
|
||||
|
||||
// 收费配件
|
||||
String sfPart = "1";
|
||||
|
|
@ -293,7 +302,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
if (partDetails.getPartId() != null) {
|
||||
// 有维修配件时,如果价格为空,设置为0
|
||||
if (partDetails.getPartCost() == null) {
|
||||
partDetails.setPartCost(new BigDecimal(0));
|
||||
partDetails.setPartCost(BigDecimal.ZERO);
|
||||
}
|
||||
partDetails.setTaskId(bean.getTaskId());
|
||||
partDetails.setMaId(bean.getMaId());
|
||||
|
|
@ -333,7 +342,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
bean.setSupplierId(partList.get(0).getSupplierId());
|
||||
}
|
||||
if (partList.get(0).getPartPrice() == null) {
|
||||
bean.setPartPrice(new BigDecimal(0));
|
||||
bean.setPartPrice(BigDecimal.ZERO);
|
||||
} else {
|
||||
bean.setPartPrice(partList.get(0).getPartPrice());
|
||||
}
|
||||
|
|
@ -380,7 +389,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
// 判断待维修数量是否大于0
|
||||
for (RepairTaskDetails bean : list) {
|
||||
BigDecimal repairedNum = bean.getRepairNum().subtract(bean.getRepairedNum()).subtract(bean.getScrapNum());
|
||||
if (repairedNum.compareTo(new BigDecimal(0)) <= 0) {
|
||||
if (repairedNum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new ServiceException("选中的数据中包含待维修数量为0的机具,请重新选择");
|
||||
}
|
||||
}
|
||||
|
|
@ -430,20 +439,20 @@ public class RepairServiceImpl implements RepairService {
|
|||
case INNER_REPAIR: {
|
||||
partList = bean.getCodeInRepairPartList();
|
||||
// 更新维修数量、并修改维修人员
|
||||
repairMapper.updateRepairedNumAndStatus(bean.getId(), BigDecimal.valueOf(1), 1, loginUser.getUserid(), loginUser.getUserid());
|
||||
repairMapper.updateRepairedNumAndStatus(bean.getId(), BigDecimal.ZERO, 1, loginUser.getUserid(), loginUser.getUserid());
|
||||
break;
|
||||
}
|
||||
case RETURN_FACTORY: {
|
||||
partList = bean.getCodeOutRepairPartList();
|
||||
// 更新维修数量、维修人员不变
|
||||
repairMapper.updateRepairedNumTwoAndStatus(bean.getId(), BigDecimal.valueOf(1), 1, loginUser.getUserid());
|
||||
repairMapper.updateRepairedNumTwoAndStatus(bean.getId(), BigDecimal.ZERO, 1, loginUser.getUserid());
|
||||
break;
|
||||
}
|
||||
case TO_SCRAP: {
|
||||
// 报废无需上传配件、直接初始化空集合
|
||||
partList = bean.getCodeScrapRepairPartList();
|
||||
// 更新报废数量
|
||||
repairMapper.updateScrapNumAndStatus(bean.getId(), BigDecimal.valueOf(1), 1, loginUser.getUserid());
|
||||
repairMapper.updateScrapNumAndStatus(bean.getId(), BigDecimal.ZERO, 1, loginUser.getUserid());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -462,23 +471,21 @@ public class RepairServiceImpl implements RepairService {
|
|||
continue;
|
||||
}
|
||||
|
||||
BigDecimal innerRepairNum = BigDecimal.valueOf(0);
|
||||
BigDecimal outerRepairNum = BigDecimal.valueOf(0);
|
||||
BigDecimal scrapNum = BigDecimal.valueOf(0);
|
||||
BigDecimal innerRepairNum = BigDecimal.ZERO;
|
||||
BigDecimal outerRepairNum = BigDecimal.ZERO;
|
||||
BigDecimal scrapNum = BigDecimal.ZERO;
|
||||
|
||||
// 处理配件--数量管理--内部维修
|
||||
if (CollectionUtil.isNotEmpty(bean.getNumberInRepairPartList())) {
|
||||
// 获取维修详情表中的维修详情记录:待维修、已维修、已报废的数量
|
||||
RepairTaskDetails details = repairMapper.getById(bean.getId());
|
||||
|
||||
if (Objects.isNull(details)) {
|
||||
throw new ServiceException("此维修记录不存在,请检查后提交!");
|
||||
}
|
||||
|
||||
partList = bean.getNumberInRepairPartList();
|
||||
if (bean.getNumberInRepairPartList().get(0).getRepairNum() != null ) {
|
||||
if (partList.get(0).getRepairNum() != null && partList.get(0).getRepairNum().compareTo(BigDecimal.ZERO) > 0 ) {
|
||||
// 获取维修详情表中的维修详情记录:待维修、已维修、已报废的数量
|
||||
RepairTaskDetails details = repairMapper.getById(bean.getId());
|
||||
if (Objects.isNull(details)) {
|
||||
throw new ServiceException("此维修记录不存在,请检查后提交!");
|
||||
}
|
||||
// 分拆维修单, 准备数据
|
||||
innerRepairNum = bean.getNumberInRepairPartList().get(0).getRepairNum();
|
||||
innerRepairNum = partList.get(0).getRepairNum();
|
||||
// 处理配件集合数据
|
||||
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
|
||||
}
|
||||
|
|
@ -488,25 +495,20 @@ public class RepairServiceImpl implements RepairService {
|
|||
if (CollectionUtil.isNotEmpty(bean.getNumberOutRepairPartList())) {
|
||||
// 获取维修详情表中的维修详情记录:待维修、已维修、已报废的数量
|
||||
RepairTaskDetails details = repairMapper.getById(bean.getId());
|
||||
|
||||
if (Objects.isNull(details)) {
|
||||
throw new ServiceException("此维修记录不存在,请检查后提交!");
|
||||
}
|
||||
|
||||
BigDecimal sfCosts = new BigDecimal("0");
|
||||
BigDecimal sfCosts = BigDecimal.ZERO;
|
||||
partList = bean.getNumberOutRepairPartList();
|
||||
|
||||
// 重新查询维修详情
|
||||
details = repairMapper.getById(bean.getId());
|
||||
|
||||
// 判断外部维修配件数量是否为空
|
||||
if (partList.get(0).getRepairNum() != null ) {
|
||||
if (partList.get(0).getRepairNum() != null && partList.get(0).getRepairNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 分拆维修单, 准备数据
|
||||
outerRepairNum = partList.get(0).getRepairNum();
|
||||
|
||||
if (partList.get(0).getSupplierId() == null) {
|
||||
throw new ServiceException("请选择返厂厂家");
|
||||
}
|
||||
if (partList.get(0).getSupplierId() == null) {throw new ServiceException("请选择返厂厂家");}
|
||||
|
||||
// 数量管理--外部返厂维修 -- 记录表插入数据
|
||||
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
|
||||
|
|
@ -516,7 +518,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
.setPartName(repairPartDetails.getPartName()).setPartType(repairPartDetails.getPartType())
|
||||
.setRepairContent(repairPartDetails.getRepairContent()).setSupplierId(repairPartDetails.getSupplierId())
|
||||
.setPartNum(repairPartDetails.getPartNum()).setRepairer(loginUser.getUsername())
|
||||
.setPartPrice(Optional.ofNullable(repairPartDetails.getPartPrice()).orElse(new BigDecimal(0)))
|
||||
.setPartPrice(Optional.ofNullable(repairPartDetails.getPartPrice()).orElse(BigDecimal.ZERO))
|
||||
.setCreateBy(loginUser.getUsername());
|
||||
|
||||
// 新增【维修记录表】
|
||||
|
|
@ -526,14 +528,14 @@ public class RepairServiceImpl implements RepairService {
|
|||
sfCosts = countPartCosts(partList, sfCosts);
|
||||
// TODO: 判断是否是收费配件,因数据存在多条,可能有些是免费配件 有些收费,所以这里用价格统一做处理,后续讨论
|
||||
// SQL: 新增【维修费用记录表】
|
||||
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
|
||||
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(BigDecimal.ZERO) ? "0" : "1");
|
||||
}
|
||||
}
|
||||
|
||||
// 处理配件集合数据 -- 数量管理--报废维修
|
||||
if (CollectionUtil.isNotEmpty(bean.getNumberScrapRepairPartList())) {
|
||||
// 判断报废数量是否为空
|
||||
if (bean.getNumberScrapRepairPartList().get(0).getScrapNum() != null ) {
|
||||
if (bean.getNumberScrapRepairPartList().get(0).getScrapNum() != null && bean.getNumberScrapRepairPartList().get(0).getScrapNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 获取维修详情表中的维修详情记录:待维修、已维修、已报废的数量
|
||||
RepairTaskDetails details = repairMapper.getById(bean.getId());
|
||||
|
||||
|
|
@ -544,7 +546,6 @@ public class RepairServiceImpl implements RepairService {
|
|||
// 分拆维修单, 准备数据
|
||||
scrapNum = bean.getNumberScrapRepairPartList().get(0).getScrapNum();
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(bean.getNumberScrapRepairPartList().get(0).getFileList())) {
|
||||
for (BmFileInfo fileInfo : bean.getNumberScrapRepairPartList().get(0).getFileList()) {
|
||||
fileInfo.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId())
|
||||
|
|
@ -583,10 +584,8 @@ public class RepairServiceImpl implements RepairService {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
// 拆分维修单
|
||||
SplitRepairDetailsToMultiple(bean, innerRepairNum, outerRepairNum, scrapNum, loginUser);
|
||||
|
||||
splitRepairDetailsToMultiple(bean, innerRepairNum, outerRepairNum, scrapNum, loginUser);
|
||||
|
||||
} else {
|
||||
throw new ServiceException("请选择正确的维修类型");
|
||||
|
|
@ -596,15 +595,29 @@ public class RepairServiceImpl implements RepairService {
|
|||
return AjaxResult.success("维修完成");
|
||||
}
|
||||
|
||||
private void SplitRepairDetailsToMultiple(RepairDeviceVO bean, BigDecimal innerRepairNum, BigDecimal outerRepairNum, BigDecimal scrapNum, LoginUser loginUser) {
|
||||
/**
|
||||
* 将维修详情拆分到多个类别
|
||||
* 此方法用于根据内修、外修和报废数量更新维修记录,
|
||||
* 它首先检查提交的总维修数量是否超过实际维修数量,如果超过,则抛出异常
|
||||
* 如果本次维修完成了全部维修任务,则直接更新实际维修数量和报废数量,否则,更新本次维修和报废的数量
|
||||
*
|
||||
* @param bean 维修设备的视图对象,包含维修相关信息
|
||||
* @param innerRepairNum 内部维修数量
|
||||
* @param outerRepairNum 外部维修数量
|
||||
* @param scrapNum 报废数量
|
||||
* @param loginUser 当前登录用户信息,用于记录操作者
|
||||
* @throws ServiceException 如果本次维修提交总数过大,则抛出此异常
|
||||
*/
|
||||
private void splitRepairDetailsToMultiple(RepairDeviceVO bean, BigDecimal innerRepairNum, BigDecimal outerRepairNum, BigDecimal scrapNum, LoginUser loginUser) {
|
||||
if (bean.getRepairNum().compareTo(innerRepairNum.add(outerRepairNum).add(scrapNum) ) < 0) {
|
||||
throw new ServiceException("本次维修提交总数过大");
|
||||
}
|
||||
if ((bean.getRepairNum().subtract(innerRepairNum).subtract(outerRepairNum).subtract(scrapNum).compareTo(BigDecimal.valueOf(0)) ) == 0) { //本次修完了
|
||||
//本次修完了
|
||||
if ((bean.getRepairNum().subtract(innerRepairNum).subtract(outerRepairNum).subtract(scrapNum).compareTo(BigDecimal.valueOf(0)) ) == 0) {
|
||||
repairMapper.updateRepairedNum(bean.getId(), innerRepairNum.add(outerRepairNum) , loginUser.getUserid(), loginUser.getUserid());
|
||||
repairMapper.updateScrapNum(bean.getId(), scrapNum, loginUser.getUserid());
|
||||
} else {
|
||||
repairMapper.updateThisRepairedAndScrapNum(bean.getId(), innerRepairNum.add(outerRepairNum) , scrapNum, loginUser.getUserid(), loginUser.getUserid());
|
||||
repairMapper.updateThisRepairedAndScrapNum(bean.getId(), innerRepairNum.add(outerRepairNum), scrapNum, loginUser.getUserid(), loginUser.getUserid());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -666,9 +679,8 @@ public class RepairServiceImpl implements RepairService {
|
|||
|
||||
if (partDetails.getPartId() != null && partDetails.getPartNum() != null) {
|
||||
// 有维修配件时,如果价格为空,设置为0
|
||||
if (partDetails.getPartCost() == null) {
|
||||
partDetails.setPartCost(new BigDecimal(0));
|
||||
}
|
||||
if (partDetails.getPartCost() == null) {partDetails.setPartCost(BigDecimal.ZERO);}
|
||||
|
||||
partDetails.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId()).setCompanyId(null);
|
||||
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
|
||||
|
||||
|
|
@ -680,7 +692,8 @@ public class RepairServiceImpl implements RepairService {
|
|||
repairMapper.addPart(partDetails);
|
||||
|
||||
// 设置维修记录的配件费用
|
||||
repairApplyRecord.setId(bean.getId()).setPartPrice(partPrice)
|
||||
repairApplyRecord.setId(bean.getId())
|
||||
.setPartPrice(partPrice)
|
||||
.setPartNum(partDetails.getPartNum())
|
||||
.setRepairContent(partDetails.getRepairContent())
|
||||
.setPartType(partDetails.getPartType())
|
||||
|
|
@ -693,10 +706,10 @@ public class RepairServiceImpl implements RepairService {
|
|||
}
|
||||
}
|
||||
|
||||
BigDecimal sfCosts = countPartCosts(partList, new BigDecimal(0));
|
||||
BigDecimal sfCosts = countPartCosts(partList, BigDecimal.ZERO);
|
||||
// TODO: 判断是否是收费配件,因数据存在多条,可能有些是免费配件 有些收费,所以这里用价格统一做处理,后续讨论
|
||||
// SQL: 新增【维修费用记录表】
|
||||
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
|
||||
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(BigDecimal.ZERO) ? "0" : "1");
|
||||
}
|
||||
|
||||
// 外部维修
|
||||
|
|
@ -723,16 +736,16 @@ public class RepairServiceImpl implements RepairService {
|
|||
throw new ServiceException("请选择返厂厂家");
|
||||
}
|
||||
repairApplyRecord.setSupplierId(partList.get(0).getSupplierId());
|
||||
repairApplyRecord.setPartPrice(Optional.ofNullable(partList.get(0).getPartPrice()).orElse(new BigDecimal(0)));
|
||||
repairApplyRecord.setPartPrice(Optional.ofNullable(partList.get(0).getPartPrice()).orElse(BigDecimal.ZERO));
|
||||
// 新增【维修记录表】
|
||||
repairMapper.addRecord(repairApplyRecord);
|
||||
|
||||
// 配件费用计算
|
||||
BigDecimal sfCosts = countPartCosts(partList, new BigDecimal(0));
|
||||
BigDecimal sfCosts = countPartCosts(partList, BigDecimal.ZERO);
|
||||
|
||||
// TODO: 判断是否是收费配件,因数据存在多条,可能有些是免费配件 有些收费,所以这里用价格统一做处理,后续讨论
|
||||
// SQL: 新增【维修费用记录表】
|
||||
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
|
||||
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(BigDecimal.ZERO) ? "0" : "1");
|
||||
}
|
||||
|
||||
// 如果是报废类型,进行上传附件相关处理
|
||||
|
|
|
|||
|
|
@ -282,33 +282,35 @@
|
|||
|
||||
<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 + rad.this_repaired_num as repairedNum,
|
||||
rad.scrap_num + rad.this_scrap_num as scrapNum,
|
||||
rad.status as status,
|
||||
su.nick_name as repairer,
|
||||
rad.update_time as updateTime,
|
||||
rad.type_id as typeId,
|
||||
rad.back_id as backId,
|
||||
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}
|
||||
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,
|
||||
sum(ifnull(rad.repaired_num,0) + ifnull(rad.this_repaired_num,0)) as repairedNum,
|
||||
sum(ifnull(rad.scrap_num,0) + ifnull(rad.this_scrap_num,0)) as scrapNum,
|
||||
rad.status as status,
|
||||
su.nick_name as repairer,
|
||||
rad.update_time as updateTime,
|
||||
rad.type_id as typeId,
|
||||
rad.back_id as backId,
|
||||
rad.create_time,
|
||||
count(rc.id) AS totalCostRecords,
|
||||
sum(ifnull(rc.costs,0)) 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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue