维修单分拆
This commit is contained in:
parent
99195a8a81
commit
11d34c654a
|
|
@ -29,7 +29,6 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -480,21 +479,9 @@ public class RepairServiceImpl implements RepairService {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// 分拆维修单
|
||||||
int thisTimeRepairedNum = bean.getNumberInRepairPartList().get(0).getRepairNum();
|
int thisTimeRepairedNum = bean.getNumberInRepairPartList().get(0).getRepairNum();
|
||||||
if ((bean.getRepairNum() - thisTimeRepairedNum) == 0) { //本次修完了
|
splitRepairList(bean, thisTimeRepairedNum, loginUser);
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理配件集合数据
|
// 处理配件集合数据
|
||||||
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
|
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
|
||||||
|
|
@ -519,15 +506,20 @@ public class RepairServiceImpl implements RepairService {
|
||||||
// 判断外部维修配件数量是否为空
|
// 判断外部维修配件数量是否为空
|
||||||
if (partList.get(0).getRepairNum() != null && partList.get(0).getRepairNum() != 0) {
|
if (partList.get(0).getRepairNum() != null && partList.get(0).getRepairNum() != 0) {
|
||||||
|
|
||||||
// 统计已维修数量 + 本次维修数量
|
// // 统计已维修数量 + 本次维修数量
|
||||||
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + partList.get(0).getRepairNum();
|
// int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + partList.get(0).getRepairNum();
|
||||||
// 统计报废数量 + 维修合计数量
|
// // 统计报废数量 + 维修合计数量
|
||||||
if ((repairNum + OptionalInt.of(details.getScrapNum()).orElse(0)) > details.getRepairNum()) {
|
// if ((repairNum + OptionalInt.of(details.getScrapNum()).orElse(0)) > details.getRepairNum()) {
|
||||||
throw new ServiceException("维修数量大于维修总量");
|
// throw new ServiceException("维修数量大于维修总量");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// // 更新维修数量、维修人员不变
|
||||||
|
// repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
|
||||||
|
|
||||||
|
// 分拆维修单
|
||||||
|
int thisTimeRepairedNum = partList.get(0).getRepairNum();
|
||||||
|
splitRepairList(bean, thisTimeRepairedNum, loginUser);
|
||||||
|
|
||||||
// 更新维修数量、维修人员不变
|
|
||||||
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
|
|
||||||
|
|
||||||
if (partList.get(0).getSupplierId() == null) {
|
if (partList.get(0).getSupplierId() == null) {
|
||||||
throw new ServiceException("请选择返厂厂家");
|
throw new ServiceException("请选择返厂厂家");
|
||||||
|
|
@ -625,6 +617,23 @@ public class RepairServiceImpl implements RepairService {
|
||||||
return AjaxResult.success("维修完成");
|
return AjaxResult.success("维修完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void splitRepairList(RepairDeviceVO bean, int thisTimeRepairedNum, LoginUser loginUser) {
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配件列表价格合计
|
* 配件列表价格合计
|
||||||
* @param partList 配件列表
|
* @param partList 配件列表
|
||||||
|
|
@ -633,7 +642,7 @@ public class RepairServiceImpl implements RepairService {
|
||||||
*/
|
*/
|
||||||
private static BigDecimal countPartCosts(List<RepairPartDetails> partList, BigDecimal sfCosts) {
|
private static BigDecimal countPartCosts(List<RepairPartDetails> partList, BigDecimal sfCosts) {
|
||||||
for (RepairPartDetails partDetails : partList) {
|
for (RepairPartDetails partDetails : partList) {
|
||||||
if (partDetails.getPartPrice() != null) {
|
if (partDetails.getPartPrice() != null && partDetails.getPartNum() != null) {
|
||||||
BigDecimal partPrice = partDetails.getPartPrice();
|
BigDecimal partPrice = partDetails.getPartPrice();
|
||||||
BigDecimal partNumber = new BigDecimal(partDetails.getPartNum());
|
BigDecimal partNumber = new BigDecimal(partDetails.getPartNum());
|
||||||
sfCosts = sfCosts.add(partPrice.multiply(partNumber));
|
sfCosts = sfCosts.add(partPrice.multiply(partNumber));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue