Browse Source

物品申购统计接口

dzx 3 months ago
parent
commit
12ebd74e8b

+ 45 - 81
src/main/java/com/xjrsoft/module/databoard/controller/DatadetailController.java

@@ -15,11 +15,15 @@ import com.xjrsoft.module.databoard.vo.DistributionVo;
 import com.xjrsoft.module.databoard.vo.DurationVo;
 import com.xjrsoft.module.databoard.vo.HealthItemCountVo;
 import com.xjrsoft.module.databoard.vo.HealthStatisticsDetailVo;
+import com.xjrsoft.module.databoard.vo.ItemCountAmountVo;
 import com.xjrsoft.module.databoard.vo.ItemCountVo;
-import com.xjrsoft.module.databoard.vo.PersonStatisticsVo;
+import com.xjrsoft.module.databoard.vo.ItemDoubleVo;
 import com.xjrsoft.module.databoard.vo.ProcessStatisticsDetailVo;
 import com.xjrsoft.module.databoard.vo.StudnetStatisticsDetailVo;
+import com.xjrsoft.module.databoard.vo.SubscriptionStatisticsDetailVo;
 import com.xjrsoft.module.databoard.vo.TeacherStatisticsDetailVo;
+import com.xjrsoft.module.ledger.entity.WfSubscription;
+import com.xjrsoft.module.ledger.service.IWfSubscriptionService;
 import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
 import com.xjrsoft.module.student.service.IBaseStudentService;
 import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
@@ -73,6 +77,7 @@ public class DatadetailController {
     private final IWorkflowExtraService extraService;
     private final ITeacherbaseManagerService teacherService;
     private final IBaseStudentService studentService;
+    private final IWfSubscriptionService subscriptionService;
 
     @GetMapping(value = "/process-statistics")
     @ApiOperation(value="流程统计详情")
@@ -544,101 +549,60 @@ public class DatadetailController {
     @GetMapping(value = "/subscription-statistics")
     @ApiOperation(value="物品申购详情数据统计")
     @SaCheckPermission("datadetail:detail")
-    public RT<StudnetStatisticsDetailVo> subscriptionStatistics(@Valid StatisticsDetailDto dto) throws ParseException {
-        StudnetStatisticsDetailVo result = new StudnetStatisticsDetailVo();
-
-        String sql = "SELECT IFNULL(t3.name,'未填写') AS item ,COUNT(*) AS a_count FROM xjr_user t1" +
-                " INNER JOIN base_student t2 ON t1.id = t2.user_id" +
-                " LEFT JOIN xjr_dictionary_detail t3 ON t1.gender  = t3.code AND t3.item_id = 2023000000000000004" +
-                " WHERE t1.delete_mark = 0 GROUP BY t3.name";
-        List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
-        List<ItemCountVo> genderList = new ArrayList<>();
-        for (Map<String, Object> objectMap : list) {
-            genderList.add(
+    public RT<SubscriptionStatisticsDetailVo> subscriptionStatistics(@Valid StatisticsDetailDto dto) {
+        SubscriptionStatisticsDetailVo result = new SubscriptionStatisticsDetailVo();
+        List<WfSubscription> list = subscriptionService.list();
+        double totalAmount = list.stream().filter(x -> x.getTotalAmount() != null).mapToDouble(WfSubscription::getTotalAmount).sum();
+        result.setTotalAmount(totalAmount);
+
+        int adoptCount = list.stream().filter(x -> x.getStatus() == 1).collect(Collectors.toList()).size();
+        result.setAdoptCount(adoptCount);
+
+        int pendingCount = list.stream().filter(x -> x.getStatus() == null || x.getStatus() == 0).collect(Collectors.toList()).size();
+        result.setPendingCount(pendingCount);
+
+        String sql = "SELECT IFNULL(t3.name, '未填写') AS item,COUNT(t1.id) AS a_count,SUM(t1.amount) as a_sum FROM wf_subscription_list t1" +
+                " INNER JOIN wf_subscription t2 ON t1.parent_id = t2.id" +
+                " LEFT JOIN xjr_dictionary_detail t3 ON t1.item_type = t3.code" +
+                " AND t3.item_id = 1752140413593518081" +
+                " WHERE t2.status = 1 GROUP BY t3.name";
+        List<Map<String, Object>> datalist = SqlRunnerAdapter.db().selectList(sql);
+        List<ItemCountVo> categoryCountList = new ArrayList<>();
+        List<ItemDoubleVo> categoryAmountList = new ArrayList<>();
+        for (Map<String, Object> objectMap : datalist) {
+            categoryCountList.add(
                     new ItemCountVo(){{
                         setItem(objectMap.get("item").toString());
                         setCount(Integer.parseInt(objectMap.get("a_count").toString()));
                     }}
             );
-        }
-        result.setGenderList(genderList);
 
-        sql = "SELECT IFNULL(t3.name,'未填写') AS item ,COUNT(*) AS a_count FROM xjr_user t1" +
-                " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
-                " LEFT JOIN xjr_dictionary_detail t3 ON t2.student_type = t3.code AND t3.item_id = 2023000000000000028" +
-                " WHERE t1.delete_mark = 0 GROUP BY t3.name";
-        list = SqlRunnerAdapter.db().selectList(sql);
-        List<ItemCountVo> studentTypeList = new ArrayList<>();
-        for (Map<String, Object> objectMap : list) {
-            studentTypeList.add(
-                    new ItemCountVo(){{
+            categoryAmountList.add(
+                    new ItemDoubleVo(){{
                         setItem(objectMap.get("item").toString());
-                        setCount(Integer.parseInt(objectMap.get("a_count").toString()));
+                        setAmount(Double.parseDouble(objectMap.get("a_sum").toString()));
                     }}
             );
         }
-        result.setStudentTypeList(studentTypeList);
-
-
-        List<BaseStudentUserPageVo> studentList = studentService.getStudentList(new BaseStudentUserPageDto());
-        Set<String> studentStayMaleSet = studentList.stream()
-                .filter(x -> (
-                        x.getGenderCn() != null
-                                && x.getGenderCn().equals(GenderDictionaryEnum.MALE.getCode())
-                                && x.getStduyStatusCn() != null
-                                && x.getStduyStatusCn().equals(StudyStatusEnum.InResidence.getCode())
-                ))
-                .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
-        result.setStudentStayMaleCount(studentStayMaleSet.size());
-
-        Set<String> studentNotStayMaleSet = studentList.stream()
-                .filter(x -> (
-                        x.getGenderCn() != null
-                                && x.getGenderCn().equals(GenderDictionaryEnum.MALE.getCode())
-                                && x.getStduyStatusCn() != null
-                                && x.getStduyStatusCn().equals(StudyStatusEnum.AttendDaySchool.getCode())
-                ))
-                .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
-        result.setStudentNotStayMaleCount(studentNotStayMaleSet.size());
-
-        Set<String> studentStayFemaleSet = studentList.stream()
-                .filter(x -> (
-                        x.getGenderCn() != null
-                                && x.getGenderCn().equals(GenderDictionaryEnum.FEMALE.getCode())
-                                && x.getStduyStatusCn() != null
-                                && x.getStduyStatusCn().equals(StudyStatusEnum.InResidence.getCode())
-                ))
-                .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
-        result.setStudentStayFemaleCount(studentStayFemaleSet.size());
-
-        Set<String> studentNotStayFemaleSet = studentList.stream()
-                .filter(x -> (
-                        x.getGenderCn() != null
-                                && x.getGenderCn().equals(GenderDictionaryEnum.FEMALE.getCode())
-                                && x.getStduyStatusCn() != null
-                                && x.getStduyStatusCn().equals(StudyStatusEnum.AttendDaySchool.getCode())
-                ))
-                .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
-        result.setStudentNotStayFemaleCount(studentNotStayFemaleSet.size());
-
-        sql = "SELECT name AS item,(" +
-                " SELECT COUNT(*) FROM xjr_user t1" +
-                " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
-                " WHERE t1.delete_mark = 0 AND t2.grade_id = base_grade.id" +
-                " ) AS a_count FROM base_grade" +
-                " WHERE delete_mark = 0 AND status = 1 ORDER BY name DESC LIMIT 3";
-        list = SqlRunnerAdapter.db().selectList(sql);
-        Collections.reverse(list);
-        List<ItemCountVo> gradeList = new ArrayList<>();
-        for (Map<String, Object> objectMap : list) {
-            gradeList.add(
-                    new ItemCountVo(){{
+        result.setCategoryCountList(categoryCountList);
+        result.setCategoryAmountList(categoryAmountList);
+
+        sql = "SELECT IFNULL(t3.name, '未填写') AS item,COUNT(t1.id) AS a_count,SUM(t1.amount) as a_sum FROM wf_subscription_list t1" +
+            " INNER JOIN wf_subscription t2 ON t1.parent_id = t2.id" +
+            " LEFT JOIN xjr_department t3 ON t2.application_department = t3.id" +
+            " WHERE t2.status = 1 GROUP BY t3.name";
+        datalist = SqlRunnerAdapter.db().selectList(sql);
+        List<ItemCountAmountVo> deptList = new ArrayList<>();
+        for (Map<String, Object> objectMap : datalist) {
+            deptList.add(
+                    new ItemCountAmountVo(){{
                         setItem(objectMap.get("item").toString());
                         setCount(Integer.parseInt(objectMap.get("a_count").toString()));
+                        setAmount(Double.parseDouble(objectMap.get("a_sum").toString()));
                     }}
             );
         }
-        result.setGradeList(gradeList);
+        result.setDeptList(deptList);
         return RT.ok(result);
     }
 

+ 29 - 0
src/main/java/com/xjrsoft/module/databoard/vo/ItemCountAmountVo.java

@@ -0,0 +1,29 @@
+package com.xjrsoft.module.databoard.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+* @title: 数据看板-流程统计出参
+* @Author dzx
+* @Date: 2024年8月2日
+* @Version 1.0
+*/
+@Data
+public class ItemCountAmountVo {
+
+    /**
+    * 发起流程总数
+    */
+    @ApiModelProperty("统计项")
+    private String item;
+    /**
+    * 完成总数
+    */
+    @ApiModelProperty("次数")
+    private Integer count;
+
+    @ApiModelProperty("金额")
+    private Double amount;
+}

+ 27 - 0
src/main/java/com/xjrsoft/module/databoard/vo/ItemDoubleVo.java

@@ -0,0 +1,27 @@
+package com.xjrsoft.module.databoard.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+* @title: 数据看板-流程统计出参
+* @Author dzx
+* @Date: 2024年8月2日
+* @Version 1.0
+*/
+@Data
+public class ItemDoubleVo {
+
+    /**
+    * 发起流程总数
+    */
+    @ApiModelProperty("统计项")
+    private String item;
+    /**
+    * 完成总数
+    */
+    @ApiModelProperty("金额")
+    private Double amount;
+
+}

+ 39 - 0
src/main/java/com/xjrsoft/module/databoard/vo/SubscriptionStatisticsDetailVo.java

@@ -0,0 +1,39 @@
+package com.xjrsoft.module.databoard.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+* @title: 物品申购数据
+* @Author dzx
+* @Date: 2024年8月2日
+* @Version 1.0
+*/
+@Data
+public class SubscriptionStatisticsDetailVo {
+
+
+    @ApiModelProperty("总金额")
+    private Double totalAmount;
+
+    @ApiModelProperty("申购类型次数对比数据")
+    private List<ItemCountVo> categoryCountList;
+
+    @ApiModelProperty("申购类型金额对比数据")
+    private List<ItemDoubleVo> categoryAmountList;
+
+    @ApiModelProperty("申购次数")
+    private Integer allCount;
+
+    @ApiModelProperty("通过次数")
+    private Integer adoptCount;
+
+    @ApiModelProperty("待审次数")
+    private Integer pendingCount;
+
+    @ApiModelProperty("部门申购统计数据")
+    private List<ItemCountAmountVo> deptList;
+
+}