Переглянути джерело

宿舍功能 - 水电明细中新增水电度数,单位的获取逻辑(sqw)

sqw 1 тиждень тому
батько
коміт
93e137c5db

+ 1 - 1
code/opmcepaq/uzi9-uzi9q-opmcepaq-epaq/src/main/java/uzi9/uzi9q/opmcepaq/epaq/plugin/form/xbt/test/personnel/operation/ChangeDormitoryServicePlugIn.java

@@ -149,7 +149,7 @@ public class ChangeDormitoryServicePlugIn extends AbstractOperationServicePlugIn
                 roomCountMap.put(roomId, roomCountMap.getOrDefault(roomId, 0) + 1);
             }
 
-            DynamicObject[] roomLoad = BusinessDataServiceHelper.load(DORMITORY_WIDE, "id,uzi9_peoples_enter", new QFilter[]{new QFilter("id", QCP.in, roomCountMap.keySet().toArray())});
+            DynamicObject[] roomLoad = BusinessDataServiceHelper.load(DORMITORY_WIDE, "id,uzi9_peoples_enter,uzi9_judgment_full", new QFilter[]{new QFilter("id", QCP.in, roomCountMap.keySet().toArray())});
 
             for (DynamicObject room : roomLoad) {
                 long roomId = room.getLong("id");

+ 43 - 1
code/opmcepaq/uzi9-uzi9q-opmcepaq-epaq/src/main/java/uzi9/uzi9q/opmcepaq/epaq/plugin/form/xbt/test/weinfor/form/WECostBasePlugIn.java

@@ -160,6 +160,15 @@ public class WECostBasePlugIn extends AbstractBasePlugIn implements Plugin {
                 // 获取人员宿舍 - 水电费信息(总)
                 HashMap<Long, HashMap<String, Double>> calculationMap = WECostUtil.dormitoryCalculation(dormitoryIds, startTime, endTime);
 
+                //获取水电总量
+                HashMap<String, Map<Long, Double>> hydroelectricAll = WECostUtil.getHydroelectricAll(dormitoryIds, startTime, endTime);
+                Map<Long, Double> waterAll = hydroelectricAll.get("water");
+                Map<Long, Double> eleAll = hydroelectricAll.get("ele");
+
+                //获取水电费单位信息
+                HashMap<Long, HashMap<String, Double>> dormitoryMap = WECostUtil.dormitoryHydroelectric(dormitoryIds);
+
+
 
                 for (DynamicObject personCheck : personCheckLoad) {
                     int row = this.getModel().createNewEntryRow("uzi9_water_ele_char");
@@ -186,7 +195,20 @@ public class WECostBasePlugIn extends AbstractBasePlugIn implements Plugin {
                     this.getModel().setValue("uzi9_stay_days_all", checkDaysAll, row);
 
                     if (calculationMapAll != null) {
-
+                        HashMap<String, Double> unitMap = dormitoryMap.get(dormitory.getLong("id"));
+
+                        //宿舍用水
+                        Double waterReAll = waterAll.get(dormitory.getLong("id"));
+                        this.getModel().setValue("uzi9_water_read_all", waterReAll, row);
+                        //宿舍用电
+                        Double eleReAll = eleAll.get(dormitory.getLong("id"));
+                        this.getModel().setValue("uzi9_ele_read_all", eleReAll, row);
+                        //水单位
+                        Double waterUnit = unitMap.get("water");
+                        this.getModel().setValue("uzi9_water_bill", waterUnit, row);
+                        //电单位
+                        Double eleUnit = unitMap.get("ele");
+                        this.getModel().setValue("uzi9_electricity_bill", eleUnit, row);
                         //宿舍用水总费用
                         Double costWaterAll = calculationMapAll.get("water");
                         this.getModel().setValue("uzi9_waterall_cost", costWaterAll, row);
@@ -202,6 +224,26 @@ public class WECostBasePlugIn extends AbstractBasePlugIn implements Plugin {
                         //当月电费
                         double costEle = Math.round((costEleAll / checkDaysAll * checkDays) * 100.0) / 100.0;
                         this.getModel().setValue("uzi9_ele_cost", costEle, row);
+                    }else {
+                        HashMap<String, Double> unitMap = dormitoryMap.get(dormitory.getLong("id"));
+                        //宿舍用水
+                        this.getModel().setValue("uzi9_water_read_all", 0, row);
+                        //宿舍用电
+                        this.getModel().setValue("uzi9_ele_read_all", 0, row);
+                        //水单位
+                        Double waterUnit = unitMap.get("water");
+                        this.getModel().setValue("uzi9_water_bill", waterUnit, row);
+                        //电单位
+                        Double eleUnit = unitMap.get("ele");
+                        this.getModel().setValue("uzi9_electricity_bill", eleUnit, row);
+                        //宿舍用水总费用
+                        this.getModel().setValue("uzi9_waterall_cost", 0, row);
+                        //宿舍用电总费用
+                        this.getModel().setValue("uzi9_eleall_cost", 0, row);
+                        //当月水费
+                        this.getModel().setValue("uzi9_water_cost", 0, row);
+                        //当月电费
+                        this.getModel().setValue("uzi9_ele_cost", 0, row);
                     }
                 }
 

+ 20 - 8
code/opmcepaq/uzi9-uzi9q-opmcepaq-epaq/src/main/java/uzi9/uzi9q/opmcepaq/epaq/plugin/form/xbt/test/weinfor/form/WECostSpBasePlugIn.java

@@ -162,11 +162,11 @@ public class WECostSpBasePlugIn extends AbstractBasePlugIn implements Plugin, Be
 
             if (waterRead > 0) {
 
-                // 获取通用水电定价
-                HashMap<String, Double> costMap = dormitoryHydropowerUtil();
-                Double waterCost = costMap.get("water");
+                //电单位
+                BigDecimal waterCost = (BigDecimal) this.getModel().getValue("uzi9_water_bill", rowIndex);
+
                 //宿舍用水总费用
-                double waterAll = Math.round((waterRead * waterCost) * 100.0) / 100.0;
+                double waterAll = Math.round((waterRead * waterCost.doubleValue()) * 100.0) / 100.0;
                 this.getModel().setValue("uzi9_waterall_cost", waterAll, rowIndex);
 
                 //特殊离职人员月水费用
@@ -197,12 +197,11 @@ public class WECostSpBasePlugIn extends AbstractBasePlugIn implements Plugin, Be
 
             if (eleRead > 0) {
 
-                // 获取通用水电定价
-                HashMap<String, Double> costMap = dormitoryHydropowerUtil();
-                Double eleCost = costMap.get("ele");
+                //电单位
+                BigDecimal eleCost = (BigDecimal) this.getModel().getValue("uzi9_electricity_bill", rowIndex);
 
                 //宿舍用水总费用
-                double eleAll = Math.round((eleRead * eleCost) * 100.0) / 100.0;
+                double eleAll = Math.round((eleRead * eleCost.doubleValue()) * 100.0) / 100.0;
                 this.getModel().setValue("uzi9_eleall_cost", eleAll, rowIndex);
 
                 //特殊离职人员月水费用
@@ -261,6 +260,17 @@ public class WECostSpBasePlugIn extends AbstractBasePlugIn implements Plugin, Be
                     //离宿日期
                     this.getModel().setValue("uzi9_departure_date", personCheck.get("uzi9_departure_date"), row);
 
+                    // 获取通用水电定价
+                    HashMap<String, Double> costMap = dormitoryHydropowerUtil();
+                    Double eleCost = costMap.get("ele");
+                    Double waterCost = costMap.get("water");
+
+                    //电单位
+                    this.getModel().setValue("uzi9_electricity_bill", eleCost, row);
+
+                    //水单位
+                    this.getModel().setValue("uzi9_water_bill", waterCost, row);
+
                     //入住天数
                     Double checkDays = WECostUtil.getDormitoryStayTime(personCheck, startTime, endTime);
                     this.getModel().setValue("uzi9_stay_days", checkDays, row);
@@ -268,6 +278,8 @@ public class WECostSpBasePlugIn extends AbstractBasePlugIn implements Plugin, Be
                     //当月宿舍所有人入住天数
                     Double checkDaysAll = dormitoryDateAll.get(dormitory.getLong("id"));
                     this.getModel().setValue("uzi9_stay_days_all", checkDaysAll, row);
+
+
                 }
 
             }

+ 37 - 1
code/opmcepaq/uzi9-uzi9q-opmcepaq-epaq/src/main/java/uzi9/uzi9q/opmcepaq/epaq/plugin/form/xbt/test/weinfor/form/weutil/WECostUtil.java

@@ -209,7 +209,7 @@ public class WECostUtil extends AbstractFormPlugin implements Plugin {
      * 宿舍水电费单位信息(度 - 吨)
      */
 
-    private static HashMap<Long, HashMap<String, Double>> dormitoryHydroelectric(Set<Long> dormitoryIds) {
+    public static HashMap<Long, HashMap<String, Double>> dormitoryHydroelectric(Set<Long> dormitoryIds) {
         //获取宿舍信息
         DynamicObject[] dormitoryLoad = BusinessDataServiceHelper.load("uzi9_dormitory_wide",
                 "id,parent,uzi9_water_bill,uzi9_electricity_bill," +
@@ -264,4 +264,40 @@ public class WECostUtil extends AbstractFormPlugin implements Plugin {
 
         return dormitoryMap;
     }
+
+
+    /**
+     * 获取宿舍水电总量
+     */
+
+    public static HashMap<String,Map<Long, Double>> getHydroelectricAll(Set<Long> dormitoryIds, Date startTime, Date endTime) {
+
+        QFilter qFilter = new QFilter("uzi9_dormitory.id", QCP.in, dormitoryIds)
+                .and("uzi9_meter_read_time", QCP.large_equals, startTime)
+                .and("uzi9_meter_read_time", QCP.less_equals, endTime);
+
+        HashMap<String,Map<Long, Double>> units = new HashMap<>();
+
+        //获取水电表信息
+        DynamicObject[] readLoad = BusinessDataServiceHelper.load("uzi9_water_ele_read", "id,uzi9_dormitory,uzi9_moon_water_read,uzi9_moon_ele_read", new QFilter[]{qFilter});
+
+
+        //水
+        Map<Long, Double> waterMap = Arrays.stream(readLoad).collect(Collectors.toMap(
+                read -> read.getDynamicObject("uzi9_dormitory").getLong("id"),
+                read -> read.getBigDecimal("uzi9_moon_water_read").doubleValue(),
+                Double::sum
+        ));
+
+        //电
+        Map<Long, Double> eleMap = Arrays.stream(readLoad).collect(Collectors.toMap(
+                read -> read.getDynamicObject("uzi9_dormitory").getLong("id"),
+                read -> read.getBigDecimal("uzi9_moon_ele_read").doubleValue(),
+                Double::sum
+        ));
+        units.put("water", waterMap);
+        units.put("ele", eleMap);
+        return units;
+
+    }
 }

+ 40 - 0
code/opmcepaq/uzi9-uzi9q-opmcepaq-epaq/src/main/java/uzi9/uzi9q/opmcepaq/epaq/plugin/form/xbt/test/weinfor/list/WECostListPlugin.java

@@ -160,6 +160,15 @@ public class WECostListPlugin extends AbstractListPlugin implements Plugin {
             HashMap<Long, HashMap<String, Double>> calculationMap = WECostUtil.dormitoryCalculation(dormitoryIds, startDate, endDate);
 
 
+            //获取水电总量
+            HashMap<String, Map<Long, Double>> hydroelectricAll = WECostUtil.getHydroelectricAll(dormitoryIds, startDate, endDate);
+            Map<Long, Double> waterAll = hydroelectricAll.get("water");
+            Map<Long, Double> eleAll = hydroelectricAll.get("ele");
+
+            //获取水电费单位信息
+            HashMap<Long, HashMap<String, Double>> dormitoryMap = WECostUtil.dormitoryHydroelectric(dormitoryIds);
+
+
 
             for (DynamicObject personCheck : personCheckLoad){
                 DynamicObject weChar = entryEntity.addNew();
@@ -180,6 +189,27 @@ public class WECostListPlugin extends AbstractListPlugin implements Plugin {
                 weChar.set("uzi9_stay_days_all", checkDaysAll);
 
                 if (calculationMapAll != null) {
+
+                    //当月水电单位
+                    HashMap<String, Double> unitMap = dormitoryMap.get(dormitory.getLong("id"));
+
+                    //宿舍用水
+                    Double waterReAll = waterAll.get(dormitory.getLong("id"));
+                    weChar.set("uzi9_water_read_all", waterReAll);
+
+                    //宿舍用电
+                    Double eleReAll = eleAll.get(dormitory.getLong("id"));
+                    weChar.set("uzi9_ele_read_all", eleReAll);
+
+                    //水单位
+                    Double waterUnit = unitMap.get("water");
+                    weChar.set("uzi9_water_bill", waterUnit);
+
+                    //电单位
+                    Double eleUnit = unitMap.get("ele");
+                    weChar.set("uzi9_electricity_bill", eleUnit);
+
+
                     //宿舍用水总费用
                     Double costWaterAll = calculationMapAll.get("water");
                     weChar.set("uzi9_waterall_cost", costWaterAll);
@@ -195,6 +225,16 @@ public class WECostListPlugin extends AbstractListPlugin implements Plugin {
                     //当月电费
                     double costEle = Math.round((costEleAll / checkDaysAll * checkDays) * 100.0) / 100.0;
                     weChar.set("uzi9_ele_cost", costEle);
+                }else {
+                    HashMap<String, Double> unitMap = dormitoryMap.get(dormitory.getLong("id"));
+
+                    //水单位
+                    Double waterUnit = unitMap.get("water");
+                    weChar.set("uzi9_water_bill", waterUnit);
+                    //电单位
+                    Double eleUnit = unitMap.get("ele");
+                    weChar.set("uzi9_electricity_bill", eleUnit);
+
                 }
 
             }