维修单分拆
This commit is contained in:
parent
230789ee33
commit
99195a8a81
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.material.repair.domain.vo;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.material.basic.domain.BmFileInfo;
|
||||
import com.bonus.material.repair.domain.RepairPartDetails;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -49,6 +50,10 @@ public class RepairDeviceVO {
|
|||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
/** 退料ID */
|
||||
@ApiModelProperty(value = "退料ID")
|
||||
private Long backId;
|
||||
|
||||
@ApiModelProperty(value = "维修配件信息")
|
||||
private String partInfo;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ public interface RepairMapper {
|
|||
*/
|
||||
int updateRepairedNum(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("repairer") Long repairer, @Param("userId") Long userId);
|
||||
|
||||
int updateRepairNum(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("repairer") Long repairer, @Param("userId") Long userId);
|
||||
|
||||
int updateRepairedNumAndStatus(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("status") int status, @Param("repairer") Long repairer, @Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.bonus.common.biz.enums.RepairTaskStatusEnum;
|
|||
import com.bonus.common.biz.enums.RepairTypeEnum;
|
||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.basic.domain.BmFileInfo;
|
||||
|
|
@ -15,12 +16,14 @@ import com.bonus.material.repair.domain.vo.RepairDeviceSummaryVo;
|
|||
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
|
||||
import com.bonus.material.repair.domain.vo.RepairInputDetailsVo;
|
||||
import com.bonus.material.repair.domain.vo.RepairTicketVo;
|
||||
import com.bonus.material.repair.mapper.RepairApplyDetailsMapper;
|
||||
import com.bonus.material.repair.mapper.RepairAuditDetailsMapper;
|
||||
import com.bonus.material.repair.mapper.RepairMapper;
|
||||
import com.bonus.material.repair.service.RepairService;
|
||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -52,6 +55,9 @@ public class RepairServiceImpl implements RepairService {
|
|||
@Resource
|
||||
private RepairAuditDetailsMapper repairAuditDetailsMapper;
|
||||
|
||||
@Resource
|
||||
private RepairApplyDetailsMapper repairApplyDetailsMapper;
|
||||
|
||||
// 1:内部维修 2:外部返厂维修 3:报废
|
||||
private final int INNER_REPAIR = 1; // 需要严格匹配枚举值 RepairTypeEnum.INNER_REPAIR.getTypeId();
|
||||
private final int RETURN_FACTORY = 2; // 需要严格匹配枚举值 RepairTypeEnum.RETURN_FACTORY.getTypeId();
|
||||
|
|
@ -74,13 +80,14 @@ 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());
|
||||
if (CollectionUtil.isNotEmpty(tempList)) {
|
||||
RepairDeviceSummaryVo vo = new RepairDeviceSummaryVo();
|
||||
Long[] ids = tempList.stream().map(RepairDeviceVO::getId).toArray(Long[]::new);
|
||||
int repairNumSum = tempList.stream().mapToInt(RepairDeviceVO::getRepairNum).sum();
|
||||
int repairedNumSum = tempList.stream().mapToInt(RepairDeviceVO::getRepairedNum).sum();
|
||||
//BigDecimal typeCostSum = tempList.stream().map(RepairDeviceVO::getTotalCost).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setRepairDeviceList(tempList);
|
||||
vo.setRepairDeviceList(toRepairList);
|
||||
vo.setIds(ids);
|
||||
vo.setTypeRepairNum(repairNumSum);
|
||||
vo.setTypeRepairedNum(repairedNumSum);
|
||||
|
|
@ -465,15 +472,30 @@ public class RepairServiceImpl implements RepairService {
|
|||
if (bean.getNumberInRepairPartList().get(0).getRepairNum() != null && bean.getNumberInRepairPartList().get(0).getRepairNum() != 0) {
|
||||
// ---------------校验维修数量-----------------
|
||||
// 统计已维修数量 + 本次维修数量
|
||||
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getNumberInRepairPartList().get(0).getRepairNum();
|
||||
// 统计报废数量 + 维修合计数量
|
||||
int num = repairNum + details.getScrapNum();
|
||||
if (num > details.getRepairNum()) {
|
||||
throw new ServiceException("维修数量大于维修总量");
|
||||
// int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getNumberInRepairPartList().get(0).getRepairNum();
|
||||
// // 统计报废数量 + 维修合计数量
|
||||
// int num = repairNum + details.getScrapNum();
|
||||
// if (num > details.getRepairNum()) {
|
||||
// throw new ServiceException("维修数量大于维修总量");
|
||||
// }
|
||||
|
||||
|
||||
int thisTimeRepairedNum = bean.getNumberInRepairPartList().get(0).getRepairNum();
|
||||
if ((bean.getRepairNum() - thisTimeRepairedNum) == 0) { //本次修完了
|
||||
repairMapper.updateRepairedNum(bean.getId(), thisTimeRepairedNum, loginUser.getUserid(), loginUser.getUserid());
|
||||
} else {
|
||||
RepairApplyDetails newDetail = new RepairApplyDetails();
|
||||
BeanUtils.copyProperties(bean, newDetail);
|
||||
newDetail.setRepairNum((long) (thisTimeRepairedNum));
|
||||
newDetail.setRepairedNum((long) thisTimeRepairedNum);
|
||||
newDetail.setCreateBy(SecurityUtils.getUsername());
|
||||
newDetail.setCreateTime(DateUtils.getNowDate());
|
||||
newDetail.setRepairer(SecurityUtils.getUsername());
|
||||
newDetail.setStatus("1");
|
||||
repairApplyDetailsMapper.insertRepairApplyDetails(newDetail);
|
||||
repairMapper.updateRepairNum(bean.getId(), bean.getRepairNum() - thisTimeRepairedNum, loginUser.getUserid(), loginUser.getUserid());
|
||||
}
|
||||
// ---------------校验维修数量-----------------
|
||||
// 更新维修数量、并修改维修人员
|
||||
repairMapper.updateRepairedNum(bean.getId(), repairNum, loginUser.getUserid(), loginUser.getUserid());
|
||||
|
||||
// 处理配件集合数据
|
||||
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,13 @@
|
|||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateRepairNum">
|
||||
update repair_apply_details
|
||||
set repair_num = #{repairNum},
|
||||
update_time = now()
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateRepairedNumAndStatus">
|
||||
update repair_apply_details
|
||||
set repaired_num = #{repairNum},
|
||||
|
|
@ -275,6 +282,7 @@
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue