yumeng 1 anno fa
parent
commit
6be1584126

+ 25 - 6
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/material/controller/FirstDeliveryValidController.java

@@ -5,12 +5,7 @@ import cn.com.ctop.toutiao.modules.material.service.FirstDeliveryValidService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-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.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -66,4 +61,28 @@ public class FirstDeliveryValidController {
         }
     }
 
+    @GetMapping(value = "/projectData")
+    @ResponseBody
+    public Result<Object> projectData(String date,Integer pageSize,Integer pageNo) {
+        try {
+            return firstDeliveryValidService.projectData(date,pageSize,pageNo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("导入EXCEL失败," + e.getMessage());
+        }
+    }
+
+
+    @GetMapping(value = "/getTotalData")
+    @ResponseBody
+    public Result<Object> getTotalData(String date,Integer pageSize,Integer pageNo) {
+        try {
+            return firstDeliveryValidService.getTotalData(date,pageSize,pageNo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("导入EXCEL失败," + e.getMessage());
+        }
+    }
+
+
 }

+ 9 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/FirstDeliveryValidMapper.java

@@ -2,6 +2,7 @@ package cn.com.ctop.toutiao.modules.material.mapper;
 
 import cn.com.ctop.toutiao.modules.material.entity.FirstDeliveryValidMaterials;
 import cn.com.ctop.toutiao.modules.material.entity.FirstDeliveryValidRatio;
+import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -15,4 +16,12 @@ public interface FirstDeliveryValidMapper {
     void delRatio(@Param("deliveryYear") String deliveryYear, @Param("deliveryMonth") String deliveryMonth);
 
     void replaceBatchRatio(@Param("list") List<FirstDeliveryValidRatio> materials);
+
+    List<JSONObject> projectData(@Param("year") String year, @Param("month") String month);
+
+    Integer projectDataTotal(@Param("year") String year, @Param("month") String month);
+
+    Integer getTotalDataSum(@Param("year") String year, @Param("month") String month);
+
+    List<JSONObject> getTotalData(String year, String month);
 }

+ 50 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/FirstDeliveryValidMapper.xml

@@ -8,6 +8,56 @@
         where delivery_year = #{deliveryYear}
           AND delivery_month = #{deliveryMonth}
     </delete>
+    <select id="projectData" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.*,
+
+               round(t1.effCount / t1.materialNum * 100, 2) as 'effRate', round(t2.target_value * 100, 2) as 'mediaEffRate', (
+            case
+                when
+                    round(t1.effCount / t1.materialNum * 100, 2) >= round(t2.target_value * 100, 2)
+                    then 1
+                else 2
+                end
+
+            ) as  'color'
+        from (select project_name as 'projectName', replace(leader_name, '(石家庄)', '') as 'dessLeaderName', replace(replace(project_leader_name, '(头条总监)', ''), '(汇创)', '') as 'projectLeaderName', rebate_type as 'rebateType', settlement_1l as 'settlement1l', settlement_2l as 'settlement2l', count(material_id) as 'materialNum', sum(
+            (
+                case
+                    when first_valid = '是'
+                        then 1
+                    else
+                        0 end
+                )
+            ) as 'effCount'
+
+              from etl_first_delivery_valid_materials
+              where delivery_year = #{year}
+                and delivery_month = #{month}
+              group by project_id) t1
+                 left join first_delivery_valid_ratio t2 on t1.settlement2l = t2.settlement_2l
+        order by t1.materialNum desc
+    </select>
+    <select id="projectDataTotal" resultType="java.lang.Integer">
+        select count(distinct project_id)
+
+        from etl_first_delivery_valid_materials
+        where delivery_year = #{year}
+          and delivery_month = #{month}
+
+    </select>
+    <select id="getTotalDataSum" resultType="java.lang.Integer">
+        select count(1)
+        from first_delivery_valid_ratio
+        where delivery_year = #{year}
+          and delivery_month = #{month}
+    </select>
+    <select id="getTotalData" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        from first_delivery_valid_ratio
+        where delivery_year = #{year}
+          and delivery_month = #{month}
+
+    </select>
 
     <insert id="replaceBatchMaterials">
         insert into first_delivery_valid_materials(

+ 4 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/material/service/FirstDeliveryValidService.java

@@ -11,4 +11,8 @@ public interface FirstDeliveryValidService {
     Result<Object> importExcelMaterials(MultipartFile file) throws Exception;
 
     Result<Object> importExcelRatio(MultipartFile file) throws Exception;
+
+    Result<Object> projectData(String date, Integer pageSize, Integer pageNo);
+
+    Result<Object> getTotalData(String date, Integer pageSize, Integer pageNo);
 }

+ 42 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/FirstDeliveryValidServiceImpl.java

@@ -7,6 +7,8 @@ import cn.com.ctop.toutiao.modules.material.entity.FirstDeliveryValidRatio;
 import cn.com.ctop.toutiao.modules.material.mapper.FirstDeliveryValidMapper;
 import cn.com.ctop.toutiao.modules.material.service.FirstDeliveryValidService;
 import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -99,6 +101,46 @@ public class FirstDeliveryValidServiceImpl implements FirstDeliveryValidService
         return Result.successMsg("导入成功", null);
     }
 
+    @Override
+    public Result<Object> projectData(String date, Integer pageSize, Integer pageNo) {
+        String[] split = date.split("-");
+        String year = split[0];
+        String monthStr = split[1];
+        String month = "";
+        if ("10".equals(month)) {
+            month = "10";
+        } else {
+            month = monthStr.replace("0", "");
+        }
+        Integer total = deliveryValidMapper.projectDataTotal(year, month);
+        PageHelper.startPage(pageNo, pageSize, true);
+        List<JSONObject> data = deliveryValidMapper.projectData(year, month);
+        PageInfo<JSONObject> page = new PageInfo<>();
+        page.setList(data);
+        page.setTotal(total);
+        return Result.OK(page);
+    }
+
+    @Override
+    public Result<Object> getTotalData(String date, Integer pageSize, Integer pageNo) {
+        String[] split = date.split("-");
+        String year = split[0];
+        String monthStr = split[1];
+        String month = "";
+        if ("10".equals(month)) {
+            month = "10";
+        } else {
+            month = monthStr.replace("0", "");
+        }
+        Integer total = deliveryValidMapper.getTotalDataSum(year, month);
+        PageHelper.startPage(pageNo, pageSize, true);
+        List<JSONObject> data = deliveryValidMapper.getTotalData(year, month);
+        PageInfo<JSONObject> page = new PageInfo<>();
+        page.setList(data);
+        page.setTotal(total);
+        return Result.OK(page);
+    }
+
 
     public static List<JSONObject> analysisFile(MultipartFile file, String fileName) throws Exception {
         JSONObject returnJson = new JSONObject();