维修管理-报废逻辑优化
This commit is contained in:
parent
7b9b0eac65
commit
a759a4bdba
|
|
@ -66,9 +66,23 @@ public class RepairPartDetails extends BaseEntity {
|
||||||
private String repairContent;
|
private String repairContent;
|
||||||
|
|
||||||
/** 维修数量 */
|
/** 维修数量 */
|
||||||
|
@ApiModelProperty(value = "维修数量")
|
||||||
private Integer repairNum;
|
private Integer repairNum;
|
||||||
|
|
||||||
|
/** 报废数量 */
|
||||||
|
@ApiModelProperty(value = "报废数量")
|
||||||
|
private Integer scrapNum;
|
||||||
|
|
||||||
|
/** 报废原因 */
|
||||||
|
@ApiModelProperty(value = "报废原因")
|
||||||
|
private String scrapReason;
|
||||||
|
|
||||||
|
/** 报废原因类型(0:自然损坏,1人为损坏) */
|
||||||
|
@Excel(name = "损坏原因类型", readConverterExp = "0=:自然损坏,1人为损坏")
|
||||||
|
private String scrapType;
|
||||||
|
|
||||||
/** 维修人员 */
|
/** 维修人员 */
|
||||||
|
@ApiModelProperty(value = "维修人")
|
||||||
private String repairer;
|
private String repairer;
|
||||||
|
|
||||||
@ApiModelProperty(value = "配件名称")
|
@ApiModelProperty(value = "配件名称")
|
||||||
|
|
|
||||||
|
|
@ -320,85 +320,106 @@ public class RepairServiceImpl implements RepairService {
|
||||||
// 处理配件--数量管理--内部维修
|
// 处理配件--数量管理--内部维修
|
||||||
if (CollectionUtil.isNotEmpty(bean.getNumberInRepairPartList())) {
|
if (CollectionUtil.isNotEmpty(bean.getNumberInRepairPartList())) {
|
||||||
partList = bean.getNumberInRepairPartList();
|
partList = bean.getNumberInRepairPartList();
|
||||||
|
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 repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getNumberInRepairPartList().get(0).getRepairNum();
|
||||||
// 统计报废数量 + 维修合计数量
|
// 统计报废数量 + 维修合计数量
|
||||||
int num = repairNum + details.getScrapNum();
|
int num = repairNum + details.getScrapNum();
|
||||||
if (num > details.getRepairNum()) {
|
if (num > details.getRepairNum()) {
|
||||||
throw new ServiceException("维修数量大于维修总量");
|
throw new ServiceException("维修数量大于维修总量");
|
||||||
|
}
|
||||||
|
// ---------------校验维修数量-----------------
|
||||||
|
// 更新维修数量、并修改维修人员
|
||||||
|
repairMapper.updateRepairedNum(bean.getId(), repairNum, loginUser.getUserid(), loginUser.getUserid());
|
||||||
|
// 处理配件集合数据
|
||||||
|
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
|
||||||
}
|
}
|
||||||
// ---------------校验维修数量-----------------
|
|
||||||
// 更新维修数量、并修改维修人员
|
|
||||||
repairMapper.updateRepairedNum(bean.getId(), repairNum, loginUser.getUserid(), loginUser.getUserid());
|
|
||||||
// 处理配件集合数据
|
|
||||||
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理配件集合数据 -- 数量管理--外部返厂维修
|
// 处理配件集合数据 -- 数量管理--外部返厂维修
|
||||||
if (CollectionUtil.isNotEmpty(bean.getNumberOutRepairPartList())) {
|
if (CollectionUtil.isNotEmpty(bean.getNumberOutRepairPartList())) {
|
||||||
|
|
||||||
BigDecimal sfCosts = new BigDecimal("0");
|
BigDecimal sfCosts = new BigDecimal("0");
|
||||||
partList = bean.getNumberOutRepairPartList();
|
partList = bean.getNumberOutRepairPartList();
|
||||||
|
|
||||||
// ---------------校验维修数量-----------------
|
// 判断外部维修配件数量是否为空
|
||||||
// 统计已维修数量 + 本次维修数量
|
if (partList.get(0).getRepairNum() != null && partList.get(0).getRepairNum() != 0) {
|
||||||
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getNumberOutRepairPartList().get(0).getRepairNum();
|
|
||||||
// 统计报废数量 + 维修合计数量
|
|
||||||
int num = repairNum + details.getScrapNum();
|
|
||||||
if (num > details.getRepairNum()) {
|
|
||||||
throw new ServiceException("维修数量大于维修总量");
|
|
||||||
}
|
|
||||||
// ---------------校验维修数量-----------------
|
|
||||||
|
|
||||||
// 更新维修数量、维修人员不变
|
// ---------------校验维修数量-----------------
|
||||||
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
|
// 统计已维修数量 + 本次维修数量
|
||||||
|
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + partList.get(0).getRepairNum();
|
||||||
|
// 统计报废数量 + 维修合计数量
|
||||||
|
int num = repairNum + details.getScrapNum();
|
||||||
|
if (num > details.getRepairNum()) {
|
||||||
|
throw new ServiceException("维修数量大于维修总量");
|
||||||
|
}
|
||||||
|
// ---------------校验维修数量-----------------
|
||||||
|
|
||||||
// 数量管理--外部返厂维修
|
// 更新维修数量、维修人员不变
|
||||||
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
|
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
|
||||||
repairApplyRecord.setTaskId(bean.getTaskId());
|
|
||||||
repairApplyRecord.setMaId(bean.getMaId());
|
|
||||||
repairApplyRecord.setTypeId(bean.getTypeId());
|
|
||||||
repairApplyRecord.setRepairType(outRepairType);
|
|
||||||
repairApplyRecord.setPartName(partList.get(0).getPartName());
|
|
||||||
repairApplyRecord.setPartType(partList.get(0).getPartType());
|
|
||||||
repairApplyRecord.setRepairContent(partList.get(0).getRepairContent());
|
|
||||||
if (partList.get(0).getSupplierId() == null) {
|
|
||||||
throw new ServiceException("请选择返厂厂家");
|
|
||||||
} else {
|
|
||||||
repairApplyRecord.setSupplierId(partList.get(0).getSupplierId());
|
|
||||||
}
|
|
||||||
if (partList.get(0).getPartPrice() == null) {
|
|
||||||
repairApplyRecord.setPartPrice(new BigDecimal(0));
|
|
||||||
} else {
|
|
||||||
repairApplyRecord.setPartPrice(partList.get(0).getPartPrice());
|
|
||||||
}
|
|
||||||
repairApplyRecord.setPartNum(partList.get(0).getPartNum());
|
|
||||||
// 新增【维修记录表】
|
|
||||||
repairMapper.addRecord(repairApplyRecord);
|
|
||||||
|
|
||||||
sfCosts = countPartCosts(partList, sfCosts);
|
// 数量管理--外部返厂维修
|
||||||
// TODO: 判断是否是收费配件,因数据存在多条,可能有些是免费配件 有些收费,所以这里用价格统一做处理,后续讨论
|
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
|
||||||
// SQL: 新增【维修费用记录表】
|
repairApplyRecord.setTaskId(bean.getTaskId());
|
||||||
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
|
repairApplyRecord.setMaId(bean.getMaId());
|
||||||
|
repairApplyRecord.setTypeId(bean.getTypeId());
|
||||||
|
repairApplyRecord.setRepairType(outRepairType);
|
||||||
|
repairApplyRecord.setPartName(partList.get(0).getPartName());
|
||||||
|
repairApplyRecord.setPartType(partList.get(0).getPartType());
|
||||||
|
repairApplyRecord.setRepairContent(partList.get(0).getRepairContent());
|
||||||
|
if (partList.get(0).getSupplierId() == null) {
|
||||||
|
throw new ServiceException("请选择返厂厂家");
|
||||||
|
} else {
|
||||||
|
repairApplyRecord.setSupplierId(partList.get(0).getSupplierId());
|
||||||
|
}
|
||||||
|
if (partList.get(0).getPartPrice() == null) {
|
||||||
|
repairApplyRecord.setPartPrice(new BigDecimal(0));
|
||||||
|
} else {
|
||||||
|
repairApplyRecord.setPartPrice(partList.get(0).getPartPrice());
|
||||||
|
}
|
||||||
|
repairApplyRecord.setPartNum(partList.get(0).getPartNum());
|
||||||
|
// 新增【维修记录表】
|
||||||
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
|
||||||
|
sfCosts = countPartCosts(partList, sfCosts);
|
||||||
|
// TODO: 判断是否是收费配件,因数据存在多条,可能有些是免费配件 有些收费,所以这里用价格统一做处理,后续讨论
|
||||||
|
// SQL: 新增【维修费用记录表】
|
||||||
|
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理配件集合数据 -- 数量管理--报废维修
|
||||||
if (CollectionUtil.isNotEmpty(bean.getNumberScrapRepairPartList())) {
|
if (CollectionUtil.isNotEmpty(bean.getNumberScrapRepairPartList())) {
|
||||||
// -------------校验维修数量开始----------------
|
// 判断报废数量是否为空
|
||||||
// 统计历史已报废数量 + 本次报废数量 = 报废总数
|
if (bean.getNumberScrapRepairPartList().get(0).getScrapNum() != null && bean.getNumberScrapRepairPartList().get(0).getScrapNum() > 0) {
|
||||||
// TODO : get数组的维修数量不对,后续修改对象
|
// -------------校验维修数量开始----------------
|
||||||
int scrapNum = OptionalInt.of(details.getScrapNum()).orElse(0) + bean.getNumberScrapRepairPartList().get(0).getRepairNum();
|
// 统计历史已报废数量 + 本次报废数量 = 报废总数
|
||||||
// 统计 报废总数 + 历史已维修数量,
|
int scrapNum = OptionalInt.of(details.getScrapNum()).orElse(0) + bean.getNumberScrapRepairPartList().get(0).getScrapNum();
|
||||||
int num = scrapNum + details.getRepairedNum();
|
// 统计 报废总数 + 历史已维修数量,
|
||||||
// 不能大与总的待维修数量
|
int num = scrapNum + details.getRepairedNum();
|
||||||
if (num > details.getRepairNum()) {
|
// 不能大与总的待维修数量
|
||||||
throw new ServiceException("报废数量大于维修总量! 本次报废数量:" + bean.getScrapNum() + ",已报废数量:" + details.getScrapNum() + ",维修总量:" + details.getRepairNum());
|
if (num > details.getRepairNum()) {
|
||||||
}
|
throw new ServiceException("报废数量大于维修总量! 本次报废数量:" + bean.getScrapNum() + ",已报废数量:" + details.getScrapNum() + ",维修总量:" + details.getRepairNum());
|
||||||
// -------------校验维修数量结束----------------
|
}
|
||||||
|
// -------------校验维修数量结束----------------
|
||||||
|
|
||||||
// 更新报废数量
|
// 更新报废数量
|
||||||
repairMapper.updateScrapNum(bean.getId(), scrapNum, loginUser.getUserid());
|
repairMapper.updateScrapNum(bean.getId(), scrapNum, loginUser.getUserid());
|
||||||
|
|
||||||
|
// 报废类型无需配件,所以配件为空,添加【维修记录表】
|
||||||
|
// 维修记录表信息
|
||||||
|
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
|
||||||
|
repairApplyRecord.setTaskId(bean.getTaskId());
|
||||||
|
repairApplyRecord.setMaId(bean.getMaId());
|
||||||
|
repairApplyRecord.setTypeId(bean.getTypeId());
|
||||||
|
repairApplyRecord.setRepairType(bean.getRepairType());
|
||||||
|
repairApplyRecord.setRepairNum(null);
|
||||||
|
repairApplyRecord.setScrapNum(bean.getNumberScrapRepairPartList().get(0).getScrapNum());
|
||||||
|
repairApplyRecord.setCreateBy(loginUser.getUsername());
|
||||||
|
repairApplyRecord.setStatus(0L);
|
||||||
|
// 不选维修配件时, 只添加【维修记录表】
|
||||||
|
repairMapper.addRecord(repairApplyRecord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceException("请选择正确的维修类型");
|
throw new ServiceException("请选择正确的维修类型");
|
||||||
|
|
@ -434,6 +455,17 @@ public class RepairServiceImpl implements RepairService {
|
||||||
*/
|
*/
|
||||||
private void copeNumberManageInList(RepairDeviceVO bean, List<RepairPartDetails> partList, LoginUser loginUser, Integer manageType) {
|
private void copeNumberManageInList(RepairDeviceVO bean, List<RepairPartDetails> partList, LoginUser loginUser, Integer manageType) {
|
||||||
if (CollectionUtil.isNotEmpty(partList)) {
|
if (CollectionUtil.isNotEmpty(partList)) {
|
||||||
|
|
||||||
|
// 如果是数量管理,那么默认为内部维修
|
||||||
|
if (bean.getRepairType() == null && bean.getManageType() != null && manageType == manageTypeByNumber) {
|
||||||
|
bean.setRepairType(inRepairType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 再检查还是null的话直接结束任务
|
||||||
|
if (bean.getRepairType() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 内部维修
|
// 内部维修
|
||||||
if (bean.getRepairType() == inRepairType) {
|
if (bean.getRepairType() == inRepairType) {
|
||||||
// 遍历配件列表,判断配件类型,收费还是不收费
|
// 遍历配件列表,判断配件类型,收费还是不收费
|
||||||
|
|
@ -455,7 +487,7 @@ public class RepairServiceImpl implements RepairService {
|
||||||
repairApplyRecord.setCreateBy(loginUser.getUsername());
|
repairApplyRecord.setCreateBy(loginUser.getUsername());
|
||||||
repairApplyRecord.setStatus(0L);
|
repairApplyRecord.setStatus(0L);
|
||||||
|
|
||||||
if (partDetails.getPartId() != null) {
|
if (partDetails.getPartId() != null && partDetails.getPartNum() != null) {
|
||||||
// 有维修配件时,如果价格为空,设置为0
|
// 有维修配件时,如果价格为空,设置为0
|
||||||
if (partDetails.getPartCost() == null) {
|
if (partDetails.getPartCost() == null) {
|
||||||
partDetails.setPartCost(new BigDecimal(0));
|
partDetails.setPartCost(new BigDecimal(0));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue