qin 11 месяцев назад
Родитель
Сommit
de7ac172a2

+ 29 - 4
src/main/java/com/poteviohealth/cgp/statistics/controller/OrderController.java

@@ -13,16 +13,14 @@ import com.poteviohealth.cgp.common.facade.log.OperationLog;
 import com.poteviohealth.cgp.common.facade.time.MethodTime;
 import com.poteviohealth.cgp.common.filter.TokenContext;
 import com.poteviohealth.cgp.common.filter.repeatSubmit.RepeatSubmit;
+import com.poteviohealth.cgp.common.integrated.customer.model.GoldSendPage;
 import com.poteviohealth.cgp.common.integrated.finance.model.CardAccTransRecharge;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanPageDTO;
 import com.poteviohealth.cgp.common.model.VaultsResponse;
 import com.poteviohealth.cgp.statistics.model.Distinction;
 import com.poteviohealth.cgp.statistics.model.indto.*;
-import com.poteviohealth.cgp.statistics.model.outdto.DishesOrderWebOutDTO;
-import com.poteviohealth.cgp.statistics.model.outdto.DistinctionDTO;
-import com.poteviohealth.cgp.statistics.model.outdto.OrderCostWebOutDTO;
-import com.poteviohealth.cgp.statistics.model.outdto.OrderExcelDTO;
+import com.poteviohealth.cgp.statistics.model.outdto.*;
 import com.poteviohealth.cgp.statistics.service.IDistinctionService;
 import com.poteviohealth.cgp.statistics.service.IOrderService;
 import com.poteviohealth.cgp.statistics.service.IWatermarkImgService;
@@ -189,6 +187,33 @@ public class OrderController extends BaseWebController {
         }
     }
 
+    @PostMapping(value = "/goldSendExport")
+    @ApiOperation(httpMethod = "POST", value = "高龄津贴发放Excel导出")
+    public void goldSendExport(HttpServletResponse resp,@RequestBody GoldSendPage page){
+        String key ="goldSendExport";
+        String error =  this.checkExcelExport(key);
+        try{
+            if ("".equals(error)) {
+                String templateLocation = "classpath:excel/goldSend.xlsx";
+                String filename = "";
+                Map<String, Object> data = Maps.newHashMap();
+                List<GoldSendExcelDTO> list = orderService.excelGoldSendList(page);
+                ExcelUtils2.easyDownload(templateLocation,data , list, filename, resp);
+            }else{
+                throw new BusinessException(error);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            throw new BusinessException(e.getMessage());
+        }finally {
+            if(cacheService.exists(key)){
+                if(cacheService.get(key).equals(TokenContext.cureWebUser().getUserId().toString())){
+                    cacheService.del(key);
+                }
+            }
+        }
+    }
+
     @DistributedLock(fairLock =true)
     private String checkExcelExport(String key){
         String returnVal = "";

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

@@ -237,5 +237,15 @@ public interface OrderMapper extends BaseMapper<Order>{
     LinkedList<CardAccTransRecharge> transRechargeExcel(@Param(Constants.WRAPPER) Wrapper wrapper,@Param("queryParam") CardWebInDTO var2, @Param("dbName")String dbName, @Param("start")Integer start);
 
 
+    @SqlParser(filter = true)
+    int goldSendListSize(@Param(Constants.WRAPPER) Wrapper wrapper, @Param("dbName") String dbName);
+
+    /**
+     * excel
+     * @param wrapper
+     * @return
+     */
+    @SqlParser(filter=true)
+    LinkedList<GoldSendExcelDTO> goldSendList(@Param(Constants.WRAPPER) Wrapper wrapper,@Param("dbName") String dbName, @Param("start")Integer start);
 
 }

+ 50 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/GoldSendExcelDTO.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;
+
+/**
+ * excel导出DTO
+ * @author Qin
+ */
+@Data
+@ApiModel(value="excel导出DTO")
+public class GoldSendExcelDTO {
+
+    @ApiModelProperty(value = "id")
+    private Integer id;
+
+    @ApiModelProperty(value = "区域")
+    private String countryName;
+
+    @ApiModelProperty(value = "街道")
+    private String streetName;
+
+    @ApiModelProperty(value = "社区")
+    private String communityName;
+
+    @ApiModelProperty("发放月")
+    private String sendMonth;
+
+    @ApiModelProperty(value = "身份证号码")
+    private String idNumber;
+
+    @ApiModelProperty(value = "姓名")
+    private String name;
+
+    @ApiModelProperty(value = "开户银行名称")
+    private String bankName;
+
+    @ApiModelProperty(value = "银行卡号")
+    private String bankCard;
+
+    @ApiModelProperty(value = "持卡人姓名")
+    private String bankHolder;
+
+    @ApiModelProperty(value = "类别0:80-89周岁;1:90-99周岁;2:100周岁以上")
+    private String goldTypeStr;
+
+    @ApiModelProperty("发放金额")
+    private String moneyStr;
+}

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

@@ -1,5 +1,6 @@
 package com.poteviohealth.cgp.statistics.service;
 
+import com.poteviohealth.cgp.common.integrated.customer.model.GoldSendPage;
 import com.poteviohealth.cgp.common.integrated.finance.model.CardAccTransRecharge;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanPageDTO;
@@ -7,6 +8,7 @@ import com.poteviohealth.cgp.common.service.IBaseService;
 import com.poteviohealth.cgp.statistics.model.Order;
 import com.poteviohealth.cgp.statistics.model.indto.*;
 import com.poteviohealth.cgp.statistics.model.outdto.DishesOrderWebOutDTO;
+import com.poteviohealth.cgp.statistics.model.outdto.GoldSendExcelDTO;
 import com.poteviohealth.cgp.statistics.model.outdto.OrderCostWebOutDTO;
 import com.poteviohealth.cgp.statistics.model.outdto.OrderExcelDTO;
 
@@ -59,4 +61,12 @@ public interface IOrderService extends IBaseService<Order> {
      * @return
      */
     List<MemberPlanDTO> pageCardExcel(MemberPlanPageDTO dto);
+
+
+    /**
+     * excel导出
+     * @param page
+     * @return
+     */
+    List<GoldSendExcelDTO> excelGoldSendList(GoldSendPage page);
 }

+ 69 - 4
src/main/java/com/poteviohealth/cgp/statistics/service/impl/OrderServiceImpl.java

@@ -8,10 +8,7 @@ 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.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.customer.model.*;
 import com.poteviohealth.cgp.common.integrated.finance.model.*;
 import com.poteviohealth.cgp.common.integrated.order.model.OrderStatisticsData;
 import com.poteviohealth.cgp.common.integrated.order.model.PayAccount;
@@ -319,6 +316,74 @@ public class OrderServiceImpl extends BaseServiceImpl<OrderMapper, Order> implem
         }
     }
 
+    @Override
+    public List<GoldSendExcelDTO> excelGoldSendList(GoldSendPage vo) {
+        try {
+            QueryWrapper queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("d.operator_id", TokenContext.cureOperatorId());
+            if(StringUtils.isNotEmpty(vo.getSendTime())){
+                queryWrapper.eq("d.send_time", vo.getSendTime());
+            }
+            if(StringUtils.isNotEmpty(vo.getExpectTime())){
+                queryWrapper.eq("d.expect_time", vo.getExpectTime());
+            }
+            if(StringUtils.isNotEmpty(vo.getIdNumber())){
+                queryWrapper.eq("d.id_number", vo.getIdNumber());
+            }
+            if(StringUtils.isNotEmpty(vo.getName())){
+                queryWrapper.like("d.name", vo.getName());
+            }
+            if(vo.getGoldType() != null){
+                queryWrapper.eq("d.gold_type", vo.getGoldType());
+            }
+            if(vo.getSendType() != null){
+                queryWrapper.eq("d.send_type", vo.getSendType());
+            }
+            if(vo.getIsDelete() != null){
+                queryWrapper.eq("d.is_delete", vo.getIsDelete());
+            }
+
+            if(vo.getCityId() != null){
+                queryWrapper.eq("d.city_id", vo.getCityId());
+            }else if(TokenContext.cureWebUser().getAuthorities().contains("11") && TokenContext.cureWebUser().getAreaId() != null){
+                queryWrapper.eq("d.city_id", TokenContext.cureWebUser().getAreaId());
+            }
+
+            if(vo.getCountryId() != null){
+                queryWrapper.eq("d.country_id", vo.getCountryId());
+            }else if(TokenContext.cureWebUser().getAuthorities().contains("12") && TokenContext.cureWebUser().getAreaId() != null){
+                queryWrapper.eq("d.country_id", TokenContext.cureWebUser().getAreaId());
+            }
+
+            if(vo.getStreetId() != null){
+                queryWrapper.eq("d.street_id", vo.getStreetId());
+            }else if(TokenContext.cureWebUser().getAuthorities().contains("10") && TokenContext.cureWebUser().getAreaId() != null){
+                queryWrapper.eq("d.street_id", TokenContext.cureWebUser().getAreaId());
+            }
+
+            if(vo.getCommunityId() != null){
+                queryWrapper.eq("d.community_id", vo.getCommunityId());
+            }else if(TokenContext.cureWebUser().getAuthorities().contains("9") && TokenContext.cureWebUser().getAreaId() != null){
+                queryWrapper.eq("d.community_id", TokenContext.cureWebUser().getAreaId());
+            }
+            int  count = baseMapper.goldSendListSize(queryWrapper,dbName);
+            //每页10000条,计算总页数
+            int maxPage = (int) Math.ceil(count/10000.0);
+            int start = 0;
+            LinkedList<GoldSendExcelDTO> list = Lists.newLinkedList();
+            for (int i = 0; i < maxPage; i++) {
+                LinkedList<GoldSendExcelDTO> findList = baseMapper.goldSendList(queryWrapper,dbName,start);
+                start = findList.getLast().getId();
+                list.addAll(findList);
+            }
+            return list;
+        }catch (Exception e){
+            e.printStackTrace();
+            throw new BuilderException("数据导出失败,请重新操作");
+        }
+
+    }
+
     private QueryWrapper cardQueryWrapper(MemberPlanPageDTO dto){
         QueryWrapper<WatermarkImg> queryWrapper = new QueryWrapper();
         queryWrapper.eq("d.operator_id",TokenContext.cureOperatorId());

BIN
src/main/resources/excel/goldSend.xlsx


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

@@ -507,4 +507,32 @@
         order by t.id
         limit 10000
     </select>
+
+    <select id="goldSendListSize" resultType="int">
+        select count(*)
+        from ${dbName}_cutomer.c_gold_send d where d.yn = 0
+        and  ${ew.sqlSegment}
+    </select>
+
+    <select id="goldSendList" resultType="com.poteviohealth.cgp.statistics.model.outdto.GoldSendExcelDTO">
+        select d.id, d.send_month,
+        d.name,
+        d.id_number,
+        TRUNCATE(d.money/100,2) as moneyStr,
+        d.country_name,
+        d.street_name,
+        d.community_name,
+        d.bank_name,
+        d.bank_card,
+        d.bank_holder,
+        case when d.gold_type = 0 then '80-89周岁'
+             when d.gold_type = 1 then '90-99周岁'
+             when d.gold_type = 2 then '100周岁以上' end as goldTypeStr
+        from ${dbName}_cutomer.c_gold_send d
+        where d.yn = 0
+        and d.id > #{start}
+        and  ${ew.sqlSegment}
+        order by t.id
+        limit 10000
+    </select>
 </mapper>