浏览代码

Merge branch 'feature-bieao' of lift-manager/lift-server into develop

bieao 5 年之前
父节点
当前提交
7f364149c9

+ 0 - 18
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/ContractService.java

@@ -95,12 +95,6 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
             //应收金额总计
             BigDecimal planMoneyTotal = paymentList.stream().map(Payment::getPlanMoney).reduce(ZERO, BigDecimal::add);
             contracts.setPlanMoneyTotal(planMoneyTotal);
-            //实收金额总计
-            BigDecimal workMoneyTotal = paymentList.stream().map(Payment::getWorkMoney).reduce(ZERO, BigDecimal::add);
-            contracts.setWorkMoneyTotal(workMoneyTotal);
-            //开票金额总计
-            BigDecimal invoiceTotal = paymentList.stream().map(Payment::getAmountInvoice).reduce(ZERO, BigDecimal::add);
-            contracts.setInvoiceMoneyTotal(invoiceTotal);
         }
         //插入合同信息
         boolean result = save(contracts);
@@ -143,12 +137,6 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
             //应收金额总计
             BigDecimal planMoneyTotal = paymentList.stream().map(Payment::getPlanMoney).reduce(ZERO, BigDecimal::add);
             contracts.setPlanMoneyTotal(planMoneyTotal);
-            //实收金额总计
-            BigDecimal workMoneyTotal = paymentList.stream().map(Payment::getWorkMoney).reduce(ZERO, BigDecimal::add);
-            contracts.setWorkMoneyTotal(workMoneyTotal);
-            //开票金额总计
-            BigDecimal invoiceTotal = paymentList.stream().map(Payment::getAmountInvoice).reduce(ZERO, BigDecimal::add);
-            contracts.setInvoiceMoneyTotal(invoiceTotal);
         }
         //插入新合同信息
         boolean result = save(contracts);
@@ -222,12 +210,6 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
         //应收金额总计
         BigDecimal planMoneyTotal = paymentList.stream().map(Payment::getPlanMoney).reduce(ZERO, BigDecimal::add);
         contracts.setPlanMoneyTotal(planMoneyTotal);
-        //实收金额总计
-        BigDecimal workMoneyTotal = paymentList.stream().map(Payment::getWorkMoney).reduce(ZERO, BigDecimal::add);
-        contracts.setWorkMoneyTotal(workMoneyTotal);
-        //开票金额总计
-        BigDecimal invoiceTotal = paymentList.stream().map(Payment::getAmountInvoice).reduce(ZERO, BigDecimal::add);
-        contracts.setInvoiceMoneyTotal(invoiceTotal);
 
         boolean contractResult = updateById(contracts);
         if (!contractResult)

+ 6 - 8
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/PaymentService.java

@@ -15,6 +15,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.IterUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -132,7 +133,7 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
         if (IterUtil.isNotEmpty(insertList)) {
             for (Payment payment : insertList) {
                 PaymentHistory history = new PaymentHistory();
-                history.setPaymentId(payment.getId());
+                history.setPaymentId(IdWorker.getId());
                 history.setContractsId(payment.getContractsId());
                 history.setDescription("新增收款项");
                 history.setBeforeContent("--");
@@ -211,18 +212,15 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
         List<Long> paymentIdList = paymentList.stream().map(Payment::getId).collect(Collectors.toList());
         //查询原有付款列表
         Collection<Payment> oldPaymentList = paymentList(paymentIdList);
+        Long contractsId = paymentList.get(0).getContractsId();
         //设置合同付款的合同id
         paymentList.forEach(entry -> {
-            entry.setContractsId(request.getContractId());
+            entry.setContractsId(contractsId);
             entry.setCode("PA" + DateUtils.generateCode());
             entry.setType(request.getContractType());
         });
-        Long contractId = request.getContractId();
-        Contracts contracts = contractService.getOne(contractId);
+        Contracts contracts = contractService.getOne(contractsId);
         if (Objects.nonNull(contracts)) {
-            //应收金额总计
-            BigDecimal planMoneyTotal = paymentList.stream().map(Payment::getPlanMoney).reduce(ZERO, BigDecimal::add);
-            contracts.setPlanMoneyTotal(planMoneyTotal);
             //实收金额总计
             BigDecimal workMoneyTotal = paymentList.stream().map(Payment::getWorkMoney).reduce(ZERO, BigDecimal::add);
             contracts.setWorkMoneyTotal(workMoneyTotal);
@@ -230,7 +228,7 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
             BigDecimal invoiceTotal = paymentList.stream().map(Payment::getAmountInvoice).reduce(ZERO, BigDecimal::add);
             contracts.setInvoiceMoneyTotal(invoiceTotal);
             boolean result = contractService.updateById(contracts);
-            if (result) {
+            if (!result) {
                 return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
             }
         }

+ 8 - 11
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenancePlanService.java

@@ -26,6 +26,7 @@ import cn.com.ty.lift.common.model.PushMessage;
 import cn.com.ty.lift.common.model.PushUserInfo;
 import cn.com.ty.lift.common.utils.DateUtils;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelWriter;
@@ -387,7 +388,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
         LambdaQueryWrapper<MaintenancePlan> lambdaQueryWrapper = queryWrapper.lambda();
         lambdaQueryWrapper.eq(MaintenancePlan::getMtCompanyId, mtCompanyId);
         lambdaQueryWrapper.eq(MaintenancePlan::getLiftId, liftId);
-        lambdaQueryWrapper.gt(MaintenancePlan::getCount, periods);
+        lambdaQueryWrapper.ge(MaintenancePlan::getCount, periods);
         return list(lambdaQueryWrapper);
     }
 
@@ -446,17 +447,13 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
         } else if (isNull && ObjectUtil.isNotEmpty(updateInterval)) {
             //获取当前期数后的维保计划列表,并清除计划
             planList = findPlanList(mtCompanyId, liftId, periods);
-            LocalDate planDate;
-            Optional<MaintenancePlan> planOptional = planList.stream()
-                    .filter(entity -> entity.getCount().equals(periods)).findFirst();
-            if (planOptional.isPresent()) {
-                MaintenancePlan maintenancePlan = planOptional.get();
-                planDate = maintenancePlan.getPlanDate();
+            if (CollUtil.isNotEmpty(planList)) {
+                LocalDate planDate = planList.get(0).getPlanDate();
+                removeByIds(planList.stream().map(MaintenancePlan::getId).collect(Collectors.toList()));
+                //更新项目电梯关联表保养间隔
+                projectLiftRelevanceService.modify(relevance);
+                plans = generatePlan(plan, periods, updateInterval, planDate, endDate);
             } else return false;
-            removeByIds(planList.stream().map(MaintenancePlan::getId).collect(Collectors.toList()));
-            //更新项目电梯关联表保养间隔
-            projectLiftRelevanceService.modify(relevance);
-            plans = generatePlan(plan, periods, updateInterval, planDate, endDate);
         } else if (isNotNull && ObjectUtil.isNotEmpty(updateInterval)) {
             //获取当前期数后的维保计划列表,并清除计划
             planList = findPlanList(mtCompanyId, liftId, periods);