wangbo 4 роки тому
батько
коміт
233527716d

+ 42 - 5
sms_water/src/main/java/com/huaxu/controller/AppPageReportController.java

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -36,18 +37,54 @@ public class AppPageReportController {
     private RevenueService revenueService;
 
     /**
-     * 生产总览数据
+     * App生产总览数据-本月数据
      * @param companyOrgId
      * @return
      */
     @RequestMapping(value = "getProductionDataForSameMonth",method = RequestMethod.GET)
     @ApiOperation(value = "App总览——生产数据(本月)")
-    public AjaxMessage<List<DeviceWaterSupply>> getProductionDataForSameMonth(
+    public AjaxMessage<List<DeviceWaterSupply>> getProductionDataForMonth(
             @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         List<DeviceWaterSupply>  result = new ArrayList<DeviceWaterSupply>();
-        result.addAll(appPageReportService.deviceWaterReportForSameMonth(companyOrgId,"水源",4));
-        result.addAll(appPageReportService.deviceWaterReportForSameMonth(companyOrgId,"水厂",3));
-        result.addAll(appPageReportService.deviceSellerWaterReportForSameMonth(companyOrgId));
+        result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1));
+        result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,1));
+        result.addAll(appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,1));
+        return new AjaxMessage<>(ResultStatus.OK,result);
+    }
+
+
+
+    /**
+     * App生产总览数据-本年数据
+     * @param companyOrgId
+     * @return
+     */
+    @RequestMapping(value = "getProductionDataForSameYear",method = RequestMethod.GET)
+    @ApiOperation(value = "App总览——生产数据(本月)")
+    public AjaxMessage<List<DeviceWaterSupply>> getProductionDataForSameYear(
+            @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
+        LocalDate localDate = LocalDate.now();
+        List<DeviceWaterSupply>  result = new ArrayList<DeviceWaterSupply>();
+        result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,localDate.getMonthValue()));
+        result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,localDate.getMonthValue()));
+        result.addAll(appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,localDate.getMonthValue()));
+        return new AjaxMessage<>(ResultStatus.OK,result);
+    }
+
+
+    /**
+     * App生产总览数据-近一年数据
+     * @param companyOrgId
+     * @return
+     */
+    @RequestMapping(value = "getProductionDataFor12Month",method = RequestMethod.GET)
+    @ApiOperation(value = "App总览——生产数据(本月)")
+    public AjaxMessage<List<DeviceWaterSupply>> getProductionDataFor12Month(
+            @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
+        List<DeviceWaterSupply>  result = new ArrayList<DeviceWaterSupply>();
+        result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,12));
+        result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,12));
+        result.addAll(appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,12));
         return new AjaxMessage<>(ResultStatus.OK,result);
     }
 }

+ 0 - 3
sms_water/src/main/java/com/huaxu/controller/HomePageReportController.java

@@ -34,9 +34,6 @@ public class HomePageReportController {
     @Autowired
     private HomePageReportService homePageReportService;
 
-
-
-
     @RequestMapping(value = "getDeviceWaterIntake",method = RequestMethod.GET)
     @ApiOperation(value = "综合展示——取水图表(近6月)")
     public AjaxMessage<List<DeviceWaterSupply>> getDeviceWaterIntake(

+ 7 - 0
sms_water/src/main/java/com/huaxu/dao/HomePageReportMapper.java

@@ -28,6 +28,13 @@ public interface HomePageReportMapper {
                                                       @Param("permissonType")Integer permissonType,
                                                       @Param("programItems")List<ProgramItem> programItems);
 
+    List<DeviceWaterSupply> getDeviceWaterForMonth(@Param("companyOrgId")Integer companyOrgId,
+                                                      @Param("sceneType")String sceneType, @Param("parmType")Integer parmType,
+                                                      @Param("tenantId")String tenantId, @Param("userType")String userType,
+                                                      @Param("permissonType")Integer permissonType,
+                                                      @Param("programItems")List<ProgramItem> programItems,
+                                                      @Param("month")Integer month);
+
 
     CompanyCount countSceneByType(@Param("companyOrgId")Integer companyOrgId,
                                         @Param("tenantId")String tenantId, @Param("userType")String userType,

+ 2 - 2
sms_water/src/main/java/com/huaxu/service/AppPageReportService.java

@@ -6,7 +6,7 @@ import java.util.List;
 
 public interface AppPageReportService {
 
-    List<DeviceWaterSupply> deviceWaterReportForSameMonth(Integer companyOrgId, String sceneType, Integer parmType);
+    List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer month);
 
-    List<DeviceWaterSupply> deviceSellerWaterReportForSameMonth(Integer companyOrgId);
+    List<DeviceWaterSupply> deviceSellerWaterReportForMonth(Integer companyOrgId,Integer month);
 }

+ 4 - 0
sms_water/src/main/java/com/huaxu/service/HomePageReportService.java

@@ -21,6 +21,10 @@ public interface HomePageReportService {
     //近6月制水量(水厂:3)
     List<DeviceWaterSupply> deviceWaterReportForSixMonth(Integer companyOrgId,String sceneType, Integer parmType);
 
+    //前N个月的去取水量(水源:4)
+    //前N个月的去制水量(水厂:3)
+    List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId,String sceneType, Integer parmType,Integer month);
+
     //公司投资统计(公司场景)
     CompanyCount countSceneByType(Integer companyOrgId);
 

+ 14 - 31
sms_water/src/main/java/com/huaxu/service/impl/AppPageReportServiceImpl.java

@@ -9,6 +9,7 @@ import com.huaxu.model.AjaxMessage;
 import com.huaxu.model.LoginUser;
 import com.huaxu.model.ResultStatus;
 import com.huaxu.service.AppPageReportService;
+import com.huaxu.service.HomePageReportService;
 import com.huaxu.service.MonitorDataReportService;
 import com.huaxu.service.RevenueService;
 import com.huaxu.util.UserUtil;
@@ -31,60 +32,42 @@ import java.util.List;
 @Service
 public class AppPageReportServiceImpl implements AppPageReportService {
 
-    @Resource
-    private HomePageReportMapper homePageReportMapper;
-
-
-    @Resource
-    private MonitorDataReportMapper monitorDataReportMapper;
-
-    @Autowired
-    private UserCenterClient userCenterClient;
-
     @Autowired
-    private com.huaxu.service.MonitorDataReportService MonitorDataReportService;
-
+    private HomePageReportService homePageReportService;
 
     @Autowired
     private RevenueService revenueService;
 
     /**
-     * App 总览 本月制水量
-     *
+     * App 总览 前N个月的取水量、制水量
      * @param companyOrgId
      * @param sceneType
      * @param parmType
      * @return
      */
     @Override
-    public List<DeviceWaterSupply> deviceWaterReportForSameMonth(Integer companyOrgId, String sceneType, Integer parmType) {
-        LocalDate localDate = LocalDate.now();
-        List<DeviceWaterSupply> deviceWaterSupplies = new ArrayList<DeviceWaterSupply>();
-        BigDecimal AmountCountMonth = MonitorDataReportService.getAmountCount(companyOrgId, null, sceneType, parmType, 2);
-        DeviceWaterSupply deviceWaterSupplyMonth = new DeviceWaterSupply();
-        deviceWaterSupplyMonth.setOrderNo(1);
-        deviceWaterSupplyMonth.setAmount(AmountCountMonth != null ? AmountCountMonth.divide(new BigDecimal("10000")) : BigDecimal.ZERO);
-        deviceWaterSupplyMonth.setYear(localDate.getYear());
-        deviceWaterSupplyMonth.setMonth(localDate.getMonthValue());
-        deviceWaterSupplyMonth.setDate(localDate);
-        deviceWaterSupplyMonth.setDateLabel(localDate.getYear() + "-" + localDate.getMonthValue());
-        deviceWaterSupplies.add(0, deviceWaterSupplyMonth);
-        deviceWaterSupplies.sort(Comparator.comparing(DeviceWaterSupply::getOrderNo).reversed());
+    public List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer month) {
+        List<DeviceWaterSupply> deviceWaterSupplies =  homePageReportService.deviceWaterReportForMonth(companyOrgId,sceneType,parmType,month);
         return deviceWaterSupplies;
     }
 
+    /**
+     * App 总览 前N个月的售水量
+     * @param companyOrgId
+     * @return
+     */
     @Override
-    public List<DeviceWaterSupply> deviceSellerWaterReportForSameMonth(Integer companyOrgId) {
+    public List<DeviceWaterSupply> deviceSellerWaterReportForMonth(Integer companyOrgId,Integer month) {
         BigDecimal AmountCountMonth = null;
         LocalDate localDate = LocalDate.now();
         List<DeviceWaterSupply> deviceWaterSupplies = new ArrayList<DeviceWaterSupply>();
-        List<MonthRevenueDto> sellerWater = revenueService.selectOverviewRevenue(companyOrgId,1);
-        if(sellerWater.size()>0){
+        List<MonthRevenueDto> sellerWater = revenueService.selectOverviewRevenue(companyOrgId,month);
+        if(sellerWater.size()>0 && sellerWater.get(0).getMeterReadingUsage() != null){
             AmountCountMonth = new BigDecimal(sellerWater.get(0).getMeterReadingUsage());
         }
         DeviceWaterSupply deviceWaterSupplyMonth = new DeviceWaterSupply();
         deviceWaterSupplyMonth.setOrderNo(1);
-        deviceWaterSupplyMonth.setAmount(AmountCountMonth != null ? AmountCountMonth.divide(new BigDecimal("10000")) : BigDecimal.ZERO);
+        deviceWaterSupplyMonth.setAmount(AmountCountMonth != null ? AmountCountMonth : BigDecimal.ZERO);
         deviceWaterSupplyMonth.setYear(localDate.getYear());
         deviceWaterSupplyMonth.setMonth(localDate.getMonthValue());
         deviceWaterSupplyMonth.setDate(localDate);

+ 45 - 0
sms_water/src/main/java/com/huaxu/service/impl/HomePageReportServiceImpl.java

@@ -94,6 +94,51 @@ public class HomePageReportServiceImpl implements HomePageReportService {
         return deviceWaterSupplies;
     }
 
+    @Override
+    public List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId,String sceneType, Integer parmType,Integer month){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        String tenantId = loginUser.getTenantId();
+        LocalDate localDate = LocalDate.now();
+
+        List<DeviceWaterSupply> deviceWaterSupplies = homePageReportMapper.getDeviceWaterForMonth(companyOrgId,sceneType,parmType ,tenantId,loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList(),month);
+
+        BigDecimal AmountCountMonth = MonitorDataReportService.getAmountCount(companyOrgId,null, sceneType, parmType,2 );
+
+        DeviceWaterSupply deviceWaterSupplyMonth = new DeviceWaterSupply();
+        deviceWaterSupplyMonth.setOrderNo(1);
+        deviceWaterSupplyMonth.setAmount(AmountCountMonth!=null?AmountCountMonth.divide(new BigDecimal("10000")):BigDecimal.ZERO);
+        deviceWaterSupplyMonth.setYear(localDate.getYear());
+        deviceWaterSupplyMonth.setMonth(localDate.getMonthValue());
+        deviceWaterSupplyMonth.setDate(localDate);
+        deviceWaterSupplyMonth.setDateLabel(localDate.getYear()+"-"+localDate.getMonthValue());
+        deviceWaterSupplies.add(0, deviceWaterSupplyMonth);
+
+        for (int i = 0; i < 6; i++) {
+            LocalDate newLocalDate = localDate.plusMonths(-i );
+            if (i == deviceWaterSupplies.size()
+                    || newLocalDate.getMonthValue() != deviceWaterSupplies.get(i).getMonth().intValue()
+                    || newLocalDate.getYear() != deviceWaterSupplies.get(i).getYear().intValue()) {
+
+                DeviceWaterSupply deviceWaterSupply = new DeviceWaterSupply();
+                deviceWaterSupply.setOrderNo(i + 1);
+                deviceWaterSupply.setAmount(BigDecimal.ZERO);
+                deviceWaterSupply.setYear(newLocalDate.getYear());
+                deviceWaterSupply.setMonth(newLocalDate.getMonthValue());
+                deviceWaterSupply.setDate(newLocalDate);
+                deviceWaterSupply.setDateLabel(newLocalDate.getYear()+"-"+newLocalDate.getMonthValue());
+                deviceWaterSupplies.add(i, deviceWaterSupply);
+            } else {
+                deviceWaterSupplies.get(i).setOrderNo(i + 1);
+                deviceWaterSupplies.get(i).setDate(newLocalDate);
+                deviceWaterSupplies.get(i).setDateLabel(newLocalDate.getYear()+"-"+newLocalDate.getMonthValue());
+            }
+        }
+        deviceWaterSupplies.sort(Comparator.comparing(DeviceWaterSupply::getOrderNo).reversed());
+
+        return deviceWaterSupplies;
+
+    }
+
 
     @Override
     public CompanyCount countSceneByType(Integer companyOrgId) {

+ 47 - 0
sms_water/src/main/resources/mapper/HomePageReportMapper.xml

@@ -48,6 +48,53 @@
         order by r.year desc,r.month desc
     </select>
 
+
+    <select id="getDeviceWaterForMonth" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
+        select
+        r.year,r.month,
+        sum(r.SUM_VALUE)/10000 as "amount"
+        from sms_scene_type st
+        left join sms_scene s on s.SCENE_TYPE_ID =st.id
+        left join sms_device_parm dp on s.id=dp.PARENT_SCENE_ID
+        left join sms_year_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
+
+        where  dp.`STATUS`=1  and s.ENABLE_STATE = 1 and dp.TENANT_ID=#{tenantId}
+        <if test="companyOrgId != null">
+            and s.COMPANY_ORG_ID = #{companyOrgId}
+        </if>
+        and dp.PARM_TYPE = #{parmType} and st.SCENE_TYPE_NAME = #{sceneType}
+        and r.year*12 + r.month >=  year(CURDATE())*12 + month(CURDATE()) + 1 - #{month}
+        <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0">
+            <if test="permissonType == 5 or permissonType == 2">
+                and ( s.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                or
+                s.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                )
+            </if>
+            <if test="permissonType == 4 or permissonType == 3">
+                and s.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+            </if>
+            <if test="permissonType == 1">
+                and s.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
+            </if>
+        </if>
+        group by r.year,r.month
+        order by r.year desc,r.month desc
+    </select>
+
     <select id="countSceneByType" resultType="com.huaxu.dto.homePage.CompanyCount">
 
         select