Przeglądaj źródła

添加利润分析数据查询,先按自己逻辑写后期再修正
修改平安车险数据接口

hxl13994548489 2 lat temu
rodzic
commit
88f648898c

+ 1 - 1
sql/Online.sql

@@ -25,7 +25,7 @@ CREATE TABLE `pingan_api_log`  (
 DROP TABLE IF EXISTS `ins_labor_cost`;
 CREATE TABLE `ins_labor_cost`  (
                                    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
-                                   `year_month` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '年',
+                                   `year_and_month` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '年',
                                    `labor_cost` decimal(10, 2) NULL DEFAULT NULL COMMENT '人力成本',
                                    `fixed_cost` decimal(10, 2) NULL DEFAULT NULL COMMENT '固定成本',
                                    `variable_cost` decimal(10, 2) NULL DEFAULT NULL COMMENT '变动成本',

+ 50 - 0
src/main/java/com/ydtech/modules/admin/controller/profitAnalysis/ProfitAnalysisController.java

@@ -0,0 +1,50 @@
+package com.ydtech.modules.admin.controller.profitAnalysis;
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto;
+import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
+import com.ydtech.modules.admin.service.ProfitAnalysisService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/7/31 15:33
+ *  @Description: 利润分析
+ */
+@Api(tags = "利润分析统计")
+@RequestMapping("/profitAnalysis")
+@RestController
+public class ProfitAnalysisController {
+
+
+    @Autowired
+    private ProfitAnalysisService profitAnalysisService;
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/31 15:35
+     *  @Description:  查询利润分析统计
+     */
+    @PostMapping("queryPage")
+    @ApiOperation(value = "查询利润分析数据")
+    public HttpResult<List<ProfitAnalysisDto>> queryPage(@RequestBody ProfitAnalysisQueryDto profitAnalysisQueryDto) {
+        try{
+            List<ProfitAnalysisDto> result = profitAnalysisService.queryPage(profitAnalysisQueryDto);
+            return HttpResult.ok("查询数据成功", result);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
+
+
+
+}

+ 59 - 0
src/main/java/com/ydtech/modules/admin/model/report/profitAnalysis/ProfitAnalysisDto.java

@@ -0,0 +1,59 @@
+package com.ydtech.modules.admin.model.report.profitAnalysis;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/7/31 15:37
+ *  @Description:  利润分析返回对象
+ */
+@Data
+@ApiModel("利润分析对象")
+public class ProfitAnalysisDto {
+
+    @ApiModelProperty("年份")
+    private String yearAndMonth;
+
+    @ApiModelProperty("保费")
+    private String sumpremium;
+
+    @ApiModelProperty("应收")
+    private String sumcount;
+    @ApiModelProperty("实收")
+    private String paid;
+
+    @ApiModelProperty("未收")
+    private String unpaid;
+
+    @ApiModelProperty("毛利润")
+    private String grossProfit;
+
+    @ApiModelProperty("人力成本")
+    private String laborCost;
+
+
+    @ApiModelProperty("固定成本")
+    private String fixedCost;
+
+    @ApiModelProperty("变动成本")
+    private BigDecimal variableCost;
+
+
+    @ApiModelProperty("经营利润")
+    @TableField(value="operating_profit")
+    private BigDecimal operatingProfit;
+
+    @ApiModelProperty("税费")
+    @TableField(value="taxation")
+    private BigDecimal taxation;
+
+    @ApiModelProperty("净利润")
+    @TableField(value="net_profit")
+    private BigDecimal netProfit;
+}

+ 34 - 0
src/main/java/com/ydtech/modules/admin/model/report/profitAnalysis/ProfitAnalysisQueryDto.java

@@ -0,0 +1,34 @@
+package com.ydtech.modules.admin.model.report.profitAnalysis;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/7/31 15:37
+ *  @Description:  利润分析的年度
+ */
+@Data
+@ApiModel("利润分析查询对象")
+public class ProfitAnalysisQueryDto {
+    /***
+     *  年份
+     */
+    @ApiModelProperty("年份")
+    private  String year;
+
+    /***
+     * 查询类型 1 近1月 2.近3月  3.近一年
+     */
+    @ApiModelProperty("查询类型")
+    private  String dateType;
+
+    @ApiModelProperty("开始时间不用赋值")
+    private  String beginDate;
+
+    @ApiModelProperty("结束时间不用赋值")
+    private  String endDate;
+
+}

+ 26 - 0
src/main/java/com/ydtech/modules/admin/service/ProfitAnalysisService.java

@@ -0,0 +1,26 @@
+package com.ydtech.modules.admin.service;
+
+
+import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto;
+import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
+
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/7/31 15:34
+ *  @Description: 利润分析页面统计
+ */
+public interface ProfitAnalysisService {
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/31 17:43
+     *  @Description:  利润分析
+     */
+    List<ProfitAnalysisDto> queryPage(ProfitAnalysisQueryDto profitAnalysisQueryDto);
+}
+
+
+

+ 90 - 0
src/main/java/com/ydtech/modules/admin/service/impl/ProfitAnalysisServiceImpl.java

@@ -0,0 +1,90 @@
+package com.ydtech.modules.admin.service.impl;
+
+import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto;
+import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
+import com.ydtech.modules.admin.service.ProfitAnalysisService;
+import com.ydtech.modules.admin.utils.SliceUpDateUtil;
+import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/7/1 11:36
+ *  @Description: 控制台-运营数据
+ */
+@Service
+public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
+
+
+    @Autowired
+    private InsPlyIncomeMapper insPlyIncomeMapper;
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/31 17:42
+     *  @Description: 查询利润数据
+     */
+    @Override
+    public List<ProfitAnalysisDto> queryPage(ProfitAnalysisQueryDto profitAnalysisQueryDto) {
+        HashMap<String, String> dateMapByType = getDateMapByType(profitAnalysisQueryDto.getDateType(), profitAnalysisQueryDto.getYear());
+        profitAnalysisQueryDto.setBeginDate(dateMapByType.get("startDate"));
+        profitAnalysisQueryDto.setEndDate(dateMapByType.get("endDate"));
+        List<ProfitAnalysisDto> list = insPlyIncomeMapper.queryPage(profitAnalysisQueryDto);
+        return list;
+    }
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/19 11:57
+     *  @Description:  通过时间类型判断
+     */
+    private static HashMap<String,String> getDateMapByType(String type, String year) {
+        HashMap<String,String> map =new HashMap<>();
+        String  startDateStr="";
+        String  endDateStr="";
+        if(StringUtils.isBlank(year) && StringUtils.isBlank(type)){
+            Calendar cale = Calendar.getInstance();
+            int yearNow = cale.get(Calendar.YEAR);
+            startDateStr= SliceUpDateUtil.getYearBeginDateStr(yearNow)+" 00:00:00";
+            endDateStr= SliceUpDateUtil.getYearEndDateStr(yearNow)+" 23:59:59";
+        }else{
+            if(StringUtils.isNotBlank(year)){
+                startDateStr= SliceUpDateUtil.getYearBeginDateStr(Integer.parseInt(year))+" 00:00:00";
+                endDateStr= SliceUpDateUtil.getYearEndDateStr(Integer.parseInt(year))+" 23:59:59";
+            }else{
+                if(StringUtils.isNotBlank(type)){
+                    if("1".equals(type)){
+                        // 一月内
+                        startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),2)+" 00:00:00";
+                        endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
+                    }else if("2".equals(type)){
+                        // 三月内
+                        startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),3)+" 00:00:00";
+                        endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
+                    }else if("3".equals(type)){
+                        // 近半年
+                        startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),4)+" 00:00:00";
+                        endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
+                    }
+                }
+            }
+
+        }
+        map.put("startDate",startDateStr);
+        map.put("endDate",endDateStr);
+        return map;
+    }
+}
+
+
+

+ 32 - 0
src/main/java/com/ydtech/modules/admin/utils/SliceUpDateUtil.java

@@ -198,4 +198,36 @@ public class SliceUpDateUtil {
         }
         return format.format(c.getTime());
     }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/31 17:59
+     *  @Description: 获取年份的开始时间
+     */
+    public static String getYearBeginDateStr(int year) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.YEAR, year);
+        calendar.set(Calendar.MONTH, Calendar.JANUARY);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        int startYear = calendar.get(Calendar.YEAR);
+        int startMonth = calendar.get(Calendar.MONTH);
+        int startDay = calendar.get(Calendar.DAY_OF_MONTH);
+        return startYear+""+startMonth+""+startDay;
+    }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/31 18:00
+     *  @Description: 获取年份的结束时间
+     */
+    public static String getYearEndDateStr(int year) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.YEAR, year);
+        calendar.set(Calendar.MONTH, Calendar.DECEMBER);
+        calendar.set(Calendar.DAY_OF_MONTH, 31);
+        int startYear = calendar.get(Calendar.YEAR);
+        int startMonth = calendar.get(Calendar.MONTH);
+        int startDay = calendar.get(Calendar.DAY_OF_MONTH);
+        return startYear+""+startMonth+""+startDay;
+    }
 }

+ 9 - 0
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -1,6 +1,8 @@
 package com.ydtech.modules.fnc.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto;
+import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
 import com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
@@ -146,4 +148,11 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
      */
 
     List<HashMap<String, Object>> ptSumGroupByMonth(HashMap<String, Object> params);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/31 18:04
+     *  @Description: 查询数据
+     */
+    List<ProfitAnalysisDto> queryPage( @Param("vo") ProfitAnalysisQueryDto profitAnalysisQueryDto);
 }

+ 3 - 1
src/main/java/com/ydtech/modules/order/components/pingan/PinganRequestApiComponents.java

@@ -267,7 +267,9 @@ public class PinganRequestApiComponents {
             DataResponse obj = JSON.parseObject(responseBody).toJavaObject(DataResponse.class);
             String sm4DecodeResult  = sm4.decryptStr(obj.getData());
             InsuranceLog.infoLog(InsuranceEnum.PAIC.getPinyin(), "\n\t---------> {} \n\t---------> 返回数据:{}", requestUrl.getCode() + "--" + url + "--" + requestUrl.getDesc(), sm4DecodeResult);
-            return JSON.parseObject(sm4DecodeResult).toJavaObject(tClass);
+            SignEleApplyResponse signEleApplyResponse =new  SignEleApplyResponse();
+            signEleApplyResponse.setResultMessage(sm4DecodeResult);
+            return (S)signEleApplyResponse;
         }else{
             CommonResponse obj = JSON.parseObject(responseBody).toJavaObject(CommonResponse.class);
             pinganApiLog.setResponseType(obj.getRet());

+ 1 - 2
src/main/java/com/ydtech/modules/order/controller/PingAnOrderApiController.java

@@ -4,7 +4,6 @@ package com.ydtech.modules.order.controller;
 import com.ydtech.aop.request.RequestSingleParam;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.ins.model.vo.QuoteRespVo;
-import com.ydtech.modules.order.aop.AuditVerification;
 import com.ydtech.modules.order.aop.QuoteVerification;
 import com.ydtech.modules.order.components.InsOrdersComponents;
 import com.ydtech.modules.order.entity.api.pingan.request.*;
@@ -95,7 +94,7 @@ public class PingAnOrderApiController {
      *  @Date: 2024/7/23 18:46
      *  @Description: 测试通过
      */
-    @AuditVerification("核保")
+    //@AuditVerification("核保")
     @PostMapping(value = "/audit")
     @ApiOperation(value = "2核保-提交核保")
     public HttpResult<Object> audit(@RequestBody SpecialAuditVo<SubmitVerifyRequest.EngageListDTO> specialAudit) throws Exception {

+ 50 - 0
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -2389,6 +2389,56 @@
         DATE_FORMAT( a.signdate, '%m')
     </select>
 
+    <select id="queryPage" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
+        SELECT
+            c.years AS yearAndMonth,
+            c.sumpremium AS sumpremium,
+            IFNULL( a.sumcount, 0 ) AS sumcount,
+            IFNULL( a.paid, 0 ) AS paid,
+            IFNULL( a.unpaid, 0 ) AS unpaid,
+            (IFNULL( a.sumcount, 0 ) - IFNULL( a.paid, 0 )) grossProfit,
+            IFNULL( b.labor_cost, 0 ) AS laborCost,
+            IFNULL( b.fixed_cost, 0 ) AS fixedCost,
+            IFNULL( b.variable_cost, 0 ) AS variableCost,
+            IFNULL( b.operating_profit, 0 ) AS operatingProfit,
+            IFNULL( b.taxation, 0 ) AS taxation,
+            IFNULL( b.net_profit, 0 ) AS netProfit
+        FROM
+            (
+                SELECT
+                    DATE_FORMAT( createtime, '%Y-%m' ) AS years,
+                    sum( sumpremium ) AS sumpremium
+                FROM
+                    ins_area_company
+                <where>
+                    <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                        AND  createtime  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+                    </if>
+                </where>
+                GROUP BY
+                    DATE_FORMAT( createtime, '%Y-%m' )
+                ORDER BY
+                    DATE_FORMAT( createtime, '%Y-%m' )
+            ) c
+                LEFT JOIN (
+                SELECT
+                    DATE_FORMAT( create_time, '%Y-%m' ) AS years,
+                    sum( all_fee_value ) AS sumcount,
+                    SUM( CASE WHEN handling_fees_status = '2' THEN ifnull( invoic_amount, 0 ) ELSE 0 END ) AS paid,
+                    SUM( CASE WHEN handling_fees_status != '2' THEN ifnull(( all_fee_value - ifnull( invoic_amount, 0 )), 0 ) ELSE 0 END ) AS unpaid
+                FROM
+                    ins_ply_income
+                <where>
+                    <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                        AND  create_time  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+                    </if>
+                </where>
+                GROUP BY
+                    DATE_FORMAT( create_time, '%Y-%m' )
+            ) a ON c.years = a.years
+                LEFT JOIN ins_labor_cost b ON a.years = b.year_and_month
+
+    </select>
 
 
 </mapper>