Browse Source

Merge remote-tracking branch 'origin/master'

bridge 3 years ago
parent
commit
5ba85747f1

+ 1 - 1
src/main/java/cn/fastfun/config/TokenConfig.java

@@ -12,7 +12,7 @@ public class TokenConfig extends WebMvcConfigurationSupport {
     public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(new TokenInterceptor())
                 .addPathPatterns("/api/**")
-                .excludePathPatterns("/api/user/**", "/api/v1/appdevice/excelTemplate","/api/v1/appdevice/excelImport");
+                .excludePathPatterns("/api/user/**", "/api/v1/appdevice/excelTemplate","/api/v1/appdevice/excelImport","/api/v1/appassetprofit/export");
     }
 
     @Override

+ 86 - 12
src/main/java/cn/fastfun/controller/api/ApiAssetProfitController.java

@@ -1,13 +1,17 @@
 package cn.fastfun.controller.api;
 
+import cn.fastfun.controller.dto.asset.AssetConfDto;
 import cn.fastfun.controller.dto.asset.BaseInfoDTO;
 import cn.fastfun.controller.dto.asset.ResponseDTO;
 import cn.fastfun.controller.dto.asset.FigureDTO;
 import cn.fastfun.controller.param.*;
+import cn.fastfun.service.AppDeviceService;
 import cn.fastfun.service.SysExcelFieldService;
 import cn.fastfun.service.entity.AppAssetConf;
+import cn.fastfun.service.entity.AppDevice;
 import cn.fastfun.service.impl.AppAssetConfServiceImpl;
 import cn.fastfun.service.impl.AppAssetProfitServiceImpl;
+import cn.fastfun.service.mapper.AppAssetConfMapper;
 import cn.fastfun.util.IrrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -46,6 +50,12 @@ public class ApiAssetProfitController {
     @Autowired
     AppAssetConfServiceImpl appAssetConfService;
 
+    @Autowired
+    AppDeviceService appDeviceService;
+
+    @Autowired
+    AppAssetConfMapper appAssetConfMapper;
+
 
     @ApiOperation(value = "基础信息")
     @RequestMapping(value = "getBaseInfo", method = RequestMethod.POST)
@@ -77,6 +87,7 @@ public class ApiAssetProfitController {
             ResponseDTO responseDTO = new ResponseDTO();
 
             Page<AppAssetConf> appAssetConfPage = appAssetConfService.appAssetConfPageQuery(param);
+            responseDTO.setTotal(appAssetConfPage.getTotal());
             if (appAssetConfPage.getTotal() > 0) {
                 appAssetConfPage.getRecords().forEach(p -> {
                     ResponseDTO.AllInfo allInfo = new ResponseDTO.AllInfo();
@@ -148,6 +159,8 @@ public class ApiAssetProfitController {
             ResponseDTO responseDTO = new ResponseDTO();
 
             Page<AppAssetConf> appAssetConfPage = appAssetConfService.appAssetConfPageQuery(param);
+            responseDTO.setTotal(appAssetConfPage.getTotal());
+
             if (appAssetConfPage.getTotal() > 0) {
                 appAssetConfPage.getRecords().forEach(p -> {
                     ResponseDTO.AllInfo allInfo = new ResponseDTO.AllInfo();
@@ -193,6 +206,8 @@ public class ApiAssetProfitController {
             ResponseDTO responseDTO = new ResponseDTO();
 
             Page<AppAssetConf> appAssetConfPage = appAssetConfService.appAssetConfPageQuery(param);
+            responseDTO.setTotal(appAssetConfPage.getTotal());
+
             if (appAssetConfPage.getTotal() > 0) {
                 appAssetConfPage.getRecords().forEach(p -> {
                     ResponseDTO.AllInfo allInfo = new ResponseDTO.AllInfo();
@@ -315,6 +330,8 @@ public class ApiAssetProfitController {
             ResponseDTO responseDTO = new ResponseDTO();
 
             Page<AppAssetConf> appAssetConfPage = appAssetConfService.appAssetConfPageQuery(param);
+            responseDTO.setTotal(appAssetConfPage.getTotal());
+
             if (appAssetConfPage.getTotal() > 0) {
                 appAssetConfPage.getRecords().forEach(p -> {
                     ResponseDTO.AllInfo allInfo = new ResponseDTO.AllInfo();
@@ -371,6 +388,8 @@ public class ApiAssetProfitController {
         else if (param.getTableOrder() != null && param.getTableOrder().equals(7)) {
             ResponseDTO responseDTO = new ResponseDTO();
             Page<AppAssetConf> appAssetConfPage = appAssetConfService.appAssetConfPageQuery(param);
+            responseDTO.setTotal(appAssetConfPage.getTotal());
+
             if (appAssetConfPage.getTotal() > 0) {
                 appAssetConfPage.getRecords().forEach(p -> {
                     ResponseDTO.AllInfo allInfo = new ResponseDTO.AllInfo();
@@ -414,6 +433,8 @@ public class ApiAssetProfitController {
         else if (param.getTableOrder() != null && param.getTableOrder().equals(8)) {
             ResponseDTO responseDTO = new ResponseDTO();
             Page<AppAssetConf> appAssetConfPage = appAssetConfService.appAssetConfPageQuery(param);
+            responseDTO.setTotal(appAssetConfPage.getTotal());
+
             if (appAssetConfPage.getTotal() > 0) {
                 appAssetConfPage.getRecords().forEach(p -> {
                     ResponseDTO.AllInfo allInfo = new ResponseDTO.AllInfo();
@@ -661,9 +682,37 @@ public class ApiAssetProfitController {
         return ApiDTO.ok("成功", response);
     }
 
+    @ApiOperation(value = "获取sn列表")
+    @PostMapping("getSn")
+    public ApiDTO getSn(){
+        List<String> sns = new ArrayList<>();
+        List<AppDevice> appDevices = appDeviceService.findAll();
+        appDevices.forEach(p->sns.add(p.getSn()));
+
+        return ApiDTO.ok(sns);
+    }
+
+    @ApiOperation(value = "导出认证")
+    @PostMapping("exportAuth")
+    public ApiDTO exportAuth(@RequestBody @ApiParam(name = "设备信息对象", value = "传入json格式", required = true) AssetProfitParam param){
+        String name;
+        switch (param.getTableOrder()){
+            case 1: name = "租赁信息";break;
+            case 2: name = "运维信息";break;
+            case 3: name = "赔偿信息";break;
+            case 4: name = "营销信息";break;
+            case 5: name = "运营信息";break;
+            case 6: name = "金融成本信息";break;
+            case 7: name = "处置信息";break;
+            case 8: name = "其他信息";break;
+            default: name=null;
+        }
+        return ApiDTO.ok(name);
+    }
+
     @ApiOperation(value = "导出")
     @GetMapping("export")
-    public void export(HttpServletResponse response, @RequestParam String sn, @RequestParam String timeStart, @RequestParam String timeEnd, @RequestParam Integer tableOrder, @RequestParam String type) throws ParseException {
+    public void export(HttpServletResponse response, @RequestParam String name, @RequestParam String sn, @RequestParam String timeStart, @RequestParam String timeEnd, @RequestParam Integer tableOrder, @RequestParam String type) throws ParseException {
 
         AssetProfitParam param = new AssetProfitParam();
         param.setSn(sn.equals("null") ? null : sn);
@@ -690,9 +739,24 @@ public class ApiAssetProfitController {
                         put("remark", p.getDescription());
                     }});
                 });
-                sysExcelFieldService.outExcelFile(sysExcelFieldService.export("rent_info", data), response, "租赁信息.xlsx");
+                sysExcelFieldService.outExcelFile(sysExcelFieldService.export("rent_info", data), response, name);
             }
-            if (param.getTableOrder() != null && (param.getTableOrder().equals(2) || param.getTableOrder().equals(3)
+            // 营销信息
+            if (param.getTableOrder() != null && param.getTableOrder().equals(4)) {
+                param.setFigureOrNot(false);
+                ResponseDTO responseDTO = (ResponseDTO) appAssetService.getSaleInfo(param);
+                List<Map<String, Object>> data = new ArrayList<>();
+                responseDTO.getAllInfoList().forEach(p -> {
+                    data.add(new HashMap<String, Object>() {{
+                        put("time", p.getTime());
+                        put("type", p.getType());
+                        put("amount", p.getAmount());
+                        put("remark", p.getDescription());
+                    }});
+                });
+                sysExcelFieldService.outExcelFile(sysExcelFieldService.export("sale_info", data), response, name);
+            }
+            else if (param.getTableOrder() != null && (param.getTableOrder().equals(2) || param.getTableOrder().equals(3)
                     || param.getTableOrder().equals(5) || param.getTableOrder().equals(6)
                     || param.getTableOrder().equals(7) || param.getTableOrder().equals(8))) {
                 AssetPageQueryParam appAssetConf = new AssetPageQueryParam();
@@ -721,13 +785,22 @@ public class ApiAssetProfitController {
                 if (appAssetConf.getTimeEnd() != null) {
                     appAssetConfQueryWrapper.lt("time", appAssetConf.getTimeEnd());
                 }
+
                 Page<AppAssetConf> appAssetConfPage = appAssetConfService.page(page, appAssetConfQueryWrapper);
+
+                List<String> strings = Arrays.asList(param.getType());
+
+                List<AssetConfDto> assetConf = appAssetConfMapper.getAssetConf(param.getSn(), param.getTableOrder(),
+                        param.getType() == null?null:Arrays.asList(param.getType()),
+                        param.getTimeStart() == null?null:new SimpleDateFormat("yyyy-MM-dd").format(param.getTimeStart()),
+                        param.getTimeEnd() == null?null:new SimpleDateFormat("yyyy-MM-dd").format(param.getTimeEnd()),
+                        (param.getIndex() - 1) * param.getLength(), param.getLength());
                 List<Map<String, Object>> data = new ArrayList<>();
-                if (appAssetConfPage.getTotal() > 0) {
-                    appAssetConfPage.getRecords().forEach(p -> {
+                if (assetConf.size() > 0) {
+                    assetConf.forEach(p -> {
                         data.add(new HashMap<String, Object>() {{
                             put("time", p.getTime());
-                            put("type", p.getType());
+                            put("type", p.getTypeText());
                             put("amount", p.getAmount());
                             put("remark", "");
                         }});
@@ -735,22 +808,23 @@ public class ApiAssetProfitController {
                 }
                 switch (param.getTableOrder()) {
                     case 2:
-                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("om_info", data), response, "运维信息.xlsx");
+
+                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("om_info", data), response, name);
                         break;
                     case 3:
-                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("com_info", data), response, "赔偿信息.xlsx");
+                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("com_info", data), response, name);
                         break;
                     case 5:
-                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("op_info", data), response, "运营信息.xlsx");
+                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("op_info", data), response, name);
                         break;
                     case 6:
-                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("fi_info", data), response, "金融成本信息.xlsx");
+                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("fi_info", data), response, name);
                         break;
                     case 7:
-                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("handle_info", data), response, "处置信息.xlsx");
+                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("handle_info", data), response, name);
                         break;
                     case 8:
-                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("other_info", data), response, "其他信息.xlsx");
+                        sysExcelFieldService.outExcelFile(sysExcelFieldService.export("other_info", data), response, name);
                         break;
 
                     default:

+ 20 - 0
src/main/java/cn/fastfun/controller/dto/asset/AssetConfDto.java

@@ -0,0 +1,20 @@
+package cn.fastfun.controller.dto.asset;
+
+import cn.fastfun.service.entity.AppAssetConf;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 资产基础信息
+ * @author user
+ */
+@Data
+public class AssetConfDto extends AppAssetConf {
+
+    private static final long serialVersionUID = -1821068317406106793L;
+
+    private String typeText;
+}

+ 6 - 0
src/main/java/cn/fastfun/controller/dto/asset/ResponseDTO.java

@@ -132,6 +132,9 @@ public class ResponseDTO {
     // 处置净收益
     private BigDecimal handleProfit = new BigDecimal(0);
 
+    // 毛利
+    private BigDecimal grossProfit = new BigDecimal(0);
+
     // 其他总支出
     private BigDecimal otherTotalCost = new BigDecimal(0);
 
@@ -141,6 +144,9 @@ public class ResponseDTO {
     // 净收入
     private BigDecimal netIncome = new BigDecimal(0);
 
+    // 分页total
+    private long total;
+
 
 
 }

+ 1 - 0
src/main/java/cn/fastfun/service/entity/AppAssetConf.java

@@ -41,6 +41,7 @@ public class AppAssetConf implements Serializable {
 
     private Integer type;
 
+
     @ApiModelProperty(value = "费用")
     private BigDecimal amount;
 

+ 3 - 0
src/main/java/cn/fastfun/service/impl/AppAssetProfitServiceImpl.java

@@ -194,6 +194,7 @@ public class AppAssetProfitServiceImpl {
             List<RentAndDepositDto> rentAndDepositDtos = new ArrayList<>();
             if (rentInfo.get("data") != null && rentInfo.get("data") != "") {
                 JSONObject responseData = JSONObject.parseObject(rentInfo.get("data").toString());
+                responseDTO.setTotal((Integer)responseData.get("total"));
                 if (responseData.get("summary") != null && responseData.get("summary") != "") {
                     summaryCentAndDepositDto = JSONObject.parseObject(responseData.get("summary").toString(), SummaryCentAndDepositDto.class);
                 }
@@ -228,6 +229,7 @@ public class AppAssetProfitServiceImpl {
                 }
                 responseDTO.getAllInfoList().add(allInfo);
             }
+
             responseDTO.setOrderStartTime(summaryCentAndDepositDto.getOrderStartTime());
             responseDTO.setOrderEndTime(summaryCentAndDepositDto.getOrderEndTime());
             responseDTO.setRental(summaryCentAndDepositDto.getCurrentCent());
@@ -362,6 +364,7 @@ public class AppAssetProfitServiceImpl {
             List<MarketingInformationDto> rentAndDepositDtos = new ArrayList<>();
             if (rentInfo.get("data") != null && rentInfo.get("data") != "") {
                 JSONObject responseData = JSONObject.parseObject(rentInfo.get("data").toString());
+                responseDTO.setTotal((Integer)responseData.get("total"));
                 if (responseData.get("summary") != null && responseData.get("summary") != "") {
                     summaryCentAndDepositDto = JSONObject.parseObject(responseData.get("summary").toString(), SummaryCentAndDepositDto.class);
                 }

+ 61 - 0
src/main/java/cn/fastfun/service/mapper/AppAssetConfMapper.java

@@ -1,7 +1,13 @@
 package cn.fastfun.service.mapper;
 
+import cn.fastfun.controller.dto.asset.AssetConfDto;
 import cn.fastfun.service.entity.AppAssetConf;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -13,4 +19,59 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface AppAssetConfMapper extends BaseMapper<AppAssetConf> {
 
+    @Select({"<script>" +
+            " SELECT" +
+            " d.sn," +
+            " d.amount," +
+            " d.time," +
+            " CASE" +
+            " CONCAT( d.table_order, d.type ) " +
+            " WHEN ( '21' ) THEN" +
+            " '故障花费' " +
+            " WHEN ( '22' ) THEN" +
+            " '平台服务费' " +
+            " WHEN ( '31' ) THEN" +
+            " '赔偿花费' " +
+            " WHEN ( '51' ) THEN" +
+            " '仓储费用' " +
+            " WHEN ( '52' ) THEN" +
+            " '运输费用' " +
+            " WHEN ( '53' ) THEN" +
+            " '销售费用' " +
+            " WHEN ( '54' ) THEN" +
+            " '平台费用' " +
+            " WHEN ( '61' ) THEN" +
+            " '已支付金融成本' " +
+            " WHEN ( '62' ) THEN" +
+            " '未支付金融成本' " +
+            " WHEN ( '71' ) THEN" +
+            " '翻新金额-支' " +
+            " WHEN ( '72' ) THEN" +
+            " '处置支出' " +
+            " WHEN ( '73' ) THEN" +
+            " '处置收益' " +
+            " WHEN ( '81' ) THEN" +
+            " '其他支出项目' " +
+            " WHEN ( '82' ) THEN" +
+            " '其他收入项目' ELSE '其他' " +
+            " END AS typeText " +
+            " FROM" +
+            " app_asset_conf d " +
+            " where sn = #{sn} " +
+            " and table_order = #{tableOrder} " +
+            "<when test='type!=null'>" +
+            " and type in " +
+            "<foreach item='id' collection='type' index='index'  open='(' separator=',' close=')'>#{id}</foreach>" +
+            "</when>" +
+            "<when test='timeStart!=null'>" +
+            " and time &gt; #{timeStart} " +
+            "</when>" +
+            "<when test='timeEnd!=null'>" +
+            " and time &lt; #{timeEnd} " +
+            "</when>" +
+            " limit #{offset}, #{length}" +
+            "</script>"})
+    List<AssetConfDto> getAssetConf(@Param("sn") String sn, @Param("tableOrder") Integer tableOrder, @Param("type") List<String> type,
+                                    @Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("offset") Integer offset, @Param("length") Integer length);
+
 }

+ 4 - 0
src/main/resources/application-dev.yml

@@ -20,6 +20,10 @@ spring:
     hibernate:
       ddl-auto: update
 
+mybatis-plus:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
 logging:
   level:
     com.bridge: debug