ezhizao_zx hai 1 ano
pai
achega
ef4a10e1c5

+ 17 - 11
src/main/java/cn/ezhizao/project/business/workOrder/controller/BizWorkOrderController.java

@@ -161,33 +161,33 @@ public class BizWorkOrderController extends BaseController {
 
                             //且收款金额为0
                             detailList.get(0).setTotalityMoney(detailList.get(0).getTotalityMoney() == null ? new BigDecimal(0) : detailList.get(0).getTotalityMoney());
-                            if(detailList.get(0).getAccountsReceivable().compareTo(new BigDecimal(0)) == 0){
+                            if (detailList.get(0).getAccountsReceivable().compareTo(new BigDecimal(0)) == 0) {
                                 v.setClosingMonth("已收款");
                             } else if (detailList.get(0).getTotalityMoney().compareTo(new BigDecimal(0)) == 0) {
                                 v.setClosingMonth("未收款");
                             } else if (detailList.get(0).getTotalityMoney().compareTo(detailList.get(0).getAccountsReceivable()) >= 0) {
                                 v.setClosingMonth("已收款");
                             } else {
-                                List<BizCollection>  collectionList = new ArrayList<>();
-                                BizCollection  collection=new BizCollection();
+                                List<BizCollection> collectionList = new ArrayList<>();
+                                BizCollection collection = new BizCollection();
                                 collection.setContractId(detailList.get(0).getContractId());
                                 collectionList = bizCollectionService.getList(collection);
-                                if(collectionList.size() > 0) {
+                                if (collectionList.size() > 0) {
                                     BizCollectionDetail collectionDetails = new BizCollectionDetail();
                                     collectionDetails.setContractId(detailList.get(0).getContractId());
                                     collectionDetails.setTaskTypeId(detailList.get(0).getTaskTypeId());
                                     collectionDetails.setCollectionId(collectionList.get(0).getId());
-                                    List<BizCollectionDetail>  collectionDetail = bizCollectionDetailService.getListByBean(collectionDetails);
+                                    List<BizCollectionDetail> collectionDetail = bizCollectionDetailService.getListByBean(collectionDetails);
 
                                     for (BizCollectionDetail d : collectionDetail) {
-                                        if(d.getTaskTypeId()== detailList.get(0).getTaskTypeId()) {
-                                            if(d.getAmount().compareTo(d.getArriveAmount())<=0){
+                                        if (d.getTaskTypeId() == detailList.get(0).getTaskTypeId()) {
+                                            if (d.getAmount().compareTo(d.getArriveAmount()) <= 0) {
                                                 v.setClosingMonth("已收款");
-                                            }else if (d.getAmount().compareTo(d.getArriveAmount())>0&&d.getArriveAmount().compareTo(new BigDecimal(0))!=0) {
+                                            } else if (d.getAmount().compareTo(d.getArriveAmount()) > 0 && d.getArriveAmount().compareTo(new BigDecimal(0)) != 0) {
                                                 v.setClosingMonth("部分收款");
-                                            } else if (d.getArriveAmount()==new BigDecimal(0)) {
+                                            } else if (d.getArriveAmount() == new BigDecimal(0)) {
                                                 v.setClosingMonth("未收款");
-                                            }else{
+                                            } else {
                                                 v.setClosingMonth("未收款");
                                             }
                                         }
@@ -199,14 +199,20 @@ public class BizWorkOrderController extends BaseController {
                         } else {
                             //根据单价计算月数
                             for (BizWorkOrderDetail d : detailList) {
+                                // 该明细的合同总金额
+                                BizArchiveInput e = bizArchiveInputService.getById(d.getContractId());
+                                money = e.getAmount();
                                 //如果收款金额大于0
                                 if (d.getTotalityMoney() != null && d.getTotalityMoney().compareTo(new BigDecimal(0)) > 0) {
                                     detail.setContractId(d.getContractId());
                                     detail.setTaskTypeId(d.getTaskTypeId());
                                     detail = bizArchiveInputDetailService.getDetail(detail);
-                                    BigDecimal price =money.divide(new BigDecimal(d.getServiceNum()), 2, RoundingMode.HALF_UP);//除法,保留两位小数,四舍五入
+                                    BigDecimal price = money.divide(new BigDecimal(d.getServiceNum()), 2, RoundingMode.HALF_UP);//除法,保留两位小数,四舍五入
                                     monthNum += d.getTotalityMoney().divide(price, MathContext.DECIMAL64).setScale(0, RoundingMode.DOWN).intValue();
                                 }
+                                if (money.compareTo(BigDecimal.ZERO) == 0) {
+                                    monthNum = monthNum + detail.getServiceNum() + detail.getFreeNum();
+                                }
                             }
                             //判断收款月数是否等于服务月数
                             if (detail.getServiceNum() == monthNum) {