Bläddra i källkod

Merge branch 'develop' of http://132.232.206.88:3000/lift-manager/lift-server into wanghaicheng

wanghaicheng 5 år sedan
förälder
incheckning
dfd48ba10e

+ 16 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/capital/controller/CapitalRepairController.java

@@ -7,6 +7,7 @@ import cn.com.ty.lift.business.capital.dao.entity.model.response.SignInResponse;
 import cn.com.ty.lift.business.capital.service.CapitalRepairService;
 import cn.com.ty.lift.business.capital.service.SignInService;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
+import cn.com.ty.lift.business.project.dao.entity.model.request.ProjectCountRequest;
 import cn.com.ty.lift.business.project.dao.entity.model.response.ProjectUserResponse;
 import cn.com.ty.lift.business.project.service.ProjectUserService;
 import cn.com.xwy.boot.web.dto.RestResponse;
@@ -57,6 +58,21 @@ public class CapitalRepairController {
         return RestResponse.success(page, MessageUtils.get("msg.query.success"));
     }
 
+    /**
+     * @param request 公司id,项目状态
+     * @return 项目数量、电梯数量、停保电梯数量
+     * @description 查询大修项目数量、电梯数量、停保电梯数量
+     * @date 2020/4/23 3:31 下午
+     */
+    @PostMapping("countAll")
+    public RestResponse countAll(@Valid @RequestBody ProjectCountRequest request) {
+        Map<String, Object> resultMap = capitalRepairService.countAll(request.getMtCompanyId(), request.getProjectStatus());
+        if (CollUtil.isEmpty(resultMap)) {
+            return RestResponse.success();
+        }
+        return RestResponse.success(resultMap, MessageUtils.get("msg.query.detail.success"));
+    }
+
     /**
      * @param request 大修项目id
      * @return CapitalRepair 大修项目详情

+ 2 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/capital/dao/mapper/CapitalRepairLiftRelevanceMapper.java

@@ -41,4 +41,6 @@ public interface CapitalRepairLiftRelevanceMapper extends BaseMapper<CapitalRepa
      * @date 2020/4/21 9:13 下午
      */
     ProjectDetailResponse findProjectById(@Param("request") ProjectDetailRequest request);
+
+    int count(@Param("mtCompanyId") Long mtCompanyId, @Param("projectStatus") String projectStatus);
 }

+ 11 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/capital/service/CapitalRepairLiftRelevanceService.java

@@ -30,4 +30,15 @@ public class CapitalRepairLiftRelevanceService extends ServiceImpl<CapitalRepair
         relevance.setMtCompanyId(request.getMtCompanyId());
         return save(relevance);
     }
+
+    /**
+     * @param mtCompanyId   公司id
+     * @param projectStatus 项目状态
+     * @return 条数
+     * @description 根据公司id和项目状态查询电梯
+     * @date 2020/4/23 3:44 下午
+     */
+    public int count(Long mtCompanyId, String projectStatus) {
+        return baseMapper.count(mtCompanyId, projectStatus);
+    }
 }

+ 52 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/capital/service/CapitalRepairService.java

@@ -5,6 +5,7 @@ import cn.com.ty.lift.business.capital.dao.entity.model.request.*;
 import cn.com.ty.lift.business.capital.dao.entity.model.response.CapitalRepairResponse;
 import cn.com.ty.lift.business.capital.dao.mapper.CapitalRepairMapper;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
+import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
 import cn.com.ty.lift.business.project.dao.entity.ProjectUser;
 import cn.com.ty.lift.business.project.dao.entity.model.response.ProjectUserResponse;
 import cn.com.ty.lift.business.project.service.ProjectUserService;
@@ -24,6 +25,7 @@ import java.time.LocalDate;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import static cn.com.ty.lift.common.constants.CommonEnum.CapitalRepairStatus;
 
@@ -38,6 +40,12 @@ public class CapitalRepairService extends ServiceImpl<CapitalRepairMapper, Capit
     @Resource
     private ProjectUserService projectUserService;
 
+    @Resource
+    private PlatformCompanyLiftRelevanceService platformCompanyService;
+
+    @Resource
+    private CapitalRepairLiftRelevanceService capitalRepairLiftRelevanceService;
+
     /**
      * @param request 大修项目列表查询条件
      * @return RestResponse 结果集
@@ -48,6 +56,50 @@ public class CapitalRepairService extends ServiceImpl<CapitalRepairMapper, Capit
         return baseMapper.findByCondition(request.getPage(), request);
     }
 
+    /**
+     * @param mtCompanyId   公司id
+     * @param projectStatus 项目状态
+     * @return 项目数量、电梯数量、停保电梯数量
+     * @description 查询大修项目数量、电梯数量、停保电梯数量
+     * @date 2020/4/23 3:31 下午
+     */
+    public Map<String, Object> countAll(Long mtCompanyId, String projectStatus) {
+        LambdaQueryWrapper<CapitalRepair> lambdaQueryWrapper = new QueryWrapper<CapitalRepair>().lambda();
+        lambdaQueryWrapper.eq(CapitalRepair::getMtCompanyId, mtCompanyId);
+        List<CapitalRepair> projects = list(lambdaQueryWrapper);
+        Map<String, Long> collect = projects.stream().collect(Collectors.groupingBy(CapitalRepair::getProjectStatus, Collectors.counting()));
+        Map<String, Long> totalMap = new HashMap<>();
+        Long notStart = collect.get(CapitalRepairStatus.NO_START.getCode());
+        Long inService = collect.get(CapitalRepairStatus.ABUILDING.getCode());
+        Long complete = collect.get(CapitalRepairStatus.COMPLETE.getCode());
+        totalMap.put("notStart", notStart == null ? 0 : notStart);
+        totalMap.put("inService", inService == null ? 0 : inService);
+        totalMap.put("complete", complete == null ? 0 : complete);
+        int projectCount = count(mtCompanyId, projectStatus);
+        int liftCount = capitalRepairLiftRelevanceService.count(mtCompanyId, projectStatus);
+        int stopLiftCount = platformCompanyService.count(mtCompanyId, projectStatus);
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("totalCount", totalMap);
+        resultMap.put("projectCount", projectCount);
+        resultMap.put("liftCount", liftCount);
+        resultMap.put("stopLiftCount", stopLiftCount);
+        return resultMap;
+    }
+
+    /**
+     * @param mtCompanyId   公司id
+     * @param projectStatus 项目状态
+     * @return 符合条件的项目数量
+     * @description 根据项目状态和公司id查询项目数量
+     * @date 2020/4/23 3:31 下午
+     */
+    public int count(Long mtCompanyId, String projectStatus) {
+        LambdaQueryWrapper<CapitalRepair> lambdaQueryWrapper = new QueryWrapper<CapitalRepair>().lambda();
+        lambdaQueryWrapper.eq(CapitalRepair::getMtCompanyId, mtCompanyId);
+        lambdaQueryWrapper.eq(CapitalRepair::getProjectStatus, projectStatus);
+        return count(lambdaQueryWrapper);
+    }
+
     /**
      * @param id 大修项目id
      * @return CapitalRepair 大修项目详情

+ 15 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/entity/Contracts.java

@@ -58,6 +58,21 @@ public class Contracts extends BaseEntity {
      */
     private BigDecimal moneys;
 
+    /**
+     * 应收金额总计
+     */
+    private BigDecimal planMoneyTotal;
+
+    /**
+     * 实收金额总计
+     */
+    private BigDecimal workMoneyTotal;
+
+    /**
+     * 开票金额总计
+     */
+    private BigDecimal invoiceMoneyTotal;
+
     /**
      * 合同类型(1 : 半包;2:大包;3:清包;4:全包;5:大修)
      */

+ 6 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/entity/Payment.java

@@ -18,6 +18,12 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper = true)
 public class Payment extends BaseEntity {
 
+	public Payment() {
+		this.planMoney = new BigDecimal(0);
+		this.workMoney = new BigDecimal(0);
+		this.amountInvoice = new BigDecimal(0);
+	}
+
 	/**
 	 * 收付款ID
 	 */

+ 30 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/ContractService.java

@@ -5,18 +5,18 @@ import cn.com.ty.lift.business.contract.dao.entity.ContractsExtend;
 import cn.com.ty.lift.business.contract.dao.entity.ContractsHistory;
 import cn.com.ty.lift.business.contract.dao.entity.Payment;
 import cn.com.ty.lift.business.contract.dao.entity.model.request.ContractRequest;
-import cn.com.ty.lift.business.contract.dao.entity.model.response.ContractResponse;
 import cn.com.ty.lift.business.contract.dao.entity.model.request.ContractsHistoryRequest;
+import cn.com.ty.lift.business.contract.dao.entity.model.response.ContractResponse;
 import cn.com.ty.lift.business.contract.dao.mapper.ContractsMapper;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.business.project.dao.entity.Project;
 import cn.com.ty.lift.business.project.service.ProjectService;
 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 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 lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -24,10 +24,13 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static java.math.BigDecimal.ZERO;
+
 /**
  * @author bieao
  * @date 2019/12/07
@@ -113,6 +116,18 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
             String contractCode = DateUtils.generateCode();
             contracts.setCode("HT" + contractCode);
         }
+        List<Payment> paymentList = extend.getPaymentList();
+        if (CollUtil.isNotEmpty(paymentList)) {
+            //应收金额总计
+            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);
+        }
         //插入合同信息
         int result = contractsMapper.insert(contracts);
         if (result < 0) {
@@ -121,7 +136,7 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
             return RestResponse.fail(MessageUtils.get("msg.add.fail"));
         }
         //批量插入收款信息
-        boolean ret = paymentService.insertBatch(extend.getPaymentList(), contracts.getId());
+        boolean ret = paymentService.insertBatch(paymentList, contracts.getId());
         if (!ret) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return RestResponse.fail(MessageUtils.get("msg.add.batch.fail"));
@@ -151,11 +166,23 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
         Contracts contracts = extend.getContracts();
         //修改合同信息
         contracts.setIsCheck(0);
+        List<Payment> paymentList = extend.getPaymentList();
+        //应收金额总计
+        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) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
         }
+
         //修改付款信息
         boolean paymentResult = paymentService.modifyBatchById(extend.getPaymentList());
         if (!paymentResult) {

+ 1 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/PaymentService.java

@@ -46,12 +46,11 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
      */
     public PaymentResponse detail(PaymentDetailRequest request){
         PaymentResponse response = new PaymentResponse();
-        PaymentDetailResponse detail = new PaymentDetailResponse();
+        PaymentDetailResponse detail = baseMapper.queryProjectDetailById(request);;
         //大修收款详情
         if ("2".equals(request.getPaymentType())) {
             detail = baseMapper.queryCapitalDetailById(request);
         }
-        detail = baseMapper.queryProjectDetailById(request);
         LambdaQueryWrapper<Payment> lambdaQueryWrapper = new QueryWrapper<Payment>().lambda();
         lambdaQueryWrapper.eq(Payment::getContractsId, request.getId());
         List<Payment> paymentList = list(lambdaQueryWrapper);

+ 6 - 6
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/controller/EmergencyRepairController.java

@@ -461,13 +461,13 @@ public class EmergencyRepairController {
         Verify.notNull(repair);
 
         List<ErRecordCost> erRecordCosts = request.getErRecordCosts();
-        BigDecimal costTotal = erRecordCosts.stream().map(ErRecordCost::getCostMoney).reduce(BigDecimal.ZERO, (m1, m2) -> m1.add(m2));
+        BigDecimal costTotal = erRecordCosts.stream().map(ErRecordCost::getCostMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
         repair.setCostTotal(costTotal);
 
-        BigDecimal payTotal = erRecordCosts.stream().map(ErRecordCost::getPayMoney).reduce(BigDecimal.ZERO, (m1, m2) -> m1.add(m2));
+        BigDecimal payTotal = erRecordCosts.stream().map(ErRecordCost::getPayMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
         repair.setPayTotal(payTotal);
 
-        BigDecimal invoiceTotal = erRecordCosts.stream().map(ErRecordCost::getInvoiceMoney).reduce(BigDecimal.ZERO, (m1, m2) -> m1.add(m2));
+        BigDecimal invoiceTotal = erRecordCosts.stream().map(ErRecordCost::getInvoiceMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
         repair.setInvoiceTotal(invoiceTotal);
 
         return emergencyRepairService.addCost(repair, erRecordCosts);
@@ -529,13 +529,13 @@ public class EmergencyRepairController {
         Verify.notNull(repair);
 
         List<ErRecordCost> erRecordCosts = request.getErRecordCosts();
-        BigDecimal costTotal = erRecordCosts.stream().map(ErRecordCost::getCostMoney).reduce(BigDecimal.ZERO, (m1, m2) -> m1.add(m2));
+        BigDecimal costTotal = erRecordCosts.stream().map(ErRecordCost::getCostMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
         repair.setCostTotal(costTotal);
 
-        BigDecimal payTotal = erRecordCosts.stream().map(ErRecordCost::getPayMoney).reduce(BigDecimal.ZERO, (m1, m2) -> m1.add(m2));
+        BigDecimal payTotal = erRecordCosts.stream().map(ErRecordCost::getPayMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
         repair.setPayTotal(payTotal);
 
-        BigDecimal invoiceTotal = erRecordCosts.stream().map(ErRecordCost::getInvoiceMoney).reduce(BigDecimal.ZERO, (m1, m2) -> m1.add(m2));
+        BigDecimal invoiceTotal = erRecordCosts.stream().map(ErRecordCost::getInvoiceMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
         repair.setInvoiceTotal(invoiceTotal);
 
         List<ErRecordCost> oldRecordCosts = erRecordCostService.listByErRecordId(request.getId());

+ 12 - 7
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectService.java

@@ -14,7 +14,7 @@ import cn.com.ty.lift.business.project.dao.entity.model.response.ProjectUserResp
 import cn.com.ty.lift.business.project.dao.mapper.ProjectHistoryMapper;
 import cn.com.ty.lift.business.project.dao.mapper.ProjectMapper;
 import cn.com.ty.lift.common.base.ExportRequest;
-import cn.com.ty.lift.common.constants.CommonEnum;
+import cn.com.ty.lift.common.constants.CommonEnum.ProjectStatus;
 import cn.com.ty.lift.common.export.ExportUtils;
 import cn.com.ty.lift.common.utils.DateUtils;
 import cn.com.ty.lift.common.verify.Verify;
@@ -103,10 +103,10 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
         List<Project> projects = list(lambdaQueryWrapper);
         Map<String, Long> collect = projects.stream().collect(Collectors.groupingBy(Project::getProjectStatus, Collectors.counting()));
         Map<String, Long> totalMap = new HashMap<>();
-        Long notStart = collect.get(CommonEnum.ProjectStatus.NOT_START.getCode());
-        Long inService = collect.get(CommonEnum.ProjectStatus.IN_SERVICE.getCode());
-        Long stopService = collect.get(CommonEnum.ProjectStatus.STOP_SERVICE.getCode());
-        Long overdue = collect.get(CommonEnum.ProjectStatus.OVERDUE.getCode());
+        Long notStart = collect.get(ProjectStatus.NOT_START.getCode());
+        Long inService = collect.get(ProjectStatus.IN_SERVICE.getCode());
+        Long stopService = collect.get(ProjectStatus.STOP_SERVICE.getCode());
+        Long overdue = collect.get(ProjectStatus.OVERDUE.getCode());
         totalMap.put("notStart", notStart == null ? 0 : notStart);
         totalMap.put("inService", inService == null ? 0 : inService);
         totalMap.put("stopService", stopService == null ? 0 : stopService);
@@ -316,8 +316,13 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
         List<ProjectLiftRelevance> liftList = projectLiftRelevanceService.findLiftList(request.getMtCompanyId(), request.getId());
 
         List<Long> liftIdList = liftList.stream().map(ProjectLiftRelevance::getLiftId).collect(Collectors.toList());
-        //根据公司id和电梯id列表查询维保计划列表
-        List<LiftPrintResponse> liftMaintenancePlanList = maintenancePlanService.getLiftMaintenancePlanList(request.getMtCompanyId(), liftIdList, request.getBeginTime());
+        List<LiftPrintResponse> liftMaintenancePlanList;
+        if (CollUtil.isEmpty(liftIdList)) {
+            liftMaintenancePlanList = new ArrayList<>();
+        } else {
+            //根据公司id和电梯id列表查询维保计划列表
+            liftMaintenancePlanList = maintenancePlanService.getLiftMaintenancePlanList(request.getMtCompanyId(), liftIdList, request.getBeginTime());
+        }
         project.setLiftList(liftMaintenancePlanList);
         project.setNum(liftList.size());
         project.setMonthDay(monthDay);

+ 8 - 0
lift-business-service/src/main/resources/mapper/capital/CapitalRepairLiftRelevanceMapper.xml

@@ -91,4 +91,12 @@
         LEFT JOIN property_contact pcc ON t.contact_id = pcc.id
         LEFT JOIN user_info ui ON ui.user_id = t.clerk_id
     </select>
+
+    <select id="count" resultType="java.lang.Integer">
+        SELECT count(1)
+        FROM capital_repair_lift_relevance crlr
+                 LEFT JOIN capital_repair cr ON crlr.project_id = cr.id
+        WHERE crlr.mt_company_id = #{mtCompanyId}
+          AND cr.project_status = #{projectStatus}
+    </select>
 </mapper>

+ 3 - 0
lift-business-service/src/main/resources/mapper/contract/ContractsMapper.xml

@@ -10,6 +10,9 @@
         <result column="pay_mode" property="payMode" jdbcType="VARCHAR" />
         <result column="lift_num" property="liftNum" jdbcType="INTEGER" />
         <result column="moneys" property="moneys" jdbcType="DECIMAL" />
+        <result column="plan_money_total" property="planMoneyTotal" jdbcType="DECIMAL" />
+        <result column="work_money_total" property="workMoneyTotal" jdbcType="DECIMAL" />
+        <result column="invoice_money_total" property="invoiceMoneyTotal" jdbcType="DECIMAL" />
         <result column="type" property="type" jdbcType="INTEGER" />
         <result column="status" property="status" jdbcType="INTEGER" />
         <result column="given_date" property="givenDate" jdbcType="TIMESTAMP" />

+ 3 - 3
lift-business-service/src/main/resources/mapper/contract/PaymentMapper.xml

@@ -40,10 +40,10 @@
 		       c.code                          AS contractCode,
 			   p.project_name                  AS projectName,
 			   pa.code                         AS paymentCode,
-			   pa.plan_money                   AS receivableAmount,
-			   pa.work_money                   AS receivedAmount,
-			   (pa.plan_money - pa.work_money) AS unCollectedAmount,
+			   c.plan_money_total              AS planMoney,
+			   c.work_money_total              AS workMoney,
 		       pa.plan_date                    AS planDate,
+		       pa.work_date                    AS workDate,
 			   pa.cashier_user                 AS cashierUser
 		FROM contracts c
 				 LEFT JOIN payment pa ON c.id = pa.contracts_id