Browse Source

Merge remote-tracking branch 'origin/20210223' into 20210223

wangyangyang 3 years ago
parent
commit
bcf4d244b2

+ 3 - 0
common/src/main/java/com/huaxu/util/DatesUtil.java

@@ -596,6 +596,9 @@ public class DatesUtil {
 	}
 
 	public static Date addMinuteOfDate(Date date,int i){
+		if (date == null) {
+			return null;
+		}
 		Calendar c = Calendar.getInstance();
 		c.setTime(date);
 		c.add(Calendar.MINUTE, i);

+ 5 - 0
operation_manager/src/main/java/com/huaxu/client/UserCenterClient.java

@@ -63,4 +63,9 @@ public interface UserCenterClient {
      */
     @RequestMapping(value = "/user/findMaintainerCount", method = RequestMethod.GET)
     Integer findMaintainerCount(@RequestParam("endDate") String endDate);
+
+    @GetMapping(value = "/user/findAllUserList")
+    List<UserEntity> findAllUserList(@RequestParam(value = "companyOrgId", required = false) Integer companyOrgId,
+                                                  @RequestParam(value = "tenantId", required = false)String tenantId,
+                                                  @RequestParam(value = "type", required = false)Integer type);
 }

+ 19 - 19
operation_manager/src/main/java/com/huaxu/evaluation/job/EvaluationResultJob.java

@@ -12,6 +12,7 @@ import com.huaxu.evaluation.vo.EvaluationItemValueVo;
 import com.huaxu.evaluation.vo.EvaluationItemVo;
 import com.huaxu.evaluation.vo.EvaluationResultTaskDetailsVo;
 import com.huaxu.exception.ServiceException;
+import com.huaxu.model.AjaxMessage;
 import com.huaxu.order.dao.WorkOrderManageMapper;
 import com.huaxu.order.dto.WorkOrderManageDto;
 import com.huaxu.task.entity.UserEntity;
@@ -71,7 +72,7 @@ public class EvaluationResultJob {
     /**
      * 运维类型
      */
-    private static final String OPERATION_TYPE = "3";
+    private static final int OPERATION_TYPE = 3;
 
     /**
      * 保存考评项目设置
@@ -81,7 +82,7 @@ public class EvaluationResultJob {
     /**
      * 保存用户ID
      */
-    static Map<String,  List<Integer>> userIdsMap = new HashMap<>();
+    static Map<String,  List<UserEntity>> userInfoMap = new HashMap<>();
 
 
     /***
@@ -91,6 +92,7 @@ public class EvaluationResultJob {
      * @Date 18:26 2021/5/17
      * @return void
      **/
+
     @Async
     public void run(){
         if (lock){
@@ -142,17 +144,11 @@ public class EvaluationResultJob {
         List<EvaluationItemVo> itemEntityList = null;
         Integer cycle = evaluationCycleEntity.getType();
         // 查询该租户公司下的所有用户
-        List<Integer> userIds = getUserIds(evaluationCycleEntity.getTenantId(), evaluationCycleEntity.getCompanyOrgId());
-        Map<Long, UserEntity> userEntityMap = toMap(userIds);
-        if (userEntityMap == null) {
+        List<UserEntity> userEntityList = getUserInfo(evaluationCycleEntity.getTenantId(), evaluationCycleEntity.getCompanyOrgId());
+        if (userEntityList == null) {
             return;
         }
-        for (Integer userId : userIds) {
-            UserEntity userEntity = userEntityMap.get(Long.parseLong(userId.toString()));
-            // 过滤掉不是运维的用户
-            if (userEntity == null || !OPERATION_TYPE.equals(userEntity.getUserType())) {
-                continue;
-            }
+        for (UserEntity userEntity : userEntityList) {
             itemEntityList = findItem(userEntity);
             // 1.获取部门考评项设置,如果未设置直接过滤
             // 2.判断部门考评项目设置里面有没有设置对应的考评周期,没有就直接过滤
@@ -176,12 +172,12 @@ public class EvaluationResultJob {
      * @param companyOrgId :  公司id
      * @return java.util.List<java.lang.Integer>
      **/
-    private List<Integer> getUserIds(String tenantId, Integer companyOrgId){
+    private List<UserEntity> getUserInfo(String tenantId, Integer companyOrgId){
         String key = tenantId + "_" + companyOrgId;
-        List<Integer> result = userIdsMap.get(key);
+        List<UserEntity> result = userInfoMap.get(key);
         if (result == null){
-            result = userCenterClient.findUserIdsByPermissonOrg(tenantId, companyOrgId, null);
-            userIdsMap.put(key, result);
+            result = userCenterClient.findAllUserList(companyOrgId, tenantId, OPERATION_TYPE);
+            userInfoMap.put(key, result);
         }
         return result;
     }
@@ -209,7 +205,8 @@ public class EvaluationResultJob {
         // 保存考评结果任务详情
         evaluationResultTaskMapper.insertEvaluationResultTask(taskDetailsVo);
         BigDecimal completeCount   = new BigDecimal(taskDetailsVo.getCompleteCount()) ;
-        BigDecimal completionRate  = taskDetailsVo.getCompletionRate();
+        // 按时完成率
+        BigDecimal completionRate  = EvaluationUtil.divide(taskDetailsVo.getCompleteCount() - taskDetailsVo.getDelayCompleteCount(), taskDetailsVo.getTotalCount());
         BigDecimal evaluationValue = null;
         for (EvaluationItemVo item : itemEntityList) {
             // 不是当前季度的,过滤
@@ -253,9 +250,8 @@ public class EvaluationResultJob {
                 taskEntity.setTotalCount(taskEntity.getTotalCount() + 1);
                 taskEntity.setCompleteCount(taskEntity.getCompleteCount() + (completedBoolean ? 1 : 0));
                 taskEntity.setNoCompleteCount(taskEntity.getNoCompleteCount() + (!completedBoolean ? 1 : 0));
-                int addMinute = valueCondition == null ? EvaluationUtil.minute(dto.getDateLimit()) : valueCondition.intValue();
                 // 计算完成的是否属于延期完成
-                if (completedBoolean && isDelay(dto, addMinute)) {
+                if (completedBoolean && isDelay(dto, EvaluationUtil.minute(dto.getDateLimit())  + valueCondition.intValue())) {
                     taskEntity.setDelayCompleteCount(taskEntity.getDelayCompleteCount() + 1);
                 }
             }
@@ -287,9 +283,13 @@ public class EvaluationResultJob {
      * @return boolean
      **/
     private boolean isDelay(WorkOrderManageDto dto, int addMinute){
+        // 工单时间
         Date planFinishDate = dto.getSendTime();
-        // 判断是不是任务
+        // 任务时间
         if (!EvaluationUtil.isWork(dto.getOrderTypeId())) {
+            if (dto.getPlanFinishDate() == null) {
+                return false;
+            }
             planFinishDate = DatesUtil.parseDate(DatesUtil.formatDate(dto.getPlanFinishDate(), "yyyy-MM-dd") + " 23:59:59",
                     "yyyy-MM-dd HH:mm:ss");
         }

+ 10 - 6
operation_manager/src/main/java/com/huaxu/evaluation/service/impl/EvaluationResultServiceImpl.java

@@ -97,7 +97,7 @@ public class EvaluationResultServiceImpl implements EvaluationResultService {
         }
         for (EvaluationGradePercentageVo vo: list) {
             vo.setEvaluationGrade(gradMap.get(vo.getEvaluationGrade()));
-            vo.setPercentage(new BigDecimal(vo.getPercentage()).divide(total,4, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
+            vo.setPercentageRate(new BigDecimal(vo.getPercentage()).divide(total,4, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
         }
         return list;
     }
@@ -184,7 +184,7 @@ public class EvaluationResultServiceImpl implements EvaluationResultService {
         BeanUtils.copyProperties(dto, queryDto);
         // 季度需要格式化月份
         if (dto.getCycle() == EvaluationCycleEnums.QUARTER.getType()){
-            dto.setMonth(format(dto.getCycle(), dto.getMonth()));
+            queryDto.setMonth(format(dto.getCycle(), dto.getMonth()));
         }
         // 获取用户权限
         LoginUser currentUser = UserUtil.getCurrentUser();
@@ -272,16 +272,20 @@ public class EvaluationResultServiceImpl implements EvaluationResultService {
         if (month == null){
             throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
         }
-        if (month == 1) {
+        if (month == 3) {
             return Arrays.asList(1,2,3);
-        } else if (month == 2 ){
+        } else if (month == 6 ){
             return Arrays.asList(4,5,6);
-        } else if (month == 3) {
+        } else if (month == 9) {
             return Arrays.asList(7,8,9);
-        } else if (month == 4) {
+        } else if (month == 12) {
             return Arrays.asList(10,11,12);
         } else {
             throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
         }
     }
+
+    public static void main(String[] args) {
+        System.out.println(new BigDecimal(1).divide( new BigDecimal(1),4, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_DOWN));
+    }
 }

+ 4 - 1
operation_manager/src/main/java/com/huaxu/evaluation/vo/EvaluationGradePercentageVo.java

@@ -20,7 +20,10 @@ public class EvaluationGradePercentageVo {
     @ApiModelProperty(value = "绩效等级")
     private String evaluationGrade;
 
-    @ApiModelProperty(value = "占比")
+    @ApiModelProperty(value = "占比")
     private String percentage;
 
+    @ApiModelProperty(value = "占比率")
+    private String percentageRate;
+
 }

+ 5 - 2
operation_manager/src/main/java/com/huaxu/order/controller/WorkOrderManageController.java

@@ -1064,10 +1064,13 @@ public class WorkOrderManageController {
             if (EvaluationUtil.isWork(workOrderManageDto.getOrderTypeId())) {
                 planFinishDate = DatesUtil.addMinuteOfDate(workOrderManageDto.getSendTime(), EvaluationUtil.minute(workOrderManageDto.getDateLimit()));
             } else {
-                planFinishDate = DatesUtil.parseDate(DatesUtil.formatDate(workOrderManageDto.getPlanFinishDate(), "yyyy-MM-dd") + " 23:59:59",
-                        "yyyy-MM-dd HH:mm:ss");
+                if (workOrderManageDto.getPlanFinishDate() != null) {
+                    planFinishDate = DatesUtil.parseDate(DatesUtil.formatDate(workOrderManageDto.getPlanFinishDate(), "yyyy-MM-dd") + " 23:59:59",
+                            "yyyy-MM-dd HH:mm:ss");
+                }
             }
             workOrderManageDto.setPlanFinishDate(planFinishDate);
+            workOrderManageDto.setOrderStatusName(EvaluationUtil.getOrderStatusName(workOrderManageDto.getOrderStatus()));
         }
         return new AjaxMessage<>(ResultStatus.OK, pages);
     }

+ 77 - 17
operation_manager/src/main/java/com/huaxu/order/controller/WorkOrderStatisticsController.java

@@ -24,6 +24,7 @@ import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.*;
 
 @RestController
@@ -49,6 +50,7 @@ public class WorkOrderStatisticsController {
             @ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
             @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计开始日期", required = true) @RequestParam(required = true) String startDate,
             @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
+        LocalDate localDate = LocalDate.now();
         //同比日期
         String sameStartDate = null, sameEndDate = null;
         //环比日期
@@ -74,7 +76,12 @@ public class WorkOrderStatisticsController {
         } else if (statsType == 2) {
             startDate = String.format("%s-01", startDate);
             endDate = String.format("%s-01", endDate);
-            endDate = subMonth(endDate,1);
+            if(isCurrentMonth(endDate)==true){
+                endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
+            }
+            else {
+                endDate = subMonth(endDate, 1);
+            }
         }
         //根据用户编号,获取用户的权限
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -117,34 +124,34 @@ public class WorkOrderStatisticsController {
         DecimalFormat df = new DecimalFormat("#0.00");
 
         if (sameStatistic.get("工单完成率") == null || sameStatistic.get("工单完成率").toString().equals("0")) {
-            statistics.put("工单完成率同比", "-");
+            statistics.put("工单完成率同比", null);
         } else {
             Double finishedSameRate = (Double.parseDouble(statistics.get("工单完成率").toString()) - Double.parseDouble(sameStatistic.get("工单完成率").toString())) * 100 / Double.parseDouble(sameStatistic.get("工单完成率").toString());
             statistics.put("工单完成率同比", df.format(finishedSameRate));
         }
 
         if (chainStatistic.get("工单完成率") == null || chainStatistic.get("工单完成率").toString().equals("0")) {
-            statistics.put("工单完成率环比", "-");
+            statistics.put("工单完成率环比", null);
         } else {
             Double finishedChainRate = (Double.parseDouble(statistics.get("工单完成率").toString()) - Double.parseDouble(chainStatistic.get("工单完成率").toString())) * 100 / Double.parseDouble(chainStatistic.get("工单完成率").toString());
             statistics.put("工单完成率环比", df.format(finishedChainRate));
         }
         
         if (sameStatistic.get("工单总数") == null || sameStatistic.get("工单总数").toString().equals("0")) {
-            statistics.put("工单总数同比", "-");
+            statistics.put("工单总数同比", null);
         } else {
             Double orderSameTotalNumberRate = (Double.parseDouble(statistics.get("工单总数").toString()) - Double.parseDouble(sameStatistic.get("工单总数").toString())) * 100 / Double.parseDouble(sameStatistic.get("工单总数").toString());
             statistics.put("工单总数同比", df.format(orderSameTotalNumberRate));
         }
         if (chainStatistic.get("工单总数") == null || chainStatistic.get("工单总数").toString().equals("0")) {
-            statistics.put("工单总数环比", "-");
+            statistics.put("工单总数环比", null);
         } else {
             Double orderChainTotalNumberRate = (Double.parseDouble(statistics.get("工单总数").toString()) - Double.parseDouble(chainStatistic.get("工单总数").toString())) * 100 / Double.parseDouble(chainStatistic.get("工单总数").toString());
             statistics.put("工单总数环比", df.format(orderChainTotalNumberRate));
         }
 
         if (sameStatistic.get("工单完成数") == null || sameStatistic.get("工单完成数").toString().equals("0")) {
-            statistics.put("工单完成数同比", "-");
+            statistics.put("工单完成数同比", null);
 
         } else {
             Double finishedSameNumber = (Double.parseDouble(statistics.get("工单完成数").toString()) - Double.parseDouble(sameStatistic.get("工单完成数").toString())) * 100 / Double.parseDouble(sameStatistic.get("工单完成数").toString());
@@ -152,7 +159,7 @@ public class WorkOrderStatisticsController {
         }
 
         if (chainStatistic.get("工单完成数") == null || chainStatistic.get("工单完成数").toString().equals("0")) {
-            statistics.put("工单完成数环比", "-");
+            statistics.put("工单完成数环比", null);
         } else {
             Double finishedChainNumber = (Double.parseDouble(statistics.get("工单完成数").toString()) - Double.parseDouble(chainStatistic.get("工单完成数").toString())) * 100 / Double.parseDouble(chainStatistic.get("工单完成数").toString());
             statistics.put("工单完成数环比", df.format(finishedChainNumber));
@@ -168,6 +175,7 @@ public class WorkOrderStatisticsController {
             @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
             @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
         int maintainerCount = 0;
+        LocalDate localDate = LocalDate.now();
         Map<String,Object> result = new HashMap<>();
         List<Map<String, Object>> statistics = new ArrayList<>(), average =new ArrayList<>();
         //根据用户编号,获取用户的权限
@@ -182,7 +190,12 @@ public class WorkOrderStatisticsController {
             case 0:
                 maintainerCount = userCenterClient.findMaintainerCount(startDate);
                 startDate = String.format("%s-01", startDate);
-                endDate = subMonth(startDate, 1);
+                if(isCurrentMonth(startDate)==true){
+                    endDate = String.format("%s-%s", startDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(startDate, 1);
+                }
                 break;
             case 1:
                 maintainerCount = userCenterClient.findMaintainerCount(String.format("%s-12",startDate));
@@ -193,7 +206,12 @@ public class WorkOrderStatisticsController {
                 maintainerCount = userCenterClient.findMaintainerCount(endDate);
                 startDate = String.format("%s-01", startDate);
                 endDate = String.format("%s-01", endDate);
-                endDate = subMonth(endDate,1);
+                if(isCurrentMonth(endDate)==true){
+                    endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(endDate, 1);
+                }
                 break;
         }
         workOrderManageDto.setStartDate(startDate);
@@ -230,6 +248,7 @@ public class WorkOrderStatisticsController {
             @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
             @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
         //根据用户编号,获取用户的权限
+        LocalDate localDate = LocalDate.now();
         LoginUser loginUser = UserUtil.getCurrentUser();
         WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
         workOrderManageDto.setTenantId(loginUser.getTenantId());
@@ -240,7 +259,12 @@ public class WorkOrderStatisticsController {
         switch (statsType) {
             case 0:
                 startDate = String.format("%s-01", startDate);
-                endDate = subMonth(startDate, 1);
+                if(isCurrentMonth(startDate)==true){
+                    endDate = String.format("%s-%s", startDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(startDate, 1);
+                }
                 break;
             case 1:
                 startDate = String.format("%s-01-01", startDate);
@@ -249,7 +273,12 @@ public class WorkOrderStatisticsController {
             case 2:
                 startDate = String.format("%s-01", startDate);
                 endDate = String.format("%s-01", endDate);
-                endDate = subMonth(endDate,1);
+                if(isCurrentMonth(endDate)==true){
+                    endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(endDate, 1);
+                }
                 break;
         }
         workOrderManageDto.setStartDate(startDate);
@@ -267,15 +296,18 @@ public class WorkOrderStatisticsController {
             @ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
             @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
             @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
-
-        List<Integer> idList = new ArrayList<>();
+        LocalDate localDate = LocalDate.now();
         List<Map<String,Object>> statistics = new ArrayList<Map<String, Object>>();
-
         WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
         switch (statsType) {
             case 0:
                 startDate = String.format("%s-01", startDate);
-                endDate = subMonth(startDate, 1);
+                if(isCurrentMonth(startDate)==true){
+                    endDate = String.format("%s-%s", startDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(startDate, 1);
+                }
                 break;
             case 1:
                 startDate = String.format("%s-01-01", startDate);
@@ -284,7 +316,12 @@ public class WorkOrderStatisticsController {
             case 2:
                 startDate = String.format("%s-01", startDate);
                 endDate = String.format("%s-01", endDate);
-                endDate = subMonth(endDate,1);
+                if(isCurrentMonth(endDate)==true){
+                    endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(endDate, 1);
+                }
                 break;
         }
         workOrderManageDto.setScenesId(scenesId);
@@ -308,6 +345,7 @@ public class WorkOrderStatisticsController {
             @ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
             @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
             @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
+        LocalDate localDate = LocalDate.now();
         Map<String, Object> result = new HashMap<>();
         //根据用户编号,获取用户的权限
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -327,7 +365,12 @@ public class WorkOrderStatisticsController {
         } else if (statsType == 2) {
             startDate = String.format("%s-01", startDate);
             endDate = String.format("%s-01", endDate);
-            endDate = subMonth(endDate,1);
+            if(isCurrentMonth(endDate)==true){
+                endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
+            }
+            else {
+                endDate = subMonth(endDate, 1);
+            }
         }
         workOrderManageDto.setStartDate(startDate);
         workOrderManageDto.setEndDate(endDate);
@@ -421,4 +464,21 @@ public class WorkOrderStatisticsController {
         String reStr = sdf.format(dt1);
         return reStr;
     }
+
+    /**
+     * 日期是否当前月份
+     */
+    public boolean isCurrentMonth(String date) throws ParseException {
+        LocalDate localDate = LocalDate.now();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date dt = sdf.parse(date);
+        Calendar rightNow = Calendar.getInstance();
+        rightNow.setTime(dt);
+        int y = rightNow.get(Calendar.YEAR);
+        int m =rightNow.get(Calendar.MONTH)+1;
+        if( y== localDate.getYear() &&  m == localDate.getMonthValue()){
+            return true;
+        }
+        return false;
+    }
 }

+ 14 - 0
operation_manager/src/main/java/com/huaxu/utils/EvaluationUtil.java

@@ -401,6 +401,20 @@ public class EvaluationUtil {
     }
 
 
+    public static String getOrderStatusName(int status){
+        switch (status) {
+            case 0 :
+                return "待处理";
+            case 1 :
+                return "处理中";
+            case 2 :
+                return "完成";
+            case 3 :
+                return "终止";
+        }
+        return "";
+    }
+
     public static void main(String[] args) {
         System.out.println(EvaluationUtil.getStartTime(1, 15));
         System.out.println(EvaluationUtil.getEndTime(1, 15));

+ 1 - 0
operation_manager/src/main/resources/mapper/evaluation/EvaluationItemMapper.xml

@@ -157,6 +157,7 @@
             </if>
             and a.TENANT_ID = #{tenantId}
             and a.status=1
+            and v.status=1
         </where>
     </select>
 

+ 54 - 5
sms_water/src/main/java/com/huaxu/controller/SceneController.java

@@ -24,6 +24,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.ui.ModelMap;
 
 import java.io.IOException;
+import java.rmi.registry.LocateRegistry;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
@@ -247,14 +248,26 @@ public class SceneController {
                 }
                 break;
             case 1:
-                days =LocalDate.of(Integer.parseInt(startDate),1,1).lengthOfYear();
+                int year = Integer.parseInt(startDate);
+                if(year == localDate.getYear()){
+                    days = differentDaysByMillisecond(String.format("%s-%s-%s",startDate,1,1),
+                            String.format("%s-%s-%s",localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth()));
+                }
+                else {
+                    days = LocalDate.of(year, 1, 1).lengthOfYear();
+                }
                 startDate = String.format("%s-01-01", startDate);
                 endDate = subYear(startDate, 1);
                 break;
             case 2:
                 startDate = String.format("%s-01", startDate);
                 endDate = String.format("%s-01", endDate);
-                endDate = subMonth(endDate,1);
+                if(isCurrentMonth(endDate)==true){
+                    endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(endDate, 1);
+                }
                 days = differentDaysByMillisecond(startDate,endDate);
                 break;
         }
@@ -310,12 +323,18 @@ public class SceneController {
             @ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
             @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
             @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
+        LocalDate localDate = LocalDate.now();
         SceneEntity sceneEntity = new SceneEntity();
         sceneEntity.setId(Long.parseLong(String.valueOf(id)));
         switch (statsType) {
             case 0:
                 startDate = String.format("%s-01", startDate);
-                endDate = subMonth(startDate, 1);
+                if(isCurrentMonth(startDate)==true){
+                    endDate = String.format("%s-%s", startDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(startDate, 1);
+                }
                 break;
             case 1:
                 startDate = String.format("%s-01-01", startDate);
@@ -324,7 +343,13 @@ public class SceneController {
             case 2:
                 startDate = String.format("%s-01", startDate);
                 endDate = String.format("%s-01", endDate);
-                endDate = subMonth(endDate,1);
+
+                if(isCurrentMonth(endDate)==true){
+                    endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(endDate, 1);
+                }
                 break;
         }
         List<Map<String,Object>> list = new ArrayList<>();
@@ -357,6 +382,7 @@ public class SceneController {
             @ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
             @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
             @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
+        LocalDate localDate = LocalDate.now();
         SceneEntity sceneEntity = new SceneEntity();
         sceneEntity.setId(Long.parseLong(String.valueOf(id)));
         switch (statsType) {
@@ -371,7 +397,12 @@ public class SceneController {
             case 2:
                 startDate = String.format("%s-01", startDate);
                 endDate = String.format("%s-01", endDate);
-                endDate = subMonth(endDate,1);
+                if(isCurrentMonth(endDate)==true){
+                   endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
+                }
+                else {
+                    endDate = subMonth(endDate, 1);
+                }
                 break;
         }
         List<Map<String,Object>> list = sceneService.selectAlarmLable(sceneEntity,startDate,endDate,sort);
@@ -390,6 +421,7 @@ public class SceneController {
         return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
     }
 
+
     public int differentDaysByMillisecond(String date1,String date2) throws ParseException {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         Date dt1 = sdf.parse(date1);
@@ -399,6 +431,23 @@ public class SceneController {
     }
 
 
+    /**
+     * 日期是否当前月份
+     */
+    public boolean isCurrentMonth(String date) throws ParseException {
+        LocalDate localDate = LocalDate.now();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date dt = sdf.parse(date);
+        Calendar rightNow = Calendar.getInstance();
+        rightNow.setTime(dt);
+        int y = rightNow.get(Calendar.YEAR);
+        int m =rightNow.get(Calendar.MONTH)+1;
+        if( y== localDate.getYear() &&  m == localDate.getMonthValue()){
+            return true;
+        }
+        return false;
+    }
+
     /**
      * 日期增加一年
      */

+ 5 - 0
sms_water/src/main/java/com/huaxu/service/SceneService.java

@@ -500,6 +500,8 @@ public class SceneService extends ServiceImpl<SceneMapper, SceneEntity> {
         return result;
     }
 
+
+
     public List<Map<String,Object>> selectAlarmLable(@Param("scene") SceneEntity sceneEntity, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("sort") int sort){
         return sceneMapper.selectAlarmLable(sceneEntity, startDate, endDate, sort);
     }
@@ -508,6 +510,9 @@ public class SceneService extends ServiceImpl<SceneMapper, SceneEntity> {
         return sceneMapper.selectAlarmDeviceIdBySenceId(id);
     }
 
+
+
+
     public int differentDaysByMillisecond(String date1,String date2) throws ParseException {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         Date dt1 = sdf.parse(date1);

+ 11 - 11
sms_water/src/main/resources/mapper/SceneMapper.xml

@@ -466,8 +466,8 @@
                     and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
                 </if>
             </if>
-            and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
-            and c.date_create &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
             and SCENE_TYPE_NAME in('水源','水厂','泵站')
         </where>
         group by a.scene_name, a.id, sort
@@ -477,7 +477,7 @@
         select count(1) amount, d.id,c.scene_id, d.device_name name,1 sort
         from sms_alarm_details c
         INNER JOIN sms_device d on c.DEVICE_ID=d.ID
-        INNER JOIN sms_scene a on  c.SCENE_ID=a.ID
+        INNER JOIN sms_scene a on  c.PARENT_SCENE_ID=a.ID
         INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
         <where>
             a.PARENT_SCENE_ID=0 and a.STATUS=1
@@ -511,8 +511,8 @@
                     and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
                 </if>
             </if>
-            and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
-            and c.date_create &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
             and SCENE_TYPE_NAME='管网'
         </where>
         group by d.device_name, d.id, c.scene_id, sort) t
@@ -530,8 +530,8 @@
                 from sms_alarm_details c
                 where c.device_id = #{scene.id}
             </if>
-            and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
-            and c.date_create &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
             group by DATE_FORMAT(c.DATE_CREATE,'%Y-%m-%d')
     </select>
 
@@ -564,14 +564,14 @@
                             INNER JOIN sms_alarm_details c on c.PARENT_SCENE_ID=a.ID
                             INNER JOIN sms_device_attribute e on e.ID = c.ATTRIBUTE_ID and e.STATUS=1
                             LEFT JOIN sms_device_parm d on d.ATTRIBUTE_ID = c.ATTRIBUTE_ID and d.DEVICE_ID=c.DEVICE_ID and d.TENANT_ID=c.TENANT_ID and d.PARENT_SCENE_ID=c.PARENT_SCENE_ID and d.STATUS=1
-                            INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID and f.STATUS=1
+                            INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID  and f.ATTRIBUTE_ID=c.ATTRIBUTE_ID and f.STATUS=1
                             where a.ID = #{scene.id}
                         </if>
                         <if test="sort == 1">
                             from sms_alarm_details c
                             INNER JOIN sms_device_attribute e on e.ID = c.ATTRIBUTE_ID and e.STATUS=1
                             LEFT JOIN sms_device_parm d on d.ATTRIBUTE_ID = c.ATTRIBUTE_ID and d.DEVICE_ID=c.DEVICE_ID and d.TENANT_ID=c.TENANT_ID and d.PARENT_SCENE_ID=c.PARENT_SCENE_ID and d.STATUS=1
-                            INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID and f.STATUS=1
+                            INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID and f.ATTRIBUTE_ID=c.ATTRIBUTE_ID and f.STATUS=1
                             where c.device_id = #{scene.id}
                         </if>
                         and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
@@ -591,8 +591,8 @@
                         from sms_alarm_details c
                         where c.device_id = #{scene.id} and alarm_type='状态报警'
                     </if>
-                    and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
-                    and c.date_create &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
+                    and c.alarm_start_time &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
+                    and c.alarm_start_time &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
                 ) t1
                 group by label
             ) t2

+ 1 - 1
user_center/src/main/java/com/huaxu/config/ResourceServerConfig.java

@@ -17,7 +17,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
                 .and()
                 .authorizeRequests()
                 .antMatchers("/swagger-ui.html","/webjars/**", "/webjars/**", "/swagger-resources/**",
-                       "/user/findUserIdsByPermissonOrg","/user/findUserIdsByUserIds","/verManage/selectVer",
+                       "/user/findUserIdsByPermissonOrg","/user/findAllUserList", "/user/findUserIdsByUserIds","/verManage/selectVer",
                        "/v2/**")
                 .permitAll() //配置不需要身份认证的请求路径
                 .anyRequest().authenticated() //其他所有访问路径都需要身份认证

+ 8 - 7
user_center/src/main/java/com/huaxu/controller/UserController.java

@@ -283,15 +283,16 @@ public class UserController {
         return new AjaxMessage<>(ResultStatus.OK, userList);
     }
 
-    /**
-     * 按公司 租户及用户类型查询所有用户信息
-     * @return
-     */
+
+    @ApiOperation(value = "按公司 租户及用户类型查询所有用户信息")
     @RequestMapping(value = "/findAllUserList", method = RequestMethod.GET)
-    public AjaxMessage<List<UserEntity>> findAllUserList(Integer companyOrgId, String tenantId,int type) {
-        List<UserEntity> userList = userService.findAllUserList(companyOrgId, tenantId, type);
-        return new AjaxMessage<>(ResultStatus.OK, userList);
+    public List<UserEntity> findAllUserList(
+            @RequestParam(value = "companyOrgId", required = false) Integer companyOrgId,
+            @RequestParam(value = "tenantId", required = false)String tenantId,
+            @RequestParam(value = "type", required = false)Integer type){
+        return userService.findAllUserList(companyOrgId, tenantId, type);
     }
+
     @RequestMapping(value = "/findUserIdsByUserIds", method = RequestMethod.POST)
     public List<UserEntity> findUserIdsByUserIds(Long[] ids) {
         List list = Arrays.asList(ids.clone());

+ 1 - 1
user_center/src/main/resources/mapper/UserMapper.xml

@@ -205,7 +205,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     </select>
     <select id="findAllUserListByType" resultType="com.huaxu.entity.UserEntity">
-        select a.id,a.DEPT_ORG_ID,a.COMPANY_ORG_ID,
+        select a.id,a.DEPT_ORG_ID,a.COMPANY_ORG_ID,a.TENANT_ID,
         a.USERNAME,company.ORG_NAME
         companyOrgName,department.ORG_NAME deptOrgName,
         a.phone phone