소스 검색

优化代码

wuxw 4 년 전
부모
커밋
50ce31f170

+ 7 - 0
java110-interface/src/main/java/com/java110/intf/report/IReportFeeYearCollectionInnerServiceSMO.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName IReportFeeYearCollectionInnerServiceSMO
@@ -50,4 +51,10 @@ public interface IReportFeeYearCollectionInnerServiceSMO {
      */
     @RequestMapping(value = "/queryReportFeeYearCollectionsCount", method = RequestMethod.POST)
     int queryReportFeeYearCollectionsCount(@RequestBody ReportFeeYearCollectionDto reportFeeYearCollectionDto);
+
+    @RequestMapping(value = "/queryReportFeeYearCollectionsCount", method = RequestMethod.POST)
+    List<Map> getReportFeeYearCollectionInfo(@RequestBody Map beanCovertMap);
+
+    @RequestMapping(value = "/saveReportFeeYearCollectionInfo", method = RequestMethod.POST)
+    void saveReportFeeYearCollectionInfo(@RequestBody Map beanCovertMap);
 }

+ 127 - 0
service-job/src/main/java/com/java110/job/adapt/payment/fee/PayFeeDetailToMonthAdapt.java

@@ -0,0 +1,127 @@
+package com.java110.job.adapt.payment.fee;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.fee.FeeDetailDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.owner.OwnerDto;
+import com.java110.entity.order.Business;
+import com.java110.intf.community.ICommunityInnerServiceSMO;
+import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.fee.IFeeReceiptDetailInnerServiceSMO;
+import com.java110.intf.fee.IFeeReceiptInnerServiceSMO;
+import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.intf.user.IOwnerInnerServiceSMO;
+import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.adapt.payment.fee.asyn.IPayFeeDetailToMonth;
+import com.java110.po.fee.PayFeeDetailPo;
+import com.java110.po.feeReceipt.FeeReceiptPo;
+import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ *  缴费数据离散到每个月
+ *
+ *  主要为了解决 华宁物业需求
+ *
+ * @author 吴学文
+ * @date 2020-12-11  18:54
+ */
+@Component(value = "payFeeDetailToMonthAdapt")
+public class PayFeeDetailToMonthAdapt extends DatabusAdaptImpl {
+
+    private static Logger logger = LoggerFactory.getLogger(PayFeeDetailToMonthAdapt.class);
+
+    @Autowired
+    private ICommunityInnerServiceSMO communityInnerServiceSMO;
+
+
+
+    @Autowired
+    private IFeeDetailInnerServiceSMO feeDetailInnerServiceSMOImpl;
+
+
+
+    @Autowired
+    private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMO;
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMO;
+
+    @Autowired
+    private IOwnerInnerServiceSMO ownerInnerServiceSMO;
+
+    @Autowired
+    private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMO;
+
+    @Autowired
+    private IPayFeeDetailToMonth payFeeDetailToMonthImpl;
+
+    //模板信息推送地址
+    private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
+
+    public final static String ALI_SMS_DOMAIN = "ALI_SMS";
+
+    @Override
+    public void execute(Business business, List<Business> businesses) {
+        JSONObject data = business.getData();
+        JSONArray businessPayFeeDetails = null;
+        if (data == null) {
+            FeeDetailDto feeDetailDto = new FeeDetailDto();
+            feeDetailDto.setbId(business.getbId());
+            List<FeeDetailDto> feeDetailDtos = feeDetailInnerServiceSMOImpl.queryFeeDetails(feeDetailDto);
+            Assert.listOnlyOne(feeDetailDtos, "未查询到缴费记录");
+            businessPayFeeDetails = JSONArray.parseArray(JSONArray.toJSONString(feeDetailDtos, SerializerFeature.WriteDateUseDateFormat));
+        } else if (data.containsKey(PayFeeDetailPo.class.getSimpleName())) {
+            Object bObj = data.get(PayFeeDetailPo.class.getSimpleName());
+            if (bObj instanceof JSONObject) {
+                businessPayFeeDetails = new JSONArray();
+                businessPayFeeDetails.add(bObj);
+            } else if (bObj instanceof Map) {
+                businessPayFeeDetails = new JSONArray();
+                businessPayFeeDetails.add(JSONObject.parseObject(JSONObject.toJSONString(bObj)));
+            } else if (bObj instanceof List) {
+                businessPayFeeDetails = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+            } else {
+                businessPayFeeDetails = (JSONArray) bObj;
+            }
+        } else {
+            return;
+        }
+
+        if (businessPayFeeDetails == null) {
+            return;
+        }
+        for (int bPayFeeDetailIndex = 0; bPayFeeDetailIndex < businessPayFeeDetails.size(); bPayFeeDetailIndex++) {
+            JSONObject businessPayFeeDetail = businessPayFeeDetails.getJSONObject(bPayFeeDetailIndex);
+            doPayFeeDetail(business, businessPayFeeDetail);
+        }
+    }
+
+    /**
+     * 转异步处理
+     * @param business
+     * @param businessPayFeeDetail
+     */
+    private void doPayFeeDetail(Business business, JSONObject businessPayFeeDetail) {
+        payFeeDetailToMonthImpl.doPayFeeDetail(business,businessPayFeeDetail);
+    }
+
+
+}

+ 9 - 0
service-job/src/main/java/com/java110/job/adapt/payment/fee/asyn/IPayFeeDetailToMonth.java

@@ -0,0 +1,9 @@
+package com.java110.job.adapt.payment.fee.asyn;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.entity.order.Business;
+
+public interface IPayFeeDetailToMonth {
+
+    void doPayFeeDetail(Business business, JSONObject businessPayFeeDetail);
+}

+ 117 - 0
service-job/src/main/java/com/java110/job/adapt/payment/fee/asyn/impl/PayFeeDetailToMonthIImpl.java

@@ -0,0 +1,117 @@
+package com.java110.job.adapt.payment.fee.asyn.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.RoomDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.owner.OwnerDto;
+import com.java110.dto.reportFeeYearCollection.ReportFeeYearCollectionDto;
+import com.java110.entity.order.Business;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.report.IReportFeeYearCollectionInnerServiceSMO;
+import com.java110.job.adapt.payment.fee.asyn.IPayFeeDetailToMonth;
+import com.java110.po.fee.PayFeeDetailPo;
+import com.java110.po.feeReceipt.FeeReceiptPo;
+import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo;
+import com.java110.po.reportFeeYearCollection.ReportFeeYearCollectionPo;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.ListUtil;
+import com.java110.utils.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.util.Calendar;
+import java.util.List;
+
+@Service
+public class PayFeeDetailToMonthIImpl implements IPayFeeDetailToMonth {
+
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+    @Autowired
+    private IComputeFeeSMO computeFeeSMOImpl;
+
+
+    @Autowired
+    private IReportFeeYearCollectionInnerServiceSMO reportFeeYearCollectionInnerServiceSMOImpl;
+
+    @Override
+    @Async
+    public void doPayFeeDetail(Business business, JSONObject businessPayFeeDetail) {
+        //查询缴费明细
+        PayFeeDetailPo payFeeDetailPo = BeanConvertUtil.covertBean(businessPayFeeDetail, PayFeeDetailPo.class);
+        FeeDto feeDto = new FeeDto();
+        feeDto.setFeeId(payFeeDetailPo.getFeeId());
+        feeDto.setCommunityId(payFeeDetailPo.getCommunityId());
+        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+
+        Assert.listOnlyOne(feeDtos, "未查询到费用信息");
+
+        feeDto = feeDtos.get(0);
+
+        //查询业主信息
+        OwnerDto ownerDto = computeFeeSMOImpl.getFeeOwnerDto(feeDto);
+
+        ReportFeeYearCollectionDto reportFeeYearCollectionDto = new ReportFeeYearCollectionDto();
+        reportFeeYearCollectionDto.setCommunityId(feeDto.getCommunityId());
+        reportFeeYearCollectionDto.setConfigId(feeDto.getConfigId());
+        reportFeeYearCollectionDto.setObjId(feeDto.getPayerObjId());
+        reportFeeYearCollectionDto.setObjType(feeDto.getPayerObjType());
+        List<ReportFeeYearCollectionDto> statistics = BeanConvertUtil.covertBeanList(
+                reportFeeYearCollectionInnerServiceSMOImpl.getReportFeeYearCollectionInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDto)),
+                ReportFeeYearCollectionDto.class);
+
+        ReportFeeYearCollectionPo reportFeeYearCollectionPo = new ReportFeeYearCollectionPo();
+        if (ListUtil.isNull(statistics)) {
+            reportFeeYearCollectionPo.setBuiltUpArea(reportRoomDto.getBuiltUpArea());
+            reportFeeYearCollectionPo.setCollectionId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_collectionId));
+            reportFeeYearCollectionPo.setCommunityId(feeDto.getCommunityId());
+            reportFeeYearCollectionPo.setConfigId(feeDto.getConfigId());
+            reportFeeYearCollectionPo.setFeeId(feeDto.getFeeId());
+            reportFeeYearCollectionPo.setObjId(feeDto.getPayerObjId());
+            reportFeeYearCollectionPo.setObjType(feeDto.getPayerObjType());
+            reportFeeYearCollectionPo.setFeeName(StringUtil.isEmpty(feeDto.getImportFeeName()) ? feeDto.getFeeName() : feeDto.getImportFeeName());
+            if (RoomDto.ROOM_TYPE_ROOM.equals(reportRoomDto.getRoomType())) {
+                reportFeeYearCollectionPo.setObjName(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getUnitNum() + "-" + reportRoomDto.getRoomNum());
+            } else {
+                reportFeeYearCollectionPo.setObjName(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getRoomNum());
+            }
+            reportFeeYearCollectionPo.setOwnerId(ownerDto.getOwnerId());
+            reportFeeYearCollectionPo.setOwnerName(ownerDto.getName());
+            reportFeeYearCollectionPo.setOwnerLink(ownerDto.getLink());
+
+            //reportFeeYearCollectionPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            reportFeeYearCollectionInnerServiceSMOImpl.saveReportFeeYearCollectionInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionPo));
+        } else {
+            BeanConvertUtil.covertBean(statistics.get(0), reportFeeYearCollectionPo);
+        }
+
+        //计算费用项开始时间 起始 时间至现在的年份
+        Calendar configStartTime = Calendar.getInstance();
+        configStartTime.setTime(tmpReportFeeDto.getConfigStartTime());
+        int startYear = configStartTime.get(Calendar.YEAR);
+        //结束年
+        Calendar configEndTime = Calendar.getInstance();
+        configStartTime.setTime(tmpReportFeeDto.getConfigEndTime());
+        int endYear = configEndTime.get(Calendar.YEAR);
+
+        //当前年
+        int curYear = Calendar.getInstance().get(Calendar.YEAR)+1;
+
+        double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, null);
+        tmpReportFeeDto.setFeePrice(feePrice);
+
+        if (endYear > curYear) {
+            endYear = curYear;
+        }
+
+        for (int year = startYear; year <= endYear; year++) {
+            computeYearFee(year, tmpReportFeeDto, reportFeeYearCollectionPo);
+        }
+    }
+}

+ 10 - 0
service-report/src/main/java/com/java110/report/smo/impl/ReportFeeYearCollectionInnerServiceSMOImpl.java

@@ -167,6 +167,16 @@ public class ReportFeeYearCollectionInnerServiceSMOImpl extends BaseServiceSMO i
         return reportFeeYearCollectionServiceDaoImpl.queryReportFeeYearCollectionsCount(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDto));
     }
 
+    @Override
+    public List<Map> getReportFeeYearCollectionInfo(@RequestBody Map beanCovertMap) {
+        return reportFeeYearCollectionServiceDaoImpl.getReportFeeYearCollectionInfo(beanCovertMap);
+    }
+
+    @Override
+    public void saveReportFeeYearCollectionInfo(@RequestBody Map beanCovertMap) {
+         reportFeeYearCollectionServiceDaoImpl.saveReportFeeYearCollectionInfo(beanCovertMap);
+    }
+
     public IReportFeeYearCollectionServiceDao getReportFeeYearCollectionServiceDaoImpl() {
         return reportFeeYearCollectionServiceDaoImpl;
     }