diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java index f15a56e7..d3e1e224 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java @@ -60,7 +60,7 @@ public class ClzSltAgreementInfoController extends BaseController { @ApiOperation(value = "往来单位id和标段工程id获取协议信息") @PostMapping("getAgreementInfoById") - public AjaxResult getAgreementInfoById(@RequestBody SelectDto dto){ + public AjaxResult getAgreementInfoById(@RequestBody SelectDto dto) { return clzSltAgreementInfoService.getAgreementInfoById(dto); } @@ -79,7 +79,7 @@ public class ClzSltAgreementInfoController extends BaseController { dataList.add(vo); agreementId = info.getAgreementId(); } - bean = mergerData(bean, dataList,unitNames,projectNames); + bean = clzSltAgreementInfoService.mergerData(bean, dataList,unitNames,projectNames); // 根据协议id获取申请时间 TmTask tmTask = taskMapper.selectTaskByIdByCl(agreementId); if (tmTask != null) { @@ -88,60 +88,6 @@ public class ClzSltAgreementInfoController extends BaseController { return AjaxResult.success(bean); } - public MaterialSltInfoVo mergerData(MaterialSltInfoVo vo,List list,List unitNames,List projectNames){ - vo.setUnitName(handleData(unitNames)); - vo.setProjectName(handleData(projectNames)); - BigDecimal leaseCost = BigDecimal.valueOf(0.00); - BigDecimal repairCost = BigDecimal.valueOf(0.00); - BigDecimal scrapCost = BigDecimal.valueOf(0.00); - BigDecimal loseCost = BigDecimal.valueOf(0.00); - BigDecimal reducCost = BigDecimal.valueOf(0.00); - //租赁费用列表 - List leaseList = new ArrayList<>(); - //维修费用列表 - List repairList = new ArrayList<>(); - //报废费用列表 - List scrapList = new ArrayList<>(); - //丢失费用列表 - List loseList = new ArrayList<>(); - //减免费用列表 - List reductionList = new ArrayList<>(); - List relations = new ArrayList<>(); - for (MaterialSltInfoVo infoVo : list) { - leaseCost = leaseCost.add(infoVo.getLeaseCost()); - repairCost = repairCost.add(infoVo.getRepairCost()); - scrapCost = scrapCost.add(infoVo.getScrapCost()); - loseCost = loseCost.add(infoVo.getLoseCost()); - reducCost = reducCost.add(infoVo.getReductionCost()); - leaseList.addAll(infoVo.getLeaseList()); - repairList.addAll(infoVo.getRepairList()); - scrapList.addAll(infoVo.getScrapList()); - loseList.addAll(infoVo.getLoseList()); - reductionList.addAll(infoVo.getReductionList()); - relations.addAll(infoVo.getRelations()); - } - vo.setLeaseList(leaseList); - vo.setRepairList(repairList); - vo.setScrapList(scrapList); - vo.setLoseList(loseList); - vo.setReductionList(reductionList); - vo.setLeaseCost(leaseCost); - vo.setRepairCost(repairCost); - vo.setScrapCost(scrapCost); - vo.setLoseCost(loseCost); - vo.setReductionCost(reducCost); - vo.setRelations(relations); - return vo; - } - - public String handleData(List list){ - StringBuilder sb = new StringBuilder(); - Set set = new HashSet<>(list); - for (String str : set) { - sb.append(str).append("、"); - } - return StringUtils.removeEnd(sb.toString(), "、"); - } /** * 提交结算清单 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java index 45aae129..0fe8f76f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java @@ -28,6 +28,10 @@ public interface ClzSltAgreementInfoService { */ MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info); + MaterialSltInfoVo mergerData(MaterialSltInfoVo vo, List list, List unitNames, List projectNames); + + String handleData(List list); + /** * 工程下拉框 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java index a43bf311..57579da1 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java @@ -16,6 +16,7 @@ import com.bonus.material.common.domain.vo.AgreementVo; import com.bonus.material.settlement.domain.SltAgreementReduce; import com.bonus.material.settlement.domain.SltAgreementRelation; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -36,8 +37,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic /** * 根据条件获取协议结算列表 - * @param bean - * @return + * @param bean 查询条件 */ @Override public List getSltAgreementInfo4Project(MaterialSltAgreementInfo bean) { @@ -79,16 +79,6 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic leaseCost = leaseCost.add(lease.getCosts()); } } - /*for (MaterialSltAgreementInfo repair : repairList) { - if(repair.getCosts()!=null && (repair.getPartType().equals("收费"))){ - repairCost = repairCost.add(repair.getCosts()); - } - } - for (MaterialSltAgreementInfo scrap : scrapList) { - if(scrap.getCosts()!=null && (scrap.getPartType().equals("收费"))){ - scrapCost = scrapCost.add(scrap.getCosts()); - } - }*/ for (MaterialSltAgreementInfo lose : loseList) { if(lose.getCosts()!=null){ loseCost = loseCost.add(lose.getCosts()); @@ -109,6 +99,63 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic return sltInfoVo; } + @Override + public MaterialSltInfoVo mergerData(MaterialSltInfoVo vo, List list, List unitNames, List projectNames) { + vo.setUnitName(handleData(unitNames)); + vo.setProjectName(handleData(projectNames)); + BigDecimal leaseCost = BigDecimal.valueOf(0.00); + BigDecimal repairCost = BigDecimal.valueOf(0.00); + BigDecimal scrapCost = BigDecimal.valueOf(0.00); + BigDecimal loseCost = BigDecimal.valueOf(0.00); + BigDecimal reducCost = BigDecimal.valueOf(0.00); + //租赁费用列表 + List leaseList = new ArrayList<>(); + //维修费用列表 + List repairList = new ArrayList<>(); + //报废费用列表 + List scrapList = new ArrayList<>(); + //丢失费用列表 + List loseList = new ArrayList<>(); + //减免费用列表 + List reductionList = new ArrayList<>(); + List relations = new ArrayList<>(); + for (MaterialSltInfoVo infoVo : list) { + leaseCost = leaseCost.add(infoVo.getLeaseCost()); + repairCost = repairCost.add(infoVo.getRepairCost()); + scrapCost = scrapCost.add(infoVo.getScrapCost()); + loseCost = loseCost.add(infoVo.getLoseCost()); + reducCost = reducCost.add(infoVo.getReductionCost()); + leaseList.addAll(infoVo.getLeaseList()); + repairList.addAll(infoVo.getRepairList()); + scrapList.addAll(infoVo.getScrapList()); + loseList.addAll(infoVo.getLoseList()); + reductionList.addAll(infoVo.getReductionList()); + relations.addAll(infoVo.getRelations()); + } + vo.setLeaseList(leaseList); + vo.setRepairList(repairList); + vo.setScrapList(scrapList); + vo.setLoseList(loseList); + vo.setReductionList(reductionList); + vo.setLeaseCost(leaseCost); + vo.setRepairCost(repairCost); + vo.setScrapCost(scrapCost); + vo.setLoseCost(loseCost); + vo.setReductionCost(reducCost); + vo.setRelations(relations); + return vo; + } + + @Override + public String handleData(List list) { + StringBuilder sb = new StringBuilder(); + Set set = new HashSet<>(list); + for (String str : set) { + sb.append(str).append("、"); + } + return StringUtils.removeEnd(sb.toString(), "、"); + } + /** * 工程下拉框 * @@ -169,7 +216,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic @Override public AjaxResult getAgreementInfoById(SelectDto dto) { - List vo = new ArrayList<>(); + List vo; try { List list = clzSltAgreementInfoMapper.getAgreementInfoById(dto.getUnitIds(), Integer.parseInt(dto.getProjectId())); if (CollectionUtils.isNotEmpty(list)) { @@ -191,7 +238,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic @Override public int submitCosts(MaterialSltInfoVo sltInfoVo) { try { - if(sltInfoVo.getAgreementIds()!=null) { + if (sltInfoVo.getAgreementIds() != null) { for (Long agreementId : sltInfoVo.getAgreementIds()) { Long id = null; @@ -260,7 +307,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic throw new ServiceException("bm_agreement_info修改失败"); }*/ } - if (sltInfoVo.getLeaseList().size() > 0) { + if (!sltInfoVo.getLeaseList().isEmpty()) { List filteredLeaseList = sltInfoVo.getLeaseList().stream() .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) .collect(Collectors.toList()); @@ -284,7 +331,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic clzSltAgreementInfoMapper.insertSltAgreementDetailScrap(filteredScrapList, id); } }*/ - if (sltInfoVo.getLoseList().size() > 0) { + if (!sltInfoVo.getLoseList().isEmpty()) { List filteredLoseList = sltInfoVo.getLoseList().stream() .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) .collect(Collectors.toList()); @@ -302,23 +349,22 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic /** * 获取结算关系列表 - * @param leaseList - * @param repairList - * @param scrapList - * @param loseList - * @param sltInfo - * @return + * @param leaseList 领料数据 + * @param repairList 维修数据 + * @param scrapList 报废数据 + * @param loseList 丢失数据 + * @param sltInfo 结算信息 + * @return 协议费用列表 */ private List getRelations(List leaseList, List repairList, List scrapList, List loseList, MaterialSltAgreementInfo sltInfo) { List relations = new ArrayList<>(); -// for (SltAgreementInfo info : list) { SltAgreementRelation relation = new SltAgreementRelation(); BigDecimal loseCost = BigDecimal.ZERO; BigDecimal leaseCost = BigDecimal.ZERO; BigDecimal scrapCost = BigDecimal.ZERO; BigDecimal repairCost = BigDecimal.ZERO; for (MaterialSltAgreementInfo lease : leaseList) { - if (lease.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + if (lease.getAgreementId().equals(sltInfo.getAgreementId())) { relation.setAgreementId(String.valueOf(lease.getAgreementId())); relation.setProjectName(lease.getProjectName()); relation.setUnitName(lease.getUnitName()); @@ -328,19 +374,19 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic } } for (MaterialSltAgreementInfo repair : repairList) { - if (repair.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + if (repair.getAgreementId().equals(sltInfo.getAgreementId())) { BigDecimal cost = repair.getCosts(); repairCost = repairCost.add(cost); } } for (MaterialSltAgreementInfo scrap : scrapList) { - if (scrap.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + if (scrap.getAgreementId().equals(sltInfo.getAgreementId())) { BigDecimal cost = scrap.getCosts(); scrapCost = scrapCost.add(cost); } } for (MaterialSltAgreementInfo lose : loseList) { - if (lose.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + if (lose.getAgreementId().equals(sltInfo.getAgreementId())) { //TODO 上面已经set过值,这里为什么还要set值 relation.setAgreementId(String.valueOf(lose.getAgreementId())); relation.setProjectName(lose.getProjectName()); @@ -355,14 +401,12 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic relation.setScrapCost(scrapCost); relation.setLoseCost(loseCost); relations.add(relation); -// } return relations; } /** * 获取减免费用列表 - * @param info - * @return + * @param info 信息表 */ private List getReductionList(MaterialSltAgreementInfo info) { SltAgreementReduce bean =new SltAgreementReduce(); @@ -372,20 +416,17 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic /** * 获取丢失费用列表 - * @param info - * @return + * @param info 信息表 */ private List getLoseList(MaterialSltAgreementInfo info) { - List loseList = new ArrayList<>(); - List oneOfList = clzSltAgreementInfoMapper.getLoseList(info); - loseList.addAll(oneOfList); + List loseList = new ArrayList<>(oneOfList); for (MaterialSltAgreementInfo bean : loseList) { - if (null == bean.getBuyPrice()) { + if (Objects.isNull(bean.getBuyPrice())) { bean.setBuyPrice(BigDecimal.valueOf(0.00)); } - if (null == bean.getNum()) { + if (Objects.isNull(bean.getNum())) { bean.setNum(BigDecimal.valueOf(0L)); } BigDecimal buyPrice = bean.getBuyPrice(); @@ -400,14 +441,11 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic /** * 获取租赁费用列表 - * @param info - * @return + * @param info 获取租赁费用列表参数 */ private List getLeaseList(MaterialSltAgreementInfo info) { - List leaseList = new ArrayList<>(); - List oneOfList = clzSltAgreementInfoMapper.getLeaseList(info); - leaseList.addAll(oneOfList); + List leaseList = new ArrayList<>(oneOfList); for (MaterialSltAgreementInfo bean : leaseList) { if (null == bean.getLeasePrice()) { @@ -415,10 +453,10 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic }else{ bean.setLeasePrice(bean.getLeasePrice().setScale(2, RoundingMode.HALF_UP)); } - if (null == bean.getNum()) { + if (Objects.isNull(bean.getNum())) { bean.setNum(BigDecimal.valueOf(0L)); } - if (null == bean.getLeaseDays()) { + if (Objects.isNull(bean.getLeaseDays())) { bean.setLeaseDay(0L); } BigDecimal leasePrice = bean.getLeasePrice(); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java index 5e2f2396..2c190960 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java @@ -129,6 +129,7 @@ public class SltAgreementInfoController extends BaseController { } return AjaxResult.success(bean); } + public SltInfoVo mergerData(SltInfoVo vo,List list,List unitNames,List projectNames){ vo.setUnitName(handleData(unitNames)); vo.setProjectName(handleData(projectNames));