lmstack 3 anni fa
parent
commit
0830bd7d84

+ 6 - 0
src/main/java/cn/fastfun/controller/api/ApiAssetProfitController.java

@@ -10,6 +10,7 @@ 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;
@@ -51,6 +52,9 @@ public class ApiAssetProfitController {
     @Autowired
     AppDeviceService appDeviceService;
 
+    @Autowired
+    AppAssetConfMapper appAssetConfMapper;
+
 
     @ApiOperation(value = "基础信息")
     @RequestMapping(value = "getBaseInfo", method = RequestMethod.POST)
@@ -782,6 +786,8 @@ public class ApiAssetProfitController {
                 }
 
                 Page<AppAssetConf> appAssetConfPage = appAssetConfService.page(page, appAssetConfQueryWrapper);
+                appAssetConfMapper.getAssetConf(param.getSn(), param.getTableOrder(), param.getType().split(","),
+                        new SimpleDateFormat("yyyy-MM-dd").format(param.getTimeStart()), new SimpleDateFormat("yyyy-MM-dd").format(param.getTimeEnd()));
                 List<Map<String, Object>> data = new ArrayList<>();
                 if (appAssetConfPage.getTotal() > 0) {
                     appAssetConfPage.getRecords().forEach(p -> {

+ 53 - 2
src/main/java/cn/fastfun/service/mapper/AppAssetConfMapper.java

@@ -17,7 +17,58 @@ import java.util.List;
  */
 public interface AppAssetConfMapper extends BaseMapper<AppAssetConf> {
 
-    @Select("select time_st as time, FLOOR(DATEDIFF(time_st,'2021-01-01')/7)+1 as weeks, AVG(soh) as soh from soh_result where device_id = #{sn} group by weeks order by weeks")
-    List<AppAssetConf> getAssetConf(@Param("sn") String sn);
+    @Select("<script>" +
+            "SELECT\n" +
+            "\td.sn,\n" +
+            "\td.amount,\n" +
+            "CASE\n" +
+            "\t\tCONCAT( d.table_order, d.type ) \n" +
+            "\t\tWHEN ( 21 ) THEN\n" +
+            "\t\t'故障花费' \n" +
+            "\t\tWHEN ( 22 ) THEN\n" +
+            "\t\t'平台服务费' \n" +
+            "\t\tWHEN ( 31 ) THEN\n" +
+            "\t\t'赔偿花费' \n" +
+            "\t\tWHEN ( 51 ) THEN\n" +
+            "\t\t'仓储费用' \n" +
+            "\t\tWHEN ( 52 ) THEN\n" +
+            "\t\t'运输费用' \n" +
+            "\t\tWHEN ( 53 ) THEN\n" +
+            "\t\t'销售费用' \n" +
+            "\t\tWHEN ( 54 ) THEN\n" +
+            "\t\t'平台费用' \n" +
+            "\t\tWHEN ( 61 ) THEN\n" +
+            "\t\t'已支付金融成本' \n" +
+            "\t\tWHEN ( 62 ) THEN\n" +
+            "\t\t'未支付金融成本' \n" +
+            "\t\tWHEN ( 71 ) THEN\n" +
+            "\t\t'翻新金额-支' \n" +
+            "\t\tWHEN ( 72 ) THEN\n" +
+            "\t\t'处置支出' \n" +
+            "\t\tWHEN ( 73 ) THEN\n" +
+            "\t\t'处置收益' \n" +
+            "\t\tWHEN ( 81 ) THEN\n" +
+            "\t\t'其他支出项目' \n" +
+            "\t\tWHEN ( 82 ) THEN\n" +
+            "\t\t'其他收入项目' ELSE '其他' \n" +
+            "\tEND AS type \n" +
+            "FROM\n" +
+            "\tapp_asset_conf d " +
+            "where sn = #{sn} " +
+            "and table_order = #{tableOrder} " +
+            "<when test='type!=null'>" +
+            "and type in " +
+            "<foreach  item=\"item\" collection=\"array\" index=\"index\"  open=\"(\" separator=\",\" close=\")\">#{type}</foreach>" +
+            "</when>" +
+            "<when test='timeStart!=null'>" +
+            "and time > #{timeStart} " +
+            "</when>" +
+            "<when test='timeEnd!=null'>" +
+            "and time < #{timeEnd} " +
+            "</when>" +
+            "limit #{length}, #{index}" +
+            "</script")
+    List<AppAssetConf> getAssetConf(@Param("sn") String sn, @Param("tableOrder") Integer tableOrder, @Param("type") String[] type,
+                                    @Param("timeStart") String timeStart,@Param("timeEnd") String timeEnd);
 
 }