diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java index c97fc19..5962cfe 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java @@ -59,7 +59,8 @@ public class SltAgreementApply { *结算总费用 */ private String cost; + private String repairIds; - private List relations; + private SltAgreementRelation relation; } diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java index 361ee93..558bf9b 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java @@ -44,6 +44,10 @@ public class SltAgreementInfo { *机具id */ private String maId; + /** + *配件单价 + */ + private String partPrice; /** *领料数量 */ @@ -67,6 +71,10 @@ public class SltAgreementInfo { *领料id */ private String leaseId; + /** + *配件数量 + */ + private String partNum; /** *退料id */ diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java index c9ee9fd..5ede08f 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java @@ -47,6 +47,7 @@ public class SltAgreementRelation { private String leaseCostOne; private String leaseCostThree; private String scrapCost; + private String preScrapCost; private String repairCost; private String isSltOne; private String isSltThree; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/RepairApplyRecord.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/RepairApplyRecord.java index eb51bd1..ab0931a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/RepairApplyRecord.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/RepairApplyRecord.java @@ -119,6 +119,7 @@ public class RepairApplyRecord implements Serializable { private List partList; private String partStrList; private Long companyId; + private Integer partId; /** * 损坏照片id */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/RepairMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/RepairMapper.java index 5f8700f..666bed5 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/RepairMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/RepairMapper.java @@ -161,4 +161,6 @@ public interface RepairMapper { List exportRepairTaskList(RepairTask bean); int addRepairCost(@Param("bean") RepairApplyRecord bean, @Param("costs") BigDecimal costs,@Param("partType") String partType); + + String selectPartPrice(Long partId); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/RepairServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/RepairServiceImpl.java index 92e2dee..78d8a91 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/RepairServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/RepairServiceImpl.java @@ -8,11 +8,11 @@ import com.bonus.sgzb.base.domain.vo.DictVo; import com.bonus.sgzb.base.mapper.RepairMapper; import com.bonus.sgzb.base.service.RepairService; import com.bonus.sgzb.common.core.exception.ServiceException; -import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.system.api.domain.SysUser; import com.bonus.sgzb.system.api.model.LoginUser; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -58,8 +58,6 @@ public class RepairServiceImpl implements RepairService { bean.setCreateBy(loginUser.getUserid()); List partList = bean.getPartList(); BigDecimal sfCosts = new BigDecimal("0"); - BigDecimal bsfCosts = new BigDecimal("0"); - Integer partNum = 0; String nbType = "1"; String fcType = "2"; String sfPart = "1"; @@ -103,6 +101,7 @@ public class RepairServiceImpl implements RepairService { if (nbType.equals(bean.getRepairType())) { for (RepairPartDetails partDetails : partList) { if (partDetails.getPartId() != null) { + // 有维修配件时 if (partDetails.getPartCost() == null || partDetails.getPartCost().isEmpty()) { partDetails.setPartCost("0"); } @@ -111,14 +110,21 @@ public class RepairServiceImpl implements RepairService { partDetails.setTypeId(bean.getTypeId()); partDetails.setCreateBy(loginUser.getUserid()); partDetails.setCompanyId(bean.getCompanyId()); + // 根据partid 找到配件单价 + String partPrice = mapper.selectPartPrice(partDetails.getPartId()); + partDetails.setPartCost(partPrice); mapper.addPart(partDetails); bean.setPartPrice(partDetails.getPartCost()); - partNum += partDetails.getPartNum(); + bean.setPartId(partDetails.getPartId().intValue()); + bean.setPartNum(partDetails.getPartNum()); bean.setRepairContent(partDetails.getRepairContent()); bean.setPartType(partDetails.getPartType()); + mapper.addRecord(bean); + } else { + // 不选维修配件时 + mapper.addRecord(bean); } } - bean.setPartNum(partNum); } if (fcType.equals(bean.getRepairType())) { bean.setPartName(partList.get(0).getPartName()); @@ -129,40 +135,26 @@ public class RepairServiceImpl implements RepairService { } else { bean.setSupplierId(partList.get(0).getSupplierId()); } - if (bean.getPartPrice() == null || bean.getPartPrice().isEmpty()) { + if (partList.get(0).getPartPrice() == null || partList.get(0).getPartPrice().isEmpty()) { bean.setPartPrice("0"); } else { bean.setPartPrice(partList.get(0).getPartPrice()); } bean.setPartNum(partList.get(0).getPartNum()); + mapper.addRecord(bean); } for (RepairPartDetails partDetails : partList) { - - if (sfPart.equals(partDetails.getPartType())) { - if (StringUtils.isBlank(partDetails.getPartCost())) { - partDetails.setPartCost("0"); - } + if (StringUtils.isNotBlank(partDetails.getPartCost())) { BigDecimal partCost = new BigDecimal(partDetails.getPartCost()); BigDecimal partNumber = new BigDecimal(partDetails.getPartNum()); sfCosts = sfCosts.add(partCost.multiply(partNumber)); - } else if (bsfPart.equals(partDetails.getPartType())) { - if (StringUtils.isBlank(partDetails.getPartCost())) { - partDetails.setPartCost("0"); - } - BigDecimal partCost = new BigDecimal(partDetails.getPartCost()); - bsfCosts = bsfCosts.add(partCost); - } else { - throw new ServiceException("请选择配件收费类型"); } } + if (!"0".equals(sfCosts.toString())) { mapper.addRepairCost(bean, sfCosts, sfPart); } - if (!"0".equals(bsfCosts.toString())) { - mapper.addRepairCost(bean, bsfCosts, bsfPart); - } } - mapper.addRecord(bean); return AjaxResult.success(); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/RepairAuditDetailsMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/RepairAuditDetailsMapper.java index 7573f38..1918db0 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/RepairAuditDetailsMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/RepairAuditDetailsMapper.java @@ -145,4 +145,8 @@ public interface RepairAuditDetailsMapper List getPartRecord(RepairAuditDetails bean); int updateRepairCost(@Param("inputDetails")RepairAuditDetails inputDetails, @Param("status") String status); + + List getRepairApplyRecordId(Long repairId); + + void updateRecodeStatus(String id); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java index 0530ee4..bc1700d 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java @@ -70,4 +70,6 @@ public interface SltAgreementInfoMapper { int updateOutSourceCosts(SltAgreementInfo sltAgreementInfo); int updateBmAgreementInfo(@Param("agreementId") String agreementId); + + int updateRecodeIsSlt(String id); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairAuditDetailsServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairAuditDetailsServiceImpl.java index a1fbc60..de4cc20 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairAuditDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairAuditDetailsServiceImpl.java @@ -241,6 +241,12 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService repairTestInputMapper.insertRepairInputDetails(repairInputDetails); } repairAuditDetailsMapper.updateRepairCost(inputDetails,status); + // 根据repairId找到taskId和 typeId 、maid + List repairApplyRecordId = repairAuditDetailsMapper.getRepairApplyRecordId(inputDetails.getRepairId()); + // 再去repair_apply_record 中查,并给一个标识表示审核完成 + for (String id : repairApplyRecordId) { + repairAuditDetailsMapper.updateRecodeStatus(id); + } } } if (scrapNumList != null && scrapNumList.size() > 0) { diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java index feac9e0..f1889fa 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java @@ -71,7 +71,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { sltInfoVo.setScrapList(scrapList); sltInfoVo.setPreScrapList(preScrapList); sltInfoVo.setLoseList(loseList); - List relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, loseList, list); + List relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, preScrapList, loseList, list); sltInfoVo.setRelations(relations); return sltInfoVo; } @@ -237,7 +237,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return leaseList; } - private List getRelations(List leaseListOne, List leaseListThree, List repairList, List scrapList, List loseList, List list) { + private List getRelations(List leaseListOne, List leaseListThree, List repairList, List scrapList, List preScrapList, List loseList, List list) { List relations = new ArrayList<>(); for (AgreementInfo info : list) { SltAgreementRelation relation = new SltAgreementRelation(); @@ -245,6 +245,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { BigDecimal leaseCostOne = BigDecimal.ZERO; BigDecimal leaseCostThree = BigDecimal.ZERO; BigDecimal scrapCost = BigDecimal.ZERO; + BigDecimal preScrapCost = BigDecimal.ZERO; BigDecimal repairCost = BigDecimal.ZERO; for (SltAgreementInfo lease : leaseListOne) { if (lease.getAgreementId().equals(info.getAgreementId().toString())) { @@ -268,7 +269,8 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { } for (SltAgreementInfo repair : repairList) { if (repair.getAgreementId().equals(info.getAgreementId().toString())) { - BigDecimal allCost = new BigDecimal(repair.getAllCosts()); + // 暂时先计算配件总价,后期需要加上委外维修费用 + BigDecimal allCost = new BigDecimal(repair.getPartAllCosts()); repairCost = repairCost.add(allCost); } } @@ -278,6 +280,12 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { scrapCost = scrapCost.add(cost); } } + for (SltAgreementInfo scrap : preScrapList) { + if (scrap.getAgreementId().equals(info.getAgreementId().toString())) { + BigDecimal cost = new BigDecimal(scrap.getCosts()); + preScrapCost = preScrapCost.add(cost); + } + } for (SltAgreementInfo lose : loseList) { if (lose.getAgreementId().equals(info.getAgreementId().toString())) { //TODO 上面已经set过值,这里为什么还要set值 @@ -307,6 +315,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { relation.setLeaseCostThree(leaseCostThree.toString()); relation.setRepairCost(repairCost.toString()); relation.setScrapCost(scrapCost.toString()); + relation.setPreScrapCost(preScrapCost.toString()); relation.setLoseCost(loseCost.toString()); relations.add(relation); } @@ -316,8 +325,16 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { @Override @Transactional public AjaxResult submitFee(SltAgreementApply apply) { + SltAgreementRelation relation = apply.getRelation(); + if (StringUtils.isNotBlank(apply.getRepairIds())) { + for (String id : apply.getRepairIds().split(",")) { + sltAgreementInfoMapper.updateRecodeIsSlt(id); + } + } sltAgreementInfoMapper.updateInfoStatus(apply.getAgreementId()); - int i = sltAgreementInfoMapper.updateBmAgreementInfo(apply.getAgreementId()); + sltAgreementInfoMapper.updateBmAgreementInfo(apply.getAgreementId()); + relation.setAgreementId(apply.getAgreementId()); + int i = sltAgreementInfoMapper.insRelation(relation); if (i > 0) { return AjaxResult.success("结算成功"); } else { diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/RepairMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/RepairMapper.xml index 79b06e4..c0c9108 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/RepairMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/RepairMapper.xml @@ -2,8 +2,8 @@ - insert into repair_apply_record (task_id,ma_id,type_id,repair_num,scrap_num,repair_type,create_by,create_time,repair_content,company_id,scrap_reason,scrap_type,supplier_id,part_num,part_price,part_type,part_name,repairer,file_ids,remark) - values (#{taskId},#{maId},#{typeId},#{repairNum},#{scrapNum},#{repairType},#{createBy},now(),#{repairContent},#{companyId},#{scrapReason},#{scrapType},#{supplierId},#{partNum},#{partPrice},#{partType},#{partName},#{repairer},#{fileIds},#{remark}); + insert into repair_apply_record (task_id,ma_id,type_id,repair_num,scrap_num,repair_type,create_by,create_time,repair_content,company_id,scrap_reason,scrap_type,supplier_id,part_num,part_price,part_type,part_name,repairer,file_ids,remark,part_id) + values (#{taskId},#{maId},#{typeId},#{repairNum},#{scrapNum},#{repairType},#{createBy},now(),#{repairContent},#{companyId},#{scrapReason},#{scrapType},#{supplierId},#{partNum},#{partPrice},#{partType},#{partName},#{repairer},#{fileIds},#{remark},#{partId}); insert into repair_part_details (task_id,ma_id,type_id,part_id,part_num,part_cost,part_type,create_by,create_time,company_id,repair_content) @@ -272,6 +272,9 @@ from repair_apply_details where task_id = #{taskId} + diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/RepairAuditDetailsMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/RepairAuditDetailsMapper.xml index 31a456b..5e84df4 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/RepairAuditDetailsMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/RepairAuditDetailsMapper.xml @@ -223,6 +223,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" set part_type = #{status} where repair_id = #{inputDetails.repairId} + + update repair_apply_record set status = 1 where id = #{id} + delete from repair_audit_details where id = #{id} @@ -451,5 +454,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from repair_apply_details where id = #{repairId} - + + \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml index 07e0614..73f02c2 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml @@ -31,8 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" values (#{code},#{creator},now(),'0',#{companyId},#{cost}); - insert into slt_agreement_relation (apply_id,agreement_id,add_cost,sub_cost,remark,cost,status,lease_cost,repair_cost,scrap_cost,lose_cost) - values (#{applyId},#{agreementId},#{addCost},#{subCost},#{remark},#{cost},'0',#{leaseCost},#{repairCost},#{scrapCost},#{loseCost}); + insert into slt_agreement_relation (apply_id,agreement_id,add_cost,sub_cost,remark,cost,status,lease_one_cost,lease_three_cost,repair_cost,scrap_cost,lose_cost) + values (#{applyId},#{agreementId},#{addCost},#{subCost},#{remark},#{cost},'0',#{leaseCostOne},#{leaseCostThree},#{repairCost},#{scrapCost},#{loseCost}); insert into slt_agreement_details @@ -112,6 +112,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update bm_agreement_info set is_slt = 1 where agreement_id = #{agreementId} + + update repair_apply_record set is_slt = 1 where id = #{id} +