qin 1 سال پیش
والد
کامیت
ef3d2a226e
23فایلهای تغییر یافته به همراه2337 افزوده شده و 1 حذف شده
  1. 51 0
      src/main/java/com/poteviohealth/cgp/statistics/config/SwaggerConfig.java
  2. 70 0
      src/main/java/com/poteviohealth/cgp/statistics/config/XxlJobConfig.java
  3. 36 0
      src/main/java/com/poteviohealth/cgp/statistics/job/OrderFaceJobHandler.java
  4. 171 0
      src/main/java/com/poteviohealth/cgp/statistics/mapper/OrderMapper.java
  5. 118 0
      src/main/java/com/poteviohealth/cgp/statistics/model/Order.java
  6. 21 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/Customer.java
  7. 21 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/Employee.java
  8. 17 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/IntegralProduct.java
  9. 61 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/IntegralTrans.java
  10. 23 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/IntegralTransaction.java
  11. 50 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/OrderIntegrationData.java
  12. 24 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/OrderServiceTypeDTO.java
  13. 20 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/Product.java
  14. 46 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/StationMerchant.java
  15. 25 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/SubsidyCustomerJsonVo.java
  16. 23 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/SupplierStation.java
  17. 20 0
      src/main/java/com/poteviohealth/cgp/statistics/model/outdto/SupplierStationEmployee.java
  18. 17 0
      src/main/java/com/poteviohealth/cgp/statistics/service/IOrderService.java
  19. 1312 0
      src/main/java/com/poteviohealth/cgp/statistics/service/impl/OrderServiceImpl.java
  20. 201 0
      src/main/resources/mapper/statistics/OrderMapper.xml
  21. 3 0
      src/main/resources/rizhao/application.yml
  22. 3 0
      src/main/resources/uat/application.yml
  23. 4 1
      src/main/resources/zky/application.yml

+ 51 - 0
src/main/java/com/poteviohealth/cgp/statistics/config/SwaggerConfig.java

@@ -0,0 +1,51 @@
+package com.poteviohealth.cgp.statistics.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.service.Parameter;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Qin
+ */
+@Configuration
+@EnableSwagger2
+@Profile({"develop","uat"})
+public class SwaggerConfig {
+    @Bean
+    public Docket productApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.poteviohealth.cgp.statistics"))
+//                .paths(regex("/product.*"))
+                .build()
+                .globalOperationParameters(setHeaderToken())
+                .apiInfo(metaData());
+    }
+    private List<Parameter> setHeaderToken() {
+        ParameterBuilder tokenPar = new ParameterBuilder();
+        List<Parameter> pars = new ArrayList<>();
+        tokenPar.name("x-token").description("token").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
+        pars.add(tokenPar.build());
+        return pars;
+    }
+    private ApiInfo metaData() {
+        return new ApiInfoBuilder()
+                .title("统计服务")
+                .version("1.1.0")
+                .contact(new Contact("Qin", "http://www.poteviohealth.com/", "nobody@poteviohealth.com"))
+                .build();
+    }
+}

+ 70 - 0
src/main/java/com/poteviohealth/cgp/statistics/config/XxlJobConfig.java

@@ -0,0 +1,70 @@
+package com.poteviohealth.cgp.statistics.config;
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import lombok.Data;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+/**
+ * xxl-job config
+ *
+ * @author xuxueli 2017-04-28
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "xxl.job")
+public class XxlJobConfig {
+    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
+
+    private String addresses;
+
+    private String appName;
+
+    private String ip;
+
+    private int port;
+
+    private String accessToken;
+
+    private String logPath;
+
+    private int logRetentionDays;
+
+
+    @Bean
+    public XxlJobSpringExecutor xxlJobExecutor() {
+        logger.info(">>>>>>>>>>> xxl-job config init.");
+        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+        xxlJobSpringExecutor.setAdminAddresses(addresses);
+        xxlJobSpringExecutor.setAppname(appName);
+        xxlJobSpringExecutor.setIp(ip);
+        xxlJobSpringExecutor.setPort(port);
+        xxlJobSpringExecutor.setAccessToken(accessToken);
+        xxlJobSpringExecutor.setLogPath(logPath);
+        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
+
+        return xxlJobSpringExecutor;
+    }
+
+    /**
+     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
+     *
+     *      1、引入依赖:
+     *          <dependency>
+     *             <groupId>org.springframework.cloud</groupId>
+     *             <artifactId>spring-cloud-commons</artifactId>
+     *             <version>${version}</version>
+     *         </dependency>
+     *
+     *      2、配置文件,或者容器启动变量
+     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
+     *
+     *      3、获取IP
+     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
+     */
+
+
+}

+ 36 - 0
src/main/java/com/poteviohealth/cgp/statistics/job/OrderFaceJobHandler.java

@@ -0,0 +1,36 @@
+package com.poteviohealth.cgp.statistics.job;
+
+import com.alibaba.fastjson.JSONObject;
+import com.poteviohealth.cgp.statistics.service.IOrderService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.IJobHandler;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.Optional;
+
+
+/**
+ * 大屏统计
+ * @author Qin
+ */
+
+@Component
+public class OrderFaceJobHandler extends IJobHandler {
+
+	@Resource
+	private IOrderService orderService;
+
+	@Override
+	@XxlJob(value="statisticsJobHandler")
+	public ReturnT<String> execute(String param){
+		XxlJobLogger.log("XXL-JOB, statistics Start");
+		JSONObject jsonObject = Optional.ofNullable(JSONObject.parseObject(param)).orElseGet(JSONObject::new);
+		String date = jsonObject.getString("date");
+		orderService.statisticsOrder(date);
+		return SUCCESS;
+	}
+
+}

+ 171 - 0
src/main/java/com/poteviohealth/cgp/statistics/mapper/OrderMapper.java

@@ -0,0 +1,171 @@
+package com.poteviohealth.cgp.statistics.mapper;
+
+import com.baomidou.mybatisplus.annotation.SqlParser;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.poteviohealth.cgp.common.integrated.ListParams;
+import com.poteviohealth.cgp.common.integrated.customer.model.CustomerServiceParams;
+import com.poteviohealth.cgp.common.integrated.customer.model.CustomerSubsidyDTO;
+import com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO;
+import com.poteviohealth.cgp.statistics.model.Order;
+import com.poteviohealth.cgp.statistics.model.outdto.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 居家大屏
+ * @author Qin
+ */
+@Mapper
+public interface OrderMapper extends BaseMapper<Order> {
+
+    /**
+     * 获取积分客户信息
+     * @param wrapper
+     * @param operator
+     * @param dbName
+     * @return
+     */
+    @SqlParser(filter = true)
+    List<IntegralTrans> integralCustomerList(@Param(Constants.WRAPPER) Wrapper wrapper, @Param("operatorId") Integer operator, @Param("dbName") String dbName);
+
+
+    /**
+     * 积分大屏统计
+     * @return
+     */
+    @SqlParser(filter = true)
+    List<IntegralTrans> integralTransList(@Param(Constants.WRAPPER) Wrapper wrapper, @Param("operatorId") Integer operator, @Param("dbName") String dbName);
+
+
+    /**
+     * 获取区域信息
+     * @param dbName
+     * @return
+     */
+    List<AreaDTO> areaList(@Param("dbName") String dbName);
+
+    /**
+     * 获取驿站员工信息
+     * @param dbName
+     * @return
+     */
+    List<SupplierStationEmployee> supplierStationEmployeeList(@Param("dbName") String dbName);
+
+
+    /**
+     * 获取驿站信息
+     * @param dbName
+     * @return
+     */
+    List<SupplierStation> supplierStationList(@Param("dbName") String dbName);
+
+
+    /**
+     * 获取服务人员信息
+     * @param dbName
+     * @return
+     */
+    List<Employee> employeeList(@Param("dbName") String dbName);
+
+    /**
+     * 获取平台运营商
+     * @param dbName
+     * @return
+     */
+    List<Integer> getOperatorList(@Param("dbName") String dbName);
+
+    /**
+     * 获取客户信息
+     * @param operatorId
+     * @param dbName
+     * @param wrapper
+     * @return
+     */
+    List<CustomerSubsidyDTO> getSubsidyCustomerList(@Param("operatorId")Integer operatorId, @Param("dbName")String dbName, @Param(Constants.WRAPPER) Wrapper wrapper);
+
+    /**
+     * 统计已服务客户数
+     * @param operatorId
+     * @param dbName
+     * @return
+     */
+    @SqlParser(filter = true)
+    List<CustomerServiceParams> orderServiceCustomerList(@Param("operatorId")Integer operatorId, @Param("dbName")String dbName);
+
+    /**
+     * 获取助餐客户信息
+     * @param operatorId
+     * @param dbName
+     * @param wrapper
+     * @return
+     */
+    List<Customer> getSubsidyCustomerMealList(@Param("operatorId")Integer operatorId, @Param("dbName")String dbName, @Param(Constants.WRAPPER) Wrapper wrapper);
+
+    /**
+     * 获取订单数据
+     * @param operatorId
+     * @param dbName
+     * @param wrapper
+     * @return
+     */
+    @SqlParser(filter = true)
+    List<OrderIntegrationData> queryOrderIntegrationData(@Param("operatorId")Integer operatorId, @Param("dbName")String dbName,@Param(Constants.WRAPPER) Wrapper wrapper);
+
+    /**
+     * 获取服务分类
+     * @param dbName
+     * @return
+     */
+    List<ListParams> getAllCategory(@Param("dbName")String dbName);
+
+    /**
+     * 积分交易
+     * @param dbName
+     * @return
+     */
+    List<IntegralTransaction> integralTransactionList(@Param("dbName")String dbName,@Param("operatorId")Integer operatorId);
+
+    /**
+     * 积分商品
+     * @param dbName
+     * @return
+     */
+    List<IntegralProduct> integralProductList(@Param("dbName")String dbName);
+
+    /**
+     * 获取商户
+     * @param dbName
+     * @return
+     */
+    List<StationMerchant> getStationMerchantList(@Param("dbName")String dbName);
+
+    /**
+     * 查询消费商品
+     * @param dbName
+     * @param operatorId
+     * @return
+     */
+    List<Product> queryIntegralProduct(@Param("dbName")String dbName,@Param("operatorId")Integer operatorId);
+
+    /**
+     * 获取有积分记录的运营商
+     * @param dbName
+     * @param wrapper
+     * @return
+     */
+    List<Integer> getIntegralCardAccOperatorIdList(@Param("dbName")String dbName,@Param(Constants.WRAPPER) Wrapper wrapper);
+
+    /**
+     * 获取有积分记录的运营商
+     * @param dbName
+     * @return
+     */
+    List<Integer> getIntegralCardDetailOperatorIdList(@Param("dbName")String dbName);
+
+
+
+}

+ 118 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/Order.java

@@ -0,0 +1,118 @@
+package com.poteviohealth.cgp.statistics.model;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.poteviohealth.cgp.common.model.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 居家大屏数据
+ * @author Qin
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("f_face_order")
+public class Order extends BaseEntity {
+    @ApiModelProperty(value = "运营商Id")
+    @TableField(value = "operator_id", insertStrategy= FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
+    private Integer operatorId;
+    @ApiModelProperty(value = "更新时间")
+    private Date changeDate;
+    @ApiModelProperty(value = "层级")
+    private Integer sourceLevel;
+    @ApiModelProperty(value = "区域编码")
+    private String regionAreaCode;
+    @ApiModelProperty(value = "区域Id")
+    private Integer areaId;
+    @ApiModelProperty(value = "区域名称")
+    private String areaName;
+    @ApiModelProperty(value = "结构树")
+    private String treePath;
+    @ApiModelProperty(value = "老人总数")
+    private Integer customerNum;
+    @ApiModelProperty(value = "已服务老人数")
+    private Integer customerServiceNum;
+    @ApiModelProperty(value = "政府购买服务人数")
+    private Integer customerGovernmentNum;
+    @ApiModelProperty(value = "社会化服务人数")
+    private Integer customerSocietyNum;
+    @ApiModelProperty(value = "服务覆盖率(已服务启用服务对象人数/服务对象总人数)")
+    private BigDecimal customerRate;
+    @ApiModelProperty(value = "补贴老人年龄")
+    private String customerAgeList;
+    @ApiModelProperty(value = "已服务老人数")
+    private String customerList;
+    @ApiModelProperty(value = "服务人员数(只统计服务站的服务人员)")
+    private Integer employeeNum;
+    @ApiModelProperty(value = "服务人员年龄集合")
+    private String employeeList;
+    @ApiModelProperty(value = "回访人数")
+    private Integer visitNum;
+    @ApiModelProperty(value = "回访率")
+    private BigDecimal visitRate;
+    @ApiModelProperty(value = "满意率")
+    private BigDecimal satisfactionRate;
+    @ApiModelProperty(value = "合格率")
+    private BigDecimal qualifiedRate;
+    @ApiModelProperty(value = "已完成工单总数")
+    private Integer orderNum;
+    @ApiModelProperty(value = "本月已完成工单总数")
+    private Integer orderNumMonth;
+    @ApiModelProperty(value = "本周已完成工单总数")
+    private Integer orderNumWeek;
+    @ApiModelProperty(value = "本日已完成工单总数")
+    private Integer orderNumDay;
+    @ApiModelProperty(value = "探访次数")
+    private Integer careNum;
+    @ApiModelProperty(value = "探访率")
+    private BigDecimal careRate;
+    @ApiModelProperty(value = "探访图片")
+    private String carePic;
+    @ApiModelProperty(value = "探访人数")
+    private Integer careMember;
+    @ApiModelProperty(value = "探访人群总数")
+    private Integer careAllMember;
+    @ApiModelProperty(value = "服务统计")
+    private String serviceTypeList;
+    /**
+     * 助餐
+     */
+    @ApiModelProperty(value = "助餐驿站数")
+    private Integer allStationNum;
+    @ApiModelProperty(value = "助餐客户数")
+    private Integer allCustomerNum;
+    @ApiModelProperty(value = "助餐服务人数")
+    private Integer serviceCustomerNum;
+    @ApiModelProperty(value = "积分会员数")
+    private Integer pointMember;
+    @ApiModelProperty(value = "积分商户数")
+    private Integer pointStation;
+    @ApiModelProperty(value = "积分发放数")
+    private Long pointGrant;
+    @ApiModelProperty(value = "积分兑换数")
+    private Long pointExchange;
+    @ApiModelProperty(value = "积分会员统计")
+    private String memberListData;
+    @ApiModelProperty(value = "积分商户统计")
+    private String providerData;
+    @ApiModelProperty(value = "积分商品统计")
+    private String goodsData;
+    @ApiModelProperty(value = "消分商品统计")
+    private String goodsData2;
+    @ApiModelProperty(value = "月度积分统计")
+    private String pointMonthData;
+    @ApiModelProperty(value = "交易次数统计")
+    private String pointCountData;
+    @ApiModelProperty(value = "积分商品个数统计")
+    private String pointGoodsData;
+    @ApiModelProperty(value = "消分商品个数统计")
+    private String pointGoodsData2;
+}

+ 21 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/Customer.java

@@ -0,0 +1,21 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class Customer {
+
+    @ApiModelProperty(value = "市编码")
+    private Integer nowCityId;
+    @ApiModelProperty(value = "区")
+    private Integer nowCountryId;
+    @ApiModelProperty(value = "街道")
+    private Integer nowStreetId;
+
+}

+ 21 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/Employee.java

@@ -0,0 +1,21 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class Employee {
+
+    @ApiModelProperty(value = "市编码")
+    private Integer age;
+    @ApiModelProperty(value = "性别 0=女,1=男")
+    private Integer gender;
+    @ApiModelProperty(value = "id")
+    private Integer id;
+
+}

+ 17 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/IntegralProduct.java

@@ -0,0 +1,17 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class IntegralProduct {
+
+    @ApiModelProperty(name = "merchantId" , value = "商户ID")
+    private Integer merchantId;
+
+}

+ 61 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/IntegralTrans.java

@@ -0,0 +1,61 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class IntegralTrans {
+
+    @ApiModelProperty("交易类型 0:充值;1:消费;2:退款;3:结转;4:清零;5.转赠;6.受赠;7.捐赠")
+    private String transType;
+
+    @ApiModelProperty("动账金额,单位:分")
+    private Long amount;
+
+    @ApiModelProperty("生成时间")
+    private Date buildTime;
+
+    @ApiModelProperty("创建时间")
+    private Date createdDate;
+
+    @ApiModelProperty("客户Id")
+    private Long subsidyCustomerId;
+
+    @ApiModelProperty("运营商Id")
+    private Integer operatorId;
+
+    @ApiModelProperty("商品分类")
+    private Integer productCategoryId;
+
+    @ApiModelProperty("积分")
+    private Long fundPrice;
+
+    @ApiModelProperty("性别")
+    private Integer sex;
+
+    @ApiModelProperty("年龄")
+    private Integer age;
+
+    @ApiModelProperty("分类Id")
+    private Integer parentId;
+
+    @ApiModelProperty("分类全名")
+    private String fullName;
+
+    @ApiModelProperty("市")
+    private Integer cityId;
+
+    @ApiModelProperty("区")
+    private Integer countryId;
+
+    @ApiModelProperty("街道")
+    private Integer streetId;
+
+}

+ 23 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/IntegralTransaction.java

@@ -0,0 +1,23 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class IntegralTransaction {
+
+    @ApiModelProperty(name = "integral" , value = "积分")
+    private Long integral;
+    @ApiModelProperty(name = "num" , value = "数量")
+    private Integer num;
+    @ApiModelProperty(name = "merchantId" , value = "商户ID")
+    private Integer merchantId;
+    @ApiModelProperty(name = "merchantName" , value = "商户名")
+    private String merchantName;
+
+}

+ 50 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/OrderIntegrationData.java

@@ -0,0 +1,50 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.mapstruct.Mapper;
+
+import java.util.Date;
+
+
+/**
+ * 大屏订单数据
+ * @author Qin
+ */
+@Data
+@ApiModel(value="大屏订单数据")
+@Mapper()
+public class OrderIntegrationData {
+
+    @ApiModelProperty(value="订单id",example = "3")
+    private Long orderId;
+
+    @ApiModelProperty(value = "市id", name = "cityId")
+    private Integer cityId;
+
+    @ApiModelProperty(value = "区域id", name = "countryId")
+    private Integer countryId;
+
+    @ApiModelProperty(value = "街道id", name = "streetId")
+    private Integer streetId;
+
+    @ApiModelProperty(value = "服务回访状态:0.未回访;1.已回访")
+    private Integer visitStatus;
+
+    @ApiModelProperty(value = "客户id")
+    private Long customerId;
+
+    @ApiModelProperty(value = "完成时间")
+    private Date finishTime;
+
+    @ApiModelProperty(value = "商品二级类目ID")
+    private Integer productCategoryId;
+
+    @ApiModelProperty(value = "满意度:0-不满意,1-满意")
+    private Integer result;
+
+    @ApiModelProperty(value = "综合评价:0-不合格,1-合格")
+    private Integer qualified;
+
+}

+ 24 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/OrderServiceTypeDTO.java

@@ -0,0 +1,24 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * @author Qin
+ */
+@Data
+public class OrderServiceTypeDTO {
+
+    @ApiModelProperty(value="id")
+    private Integer id;
+
+    @ApiModelProperty(value="名称")
+    private String name;
+
+    @ApiModelProperty(value="数量")
+    private Integer count;
+
+    @ApiModelProperty(value="比例")
+    private String rate;
+}

+ 20 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/Product.java

@@ -0,0 +1,20 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class Product {
+    /**
+     * 供应商ID
+     */
+    private Integer providerId;
+
+    @ApiModelProperty(value = "商品一级类目", example = "1")
+    private Long parentCategoryId;
+}

+ 46 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/StationMerchant.java

@@ -0,0 +1,46 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class StationMerchant {
+
+    @ApiModelProperty(value="id")
+    private Integer id;
+
+    @ApiModelProperty(value="运营商Id")
+    private Integer supplierId;
+
+    @ApiModelProperty(value = "商户名称")
+    private String name;
+
+    @ApiModelProperty(value = "状态 ,0=停用、1=启用")
+    private Integer status;
+
+    /**
+     * 类型:1-服务站, 17-积分商户, 18-线下商户
+     */
+    private Integer type;
+
+    @ApiModelProperty(value = "市")
+    private Integer city;
+
+    @ApiModelProperty(value = "区")
+    private Integer country;
+
+    @ApiModelProperty(value = "街道")
+    private Integer street;
+
+    @ApiModelProperty(value = "区名")
+    private String countryName;
+
+    @ApiModelProperty(value = "街道名")
+    private String streetName;
+
+}

+ 25 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/SubsidyCustomerJsonVo.java

@@ -0,0 +1,25 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 补贴客户信息
+ * @author Qin
+ */
+@Data
+@ApiModel(value = "补贴客户JSON信息")
+public class SubsidyCustomerJsonVo {
+    @ApiModelProperty(value = "id")
+    private List<String> id;
+    @ApiModelProperty(value = "标题")
+    private List<String> title;
+    @ApiModelProperty(value = "老人数")
+    private List<Integer> total;
+    @ApiModelProperty(value = "服务覆盖率")
+    private List<BigDecimal> rate;
+}

+ 23 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/SupplierStation.java

@@ -0,0 +1,23 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class SupplierStation {
+
+    @ApiModelProperty(value = "市编码")
+    private Integer city;
+    @ApiModelProperty(value = "区")
+    private Integer country;
+    @ApiModelProperty(value = "街道")
+    private Integer street;
+    @ApiModelProperty(value = "id")
+    private Integer id;
+
+}

+ 20 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/SupplierStationEmployee.java

@@ -0,0 +1,20 @@
+package com.poteviohealth.cgp.statistics.model.outdto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Qin
+ */
+@Data
+@ApiModel(description = "积分大屏统计")
+public class SupplierStationEmployee {
+
+    @ApiModelProperty("服务人员Id")
+    private Integer employeeId;
+
+    @ApiModelProperty("服务站Id")
+    private Integer stationId;
+
+}

+ 17 - 0
src/main/java/com/poteviohealth/cgp/statistics/service/IOrderService.java

@@ -0,0 +1,17 @@
+package com.poteviohealth.cgp.statistics.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.poteviohealth.cgp.statistics.model.Order;
+
+/**
+ * 居家大屏
+ * @author Qin
+ */
+public interface IOrderService extends IService<Order>{
+
+    /**
+     * 居家统计
+     * @param date
+     */
+    void statisticsOrder(String date);
+}

+ 1312 - 0
src/main/java/com/poteviohealth/cgp/statistics/service/impl/OrderServiceImpl.java

@@ -0,0 +1,1312 @@
+package com.poteviohealth.cgp.statistics.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.poteviohealth.cgp.common.filter.TokenContext;
+import com.poteviohealth.cgp.common.integrated.DateParams;
+import com.poteviohealth.cgp.common.integrated.ListParams;
+import com.poteviohealth.cgp.common.integrated.customer.model.CustomerServiceParams;
+import com.poteviohealth.cgp.common.integrated.customer.model.CustomerSubsidyDTO;
+import com.poteviohealth.cgp.common.integrated.customer.model.SubsidyCustomerFace;
+import com.poteviohealth.cgp.common.integrated.customer.model.SubsidyCustomerJsonFace;
+import com.poteviohealth.cgp.common.integrated.finance.model.MemberListData;
+import com.poteviohealth.cgp.common.integrated.finance.model.MonthData;
+import com.poteviohealth.cgp.common.integrated.order.model.OrderStatisticsData;
+import com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO;
+import com.poteviohealth.cgp.common.integrated.partner.model.EmployeeStationFace;
+import com.poteviohealth.cgp.common.integrated.partner.model.EmployeeStationJsonFace;
+import com.poteviohealth.cgp.statistics.mapper.OrderMapper;
+import com.poteviohealth.cgp.statistics.model.Order;
+import com.poteviohealth.cgp.statistics.model.outdto.*;
+import com.poteviohealth.cgp.statistics.service.IOrderService;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 居家大屏
+ * @author Qin
+ */
+@Service
+@Log4j2
+public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
+
+    @Value("${sync.dbName}")
+    private String dbName;
+    @Override
+    public void statisticsOrder(String dateTime){
+        try {
+            TokenContext.setOperator(1);
+            //检查区域,没有的新增
+            List<Order> list = this.list();
+            Date date = new Date();
+            if(StringUtils.isNotEmpty(dateTime)){
+                date = DateUtils.parseDate(dateTime,"yyyy-MM-dd HH:mm:ss");
+            }
+
+            List<AreaDTO> areaList = baseMapper.areaList(dbName);
+            if(list.size() != areaList.size()){
+                List<Integer> ids = Lists.newArrayList();
+                List<Order> newOrderList = Lists.newArrayList();
+                if(list.size()>0){
+                    ids = list.stream().map(o->o.getAreaId()).collect(Collectors.toList());
+                }
+                for (AreaDTO areaDTO : areaList) {
+                    if(!ids.contains(areaDTO.getId())){
+                        Order order = new Order();
+                        order.setOperatorId(1);
+                        order.setAreaId(areaDTO.getId());
+                        order.setAreaName(areaDTO.getName());
+                        order.setTreePath(areaDTO.getTreePath());
+                        order.setSourceLevel(areaDTO.getLevel());
+                        Integer size = 0;
+                       switch (order.getSourceLevel()){
+                           case 1:
+                               size =4;
+                               break;
+                           case 2:
+                               size =6;
+                               break;
+                           case 3:
+                               size =9;
+                               break;
+                       }
+                       if(StringUtils.isNotBlank(areaDTO.getRegionAreaCode())){
+                           order.setRegionAreaCode(areaDTO.getRegionAreaCode().substring(0,size));
+                       }
+
+                        newOrderList.add(order);
+                    }
+                }
+                this.saveBatch(newOrderList);
+                list = this.list();
+            }
+            Map<Integer,List<Order>> maps = list.stream().collect(Collectors.groupingBy(Order::getAreaId));
+
+            if(!maps.isEmpty()){
+                log.info("---数据清零开始---");
+                changeZero(maps,date);
+                log.info("---数据清零结束---");
+                Date startDate = null;
+                for (Integer integer : maps.keySet()) {
+                    startDate = maps.get(integer).get(0).getChangeDate();
+                    break;
+                }
+
+                DateParams dateParams = new DateParams();
+                dateParams.setStartDate(startDate);
+                dateParams.setEndDate(date);
+                //更新服务人员数据
+                log.info("---更新服务人员数据开始---");
+                changeEmployee(maps);
+                log.info("---更新服务人员数据结束---");
+                List<Integer> operatorIds = baseMapper.getOperatorList(dbName);
+                log.info("---获取客户数据开始---");
+                List<CustomerSubsidyDTO> customerList = this.getSubsidyCustomerList(dateParams,operatorIds);
+                log.info("---获取客户数据结束---");
+                //更新客户数据
+                if(!customerList.isEmpty()){
+                    log.info("---更新客户数据开始---");
+                    changeCustomer(maps,customerList,operatorIds);
+                    log.info("---更新客户数据结束---");
+                }
+                //获取助餐服务客户数
+                List<ListParams> mealList = this.getSubsidyCustomerMealList(dateParams,operatorIds);
+                if(CollectionUtils.isNotEmpty(mealList)){
+                    for (Integer integer : maps.keySet()) {
+                        for (ListParams params : mealList) {
+                            if(params.getId().equals(integer)){
+                                for (Order order : maps.get(integer)) {
+                                    order.setServiceCustomerNum(order.getServiceCustomerNum()+params.getKey());
+                                }
+                            }
+                        }
+                    }
+                }
+                //更新工单相关数据
+                log.info("---更新工单数据开始---");
+                List<ListParams> categoryList = baseMapper.getAllCategory(dbName);
+                changeOrder(maps,dateParams,operatorIds,categoryList);
+                log.info("---更新工单数据结束---");
+                //更新积分相关数据
+                log.info("---更新商户积分数据开始---");
+                changeIntegral(maps,operatorIds,categoryList);
+                log.info("---更新商户积分数据结束---");
+
+                log.info("---客户积分开始获取---");
+                changeCustomerIntegral(maps,dateParams);
+                log.info("---客户积分结束获取---");
+                log.info("---积分流水开始获取---");
+                changeTransIntegral(maps,dateParams);
+                log.info("---积分流水结束获取---");
+                for (Integer integer : maps.keySet()) {
+                    for (Order order : maps.get(integer)) {
+                        order.setChangeDate(date);
+                    }
+                }
+                this.saveOrUpdateBatch(list);
+            }
+            log.info("完成----");
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+    }
+
+    private List<ListParams> getSubsidyCustomerMealList(DateParams dateParams,List<Integer> operatorIds){
+        List<ListParams> returnList = Lists.newArrayList();
+        QueryWrapper queryWrapper = new QueryWrapper<>();
+        if(dateParams.getStartDate() != null){
+            queryWrapper.ge("meal_date",dateParams.getStartDate());
+        }
+        if(dateParams.getEndDate() != null){
+            queryWrapper.lt("meal_date",dateParams.getEndDate());
+        }
+        for (Integer operatorId : operatorIds) {
+            //获取签约客户信息
+            List<Customer> dto = baseMapper.getSubsidyCustomerMealList(operatorId,dbName,queryWrapper);
+            if(!dto.isEmpty()){
+                Map<Integer,List<Customer>> streetMaps = dto.stream().filter(c->c.getNowStreetId() != null).collect(Collectors.groupingBy(Customer::getNowStreetId));
+                getMealData(streetMaps,returnList);
+                //按照区分组
+                Map<Integer,List<Customer>> countryMaps = dto.stream().filter(c->c.getNowCountryId() != null).collect(Collectors.groupingBy(Customer::getNowCountryId));
+                getMealData(countryMaps,returnList);
+                //按照市分组
+                Map<Integer,List<Customer>> cityMaps = dto.stream().filter(c->c.getNowCityId() != null).collect(Collectors.groupingBy(Customer::getNowCityId));
+                getMealData(cityMaps,returnList);
+            }
+        }
+        return returnList;
+    }
+
+    private void getMealData(Map<Integer,List<Customer>> maps,List<ListParams> returnList){
+
+        for (Integer integer : maps.keySet()) {
+            ListParams params = new ListParams();
+            params.setId(integer);
+            params.setKey(maps.get(integer).size());
+            returnList.add(params);
+        }
+    }
+
+    private List<CustomerSubsidyDTO> getSubsidyCustomerList(DateParams dateParams,List<Integer> operatorIds){
+
+        List<CustomerSubsidyDTO> returnList = Lists.newArrayList();
+        QueryWrapper queryWrapper = new QueryWrapper<>();
+        if(dateParams.getStartDate() != null){
+            queryWrapper.ge("d.created_date",dateParams.getStartDate());
+        }
+        if(dateParams.getEndDate() != null){
+            queryWrapper.lt("d.created_date",dateParams.getEndDate());
+        }
+        for (Integer operatorId : operatorIds) {
+            //获取签约客户信息
+            List<CustomerSubsidyDTO> dto =baseMapper.getSubsidyCustomerList(operatorId,dbName,queryWrapper);
+            if(!dto.isEmpty()){
+                returnList.addAll(dto);
+            }
+        }
+        return returnList;
+    }
+
+    private void changeZero(Map<Integer,List<Order>> maps,Date date){
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int day = calendar.get(Calendar.DAY_OF_MONTH);
+        int week = calendar.get(Calendar.DAY_OF_WEEK);
+        int hour = calendar.get(Calendar.HOUR_OF_DAY);
+        for (Integer integer : maps.keySet()) {
+            List<Order> orders = maps.get(integer);
+            for (Order order : orders) {
+                if(day == 1 && hour == 0){
+                    //每月1日0点清零
+                    order.setOrderNumMonth(0);
+                    if(StringUtils.isNotEmpty(order.getMemberListData())){
+                        MemberListData data =JSONObject.toJavaObject(JSON.parseObject(order.getMemberListData()), MemberListData.class);
+                        data.setTotal(0);
+                        order.setMemberListData(JSONObject.toJSONString(data));
+                    }
+                }
+                if (week == Calendar.MONDAY && hour == 0) {
+                    //每周一0点清零
+                    order.setOrderNumWeek(0);
+                }
+                if(hour == 0){
+                    //每天0点清零
+                    order.setOrderNumDay(0);
+                }
+            }
+        }
+    }
+
+    private void changeEmployee(Map<Integer, List<Order>> maps) {
+
+        List<EmployeeStationFace> employeeStationFaces = this.getEmployeeStationFace();
+        for (EmployeeStationFace employeeStationFace : employeeStationFaces) {
+            List<Order> orders = maps.get(employeeStationFace.getAreaId());
+            if(orders != null){
+                for (Order order : orders) {
+                    order.setAllStationNum(employeeStationFace.getAllStationNum());
+                    order.setEmployeeNum(employeeStationFace.getNum());
+                    order.setEmployeeList(employeeStationFace.getLists());
+                }
+            }
+
+        }
+    }
+
+    private void getEmployeeData(Map<Integer,List<SupplierStation>> stationMaps, List<Employee> employeeList, List<SupplierStationEmployee> stationEmployeeList, List<EmployeeStationFace> returnList){
+        for (Integer integer : stationMaps.keySet()) {
+            List<SupplierStation> stations = stationMaps.get(integer);
+            if(org.springframework.util.CollectionUtils.isEmpty(stations)){
+                continue;
+            }
+            EmployeeStationFace face = new EmployeeStationFace();
+            face.setAreaId(integer);
+
+            List<Integer> stationIds = stations.stream().map(s->s.getId()).collect(Collectors.toList());
+            List<Integer> employeeIds = stationEmployeeList.stream().filter(se->stationIds.contains(se.getStationId())).map(se->se.getEmployeeId()
+            ).distinct().collect(Collectors.toList());
+            List<Employee> employees = employeeList.stream().filter(e->employeeIds.contains(e.getId())).collect(Collectors.toList());
+
+            face.setAllStationNum(stationIds.size());
+            face.setNum(employees.size());
+            EmployeeStationJsonFace json = new EmployeeStationJsonFace();
+            json.setTotal(face.getNum());
+            json.setTitle(Lists.newArrayList("30以下","30-39","40-49","50-59","60及以上"));
+            //按照年龄30以下,30-39,40-49,50-59,60以上
+            List<String> maleList = Lists.newArrayList();
+            List<String> womanList = Lists.newArrayList();
+            List<Employee> thirtyDown = employees.stream().filter(e->e.getAge()<30).collect(Collectors.toList());
+            Long thirtyDownMale = thirtyDown.stream().filter(e->e.getGender().equals(1)).count();
+            Long thirtyDownWoman = thirtyDown.stream().filter(e->e.getGender().equals(0)).count();
+            maleList.add(thirtyDownMale.toString());
+            womanList.add(thirtyDownWoman.toString());
+            List<Employee> thirty = employees.stream().filter(e->e.getAge()>=30 && e.getAge()<40).collect(Collectors.toList());
+            Long thirtyMale = thirty.stream().filter(e->e.getGender().equals(1)).count();
+            Long thirtyWoman = thirty.stream().filter(e->e.getGender().equals(0)).count();
+            maleList.add(thirtyMale.toString());
+            womanList.add(thirtyWoman.toString());
+            List<Employee> forty = employees.stream().filter(e->e.getAge()>=40 && e.getAge()<50).collect(Collectors.toList());
+            Long fortyMale = forty.stream().filter(e->e.getGender().equals(1)).count();
+            Long fortyWoman = forty.stream().filter(e->e.getGender().equals(0)).count();
+            maleList.add(fortyMale.toString());
+            womanList.add(fortyWoman.toString());
+            List<Employee> fifty = employees.stream().filter(e->e.getAge()>=50 && e.getAge()<60).collect(Collectors.toList());
+            Long fiftyMale = fifty.stream().filter(e->e.getGender().equals(1)).count();
+            Long fiftyWoman = fifty.stream().filter(e->e.getGender().equals(0)).count();
+            maleList.add(fiftyMale.toString());
+            womanList.add(fiftyWoman.toString());
+            List<Employee> sixtyUp = employees.stream().filter(e->e.getAge()>=60).collect(Collectors.toList());
+            Long sixtyUpMale = sixtyUp.stream().filter(e->e.getGender().equals(1)).count();
+            Long sixtyUpWoman = sixtyUp.stream().filter(e->e.getGender().equals(0)).count();
+            maleList.add(sixtyUpMale.toString());
+            womanList.add(sixtyUpWoman.toString());
+            //按照性别分组
+            json.setMale(maleList);
+            json.setWoman(womanList);
+            face.setLists(JSONObject.toJSONString(json));
+            returnList.add(face);
+        }
+    }
+
+
+    private List<EmployeeStationFace> getEmployeeStationFace(){
+        List<EmployeeStationFace> returnList = Lists.newArrayList();
+        //获取驿站员工信息
+        List<SupplierStationEmployee> stationEmployeeList = baseMapper.supplierStationEmployeeList(dbName);
+        //获取驿站
+        List<SupplierStation> stationList = baseMapper.supplierStationList(dbName);
+        //获取员工
+        List<Employee> employeeList = baseMapper.employeeList(dbName);
+
+        //按照街道分组
+        Map<Integer,List<SupplierStation>> stationStreetMaps = stationList.stream().filter(s->s.getStreet() != null).collect(Collectors.groupingBy(SupplierStation::getStreet));
+        getEmployeeData(stationStreetMaps,employeeList,stationEmployeeList,returnList);
+        //按照区分组
+        Map<Integer,List<SupplierStation>> stationCountryMaps = stationList.stream().filter(s->s.getCountry() != null).collect(Collectors.groupingBy(SupplierStation::getCountry));
+        getEmployeeData(stationCountryMaps,employeeList,stationEmployeeList,returnList);
+        //按照市分组
+        Map<Integer,List<SupplierStation>> stationCityMaps = stationList.stream().filter(s->s.getCity() != null).collect(Collectors.groupingBy(SupplierStation::getCity));
+        getEmployeeData(stationCityMaps,employeeList,stationEmployeeList,returnList);
+
+        return returnList;
+    }
+
+    private List<SubsidyCustomerFace> getSubsidyCustomerFace(List<CustomerSubsidyDTO> customerList){
+
+        List<SubsidyCustomerFace> returnList = Lists.newArrayList();
+
+        //按照街道分组
+        Map<Integer,List<CustomerSubsidyDTO>> streetMaps = customerList.stream().filter(c->c.getNowStreetId() != null).collect(Collectors.groupingBy(CustomerSubsidyDTO::getNowStreetId));
+        fillData(streetMaps,returnList,3);
+        //按照区分组
+        Map<Integer,List<CustomerSubsidyDTO>> countryMaps = customerList.stream().filter(c->c.getNowCountryId() != null).collect(Collectors.groupingBy(CustomerSubsidyDTO::getNowCountryId));
+        fillData(countryMaps,returnList,2);
+        //按照市分组
+        Map<Integer,List<CustomerSubsidyDTO>> cityMaps = customerList.stream().filter(c->c.getNowCityId() != null).collect(Collectors.groupingBy(CustomerSubsidyDTO::getNowCityId));
+        fillData(cityMaps,returnList,1);
+//      //探访关爱--已单独汇总,此处不再处理
+//      customerSubsidyVisitService.processCare(returnList,operatorIds);
+        return returnList;
+    }
+
+
+    private void fillData(Map<Integer,List<CustomerSubsidyDTO>> maps, List<SubsidyCustomerFace> returnList,Integer source){
+        for (Integer integer : maps.keySet()) {
+            List<CustomerSubsidyDTO> csList = maps.get(integer);
+            SubsidyCustomerFace face = new SubsidyCustomerFace();
+            face.setAreaId(integer);
+            face.setNum(csList.size());
+            face.setCareAllMember(csList.stream().mapToInt(e-> org.apache.commons.lang.StringUtils.isNotEmpty(e.getCustomerSignId())?1:0).sum());
+            List<Long> ids = csList.stream().map(c->c.getCustomerId()).collect(Collectors.toList());
+            face.setCustomerIds(ids);
+            // List<Long> intersectionList = (List<Long>) CollectionUtils.intersection(face.getCustomerIds(),cardCustomer);
+            face.setCustomerGovernmentNum(csList.stream().filter(c->c.getCategory().equals(1)).collect(Collectors.toList()).size());
+            face.setCustomerSocietyNum(face.getNum()-face.getCustomerGovernmentNum());
+            face.setAllCustomerNum(csList.stream().filter(c ->c.getAge() != null && c.getAge() >= 75).collect(Collectors.toList()).size());
+
+            MemberListData data = new MemberListData();
+            Long totalDetailList = csList.stream().filter(d -> d.getCategory().equals(1)).count();
+            data.setTotal(Integer.parseInt(totalDetailList.toString()));
+            data.setTitle(Lists.newArrayList("50以下","50-59", "60-69", "70-79", "80-89", "90及以上"));
+            List<Integer> maleAgeList = Lists.newArrayList();
+            maleAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) && c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() < 50).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 50 && c.getAge() < 60).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 60 && c.getAge() < 70).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 70 && c.getAge() < 80).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 80 && c.getAge() < 90).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 90).collect(Collectors.toList()).size());
+            data.setMale(maleAgeList);
+            List<Integer> womanAgeList = Lists.newArrayList();
+            womanAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() < 50).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 50 && c.getAge() < 60).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 60 && c.getAge() < 70).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 70 && c.getAge() < 80).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 80 && c.getAge() < 90).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c ->c.getCategory().equals(1) &&  c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 90).collect(Collectors.toList()).size());
+            data.setWoman(womanAgeList);
+            face.setCustomerAgeListData(data);
+
+            List<SubsidyCustomerJsonFace> jsonFaceList = Lists.newArrayList();
+            if(source.equals(1)){
+                //按区域分组
+                Map<Integer,List<CustomerSubsidyDTO>> countryMaps = csList.stream().collect(Collectors.groupingBy(CustomerSubsidyDTO::getNowCountryId));
+                for (Integer key : countryMaps.keySet()) {
+                    List<CustomerSubsidyDTO> keyList = countryMaps.get(key);
+                    SubsidyCustomerJsonFace jsonFace = new SubsidyCustomerJsonFace();
+                    jsonFace.setAreaId(key);
+                    jsonFace.setTitle(keyList.get(0).getNowCountryName());
+                    jsonFace.setTotal(keyList.size());
+                    jsonFace.setCustomerIds(keyList.stream().map(c->c.getCustomerId()).collect(Collectors.toList()));
+                    jsonFaceList.add(jsonFace);
+                }
+            }else{
+                //按老人类型分组
+                Map<String,List<CustomerSubsidyDTO>> typeMaps = csList.stream().collect(Collectors.groupingBy(CustomerSubsidyDTO::getCustomerTypeId));
+                Map<String,SubsidyCustomerJsonFace> faceMap = new HashMap<>();
+                for (String key : typeMaps.keySet()) {
+                    List<CustomerSubsidyDTO> keyList = typeMaps.get(key);
+                    List<Long> idList = keyList.stream().map(CustomerSubsidyDTO::getCustomerId).collect(Collectors.toList());
+                    String customerType = keyList.get(0).getCustomerType();
+                    if (key.contains(",")){
+                        String[] typeIds = key.split(",");
+                        String[] names = customerType.split(",");
+                        for (int i=0; i<typeIds.length; i++){
+                            mergeJsonFace(faceMap, typeIds[i], idList, names[i]);
+                        }
+                    }else{
+                        mergeJsonFace(faceMap, key, idList, customerType);
+                    }
+                }
+                jsonFaceList.addAll(faceMap.values());
+            }
+
+            face.setJsonFace(jsonFaceList);
+            returnList.add(face);
+        }
+    }
+
+    private void mergeJsonFace(Map<String, SubsidyCustomerJsonFace> faceMap, String key, List<Long> idList, String customerType) {
+        SubsidyCustomerJsonFace jsonFace = faceMap.get(key);
+        if (jsonFace== null){
+            jsonFace = new SubsidyCustomerJsonFace();
+            jsonFace.setAreaId(Integer.parseInt(key));
+            jsonFace.setTitle(customerType);
+            jsonFace.setTotal(idList.size());
+            jsonFace.setCustomerIds(idList);
+            faceMap.put(key, jsonFace);
+        }else{
+            jsonFace.getCustomerIds().addAll(idList);
+            jsonFace.setTotal(jsonFace.getCustomerIds().size());
+        }
+    }
+
+    private List<CustomerServiceParams> orderServiceCustomerList(List<Integer> operatorIds){
+        List<CustomerServiceParams> returnList = Lists.newArrayList();
+        for (Integer operatorId : operatorIds) {
+            returnList.addAll(baseMapper.orderServiceCustomerList(operatorId,dbName));
+        }
+        return returnList;
+    }
+
+    private void changeCustomer(Map<Integer, List<Order>> maps,List<CustomerSubsidyDTO> customerList,List<Integer> operatorIds) {
+        //更新客户数据
+        List<SubsidyCustomerFace> customerFaceList = this.getSubsidyCustomerFace(customerList);
+        //获取已服务老人Id集合
+        List<CustomerServiceParams> serviceCustomerList = this.orderServiceCustomerList(operatorIds);
+        for (SubsidyCustomerFace subsidyCustomerFace : customerFaceList) {
+            List<Order> orders = maps.get(subsidyCustomerFace.getAreaId());
+            if(orders == null || orders.isEmpty()){
+                continue;
+            }
+            for (Order order : orders) {
+                order.setCustomerNum((order.getCustomerNum()==null?0:order.getCustomerNum())+subsidyCustomerFace.getNum());
+                order.setCustomerGovernmentNum((order.getCustomerGovernmentNum()==null?0:order.getCustomerGovernmentNum())+subsidyCustomerFace.getCustomerGovernmentNum());
+                order.setCustomerSocietyNum((order.getCustomerSocietyNum()==null?0:order.getCustomerSocietyNum())+subsidyCustomerFace.getCustomerSocietyNum());
+                order.setCareRate(BigDecimal.ZERO);
+                order.setAllCustomerNum(order.getAllCustomerNum()+ subsidyCustomerFace.getAllCustomerNum());
+                order.setCareNum(0);
+                order.setCarePic("");
+                order.setCareMember(0);
+                order.setCareAllMember(0);
+                //已服务老人数
+                Long serviceSum = 0L;
+                if(order.getSourceLevel() == 1){
+                    serviceSum = serviceCustomerList.stream().filter(s->order.getAreaId().equals(s.getCityId())).mapToLong(s->s.getCustomerNum()).sum();
+                }else if(order.getSourceLevel() == 2){
+                    serviceSum = serviceCustomerList.stream().filter(s->order.getAreaId().equals(s.getCountryId())).mapToLong(s->s.getCustomerNum()).sum();
+                }else{
+                    serviceSum = serviceCustomerList.stream().filter(s->order.getAreaId().equals(s.getStreetId())).mapToLong(s->s.getCustomerNum()).sum();
+                }
+                order.setCustomerServiceNum(serviceSum.intValue());
+                if(order.getCustomerNum().equals(0)){
+                    order.setCustomerRate(BigDecimal.ZERO);
+                }else{
+                    BigDecimal decimal = new BigDecimal(order.getCustomerServiceNum()).divide(new BigDecimal(order.getCustomerNum()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100.0)).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    log.info("CustomerRate==="+decimal);
+                    order.setCustomerRate(decimal);
+                }
+                List<SubsidyCustomerJsonFace> jsonFace = subsidyCustomerFace.getJsonFace();
+                List<String> id = Lists.newArrayList();
+                List<String> title = Lists.newArrayList();
+                List<Integer> total = Lists.newArrayList();
+                List<BigDecimal> rate = Lists.newArrayList();
+                if(StringUtils.isNotEmpty(order.getCustomerList())){
+                    JSONObject jsonObject = new JSONObject(JSON.parseObject(order.getCustomerList()));
+                    SubsidyCustomerJsonVo vo = JSONObject.toJavaObject(jsonObject, SubsidyCustomerJsonVo.class);
+                    if(!vo.getId().isEmpty()){
+                        id.addAll(vo.getId());
+                    }
+                    title.addAll(vo.getTitle());
+                    total.addAll(vo.getTotal());
+                    rate.addAll(vo.getRate());
+                }
+
+                for (SubsidyCustomerJsonFace face : jsonFace) {
+                    Integer num = face.getTotal();
+                    Long sum = 0L;
+                    if(serviceCustomerList != null && !serviceCustomerList.isEmpty() && order.getSourceLevel().equals(1)){
+                        sum = serviceCustomerList.stream().filter(s->(face.getAreaId().equals(s.getCountryId()) || face.getAreaId().equals(s.getStreetId()))).mapToLong(s->s.getCustomerNum()).sum();
+                    }else{
+                        if(order.getSourceLevel().equals(2)){
+                            sum = serviceCustomerList.stream().filter(s->s.getCountryId().equals(order.getAreaId()) && StringUtils.isNotEmpty(s.getCustomerTypeId()) && s.getCustomerTypeId().contains(","+face.getAreaId().toString()+",")).mapToLong(s->s.getCustomerNum()).sum();
+                        }else if (order.getSourceLevel().equals(3) ){
+                            sum = serviceCustomerList.stream().filter(s->s.getStreetId().equals(order.getAreaId()) && StringUtils.isNotEmpty(s.getCustomerTypeId()) && s.getCustomerTypeId().contains(","+face.getAreaId().toString()+",")).mapToLong(s->s.getCustomerNum()).sum();
+                        }
+                     }
+                    if(id.contains(face.getAreaId().toString())){
+                        for (int i = 0; i < id.size(); i++) {
+                            if(id.get(i).equals(face.getAreaId().toString())){
+                                total.set(i,total.get(i)+face.getTotal());
+                                num = total.get(i);
+                                if(num == 0L){
+                                    rate.set(i,BigDecimal.ZERO);
+                                }else{
+                                    BigDecimal val = new BigDecimal(sum).divide(new BigDecimal(num),4, BigDecimal.ROUND_HALF_UP);
+                                    BigDecimal decimal2 = val.multiply(new BigDecimal("100.0")).setScale(2,BigDecimal.ROUND_HALF_UP);
+                                    rate.set(i,decimal2);
+                                }
+                                break;
+                            }
+                        }
+                    }else{
+                        id.add(face.getAreaId().toString());
+                        title.add(face.getTitle());
+                        total.add(face.getTotal());
+                        if(num == 0L){
+                            rate.add(BigDecimal.ZERO);
+                        }else {
+                            BigDecimal decimal2 = new BigDecimal(sum).divide(new BigDecimal(num), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100.0)).setScale(2, BigDecimal.ROUND_HALF_UP);
+                            rate.add(decimal2);
+                        }
+                    }
+                }
+                SubsidyCustomerJsonVo vo = new SubsidyCustomerJsonVo();
+                vo.setId(id);
+                vo.setTitle(title);
+                vo.setTotal(total);
+                vo.setRate(rate);
+                order.setCustomerList(JSONObject.toJSONString(vo));
+
+                if(StringUtils.isNotEmpty(order.getCustomerAgeList()) && subsidyCustomerFace.getCustomerAgeListData() != null){
+                    MemberListData data =JSONObject.toJavaObject(JSON.parseObject(order.getCustomerAgeList()), MemberListData.class);
+                    MemberListData newData = subsidyCustomerFace.getCustomerAgeListData();
+
+                    data.setTotal(data.getTotal()+newData.getTotal());
+
+                    for (int i = 0; i < data.getMale().size(); i++) {
+                        data.getMale().set(i,data.getMale().get(i)+newData.getMale().get(i));
+                    }
+
+                    for (int i = 0; i < data.getWoman().size(); i++) {
+                        data.getWoman().set(i,data.getWoman().get(i)+newData.getWoman().get(i));
+                    }
+                    order.setCustomerAgeList(JSONObject.toJSONString(data));
+                }else if(subsidyCustomerFace.getCustomerAgeListData() != null){
+                    order.setCustomerAgeList(JSONObject.toJSONString(subsidyCustomerFace.getCustomerAgeListData()));
+                }
+            }
+        }
+    }
+
+    private List<SubsidyCustomerFace> integralCustomer(DateParams dateParams){
+        List<SubsidyCustomerFace> returnList = Lists.newArrayList();
+        QueryWrapper detailQueryWrapper = new QueryWrapper<>();
+        if(dateParams.getStartDate() != null){
+            detailQueryWrapper.ge("created_date",dateParams.getStartDate());
+        }
+        if(dateParams.getEndDate() != null){
+            detailQueryWrapper.le("created_date",dateParams.getEndDate());
+        }
+        List<Integer> operationIds =  baseMapper.getIntegralCardAccOperatorIdList(dbName,detailQueryWrapper);
+
+        List<IntegralTrans> detailsCustomer = Lists.newArrayList();
+        QueryWrapper queryWrapper = new QueryWrapper();
+        if(dateParams.getStartDate() != null){
+            queryWrapper.ge("d.created_date",dateParams.getStartDate());
+        }
+        if(dateParams.getEndDate() != null){
+            queryWrapper.le("d.created_date",dateParams.getEndDate());
+        }
+
+        for (Integer operationId : operationIds) {
+            //获取积分数据
+            detailsCustomer.addAll(baseMapper.integralCustomerList(queryWrapper,operationId,dbName));
+        }
+
+        log.info("---处理积分客户数据开始----");
+        if(!detailsCustomer.isEmpty()){
+            Map<Integer,List<IntegralTrans>> streetCustomerMaps = detailsCustomer.stream().filter(i->i.getStreetId() != null).collect(Collectors.groupingBy(IntegralTrans::getStreetId));
+            fillData(streetCustomerMaps,returnList);
+
+            Map<Integer,List<IntegralTrans>> cityCustomerMaps = detailsCustomer.stream().filter(i->i.getCityId() != null).collect(Collectors.groupingBy(IntegralTrans::getCityId));
+            fillData(cityCustomerMaps,returnList);
+
+            Map<Integer,List<IntegralTrans>> countryCustomerMaps = detailsCustomer.stream().filter(i->i.getCountryId() != null).collect(Collectors.groupingBy(IntegralTrans::getCountryId));
+            fillData(countryCustomerMaps,returnList);
+        }
+
+        log.info("---处理积分客户数据结束----");
+        return returnList;
+    }
+
+    private void fillData(Map<Integer,List<IntegralTrans>> mapCustomerData, List<SubsidyCustomerFace> returnList){
+        for (Integer integer : mapCustomerData.keySet()) {
+            List<IntegralTrans> csList = mapCustomerData.get(integer);
+            SubsidyCustomerFace face = new SubsidyCustomerFace();
+            face.setAreaId(integer);
+            face.setCustomerNum(csList.size());
+
+            MemberListData data = new MemberListData();
+            List<IntegralTrans> totalDetailList = csList.stream().filter(d -> d.getCreatedDate().after(com.poteviohealth.cgp.common.utils.DateUtils.getFirstDayOfMonth(new Date()))).collect(Collectors.toList());
+            data.setTotal(totalDetailList.size());
+            data.setTitle(Lists.newArrayList("60以下", "60-69", "70-79", "80-89", "90及以上"));
+            List<Integer> maleAgeList = Lists.newArrayList();
+            maleAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() < 60).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 60 && c.getAge() < 70).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 70 && c.getAge() < 80).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 80 && c.getAge() < 90).collect(Collectors.toList()).size());
+            maleAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(1) && c.getAge() >= 90).collect(Collectors.toList()).size());
+            data.setMale(maleAgeList);
+            List<Integer> womanAgeList = Lists.newArrayList();
+            womanAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() < 60).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 60 && c.getAge() < 70).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 70 && c.getAge() < 80).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 80 && c.getAge() < 90).collect(Collectors.toList()).size());
+            womanAgeList.add(csList.stream().filter(c -> c.getSex() != null && c.getAge() != null && c.getSex().equals(0) && c.getAge() >= 90).collect(Collectors.toList()).size());
+            data.setWoman(womanAgeList);
+            face.setMemberListData(data);
+
+            returnList.add(face);
+        }
+    }
+
+    private void changeCustomerIntegral(Map<Integer, List<Order>> maps,DateParams dateParams) {
+        List<SubsidyCustomerFace> integralList = this.integralCustomer(dateParams);
+        Calendar calendar2 = Calendar.getInstance();
+        calendar2.setTime(dateParams.getEndDate());
+        int day = calendar2.get(Calendar.DAY_OF_MONTH);
+        int hour = calendar2.get(Calendar.HOUR_OF_DAY);
+
+        for (SubsidyCustomerFace subsidyCustomerFace : integralList) {
+            List<Order> orders = maps.get(subsidyCustomerFace.getAreaId());
+            if (CollectionUtils.isEmpty(orders)) {
+                continue;
+            }
+            for (Order order : orders) {
+                //积分相关
+                if(order.getPointMember() == null){
+                    order.setPointMember(0);
+                }
+                if(subsidyCustomerFace.getCustomerNum() != null){
+                    Integer num =order.getPointMember()+subsidyCustomerFace.getCustomerNum();
+                    order.setPointMember(num);
+                }
+
+                if(StringUtils.isNotEmpty(order.getMemberListData()) && subsidyCustomerFace.getMemberListData() != null){
+                    MemberListData data =JSONObject.toJavaObject(JSON.parseObject(order.getMemberListData()), MemberListData.class);
+                    MemberListData newData = subsidyCustomerFace.getMemberListData();
+
+                    if(day == 1 && hour == 0){
+                        data.setTotal(newData.getTotal());
+
+                    }else{
+                        data.setTotal(data.getTotal()+newData.getTotal());
+                    }
+
+                    for (int i = 0; i < data.getMale().size(); i++) {
+                        data.getMale().set(i,data.getMale().get(i)+newData.getMale().get(i));
+                    }
+
+                    for (int i = 0; i < data.getWoman().size(); i++) {
+                        data.getWoman().set(i,data.getWoman().get(i)+newData.getWoman().get(i));
+                    }
+                    order.setMemberListData(JSONObject.toJSONString(data));
+                }else if(subsidyCustomerFace.getMemberListData() != null){
+                    order.setMemberListData(JSONObject.toJSONString(subsidyCustomerFace.getMemberListData()));
+                }
+
+            }
+        }
+    }
+
+
+    private List<SubsidyCustomerFace> integralTrans(DateParams dateParams){
+        List<SubsidyCustomerFace> returnList = Lists.newArrayList();
+        List<Integer> operationIds = baseMapper.getIntegralCardDetailOperatorIdList(dbName);
+        List<IntegralTrans> detailsTrans = Lists.newArrayList();
+        QueryWrapper queryWrapper2 = new QueryWrapper();
+        if(dateParams.getStartDate() != null){
+            queryWrapper2.ge("t.build_time",dateParams.getStartDate());
+        }
+        if(dateParams.getEndDate() != null){
+            queryWrapper2.le("t.build_time",dateParams.getEndDate());
+        }
+        for (Integer operationId : operationIds) {
+            //获取积分数据
+            detailsTrans.addAll(baseMapper.integralTransList(queryWrapper2,operationId,dbName));
+        }
+
+        log.info("---处理流水数据开始----");
+        Map<Integer,List<IntegralTrans>> streetTransMaps = detailsTrans.stream().filter(i->i.getStreetId() != null).collect(Collectors.groupingBy(IntegralTrans::getStreetId));
+
+        fillData2(streetTransMaps,returnList);
+        Map<Integer,List<IntegralTrans>> cityTransMaps = detailsTrans.stream().filter(i->i.getCityId() != null).collect(Collectors.groupingBy(IntegralTrans::getCityId));
+
+        fillData2(cityTransMaps,returnList);
+        Map<Integer,List<IntegralTrans>> countryTransMaps = detailsTrans.stream().filter(i->i.getCountryId() != null).collect(Collectors.groupingBy(IntegralTrans::getCountryId));
+
+        fillData2(countryTransMaps,returnList);
+        log.info("---处理流水数据结束----");
+        return returnList;
+    }
+
+    private void fillData2(Map<Integer,List<IntegralTrans>> data2,List<SubsidyCustomerFace> returnList){
+        for (Integer integer : data2.keySet()) {
+            List<IntegralTrans> dataList = data2.get(integer);
+            SubsidyCustomerFace face = new SubsidyCustomerFace();
+            face.setAreaId(integer);
+
+            Long grantSum = dataList.stream().filter(t -> t.getTransType().equals("0")).mapToLong(t -> t.getAmount()).sum();
+            face.setGrantNum(grantSum);
+            Long exchangeSum = dataList.stream().filter(t -> t.getTransType().equals("1")).mapToLong(t -> t.getAmount()).sum();
+            face.setExchangeNum(exchangeSum);
+            List<MonthData> goodsList = Lists.newArrayList();
+            Map<Integer, List<IntegralTrans>> maps = dataList.stream().filter(i -> i.getParentId() != null).collect(Collectors.groupingBy(IntegralTrans::getParentId));
+            for (Integer categoryId : maps.keySet()) {
+                List<IntegralTrans> categoryList = maps.get(categoryId);
+                MonthData monthData = new MonthData();
+                monthData.setAddValue(0L);
+                for (IntegralTrans IntegralTrans : categoryList) {
+                    String fullName = IntegralTrans.getFullName();
+                    if (fullName.contains("/")) {
+                        fullName = fullName.split("/")[0];
+                    }
+                    monthData.setText(fullName);
+                    monthData.setAddValue(monthData.getAddValue() + IntegralTrans.getAmount());
+                }
+                if (monthData.getAddValue() > 0L) {
+                    goodsList.add(monthData);
+                }
+            }
+            //消分商品个数统计
+            if (!goodsList.isEmpty()) {
+                face.setPointGoodsData2(goodsList);
+            }
+            face.setPointMonthData(addMonth(dataList, 0));
+            face.setPointCountData(addMonth(dataList, 1));
+            returnList.add(face);
+        }
+    }
+
+    private List<MonthData> addMonth(List<IntegralTrans> transList,Integer type){
+        Date endDate = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(com.poteviohealth.cgp.common.utils.DateUtils.getLastDayOfMonth(endDate));
+        calendar.add(Calendar.SECOND,1);
+        calendar.add(Calendar.YEAR, -1);
+        Date startDate = calendar.getTime();
+        List<MonthData> monthList = Lists.newArrayList();
+        Calendar calendar2 = Calendar.getInstance();
+        for (int i = 0; i < 12; i++) {
+            if(i>0){
+                calendar2.add(Calendar.MONTH, 1);
+            }else{
+                calendar2.setTime(startDate);
+            }
+            String monthStr = String.format("%02d",  calendar2.get(Calendar.MONTH)+1);
+            MonthData data = new MonthData();
+            data.setText(monthStr+"月");
+            if(type.equals(0)){
+                if(transList.isEmpty()){
+                    data.setAddValue(0L);
+                    data.setUseValue(0L);
+                }else{
+                    data.setAddValue(transList.stream().filter(c->c.getBuildTime().after(calendar2.getTime()) && c.getBuildTime().before(com.poteviohealth.cgp.common.utils.DateUtils.getLastDayOfMonth(calendar2.getTime())) && c.getTransType().equals("0")).mapToLong(c->c.getAmount()).sum());
+                    data.setUseValue(transList.stream().filter(c->c.getBuildTime().after(calendar2.getTime()) && c.getBuildTime().before(com.poteviohealth.cgp.common.utils.DateUtils.getLastDayOfMonth(calendar2.getTime())) && c.getTransType().equals("1")).mapToLong(c->c.getAmount()).sum());
+                }
+
+            }else {
+                if (transList.isEmpty()) {
+                    data.setAddValue(0L);
+                    data.setUseValue(0L);
+                } else {
+                    data.setAddValue(transList.stream().filter(c -> c.getBuildTime().after(calendar2.getTime()) && c.getBuildTime().before(com.poteviohealth.cgp.common.utils.DateUtils.getLastDayOfMonth(calendar2.getTime())) && c.getTransType().equals("0")).count());
+                    data.setUseValue(transList.stream().filter(c -> c.getBuildTime().after(calendar2.getTime()) && c.getBuildTime().before(com.poteviohealth.cgp.common.utils.DateUtils.getLastDayOfMonth(calendar2.getTime())) && c.getTransType().equals("1")).count());
+                }
+            }
+            monthList.add(data);
+        }
+        return monthList;
+    }
+
+    private void changeTransIntegral(Map<Integer, List<Order>> maps,DateParams dateParams) {
+        List<SubsidyCustomerFace> integralList = this.integralTrans(dateParams);
+
+        for (SubsidyCustomerFace subsidyCustomerFace : integralList) {
+            List<Order> orders = maps.get(subsidyCustomerFace.getAreaId());
+            if (CollectionUtils.isEmpty(orders)) {
+                continue;
+            }
+            for (Order order : orders) {
+                //积分相关
+                if(order.getPointGrant() == null){
+                    order.setPointGrant(0L);
+                }
+                if(subsidyCustomerFace.getGrantNum() != null){
+                    Long num = order.getPointGrant()+subsidyCustomerFace.getGrantNum();
+                    order.setPointGrant(num);
+                }
+                if(order.getPointExchange() == null){
+                    order.setPointExchange(0L);
+                }
+                if(subsidyCustomerFace.getExchangeNum() != null){
+                    Long num =order.getPointExchange() + subsidyCustomerFace.getExchangeNum();
+                    order.setPointExchange(num);
+                }
+
+                if(StringUtils.isNotEmpty(order.getPointGoodsData2()) && CollectionUtils.isNotEmpty(subsidyCustomerFace.getPointGoodsData2())){
+                    List<MonthData> list =JSONArray.parseArray(order.getPointGoodsData2(),MonthData.class);
+                    for (MonthData data : subsidyCustomerFace.getPointGoodsData2()) {
+                        boolean isHave = false;
+                        for (MonthData monthData : list) {
+                            if(data.getText().equals(monthData.getText())){
+                                monthData.setAddValue(monthData.getAddValue()+data.getAddValue());
+                                isHave = true;
+                                break;
+                            }
+                        }
+                        if(!isHave){
+                            list.add(data);
+                        }
+                    }
+                    order.setPointGoodsData2(JSONObject.toJSONString(list));
+                }else if(CollectionUtils.isNotEmpty(subsidyCustomerFace.getPointGoodsData2())){
+                    order.setPointGoodsData2(JSONObject.toJSONString(subsidyCustomerFace.getPointGoodsData2()));
+                }
+
+                if(StringUtils.isNotEmpty(order.getPointCountData()) && CollectionUtils.isNotEmpty(subsidyCustomerFace.getPointCountData())){
+                    List<MonthData> list =JSONArray.parseArray(order.getPointCountData(),MonthData.class);
+                    List<MonthData> nowList =subsidyCustomerFace.getPointCountData();
+                    int t = 0;
+                    if(list.get(0).getText().equals(nowList.get(nowList.size()-1).getText())){
+                        t = 1;
+                    }
+                    for (int i = 0; i < nowList.size(); i++) {
+                        if(t ==nowList.size()){
+                            break;
+                        }
+                        nowList.get(i).setAddValue(nowList.get(i).getAddValue()+list.get(t).getAddValue());
+                        nowList.get(i).setUseValue(nowList.get(i).getUseValue()+list.get(t).getUseValue());
+                        t++;
+                    }
+                    order.setPointCountData(JSONObject.toJSONString(nowList));
+                }else if(CollectionUtils.isNotEmpty(subsidyCustomerFace.getPointCountData())){
+                    order.setPointCountData(JSONObject.toJSONString(subsidyCustomerFace.getPointCountData()));
+                }
+
+                if(StringUtils.isNotEmpty(order.getPointMonthData()) && CollectionUtils.isNotEmpty(subsidyCustomerFace.getPointMonthData())){
+                    List<MonthData> list =JSONArray.parseArray(order.getPointMonthData(),MonthData.class);
+                    List<MonthData> nowList =subsidyCustomerFace.getPointMonthData();
+                    int t = 0;
+                    if(list.get(0).getText().equals(nowList.get(nowList.size()-1).getText())){
+                        t = 1;
+                    }
+                    for (int i = 0; i < nowList.size(); i++) {
+                        if(t ==nowList.size()){
+                            break;
+                        }
+                        nowList.get(i).setAddValue(nowList.get(i).getAddValue()+list.get(t).getAddValue());
+                        nowList.get(i).setUseValue(nowList.get(i).getUseValue()+list.get(t).getUseValue());
+                        t++;
+                    }
+                    order.setPointMonthData(JSONObject.toJSONString(nowList));
+                }else if(CollectionUtils.isNotEmpty(subsidyCustomerFace.getPointMonthData())){
+                    order.setPointMonthData(JSONObject.toJSONString(subsidyCustomerFace.getPointMonthData()));
+                }
+            }
+        }
+    }
+
+    private List<SubsidyCustomerFace> getMerchantIntegralFace(List<Integer> operatorIds,List<ListParams> categoryList){
+        List<SubsidyCustomerFace> returnList = Lists.newArrayList();
+        List<IntegralTransaction> transList = Lists.newArrayList();
+        List<Product> products = Lists.newArrayList();
+        for (Integer operatorId : operatorIds) {
+            transList.addAll(baseMapper.integralTransactionList(dbName,operatorId));
+            products.addAll(baseMapper.queryIntegralProduct(dbName,operatorId));
+        }
+        List<StationMerchant> stationMerchantList =  baseMapper.getStationMerchantList(dbName);
+        List<IntegralProduct> productList = baseMapper.integralProductList(dbName);
+        List<StationMerchant> stationList = stationMerchantList.stream().filter(s->s.getStatus().equals(1) && !s.getType().equals(18) && s.getStreet() != null && s.getCountry() != null && s.getCity() != null).collect(Collectors.toList());
+        List<ListParams> categoryFilterList = categoryList.stream().filter(c->c.getKey().equals(1)).collect(Collectors.toList());
+
+        //按照街道分组
+        Map<Integer,List<StationMerchant>> stationStreetMaps = stationList.stream().collect(Collectors.groupingBy(StationMerchant::getStreet));
+        fillStationData(stationStreetMaps,returnList,3,productList,categoryFilterList,products,transList);
+        //按照区分组
+        Map<Integer,List<StationMerchant>> stationCountryMaps = stationList.stream().collect(Collectors.groupingBy(StationMerchant::getCountry));
+        fillStationData(stationCountryMaps,returnList,2,productList,categoryFilterList,products,transList);
+        //按照市分组
+        Map<Integer,List<StationMerchant>> stationCityMaps = stationList.stream().collect(Collectors.groupingBy(StationMerchant::getCity));
+        fillStationData(stationCityMaps,returnList,1,productList,categoryFilterList,products,transList);
+        log.info("---客户积分处理结束---");
+        return returnList;
+    }
+
+    private void fillStationData(Map<Integer,List<StationMerchant>> maps, List<SubsidyCustomerFace> returnList,Integer source,
+                                 List<IntegralProduct> productList,List<ListParams> categoryList,List<Product> products,
+                                 List<IntegralTransaction> transList){
+        for (Integer integer : maps.keySet()) {
+            List<StationMerchant> csList = maps.get(integer);
+            SubsidyCustomerFace face = new SubsidyCustomerFace();
+            face.setAreaId(integer);
+            face.setPointStation(csList.size());
+            List<MonthData> dataList = Lists.newArrayList();
+            for (StationMerchant dto : csList) {
+                MonthData monthData = new MonthData();
+                monthData.setText(dto.getName());
+                monthData.setAddValue(productList.stream().filter(p->p.getMerchantId().equals(dto.getId())).count());
+                if(monthData.getAddValue()>0L){
+                    dataList.add(monthData);
+                }
+            }
+            //积分商品统计
+            dataList = dataList.stream().sorted(Comparator.comparing(MonthData::getAddValue).reversed()).collect(Collectors.toList());
+            if(dataList.size() >=5){
+                face.setGoodsData(dataList.subList(0,5));
+            }else{
+                face.setGoodsData(dataList);
+            }
+
+            List<Integer> supplierIds = csList.stream().filter(s->s.getSupplierId() != null).map(s->s.getSupplierId()).distinct().collect(Collectors.toList());
+            List<Product> pList = products.stream().filter(p->supplierIds.contains(p.getProviderId())).collect(Collectors.toList());
+            List<MonthData> pDataList = Lists.newArrayList();
+            for (ListParams params : categoryList) {
+                MonthData monthData = new MonthData();
+                monthData.setText(params.getName());
+                Long val = 0L;
+                for (Product product : pList) {
+                    if(product.getParentCategoryId().equals(params.getId().longValue())){
+                        val++;
+                    }
+                }
+                if(val>0L){
+                    monthData.setAddValue(val);
+                    pDataList.add(monthData);
+                }
+            }
+            //消分商品统计
+            face.setGoodsData2(pDataList);
+
+            switch(source){
+                case 1:
+                    //按区域分组
+                    Map<Integer,List<StationMerchant>> countryMaps = csList.stream().collect(Collectors.groupingBy(StationMerchant::getCountry));
+                    List<MonthData> countryList = Lists.newArrayList();
+                    for (Integer country : countryMaps.keySet()) {
+                        List<StationMerchant> list = countryMaps.get(country);
+                        MonthData monthData = new MonthData();
+                        monthData.setText(countryMaps.get(country).get(0).getCountryName());
+                        monthData.setAddValue(Long.parseLong(String.valueOf(list.size())));
+                        countryList.add(monthData);
+                    }
+                    countryList = countryList.stream().sorted(Comparator.comparing(MonthData::getAddValue).reversed()).collect(Collectors.toList());
+                    if(countryList.size() >=5){
+                        face.setProviderData(countryList.subList(0,5));
+                    }else{
+                        face.setProviderData(countryList);
+                    }
+                    break;
+                case 2:
+                    //按街道分组
+                    Map<Integer,List<StationMerchant>> streetMaps = csList.stream().collect(Collectors.groupingBy(StationMerchant::getStreet));
+                    List<MonthData> streetList = Lists.newArrayList();
+                    for (Integer street : streetMaps.keySet()) {
+                        List<StationMerchant> list = streetMaps.get(street);
+                        MonthData monthData = new MonthData();
+                        monthData.setText(streetMaps.get(street).get(0).getStreetName());
+                        monthData.setAddValue(Long.parseLong(String.valueOf(list.size())));
+                        streetList.add(monthData);
+                    }
+                    streetList = streetList.stream().sorted(Comparator.comparing(MonthData::getAddValue).reversed()).collect(Collectors.toList());
+                    if(streetList.size() >=5){
+                        face.setProviderData(streetList.subList(0,5));
+                    }else{
+                        face.setProviderData(streetList);
+                    }
+                    break;
+                case 3:
+                    //按商户名称
+                    List<MonthData> nameList = Lists.newArrayList();
+                    for (StationMerchant dto : csList) {
+                        MonthData monthData = new MonthData();
+                        monthData.setText(dto.getName());
+                        nameList.add(monthData);
+                    }
+                    if(nameList.size() >=5){
+                        face.setProviderData(nameList.subList(0,5));
+                    }else{
+                        face.setProviderData(nameList);
+                    }
+                    break;
+            }
+
+            List<Integer> ids = csList.stream().map(c->c.getId()).collect(Collectors.toList());
+            Map<Integer,List<IntegralTransaction>> transMaps = transList.stream().filter(t->ids.contains(t.getMerchantId())).collect(Collectors.groupingBy(IntegralTransaction::getMerchantId));
+            List<MonthData> dataList2 = Lists.newArrayList();
+            for (Integer tran : transMaps.keySet()) {
+                List<IntegralTransaction> trans = transMaps.get(tran);
+                MonthData data = new MonthData();
+                data.setText(trans.get(0).getMerchantName());
+                Long val = 0L;
+                for (IntegralTransaction transaction : trans) {
+                    val += transaction.getIntegral() * transaction.getNum();
+                }
+                data.setAddValue(val);
+                dataList2.add(data);
+            }
+            //积分商品个数统计
+            dataList2 = dataList2.stream().sorted(Comparator.comparing(MonthData::getAddValue).reversed()).collect(Collectors.toList());
+            if(dataList2.size() >=5){
+                face.setPointGoodsData(dataList2.subList(0,5));
+            }else{
+                face.setPointGoodsData(dataList2);
+            }
+            returnList.add(face);
+
+        }
+    }
+
+    private void changeIntegral(Map<Integer, List<Order>> maps,List<Integer> operatorIds,List<ListParams> categoryList) {
+        List<SubsidyCustomerFace> customerFaceList = this.getMerchantIntegralFace(operatorIds,categoryList);
+        for (SubsidyCustomerFace subsidyCustomerFace : customerFaceList) {
+            List<Order> orders = maps.get(subsidyCustomerFace.getAreaId());
+            if(orders == null || orders.isEmpty()){
+                continue;
+            }
+            for (Order order : orders) {
+                //积分相关
+                order.setPointStation(subsidyCustomerFace.getPointStation());
+                if(CollectionUtils.isNotEmpty(subsidyCustomerFace.getPointGoodsData())){
+                    order.setPointGoodsData(JSONObject.toJSONString(subsidyCustomerFace.getPointGoodsData()));
+                }
+                if(CollectionUtils.isNotEmpty(subsidyCustomerFace.getProviderData())){
+                    order.setProviderData(JSONObject.toJSONString(subsidyCustomerFace.getProviderData()));
+                }
+                if(CollectionUtils.isNotEmpty(subsidyCustomerFace.getGoodsData())){
+                    order.setGoodsData(JSONObject.toJSONString(subsidyCustomerFace.getGoodsData()));
+                }
+                if(CollectionUtils.isNotEmpty(subsidyCustomerFace.getGoodsData2())){
+                    order.setGoodsData2(JSONObject.toJSONString(subsidyCustomerFace.getGoodsData2()));
+                }
+            }
+        }
+    }
+
+    private List<OrderStatisticsData> getOrderStatisticsDataList(List<Integer> ids,DateParams dateParams,List<ListParams> categoryList){
+        List<OrderStatisticsData> returnList = Lists.newArrayList();
+        List<OrderIntegrationData> list = Lists.newArrayList();
+
+        for (Integer id : ids) {
+            QueryWrapper queryWrapper = new QueryWrapper<>();
+            if(dateParams.getStartDate() != null){
+                queryWrapper.ge("o.finish_time",dateParams.getStartDate());
+            }
+            if(dateParams.getEndDate() != null){
+                queryWrapper.lt("o.finish_time",dateParams.getEndDate());
+            }
+            //获取已完成的服务工单
+            list.addAll(baseMapper.queryOrderIntegrationData(id,dbName,queryWrapper));
+        }
+
+
+        Map<Integer,List<ListParams>> categoryMap = categoryList.stream().collect(Collectors.groupingBy(ListParams::getId));
+        //按照市统计
+        Map<Integer,List<OrderIntegrationData>> cityMaps = list.stream().collect(Collectors.groupingBy(OrderIntegrationData::getCityId));
+        //按照区统计
+        Map<Integer,List<OrderIntegrationData>> countryMaps = list.stream().collect(Collectors.groupingBy(OrderIntegrationData::getCountryId));
+        //按照街道统计
+        Map<Integer,List<OrderIntegrationData>> streetMaps = list.stream().collect(Collectors.groupingBy(OrderIntegrationData::getStreetId));
+        for (Integer integer : cityMaps.keySet()) {
+            integrationData(returnList,cityMaps.get(integer),integer,categoryMap);
+        }
+        for (Integer integer : countryMaps.keySet()) {
+            integrationData(returnList,countryMaps.get(integer),integer,categoryMap);
+        }
+        for (Integer integer : streetMaps.keySet()) {
+            integrationData(returnList,streetMaps.get(integer),integer,categoryMap);
+        }
+
+        return returnList;
+    }
+
+    private void integrationData(List<OrderStatisticsData> returnList,List<OrderIntegrationData> orderList,
+                                 Integer areaId,Map<Integer,List<ListParams>> categoryMap){
+        OrderStatisticsData data = new OrderStatisticsData();
+        data.setAreaId(areaId);
+        List<Long> visitNumList = orderList.stream().map(o->o.getCustomerId()).distinct().collect(Collectors.toList());
+        data.setVisitNum(visitNumList.size());
+       /* List<OrderIntegrationData> visitOrderList = orderList.stream().filter(o->o.getVisitStatus().equals(1)).collect(Collectors.toList());
+        BigDecimal visitRate = new BigDecimal(visitOrderList.size()).divide(new BigDecimal(orderList.size()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100.0)).setScale(2,BigDecimal.ROUND_HALF_UP);*/
+        data.setVisitRate(new BigDecimal(100));
+        if(data.getVisitNum()>0){
+            List<Long> satisfactionList = orderList.stream().filter(v->v.getResult().equals(1)).map(o->o.getOrderId()).collect(Collectors.toList());
+            data.setSatisfactionNum(satisfactionList.size());
+            List<Long> qualifiedList = orderList.stream().filter(v->v.getQualified().equals(1)).map(o->o.getOrderId()).collect(Collectors.toList());
+            //BigDecimal qualifiedRate = new BigDecimal(qualifiedList.size()).divide(new BigDecimal(orderList.size()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100.0)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            data.setQualifiedNum(qualifiedList.size());
+        }else{
+            data.setSatisfactionNum(0);
+            data.setQualifiedNum(0);
+        }
+
+        data.setOrderNum(orderList.size());
+
+        List<OrderIntegrationData> monthOrderList = orderList.stream()
+                .filter(o-> DateUtil.isIn(o.getFinishTime(), com.poteviohealth.cgp.common.utils.DateUtils.getFirstDayOfMonth(new Date()), com.poteviohealth.cgp.common.utils.DateUtils.getLastDayOfMonth(new Date())))
+                .collect(Collectors.toList());
+        data.setOrderNumMonth(monthOrderList.size());
+        Map<String, String> dateMap = com.poteviohealth.cgp.common.utils.DateUtils.getWeekDate();
+        try {
+            Date monday = com.poteviohealth.cgp.common.utils.DateUtils.startOfDay(com.alibaba.excel.util.DateUtils.parseDate(dateMap.get("mondayDate")));
+            Date sunday = com.poteviohealth.cgp.common.utils.DateUtils.endOfDay(com.alibaba.excel.util.DateUtils.parseDate(dateMap.get("sundayDate")));
+            List<OrderIntegrationData> weekOrderList = orderList.stream().filter(o->DateUtil.isIn(o.getFinishTime(),monday,sunday)).collect(Collectors.toList());
+            data.setOrderNumWeek(weekOrderList.size());
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+
+
+        List<OrderIntegrationData> dayOrderList = orderList.stream()
+                .filter(o->DateUtil.isIn(o.getFinishTime(), com.poteviohealth.cgp.common.utils.DateUtils.startOfDay(new Date()), com.poteviohealth.cgp.common.utils.DateUtils.endOfDay(new Date())))
+                .collect(Collectors.toList());
+        data.setOrderNumDay(dayOrderList.size());
+
+        //服务类型统计
+        List<OrderServiceTypeDTO> typeList = Lists.newArrayList();
+        Map<Integer,List<OrderIntegrationData>> orderCategoryMaps = orderList.stream().collect(Collectors.groupingBy(OrderIntegrationData::getProductCategoryId));
+
+        Map<Integer,Integer> maps = Maps.newHashMap();
+        for (Integer integer : orderCategoryMaps.keySet()) {
+            List<ListParams> list = categoryMap.get(integer);
+            if(list != null && !list.isEmpty()){
+                ListParams listParent = categoryMap.get(list.get(0).getKey()).get(0);
+                if(maps.containsKey(listParent.getId())){
+                    maps.put(listParent.getId(),maps.get(listParent.getId())+orderCategoryMaps.get(integer).size());
+                }else{
+                    maps.put(listParent.getId(),orderCategoryMaps.get(integer).size());
+                }
+            }
+        }
+        DecimalFormat df = new DecimalFormat("#0.00");
+        if(!maps.isEmpty()){
+            Integer sum =  maps.values().stream().mapToInt(Integer::intValue).sum();
+            for (Integer integer : maps.keySet()) {
+                OrderServiceTypeDTO dto = new OrderServiceTypeDTO();
+                dto.setId(integer);
+                dto.setCount(maps.get(integer));
+                dto.setName(categoryMap.get(integer).get(0).getName());
+                if(sum == 0){
+                    dto.setRate("0");
+                }else{
+                    dto.setRate(df.format((dto.getCount().doubleValue()/sum)*100.0));
+                }
+                typeList.add(dto);
+            }
+            typeList = typeList.stream().sorted(Comparator.comparing(OrderServiceTypeDTO::getCount).reversed()).collect(Collectors.toList());
+        }
+        if(typeList.size()>=5){
+            data.setServiceTypeList(JSON.toJSONString(typeList.subList(0,5)));
+        }else{
+            data.setServiceTypeList(JSON.toJSONString(typeList));
+        }
+
+        returnList.add(data);
+    }
+
+    private void changeOrder(Map<Integer, List<Order>> maps,DateParams dateParams,List<Integer> operatorIds,List<ListParams> categoryList) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(dateParams.getEndDate());
+        DecimalFormat df = new DecimalFormat("#0.00");
+        //更新工单相关数据
+        List<OrderStatisticsData> orderList = this.getOrderStatisticsDataList(operatorIds,dateParams,categoryList);
+        for (OrderStatisticsData orderStatisticsData : orderList) {
+            List<Order> orders = maps.get(orderStatisticsData.getAreaId());
+            if(orders == null || orders.isEmpty()){
+                continue;
+            }
+            for (Order order : orders) {
+                if(order.getVisitNum() == null){
+                    order.setVisitNum(0);
+                }
+                if(order.getOrderNum() == null){
+                    order.setOrderNum(0);
+                }
+                if(order.getSatisfactionRate() == null){
+                    order.setSatisfactionRate(new BigDecimal("0.00"));
+                }
+                if(order.getQualifiedRate() == null){
+                    order.setQualifiedRate(new BigDecimal("0.00"));
+                }
+                BigDecimal satisfaction = order.getSatisfactionRate().multiply(new BigDecimal(order.getOrderNum())).divide(new BigDecimal("100.0"),2,BigDecimal.ROUND_HALF_UP);
+                BigDecimal qualified = order.getQualifiedRate().multiply(new BigDecimal(order.getOrderNum())).divide(new BigDecimal("100.0"),2,BigDecimal.ROUND_HALF_UP);
+                order.setOrderNum(order.getOrderNum()+orderStatisticsData.getOrderNum());
+                order.setVisitNum(order.getVisitNum()+orderStatisticsData.getVisitNum());
+                order.setVisitRate(orderStatisticsData.getVisitRate());
+                if(order.getOrderNum().equals(0)){
+                    order.setSatisfactionRate(new BigDecimal("0.00"));
+                    order.setQualifiedRate(new BigDecimal("0.00"));
+                }else{
+                    BigDecimal addSatisfaction = satisfaction.add(new BigDecimal(orderStatisticsData.getSatisfactionNum()));
+                    if(order.getOrderNum() == null || order.getOrderNum().equals(0)){
+                        order.setSatisfactionRate(new BigDecimal("0.00"));
+                        order.setQualifiedRate(new BigDecimal("0.00"));
+                    }else{
+                        order.setSatisfactionRate(addSatisfaction.multiply(new BigDecimal("100.0")).divide(new BigDecimal(order.getOrderNum()),2,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP));
+                        if(order.getSatisfactionRate().compareTo(new BigDecimal(100))>0){
+                            order.setSatisfactionRate(new BigDecimal(100));
+                        }
+                        BigDecimal addQualified = qualified.add(new BigDecimal(orderStatisticsData.getQualifiedNum()));
+                        order.setQualifiedRate(addQualified.divide(new BigDecimal(order.getOrderNum()),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100.0")).setScale(2,BigDecimal.ROUND_HALF_UP));
+                        if(order.getQualifiedRate().compareTo(new BigDecimal(100))>0){
+                            order.setQualifiedRate(new BigDecimal(100));
+                        }
+                    }
+                 }
+                if(calendar.get(Calendar.DAY_OF_MONTH) == 1 && calendar.get(Calendar.HOUR_OF_DAY) == 0){
+                    //每月1日0点清零
+                    order.setOrderNumMonth(0);
+                }else{
+                    order.setOrderNumMonth((order.getOrderNumMonth() == null ?0:order.getOrderNumMonth())+orderStatisticsData.getOrderNumMonth());
+                }
+                if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY && calendar.get(Calendar.HOUR_OF_DAY) == 0) {
+                    //每周一0点清零
+                    order.setOrderNumWeek(0);
+                }else{
+                    order.setOrderNumWeek((order.getOrderNumWeek()==null?0:order.getOrderNumWeek())+orderStatisticsData.getOrderNumWeek());
+                }
+                if(calendar.get(Calendar.HOUR_OF_DAY) == 0){
+                    //每天0点清零
+                    order.setOrderNumDay(0);
+                }else{
+                    order.setOrderNumDay((order.getOrderNumDay()==null?0:order.getOrderNumDay())+orderStatisticsData.getOrderNumDay());
+                }
+
+                if(StringUtils.isEmpty(order.getServiceTypeList())){
+                    order.setServiceTypeList(orderStatisticsData.getServiceTypeList());
+                }else if(StringUtils.isNotEmpty(orderStatisticsData.getServiceTypeList())){
+                    List<OrderServiceTypeDTO> list =JSONArray.parseArray(order.getServiceTypeList(),OrderServiceTypeDTO.class);
+                    List<OrderServiceTypeDTO> dataList = JSONArray.parseArray(orderStatisticsData.getServiceTypeList(),OrderServiceTypeDTO.class);
+                    for (OrderServiceTypeDTO orderServiceTypeDTO : dataList) {
+                        boolean have = false;
+                        for (OrderServiceTypeDTO dto : list) {
+                            if(dto.getId().equals(orderServiceTypeDTO.getId())){
+                                dto.setCount(dto.getCount()+orderServiceTypeDTO.getCount());
+                                have = true;
+                                break;
+                            }
+                        }
+                        if(!have){
+                            list.add(orderServiceTypeDTO);
+                        }
+                    }
+                    Long sum = list.stream().mapToLong(o->o.getCount()).sum();
+                    for (OrderServiceTypeDTO dto : list) {
+                        dto.setRate(df.format((dto.getCount().doubleValue()/sum)*100.0));
+                    }
+                }
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar calendar = Calendar.getInstance();
+        try {
+            calendar.setTime(df.parse("2024-03-05 00:00:24"));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
+        System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
+
+    }
+}

+ 201 - 0
src/main/resources/mapper/statistics/OrderMapper.xml

@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.poteviohealth.cgp.statistics.mapper.OrderMapper">
+    <select id="integralTransList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTrans">
+        SELECT
+            IFNULL(
+                    c.now_city_id,(
+                SELECT
+                    p.address_city_id
+                FROM
+                    ${dbName}_common.f_operator p
+                WHERE
+                    p.id = c.operator_id
+            )) AS cityId,
+            c.now_country_id AS countryId,
+            c.now_street_id AS streetId,
+            od.product_category_id AS productCategoryId,
+            g.parent_id AS parentId,
+            g.full_name AS fullName,
+            t.trans_type AS transType,
+            t.amount AS amount,
+            t.build_time AS buildTime
+        FROM
+            ${dbName}_finance.c_card_acc_trans t
+                LEFT JOIN ${dbName}_finance.c_card_acc_detail d ON t.detail_id = d.id
+                LEFT JOIN ${dbName}_order.o_order_detail_${operatorId} od ON od.order_detail_id = t.trans_id
+                LEFT JOIN ${dbName}_customer.c_customer_subsidy_${operatorId} c ON c.subsidy_customer_id = d.subsidy_customer_id
+                LEFT JOIN ${dbName}_common.f_category g ON g.id = od.product_category_id
+        WHERE
+            d.yn = 0
+          AND t.yn = 0
+          AND d.ENABLE = 1
+          AND d.type = 2
+          AND t.trans_type IN (0,1)
+          and  ${ew.sqlSegment}
+    </select>
+    <select id="integralCustomerList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTrans">
+        SELECT
+            c.age AS age,
+            c.sex AS sex,
+            IFNULL(
+                    c.now_city_id,(
+                SELECT
+                    p.address_city_id
+                FROM
+                    ${dbName}_common.f_operator p
+                WHERE
+                    p.id = c.operator_id
+            )) AS cityId,
+            c.now_country_id AS countryId,
+            c.now_street_id AS streetId,
+            d.created_date AS createdDate
+        FROM
+            ${dbName}_finance.c_card_acc_detail d
+                LEFT JOIN ${dbName}_customer.c_customer_subsidy_${operatorId} c ON c.subsidy_customer_id = d.subsidy_customer_id
+        WHERE
+            d.yn = 0
+          AND d.ENABLE = 1
+          AND d.type = 2
+          and  ${ew.sqlSegment}
+    </select>
+
+    <select id="areaList" resultType="com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO">
+        select id,parent as parentId,name,tree_path,region_area_code,(LENGTH(tree_path) - LENGTH(replace(tree_path,',',''))) as `level`
+        from ${dbName}_common.f_area
+        where yn = 0
+        and parent is not null
+        and length(tree_path)-length(replace(tree_path,',',''))
+        and (region_area_code like '37%' or
+        region_area_code like '32%' or
+        region_area_code like '11%' or
+        region_area_code like '21%' or
+        region_area_code like '51%')
+    </select>
+
+    <select id="supplierStationEmployeeList"
+            resultType="com.poteviohealth.cgp.statistics.model.outdto.SupplierStationEmployee">
+        select station_id,employee_id from ${dbName}_common.f_supplier_station_employee where yn = 0
+    </select>
+
+    <select id="supplierStationList" resultType="com.poteviohealth.cgp.statistics.model.outdto.SupplierStation">
+        select id,city,country,street from ${dbName}_common.f_supplier_station
+        where yn = 0 and `level` >=2 and status = 1 and type = 1 and LENGTH(region_code) = 12
+    </select>
+
+    <select id="employeeList" resultType="com.poteviohealth.cgp.statistics.model.outdto.Employee">
+        select id,age,gender from  ${dbName}_common.f_employee
+        where yn = 0
+          and role_id_str like '%25%'
+          and status = 1
+          and age is not null
+          and gender is not null
+    </select>
+
+    <select id="getOperatorList" resultType="java.lang.Integer">
+        select id from  ${dbName}_common.f_operator
+        where yn = 0 and id>0 and enabled = 1 and check_status = 2
+    </select>
+
+    <select id="getSubsidyCustomerList"
+            resultType="com.poteviohealth.cgp.common.integrated.customer.model.CustomerSubsidyDTO">
+        SELECT
+            c.subsidy_customer_id as subsidyCustomerId,
+            c.customer_id as customerId,
+            IFNULL(c.now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = c.operator_id)) as nowCityId,
+            IFNULL(c.now_city_name,(select p.address_city_name from ${dbName}_common.f_operator p where p.id = c.operator_id)) as nowCityName,
+            c.now_country_id as nowCountryId,
+            c.now_country_name as nowCountryName,
+            c.now_street_id as nowStreetId,
+            c.now_street_name as nowStreetName,
+            c.customer_sign_id as customerSignId,
+            c.customer_type_id as customerTypeId,
+            c.customer_type as customerType,
+            c.age as age,
+            c.sex as sex,
+            if(sum(IF( d.settlement = 1, 1, 0 ) )>0,1,0) as category
+        FROM
+            ${dbName}_finance.c_card_acc_detail d
+           ,${dbName}_customer.c_customer_subsidy_${operatorId} c
+        where c.subsidy_customer_id = d.subsidy_customer_id
+          and c.yn = 0 AND d.yn = 0
+          and c.customer_type_id is not null
+          and c.customer_type is not null
+          and c.enabled = 1
+          and ${ew.sqlSegment}
+        GROUP BY c.subsidy_customer_id
+    </select>
+
+    <select id="orderServiceCustomerList"
+            resultType="com.poteviohealth.cgp.common.integrated.customer.model.CustomerServiceParams">
+        SELECT
+            IFNULL(c.now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = c.operator_id)) as cityId,
+            IFNULL(c.now_country_id,-1) AS countryId,
+            IFNULL(c.now_street_id,-1) AS streetId,
+            count(DISTINCT c.customer_id) as customerNum,
+            CONCAT(',',c.customer_type_id,',') as customerTypeId
+        FROM
+            ${dbName}_customer.c_customer_subsidy_${operatorId} c
+                LEFT JOIN ${dbName}_order.o_order_${operatorId} o ON o.customer_id = c.customer_id
+        WHERE
+            o.order_status = 6
+          AND o.order_type = 2
+          and c.yn =0
+          and c.enabled = 1
+        GROUP BY c.now_street_id,c.customer_type_id;
+    </select>
+
+    <select id="getSubsidyCustomerMealList" resultType="com.poteviohealth.cgp.statistics.model.outdto.Customer">
+        select now_city_id,now_country_id,now_street_id from ${dbName}_customer.c_customer_subsidy_${operatorId}
+         where yn = 0
+         and ${ew.sqlSegment}
+    </select>
+
+    <select id="queryOrderIntegrationData"
+            resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderIntegrationData">
+        SELECT o.order_id as orderId,o.city_id as cityId,o.country_id as countryId,o.street_id as streetId,o.visit_status as visitStatus
+                ,o.customer_id as  customerId,o.finish_time as  finishTime,od.product_category_id as productCategoryId,v.qualified as qualified,
+               v.result as result FROM ${dbName}_order.o_order_${operatorId} o,${dbName}_order.o_order_detail_${operatorId} od,${dbName}_order.o_visit_${operatorId} v
+        where o.order_id = od.order_id
+          and v.order_id = o.order_id
+          and o.yn= 0 and v.yn = 0
+          and o.order_status = 6
+          and o.order_type = 2
+          and o.city_id is not null
+          and o.country_id is not null
+          and o.street_id is not null
+          and o.finish_time is not null
+          and od.product_category_id is not null
+          and ${ew.sqlSegment}
+        group by o.order_id
+    </select>
+
+    <select id="getAllCategory" resultType="com.poteviohealth.cgp.common.integrated.ListParams">
+        select id,name,parent_id as `key` from ${dbName}_common.f_category where yn = 0
+    </select>
+
+    <select id="integralTransactionList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTransaction">
+        select num,integral,merchant_id,merchant_name from ${dbName}_customer.c_integral_transaction_${operatorId} where yn =0 and type = 0
+    </select>
+
+    <select id="integralProductList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralProduct">
+        select merchant_id from ${dbName}_customer.c_integral_product where yn =0 and type = 0 and own_review = 1
+    </select>
+
+    <select id="getStationMerchantList"
+            resultType="com.poteviohealth.cgp.statistics.model.outdto.StationMerchant">
+        select id,name,status,type,city,country,street,supplier_id,country_name,street_name from ${dbName}_common.f_station_merchant where yn = 0
+    </select>
+
+    <select id="queryIntegralProduct" resultType="com.poteviohealth.cgp.statistics.model.outdto.Product">
+        select provider_id,parent_category_id from ${dbName}_product.p_product_${operatorId} where yn = 0 and own_status = 1 and tags like '%8962319%'
+    </select>
+
+    <select id="getIntegralCardAccOperatorIdList" resultType="java.lang.Integer">
+        select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1  and ${ew.sqlSegment} group by operator_id
+    </select>
+
+    <select id="getIntegralCardDetailOperatorIdList" resultType="java.lang.Integer">
+        select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1 group by operator_id
+    </select>
+</mapper>

+ 3 - 0
src/main/resources/rizhao/application.yml

@@ -98,3 +98,6 @@ jpush:
 ribbon:
  ReadTimeout: 5000
  ConnectTimeout: 5000
+
+sync:
+  dbName: yl

+ 3 - 0
src/main/resources/uat/application.yml

@@ -98,3 +98,6 @@ jpush:
 ribbon:
  ReadTimeout: 5000
  ConnectTimeout: 5000
+
+sync:
+  dbName: rz

+ 4 - 1
src/main/resources/zky/application.yml

@@ -99,4 +99,7 @@ jpush:
 
 ribbon:
  ReadTimeout: 5000
- ConnectTimeout: 5000
+ ConnectTimeout: 5000
+
+sync:
+  dbName: rz