Ver Fonte

Merge branch 'master' of http://172.16.120.227:10080/jichaobo/fiveep

yq há 3 anos atrás
pai
commit
233d2e716f
41 ficheiros alterados com 2311 adições e 273 exclusões
  1. 16 0
      fiveep-controller/src/main/java/com/bizmatics/controller/web/HtAnalogDataController.java
  2. 24 6
      fiveep-controller/src/main/java/com/bizmatics/controller/web/RtAnalogDataController.java
  3. 31 1
      fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysUserController.java
  4. 12 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysRole.java
  5. 27 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysUser.java
  6. 338 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysUserOne.java
  7. 28 0
      fiveep-model/src/main/java/com/bizmatics/model/system/UserSite.java
  8. 91 0
      fiveep-model/src/main/java/com/bizmatics/model/vo/EvaluationReporVo.java
  9. 418 0
      fiveep-model/src/main/java/com/bizmatics/model/vo/SingleLoopReportOneVo.java
  10. 290 0
      fiveep-model/src/main/java/com/bizmatics/model/vo/SingleLoopReportVo.java
  11. 6 0
      fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/HtAnalogDataMapper.java
  12. 22 11
      fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/RtAnalogDataMapper.java
  13. 2 1
      fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/RtSwitchDataMapper.java
  14. 11 2
      fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/UserSiteMapper.java
  15. 2 4
      fiveep-persistence/src/main/resources/mapper/mysql/DeviceAnalogVariableListMapper.xml
  16. 1 1
      fiveep-persistence/src/main/resources/mapper/mysql/DeviceMapper.xml
  17. 45 0
      fiveep-persistence/src/main/resources/mapper/mysql/HtAnalogDataMapper.xml
  18. 33 2
      fiveep-persistence/src/main/resources/mapper/mysql/RtAnalogDataMapper.xml
  19. 3 0
      fiveep-persistence/src/main/resources/mapper/mysql/RtSwitchDataMapper.xml
  20. 25 0
      fiveep-persistence/src/main/resources/mapper/mysql/UserSiteMapper.xml
  21. 3 0
      fiveep-persistence/src/main/resources/mapper/mysql/system/SysRoleMapper.xml
  22. 4 0
      fiveep-persistence/src/main/resources/mapper/mysql/system/SysUserMapper.xml
  23. 3 0
      fiveep-service/src/main/java/com/bizmatics/service/HtAnalogDataService.java
  24. 6 0
      fiveep-service/src/main/java/com/bizmatics/service/RtAnalogDataService.java
  25. 2 0
      fiveep-service/src/main/java/com/bizmatics/service/UserService.java
  26. 3 1
      fiveep-service/src/main/java/com/bizmatics/service/impl/AlarmPowerServiceImpl.java
  27. 18 3
      fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAnalogVariableListServiceImpl.java
  28. 5 1
      fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAttributeServiceImpl.java
  29. 5 2
      fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceServiceImpl.java
  30. 3 1
      fiveep-service/src/main/java/com/bizmatics/service/impl/DevopsWorkOrderServiceImpl.java
  31. 431 13
      fiveep-service/src/main/java/com/bizmatics/service/impl/HtAnalogDataServiceImpl.java
  32. 184 51
      fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java
  33. 3 1
      fiveep-service/src/main/java/com/bizmatics/service/impl/RtSwitchDataServiceImpl.java
  34. 4 1
      fiveep-service/src/main/java/com/bizmatics/service/impl/SitedtlServiceImpl.java
  35. 5 0
      fiveep-service/src/main/java/com/bizmatics/service/impl/UserServiceImpl.java
  36. 2 1
      fiveep-service/src/main/java/com/bizmatics/service/impl/WcBlackoutPlanServiceImpl.java
  37. 35 28
      fiveep-service/src/main/java/com/bizmatics/service/system/ISysUserService.java
  38. 30 0
      fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysPermissionService.java
  39. 3 0
      fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysRoleServiceImpl.java
  40. 127 142
      fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysUserServiceImpl.java
  41. 10 0
      fiveep-service/src/main/java/com/bizmatics/service/vo/RealScoreVO.java

+ 16 - 0
fiveep-controller/src/main/java/com/bizmatics/controller/web/HtAnalogDataController.java

@@ -3,6 +3,7 @@ package com.bizmatics.controller.web;
 
 import com.bizmatics.common.core.bean.ApiResult;
 import com.bizmatics.model.vo.DataManagementOneVO;
+import com.bizmatics.model.vo.SingleLoopReportOneVo;
 import com.bizmatics.service.HtAnalogDataService;
 import com.bizmatics.service.vo.CommonIcoVO;
 import com.bizmatics.service.vo.HadCountVO;
@@ -193,5 +194,20 @@ public class HtAnalogDataController {
                                                  @RequestParam String endTime) {
         return ApiResult.success(htAnalogDataService.monthlyReportExport(deviceCode, startTime, endTime, cycle));
     }
+
+    /**
+     * 电能质量(单回路报告)
+     *
+     * @param deviceCode 设备编号
+     * @param time       时间 type为1时时间格式 yyyy-MM-dd type为2时时间格式 yyyy-MM
+     * @param type       类型 1:日 2:月
+     * @return
+     */
+    @GetMapping("SingleLoopReportData")
+    public ApiResult<SingleLoopReportOneVo> SingleLoopReportData(@RequestParam String deviceCode,
+                                                                 @RequestParam Date time,
+                                                                 @RequestParam int type) {
+        return ApiResult.success(htAnalogDataService.SingleLoopReportData(deviceCode, time, type));
+    }
 }
 

+ 24 - 6
fiveep-controller/src/main/java/com/bizmatics/controller/web/RtAnalogDataController.java

@@ -88,9 +88,9 @@ public class RtAnalogDataController {
     /**
      * 伍继PC1.0-数据报表
      *
-     * @param siteId 站点ID
+     * @param siteId    站点ID
      * @param startTime 开始时间
-     * @param endTime 结束时间
+     * @param endTime   结束时间
      * @param queryType 类型 日 月 年
      * @return
      */
@@ -104,9 +104,10 @@ public class RtAnalogDataController {
 
     /**
      * 伍继PC1.0-历史趋势数据查询
-     * @param siteId 站点ID
+     *
+     * @param siteId    站点ID
      * @param startTime 开始时间
-     * @param endTime 结束时间
+     * @param endTime   结束时间
      * @param queryType 类型 日 月 年
      * @return
      */
@@ -120,9 +121,10 @@ public class RtAnalogDataController {
 
     /**
      * 伍继PC1.0-数据报表导出
-     * @param siteId 站点ID
+     *
+     * @param siteId    站点ID
      * @param startTime 开始时间
-     * @param endTime 结束时间
+     * @param endTime   结束时间
      * @param queryType 类型 日 月 年
      * @return
      */
@@ -134,5 +136,21 @@ public class RtAnalogDataController {
         return ApiResult.success(rtAnalogDataService.DataReportExport(siteId, startTime, endTime, queryType));
     }
 
+
+    /**
+     * 电能质量(评估报告)
+     *
+     * @param siteId 站点ID
+     * @param time 时间 type为1时时间格式 yyyy-MM-dd type为2时时间格式 yyyy-MM
+     * @param type 类型 1:日 2:月
+     * @return
+     */
+    @GetMapping("evaluationReport")
+    public ApiResult<List<RealScoreVO>> evaluationReport(@RequestParam int siteId,
+                                                         @RequestParam Date time,
+                                                         @RequestParam int type) {
+        return ApiResult.success(rtAnalogDataService.evaluationReport(siteId, time, type));
+    }
+
 }
 

+ 31 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysUserController.java

@@ -2,7 +2,9 @@ package com.bizmatics.controller.web.system;
 
 import com.bizmatics.common.core.bean.ApiResult;
 import com.bizmatics.common.core.exception.BusinessErrorCode;
+import com.bizmatics.common.core.exception.BusinessException;
 import com.bizmatics.common.core.util.StringUtils;
+import com.bizmatics.model.UserSite;
 import com.bizmatics.model.constants.UserConstants;
 import com.bizmatics.model.page.TableDataInfo;
 import com.bizmatics.model.system.SysRole;
@@ -13,6 +15,8 @@ import com.bizmatics.service.system.ISysUserService;
 import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -76,6 +80,7 @@ public class SysUserController extends BaseController
      * 新增用户
      */
     @PreAuthorize("@ss.hasPermi('system:user:add')")
+    @Transactional
     @PostMapping
     public ApiResult<Void> add(@Validated @RequestBody SysUser user)
     {
@@ -95,13 +100,25 @@ public class SysUserController extends BaseController
         }
         user.setCreateBy(SecurityUtils.getUsername());
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
-        return toAjax(userService.insertUser(user));
+        int row = userService.insertUser(user);
+        int userId = user.getUserId().intValue();
+        try{
+            for (int i=0;i<user.getSiteId().length;i++){
+                int siteId = user.getSiteId()[i];
+                userService.insertUserSite(userId,siteId);
+            }
+        }catch (Exception e){
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            throw  new BusinessException("用户点位关联表插入失败");
+        }
+        return toAjax(row);
     }
 
     /**
      * 修改用户
      */
     @PreAuthorize("@ss.hasPermi('system:user:edit')")
+    @Transactional
     @PutMapping
     public ApiResult<Void> edit(@Validated @RequestBody SysUser user)
     {
@@ -117,6 +134,17 @@ public class SysUserController extends BaseController
             return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
         }
         user.setUpdateBy(SecurityUtils.getUsername());
+        try{
+            userService.deleteUserByIds(user.getUserId());
+            int userId = user.getUserId().intValue();
+            for (int i=0;i<user.getSiteId().length;i++){
+                int siteId = user.getSiteId()[i];
+                userService.insertUserSite(userId,siteId);
+            }
+        }catch (Exception e){
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            throw  new BusinessException("用户点位关联表插入失败");
+        }
         return toAjax(userService.updateUser(user));
     }
 
@@ -165,7 +193,9 @@ public class SysUserController extends BaseController
         Map<String,Object> ajax = new HashMap<>();
         SysUser user = userService.selectUserById(userId);
         List<SysRole> roles = roleService.selectRolesByUserId(userId);
+        List<UserSite> userSiteList = userService.selectUserSiteById(userId);
         ajax.put("user", user);
+        ajax.put("userSite", userSiteList);
         ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
         return ApiResult.success(ajax);
     }

+ 12 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysRole.java

@@ -51,6 +51,8 @@ public class SysRole extends BaseEntity
 
     /** 部门组(数据权限) */
     private Long[] deptIds;
+    /** 创建用户 */
+    private String createByOne;
 
     public SysRole()
     {
@@ -196,6 +198,16 @@ public class SysRole extends BaseEntity
     {
         this.deptIds = deptIds;
     }
+
+    public void setCreateByOne(String createByOne)
+    {
+        this.createByOne = createByOne;
+    }
+
+    public String getCreateByOne()
+    {
+        return createByOne;
+    }
     
     @Override
     public String toString() {

+ 27 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysUser.java

@@ -79,6 +79,12 @@ public class SysUser extends BaseEntity
     /** 角色ID */
     private Long roleId;
 
+    /** 站点组组 */
+    private int[] siteId;
+
+    /** 创建用户 */
+    private String createByOne;
+
     public SysUser()
     {
 
@@ -297,6 +303,27 @@ public class SysUser extends BaseEntity
         this.roleId = roleId;
     }
 
+    public int[] getSiteId()
+    {
+        return siteId;
+    }
+
+    public void setSiteId(int[] siteId)
+    {
+        this.siteId = siteId;
+    }
+
+    public void setCreateByOne(String createByOne)
+    {
+        this.createByOne = createByOne;
+    }
+
+    public String getCreateByOne()
+    {
+        return createByOne;
+    }
+
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

+ 338 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysUserOne.java

@@ -0,0 +1,338 @@
+package com.bizmatics.model.system;
+
+import com.bizmatics.model.base.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.Email;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * 用户对象 sys_user
+ * 
+ * @author yq
+ */
+public class SysUserOne extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 用户ID */
+    private Long userId;
+
+    /** 部门ID */
+    private Long deptId;
+
+    /** 用户账号 */
+    private String userName;
+
+    /** 用户昵称 */
+    private String nickName;
+
+    /** 用户邮箱 */
+    private String email;
+
+    /** 手机号码 */
+    private String phonenumber;
+
+    /** 用户性别 */
+    private String sex;
+
+    /** 用户头像 */
+    private String avatar;
+
+    /** 密码 */
+    private String password;
+
+    /** 盐加密 */
+    private String salt;
+
+    /** 帐号状态(0正常 1停用) */
+    private String status;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    private String delFlag;
+
+    /** 最后登录IP */
+    private String loginIp;
+
+    /** 最后登录时间 */
+    private Date loginDate;
+
+    /** 部门对象 */
+    private SysDept dept;
+
+    /** 角色对象 */
+    private List<SysRole> roles;
+
+    /** 角色组 */
+    private Long[] roleIds;
+
+    /** 岗位组 */
+    private Long[] postIds;
+
+    /** 角色ID */
+    private Long roleId;
+
+    /** 站点组组 */
+    private int[] siteId;
+
+    public SysUserOne()
+    {
+
+    }
+
+    public SysUserOne(Long userId)
+    {
+        this.userId = userId;
+    }
+
+    public Long getUserId()
+    {
+        return userId;
+    }
+
+    public void setUserId(Long userId)
+    {
+        this.userId = userId;
+    }
+
+    public boolean isAdmin()
+    {
+        return isAdmin(this.userId);
+    }
+
+    public static boolean isAdmin(Long userId)
+    {
+        return userId != null && 1L == userId;
+    }
+
+    public Long getDeptId()
+    {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId)
+    {
+        this.deptId = deptId;
+    }
+
+    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
+    public String getNickName()
+    {
+        return nickName;
+    }
+
+    public void setNickName(String nickName)
+    {
+        this.nickName = nickName;
+    }
+
+    @NotBlank(message = "用户账号不能为空")
+    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
+    public String getUserName()
+    {
+        return userName;
+    }
+
+    public void setUserName(String userName)
+    {
+        this.userName = userName;
+    }
+
+    @Email(message = "邮箱格式不正确")
+    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
+    public String getEmail()
+    {
+        return email;
+    }
+
+    public void setEmail(String email)
+    {
+        this.email = email;
+    }
+
+    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
+    public String getPhonenumber()
+    {
+        return phonenumber;
+    }
+
+    public void setPhonenumber(String phonenumber)
+    {
+        this.phonenumber = phonenumber;
+    }
+
+    public String getSex()
+    {
+        return sex;
+    }
+
+    public void setSex(String sex)
+    {
+        this.sex = sex;
+    }
+
+    public String getAvatar()
+    {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar)
+    {
+        this.avatar = avatar;
+    }
+
+    @JsonIgnore
+    @JsonProperty
+    public String getPassword()
+    {
+        return password;
+    }
+
+    public void setPassword(String password)
+    {
+        this.password = password;
+    }
+
+    public String getSalt()
+    {
+        return salt;
+    }
+
+    public void setSalt(String salt)
+    {
+        this.salt = salt;
+    }
+
+    public String getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus(String status)
+    {
+        this.status = status;
+    }
+
+    public String getDelFlag()
+    {
+        return delFlag;
+    }
+
+    public void setDelFlag(String delFlag)
+    {
+        this.delFlag = delFlag;
+    }
+
+    public String getLoginIp()
+    {
+        return loginIp;
+    }
+
+    public void setLoginIp(String loginIp)
+    {
+        this.loginIp = loginIp;
+    }
+
+    public Date getLoginDate()
+    {
+        return loginDate;
+    }
+
+    public void setLoginDate(Date loginDate)
+    {
+        this.loginDate = loginDate;
+    }
+
+    public SysDept getDept()
+    {
+        return dept;
+    }
+
+    public void setDept(SysDept dept)
+    {
+        this.dept = dept;
+    }
+
+    public List<SysRole> getRoles()
+    {
+        return roles;
+    }
+
+    public void setRoles(List<SysRole> roles)
+    {
+        this.roles = roles;
+    }
+
+    public Long[] getRoleIds()
+    {
+        return roleIds;
+    }
+
+    public void setRoleIds(Long[] roleIds)
+    {
+        this.roleIds = roleIds;
+    }
+
+    public Long[] getPostIds()
+    {
+        return postIds;
+    }
+
+    public void setPostIds(Long[] postIds)
+    {
+        this.postIds = postIds;
+    }
+
+    public Long getRoleId()
+    {
+        return roleId;
+    }
+
+    public void setRoleId(Long roleId)
+    {
+        this.roleId = roleId;
+    }
+
+    public int[] getSiteId()
+    {
+        return siteId;
+    }
+
+    public void setSiteId(int[] siteId)
+    {
+        this.siteId = siteId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+            .append("userId", getUserId())
+            .append("deptId", getDeptId())
+            .append("userName", getUserName())
+            .append("nickName", getNickName())
+            .append("email", getEmail())
+            .append("phonenumber", getPhonenumber())
+            .append("sex", getSex())
+            .append("avatar", getAvatar())
+            .append("password", getPassword())
+            .append("salt", getSalt())
+            .append("status", getStatus())
+            .append("delFlag", getDelFlag())
+            .append("loginIp", getLoginIp())
+            .append("loginDate", getLoginDate())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .append("dept", getDept())
+            .toString();
+    }
+}

+ 28 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/UserSite.java

@@ -0,0 +1,28 @@
+package com.bizmatics.model.system;
+
+import com.bizmatics.model.base.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+public class UserSite extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Web端用户站点关联表ID
+     */
+    private Integer id;
+
+    /**
+     * 用户ID
+     */
+    private Integer userId;
+
+    /**
+     * 站点ID
+     */
+    private Integer siteId;
+
+}

+ 91 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/EvaluationReporVo.java

@@ -0,0 +1,91 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author ya
+ * @since 2021-07-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class EvaluationReporVo implements Serializable {
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 设备编号
+     */
+    private String deviceCode;
+
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+
+    /**
+     * 三相正向有功电度
+     */
+    @TableField("COS")
+    private Double cos;
+
+    /**
+     * A相电流
+     */
+    @TableField("Ia")
+    private Double Ia;
+
+    /**
+     * B相电流
+     */
+    @TableField("Ib")
+    private Double Ib;
+
+    /**
+     * C相电流
+     */
+    @TableField("Ic")
+    private Double Ic;
+
+    /**
+     * A相电压
+     */
+    @TableField("Ua")
+    private Double Ua;
+
+    /**
+     * B相电压
+     */
+    @TableField("Ub")
+    private Double Ub;
+
+    /**
+     * C相电压
+     */
+    @TableField("Uc")
+    private Double Uc;
+
+    /**
+     * 电压等级
+     */
+    private String voltageLevel;
+
+    /**
+     * 额定电流(A)
+     */
+    private Double ratedCurrent;
+
+
+}

+ 418 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/SingleLoopReportOneVo.java

@@ -0,0 +1,418 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author ya
+ * @since 2021-07-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class SingleLoopReportOneVo implements Serializable {
+
+    /**
+     * 伍继电力test_183消费组模拟量数据表ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 设备编号
+     */
+    private String deviceCode;
+
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+
+    /**
+     * 功率因素
+     */
+    private Double cos;
+
+    /**
+     * 频率(平均)
+     */
+    private String avgF;
+
+    /**
+     * 频率(最大)
+     */
+    private String maxF;
+
+    /**
+     * 频率(最小)
+     */
+    private String minF;
+
+    /**
+     * A相电流(平均)
+     */
+    private Double avgIa;
+
+    /**
+     * B相电流(平均)
+     */
+    private Double avgIb;
+
+    /**
+     * C相电流(平均)
+     */
+    private Double avgIc;
+
+    /**
+     * A相电流(最大)
+     */
+    private Double maxIa;
+
+    /**
+     * B相电流(最大)
+     */
+    private Double maxIb;
+
+    /**
+     * C相电流(最大)
+     */
+    private Double maxIc;
+
+    /**
+     * A相电流(最小)
+     */
+    private Double minIa;
+
+    /**
+     * B相电流(最小)
+     */
+    private Double minIb;
+
+    /**
+     * C相电流(最小)
+     */
+    private Double minIc;
+
+
+    /**
+     * A相电压(平均)
+     */
+    private String avgUa;
+
+    /**
+     * B相电压(平均)
+     */
+    private String avgUb;
+
+    /**
+     * C相电压(平均)
+     */
+    private String avgUc;
+
+    /**
+     * A相电压(最大)
+     */
+    private String maxUa;
+
+    /**
+     * B相电压(最大)
+     */
+    private String maxUb;
+
+    /**
+     * C相电压(最大)
+     */
+    private String maxUc;
+
+    /**
+     * A相电压(最小)
+     */
+    private String minUa;
+
+    /**
+     * B相电压(最小)
+     */
+    private String minUb;
+
+    /**
+     * C相电压(最小)
+     */
+    private String minUc;
+
+    /**
+     * 电压等级
+     */
+    private String voltageLevel;
+
+    /**
+     * 额定电流(A)
+     */
+    private Double ratedCurrent;
+
+    /**
+     * 上报总数
+     */
+    private Integer measuringPoints;
+
+
+    /**
+     * 电流不平衡(平均)
+     */
+    private Double avgElBalun;
+    /**
+     * 电压不平衡(平均)
+     */
+    private Double avgVtBalun;
+
+    /**
+     * 电流不平衡(最大)
+     */
+    private Double maxElBalun;
+    /**
+     * 电压不平衡(最大)
+     */
+    private Double maxVtBalun;
+
+    /**
+     * 电流不平衡(最小)
+     */
+    private Double minElBalun;
+    /**
+     * 电压不平衡(最小)
+     */
+    private Double minVtBalun;
+
+    /**
+     * A相电压比例
+     */
+    private String proportionUa;
+
+    /**
+     * A相电压合格率
+     */
+    private Double qrUa;
+
+    /**
+     * B相电压比例
+     */
+    private String proportionUb;
+
+    /**
+     * B相电压合格率
+     */
+    private Double qrUb;
+
+    /**
+     * C相电压比例
+     */
+    private String proportionUc;
+
+    /**
+     * C相电压合格率
+     */
+    private Double qrUc;
+
+    /**
+     * 频率比例
+     */
+    private String proportionF;
+
+    /**
+     * 频率合格率
+     */
+    private Double qrF;
+
+    /**
+     * 电流不平衡度比例
+     */
+    private String proportionElBalun;
+
+    /**
+     * 电流不平衡度合格率
+     */
+    private Double qrElBalun;
+
+    /**
+     * 电压不平衡度比例
+     */
+    private String proportionVtBalun;
+
+    /**
+     * 电压不平衡度合格率
+     */
+    private Double qrVtBalun;
+
+
+    /**
+     * 标称电压上限
+     */
+    private Double voltageLevelToplimit;
+
+    /**
+     * 标称电压下限
+     */
+    private Double voltageLevelLowerLimit;
+
+    /**
+     * 标称频率
+     */
+    private Double mhz;
+
+    /**
+     * 频率上限
+     */
+    private Double fToplimit;
+
+    /**
+     * 频率下限
+     */
+    private Double fLowerLimit;
+
+    /**
+     * 考核限值
+     */
+    private Double appraise;
+    /**
+     * 不平衡度上限
+     */
+    private Double balanceToplimit;
+    /**
+     * 不平衡度下限
+     */
+    private Double balanceLowerLimit;
+
+
+    /**
+     * A相电压是否合格 true:合格 false:不合格
+     */
+    private Boolean UaStatus;
+
+    /**
+     * A相电压(平均)是否合格 true:合格 false:不合格
+     */
+    private Boolean avgUaStatus;
+
+    /**
+     * A相电压(最大)是否合格 true:合格 false:不合格
+     */
+    private Boolean maxUaStatus;
+
+    /**
+     * A相电压(最小)是否合格 true:合格 false:不合格
+     */
+    private Boolean minUaStatus;
+
+    /**
+     * B相电压是否合格 true:合格 false:不合格
+     */
+    private Boolean UbStatus;
+
+    /**
+     * B相电压(平均)是否合格 true:合格 false:不合格
+     */
+    private Boolean avgUbStatus;
+
+    /**
+     * B相电压(最大)是否合格 true:合格 false:不合格
+     */
+    private Boolean maxUbStatus;
+
+    /**
+     * B相电压(最小)是否合格 true:合格 false:不合格
+     */
+    private Boolean minUbStatus;
+
+    /**
+     * C相电压是否合格 true:合格 false:不合格
+     */
+    private Boolean UcStatus;
+
+    /**
+     * C相电压(平均)是否合格 true:合格 false:不合格
+     */
+    private Boolean avgUcStatus;
+
+    /**
+     * C相电压(最大)是否合格 true:合格 false:不合格
+     */
+    private Boolean maxUcStatus;
+
+    /**
+     * C相电压(最小)是否合格 true:合格 false:不合格
+     */
+    private Boolean minUcStatus;
+
+    /**
+     * 频率是否合格 true:合格 false:不合格
+     */
+    private Boolean FStatus;
+
+    /**
+     * 频率(平均)是否合格 true:合格 false:不合格
+     */
+    private Boolean avgFStatus;
+
+    /**
+     * 频率(最大)是否合格 true:合格 false:不合格
+     */
+    private Boolean maxFStatus;
+
+    /**
+     * 频率(最小)是否合格 true:合格 false:不合格
+     */
+    private Boolean minFStatus;
+
+    /**
+     * 电流不平衡度是否合格 true:合格 false:不合格
+     */
+    private Boolean ElBalunStatus;
+
+    /**
+     * 电流不平衡度(平均)是否合格 true:合格 false:不合格
+     */
+    private Boolean avgElBalunStatus;
+
+    /**
+     * 电流不平衡度(最大)是否合格 true:合格 false:不合格
+     */
+    private Boolean maxElBalunStatus;
+
+    /**
+     * 电流不平衡度(最小)是否合格 true:合格 false:不合格
+     */
+    private Boolean minElBalunStatus;
+
+    /**
+     * 电压不平衡度是否合格 true:合格 false:不合格
+     */
+    private Boolean VtBalunStatus;
+
+    /**
+     * 电压不平衡度(平均)是否合格 true:合格 false:不合格
+     */
+    private Boolean avgVtBalunStatus;
+
+    /**
+     * 电压不平衡度(最大)是否合格 true:合格 false:不合格
+     */
+    private Boolean maxVtBalunStatus;
+
+    /**
+     * 电压不平衡度(最小)是否合格 true:合格 false:不合格
+     */
+    private Boolean minVtBalunStatus;
+
+    /**
+     * 功率因数是否合格 true:合格 false:不合格
+     */
+    private Boolean cosStatus;
+}

+ 290 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/SingleLoopReportVo.java

@@ -0,0 +1,290 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author ya
+ * @since 2021-07-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class SingleLoopReportVo implements Serializable {
+
+    /**
+     * 伍继电力test_183消费组模拟量数据表ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 设备编号
+     */
+    private String deviceCode;
+
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+
+    /**
+     * 功率因素
+     */
+    private Double cos;
+
+    /**
+     * 频率(平均)
+     */
+    private Double avgF;
+
+    /**
+     * 频率(最大)
+     */
+    private Double maxF;
+
+    /**
+     * 频率(最小)
+     */
+    private Double minF;
+
+    /**
+     * A相电流(平均)
+     */
+    private Double avgIa;
+
+    /**
+     * B相电流(平均)
+     */
+    private Double avgIb;
+
+    /**
+     * C相电流(平均)
+     */
+    private Double avgIc;
+
+    /**
+     * A相电流(最大)
+     */
+    private Double maxIa;
+
+    /**
+     * B相电流(最大)
+     */
+    private Double maxIb;
+
+    /**
+     * C相电流(最大)
+     */
+    private Double maxIc;
+
+    /**
+     * A相电流(最小)
+     */
+    private Double minIa;
+
+    /**
+     * B相电流(最小)
+     */
+    private Double minIb;
+
+    /**
+     * C相电流(最小)
+     */
+    private Double minIc;
+
+    /**
+     * A相电压(平均)
+     */
+    private Double avgUa;
+
+    /**
+     * B相电压(平均)
+     */
+    private Double avgUb;
+
+    /**
+     * C相电压(平均)
+     */
+    private Double avgUc;
+
+    /**
+     * A相电压(最大)
+     */
+    private Double maxUa;
+
+    /**
+     * B相电压(最大)
+     */
+    private Double maxUb;
+
+    /**
+     * C相电压(最大)
+     */
+    private Double maxUc;
+
+    /**
+     * A相电压(最小)
+     */
+    private Double minUa;
+
+    /**
+     * B相电压(最小)
+     */
+    private Double minUb;
+
+    /**
+     * C相电压(最小)
+     */
+    private Double minUc;
+
+    /**
+     * 电压等级
+     */
+    private String voltageLevel;
+
+    /**
+     * 额定电流(A)
+     */
+    private Double ratedCurrent;
+
+    /**
+     * 上报总数
+     */
+    private Integer measuringPoints;
+
+    /**
+     * 电流不平衡(平均)
+     */
+    private Double avgElBalun;
+    /**
+     * 电压不平衡(平均)
+     */
+    private Double avgVtBalun;
+
+    /**
+     * 电流不平衡(最大)
+     */
+    private Double maxElBalun;
+    /**
+     * 电压不平衡(最大)
+     */
+    private Double maxVtBalun;
+
+    /**
+     * 电流不平衡(最小)
+     */
+    private Double minElBalun;
+    /**
+     * 电压不平衡(最小)
+     */
+    private Double minVtBalun;
+
+    /**
+     * A相电压比例
+     */
+    private String proportionUa;
+
+    /**
+     * A相电压合格率
+     */
+    private Double qrUa;
+
+    /**
+     * B相电压比例
+     */
+    private String proportionUb;
+
+    /**
+     * B相电压合格率
+     */
+    private Double qrUb;
+
+    /**
+     * C相电压比例
+     */
+    private String proportionUc;
+
+    /**
+     * C相电压合格率
+     */
+    private Double qrUc;
+
+    /**
+     * 频率比例
+     */
+    private String proportionF;
+
+    /**
+     * 频率合格率
+     */
+    private Double qrF;
+
+    /**
+     * 电流不平衡度比例
+     */
+    private String proportionElBalun;
+
+    /**
+     * 电流不平衡度合格率
+     */
+    private Double qrElBalun;
+
+    /**
+     * 电压不平衡度比例
+     */
+    private String proportionVtBalun;
+
+    /**
+     * 电压不平衡度合格率
+     */
+    private Double qrVtBalun;
+
+
+    /**
+     * 标称电压上限
+     */
+    private Double voltageLevelToplimit;
+
+    /**
+     * 标称电压下限
+     */
+    private Double voltageLevelLowerLimit;
+
+    /**
+     * 标称频率
+     */
+    private Double mhz;
+
+    /**
+     * 频率上限
+     */
+    private Double fToplimit;
+
+    /**
+     * 频率下限
+     */
+    private Double fLowerLimit;
+
+    /**
+     * 考核限值
+     */
+    private Double appraise;
+    /**
+     * 不平衡度上限
+     */
+    private Double balanceToplimit;
+    /**
+     * 不平衡度下限
+     */
+    private Double balanceLowerLimit;
+}

+ 6 - 0
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/HtAnalogDataMapper.java

@@ -4,6 +4,7 @@ import com.bizmatics.common.mvc.base.CrudMapper;
 import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.model.vo.HtAnalogDataOneVo;
 import com.bizmatics.model.vo.HtAnalogDataVo;
+import com.bizmatics.model.vo.SingleLoopReportVo;
 import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
@@ -125,4 +126,9 @@ public interface HtAnalogDataMapper extends CrudMapper<HtAnalogData> {
                                              @Param("size") Integer size,
                                              @Param("startCurrent") Integer startCurrent);
 
+    List<SingleLoopReportVo> SingleLoopReportData(@Param("deviceCode") String deviceCode,
+                                                  @Param("startTime") String startTime,
+                                                  @Param("endTime") String endTime);
+
+
 }

+ 22 - 11
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/RtAnalogDataMapper.java

@@ -5,6 +5,7 @@ import com.bizmatics.model.Device;
 import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.model.RtAnalogData;
 import com.bizmatics.common.mvc.base.CrudMapper;
+import com.bizmatics.model.vo.EvaluationReporVo;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -14,7 +15,7 @@ import java.util.Map;
 
 /**
  * <p>
- *  Mapper 接口
+ * Mapper 接口
  * </p>
  *
  * @author ya
@@ -26,27 +27,37 @@ public interface RtAnalogDataMapper extends CrudMapper<RtAnalogData> {
 
     /**
      * 查询电力总负荷
+     *
      * @param userId
      * @param siteId
      * @return
      */
     Double selectTotalLoad(@Param("userId") Integer userId,
-                        @Param("siteId") Integer siteId);
-
+                           @Param("siteId") Integer siteId);
 
 
     List<RtAnalogData> list(@Param("userId") Integer userId);
 
 
-    Map<String,Object> getOneMap(@Param("siteId")Integer siteId);
+    Map<String, Object> getOneMap(@Param("userId") Integer userId,
+                                  @Param("siteId") Integer siteId);
+
+    List<HtAnalogData> getDataReportMap(@Param("siteId") Integer siteId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    List<Device> getDeviceListMap(@Param("siteId") Integer siteId);
+
+    List<HtAnalogData> getDataReportDMap(@Param("deviceCode") List deviceCode, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    List<HtAnalogData> getDataReportMMap(@Param("deviceCode") List deviceCode, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    Page<HtAnalogData> getDataReportMap1(Page<HtAnalogData> page, @Param("siteId") Integer siteId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    Page<HtAnalogData> getDataReportDMap1(Page<HtAnalogData> page, @Param("deviceCode") List deviceCode, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
 
-    List<HtAnalogData> getDataReportMap(@Param("siteId")Integer siteId, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
-    List<Device> getDeviceListMap(@Param("siteId")Integer siteId);
-    List<HtAnalogData> getDataReportDMap(@Param("deviceCode")List deviceCode, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
-    List<HtAnalogData> getDataReportMMap(@Param("deviceCode")List deviceCode, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
+    Page<HtAnalogData> getDataReportMMap1(Page<HtAnalogData> page, @Param("deviceCode") List deviceCode, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
 
-    Page<HtAnalogData> getDataReportMap1(Page<HtAnalogData> page, @Param("siteId")Integer siteId, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
-    Page<HtAnalogData> getDataReportDMap1(Page<HtAnalogData> page, @Param("deviceCode")List deviceCode, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
-    Page<HtAnalogData> getDataReportMMap1(Page<HtAnalogData> page, @Param("deviceCode")List deviceCode, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
+    List<EvaluationReporVo> evaluationReportList(@Param("siteId") Integer siteId,
+                                                 @Param("startTime") String startTime,
+                                                 @Param("endtime") String endtime);
 
 }

+ 2 - 1
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/RtSwitchDataMapper.java

@@ -20,7 +20,8 @@ import java.util.Map;
 public interface RtSwitchDataMapper extends CrudMapper<RtSwitchData> {
 
 
-    Map<String,Object> getOneMap(@Param("siteId") Integer siteId);
+    Map<String,Object> getOneMap(@Param("userId") Integer userId,
+                                 @Param("siteId") Integer siteId);
 
     Map<String,Object> getLoopStatusMap(@Param("siteId") Integer siteId);
 

+ 11 - 2
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/UserSiteMapper.java

@@ -1,12 +1,15 @@
 package com.bizmatics.persistence.mapper;
 
-import com.bizmatics.model.UserSite;
 import com.bizmatics.common.mvc.base.CrudMapper;
+import com.bizmatics.model.UserSite;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
  * <p>
- *  Mapper 接口
+ * Mapper 接口
  * </p>
  *
  * @author ya
@@ -14,5 +17,11 @@ import org.springframework.stereotype.Repository;
  */
 @Repository
 public interface UserSiteMapper extends CrudMapper<UserSite> {
+    public int insertUserSite(@Param("id") Integer id,
+                              @Param("userId") int userId,
+                              @Param("siteId") int siteId);
+
+    public List<UserSite> selectUserSiteById(Long userId);
 
+    public int deleteUserSiteById(Long userId);
 }

+ 2 - 4
fiveep-persistence/src/main/resources/mapper/mysql/DeviceAnalogVariableListMapper.xml

@@ -56,12 +56,10 @@
         c.monitor_device_name
         FROM
         device_analog_variable_list AS a
-        JOIN device AS b ON a.communication_equipment = b.id
-        JOIN device_attribute AS c ON a.monitoring_equipment = c.id
+        left JOIN device AS b ON a.communication_equipment = b.id
+        left JOIN device_attribute AS c ON a.monitoring_equipment = c.id
         <where>
             a. STATUS = 1
-            AND b. ENABLE = 1
-            AND c. STATUS = 1
             <if test="siteId != null and siteId !=0">
                 and c.site_id = #{siteId}
             </if>

+ 1 - 1
fiveep-persistence/src/main/resources/mapper/mysql/DeviceMapper.xml

@@ -20,7 +20,7 @@
         inner join device_status as ds
         on us.site_id = ds.site_id
         inner join device as d
-        on us.site_id = d.site_Id
+        on ds.device_code = d.device_code
         <where>
             <if test="userId != null and userId != 0">
                 and us.user_id = #{userId}

+ 45 - 0
fiveep-persistence/src/main/resources/mapper/mysql/HtAnalogDataMapper.xml

@@ -1134,4 +1134,49 @@
         </where>
         GROUP BY a.dataTime,a.deviceName
     </select>
+
+    <select id="SingleLoopReportData" resultType="com.bizmatics.model.vo.SingleLoopReportVo">
+        SELECT
+        a.device_code,
+        a.device_name,
+        AVG(b.COS) AS COS,
+        AVG(F) AS avgF,
+        MAX(F) AS maxF,
+        min(F) AS minF,
+        AVG(b.Ia) AS avgIa,
+        AVG(b.Ib) AS avgIb,
+        AVG(b.Ic) AS avgIc,
+        max(b.Ia) AS maxIa,
+        max(b.Ib) AS maxIb,
+        max(b.Ic) AS maxIc,
+        min(b.Ia) AS minIa,
+        min(b.Ib) AS minIb,
+        min(b.Ic) AS minIc,
+        AVG(b.Ua) AS avgUa,
+        AVG(b.Ub) AS avgUb,
+        AVG(b.Uc) AS avgUc,
+        max(b.Ua) AS maxUa,
+        max(b.Ub) AS maxUb,
+        max(b.Uc) AS maxUc,
+        min(b.Ua) AS minUa,
+        min(b.Ub) AS minUb,
+        min(b.Uc) AS minUc,
+        c.voltage_level,
+        d.rated_current,
+        COUNT(b.id) AS measuringPoints
+        FROM
+        device AS a
+        LEFT JOIN ht_analog_data AS b ON a.device_code = b.deviceName
+        LEFT JOIN site_dynamic_properties AS c ON a.site_id = c.site_id
+        LEFT JOIN device_attribute AS d ON a.device_code = d.monitor_device_code
+        <where>
+            and a. ENABLE = 1
+            AND a.device_type = 1
+            AND a.device_code = #{deviceCode}
+            AND b.dataTime BETWEEN #{startTime}
+            AND #{endTime}
+        </where>
+        GROUP BY a.device_code
+    </select>
+
 </mapper>

+ 33 - 2
fiveep-persistence/src/main/resources/mapper/mysql/RtAnalogDataMapper.xml

@@ -89,7 +89,10 @@
         on d.device_code = rad.deviceName
         <where>
             <if test="siteId != null and siteId != 0">
-                and us.site_id = #{siteId}
+              us.site_id = #{siteId}
+            </if>
+            <if test="userId != null and userId != 0">
+              and  us.user_id = #{userId}
             </if>
         </where>
     </select>
@@ -757,5 +760,33 @@
 
     </select>
 
-
+    <select id="evaluationReportList" resultType="com.bizmatics.model.vo.EvaluationReporVo">
+        SELECT
+        a.id,
+        a.device_code,
+        a.device_name,
+        AVG(b.COS) AS COS,
+        AVG(b.Ia) AS Ia,
+        AVG(b.Ib) AS Ib,
+        AVG(b.Ic) AS Ic,
+        AVG(b.Ua) AS Ua,
+        AVG(b.Ub) AS Ub,
+        AVG(b.Uc) AS Uc,
+        c.voltage_level,
+        d.rated_current
+        FROM
+        device AS a
+        LEFT JOIN ht_analog_data AS b ON a.device_code = b.deviceName
+        LEFT JOIN site_dynamic_properties AS c ON a.site_id = c.site_id
+        LEFT JOIN device_attribute AS d ON a.device_code = d.monitor_device_code
+        <where>
+            AND a.enable = 1
+            AND a.device_type = 1
+            AND a.site_id = #{siteId}
+            AND b.dataTime BETWEEN #{startTime}
+            AND #{endtime}
+        </where>
+        GROUP BY
+        a.device_code
+    </select>
 </mapper>

+ 3 - 0
fiveep-persistence/src/main/resources/mapper/mysql/RtSwitchDataMapper.xml

@@ -49,6 +49,9 @@
             <if test="siteId != null and siteId != 0">
                 and us.site_id = #{siteId}
             </if>
+            <if test="userId != null and userId != 0">
+                and us.user_id = #{userId}
+            </if>
         </where>
     </select>
 

+ 25 - 0
fiveep-persistence/src/main/resources/mapper/mysql/UserSiteMapper.xml

@@ -9,4 +9,29 @@
         <result column="site_id" property="siteId" />
     </resultMap>
 
+    <insert id="insertUserSite" parameterType="com.bizmatics.model.UserSite">
+        insert into user_site(
+        <if test="id != null and id != 0">id,</if>
+        <if test="userId != null and userId != 0">user_id,</if>
+        <if test="siteId != null and siteId != 0">site_id</if>
+        )values(
+        <if test="id != null and id != ''">#{id}</if>
+        <if test="userId != null and userId != ''">#{userId},</if>
+        <if test="siteId != null and siteId != ''">#{siteId}</if>
+        )
+    </insert>
+
+    <sql id="selectUserSiteVo">
+        select *
+        from user_site
+    </sql>
+
+    <select id="selectUserSiteById" parameterType="Long" resultMap="BaseResultMap">
+        <include refid="selectUserSiteVo"/>
+        where user_id = #{userId}
+    </select>
+
+    <delete id="deleteUserSiteById" parameterType="Long">
+        DELETE FROM user_site WHERE user_id = #{userId}
+    </delete>
 </mapper>

+ 3 - 0
fiveep-persistence/src/main/resources/mapper/mysql/system/SysRoleMapper.xml

@@ -36,6 +36,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="roleName != null and roleName != ''">
 			AND r.role_name like concat('%', #{roleName}, '%')
 		</if>
+		<if test="createByOne != null and createByOne != ''">
+			AND r.create_by = #{createByOne}
+		</if>
 		<if test="status != null and status != ''">
 			AND r.status = #{status}
 		</if>

+ 4 - 0
fiveep-persistence/src/main/resources/mapper/mysql/system/SysUserMapper.xml

@@ -62,6 +62,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="userName != null and userName != ''">
 			AND u.user_name like concat('%', #{userName}, '%')
 		</if>
+		<if test="createByOne != null and createByOne != ''">
+			AND u.create_by = #{createByOne}
+		</if>
 		<if test="status != null and status != ''">
 			AND u.status = #{status}
 		</if>
@@ -79,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		</if>
 		<!-- 数据范围过滤 -->
 		${params.dataScope}
+		ORDER BY u.user_id DESC
 	</select>
 	
 	<select id="selectAllocatedList" parameterType="com.bizmatics.model.system.SysUser" resultMap="SysUserResult">

+ 3 - 0
fiveep-service/src/main/java/com/bizmatics/service/HtAnalogDataService.java

@@ -4,6 +4,7 @@ import com.bizmatics.common.mvc.base.CrudService;
 import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.model.vo.DataManagementOneVO;
 import com.bizmatics.model.vo.HtAnalogDataOneVo;
+import com.bizmatics.model.vo.SingleLoopReportOneVo;
 import com.bizmatics.service.vo.CommonIcoVO;
 import com.bizmatics.service.vo.HadCountVO;
 import com.bizmatics.service.vo.RealScoreVO;
@@ -103,5 +104,7 @@ public interface HtAnalogDataService extends CrudService<HtAnalogData> {
 
     List<HtAnalogDataOneVo> monthlyReportlist(String deviceCode, String startTime, String endTime, int cycle, Integer startCurrent);
 
+    SingleLoopReportOneVo SingleLoopReportData(String deviceCode, Date time, int type);
+
 
 }

+ 6 - 0
fiveep-service/src/main/java/com/bizmatics/service/RtAnalogDataService.java

@@ -4,6 +4,7 @@ import com.bizmatics.common.mvc.base.CrudService;
 import com.bizmatics.model.DeviceAttribute;
 import com.bizmatics.model.RtAnalogData;
 import com.bizmatics.model.SiteDynamicProperties;
+import com.bizmatics.model.vo.EvaluationReporVo;
 import com.bizmatics.service.vo.RadCountVO;
 import com.bizmatics.service.vo.RealScoreOneVO;
 import com.bizmatics.service.vo.RealScoreVO;
@@ -98,4 +99,9 @@ public interface RtAnalogDataService extends CrudService<RtAnalogData> {
      */
     String DataReportExport(Integer siteId,Date startTime, Date endTime,String queryType);
 
+
+    List<RealScoreVO> fillRealScoreDataTwo(List<EvaluationReporVo> evaluationReporVo);
+
+    List<RealScoreVO> evaluationReport(int siteId, Date time, int type);
+
 }

+ 2 - 0
fiveep-service/src/main/java/com/bizmatics/service/UserService.java

@@ -17,4 +17,6 @@ public interface UserService extends CrudService<User> {
 
 
     void register(User user);
+
+    User getUser(String userId);
 }

+ 3 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/AlarmPowerServiceImpl.java

@@ -26,6 +26,7 @@ import org.springframework.util.CollectionUtils;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -209,6 +210,7 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
 
     @Override
     public String export(Date startTime, Date endTime, Integer status, Integer siteId) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
         Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         Workbook workbook = null;
         File file = null;
@@ -221,7 +223,7 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
                         return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), AlarmPower.class, AlarmPowerExportVO.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "电力告警", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "电力告警", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);

+ 18 - 3
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAnalogVariableListServiceImpl.java

@@ -34,6 +34,8 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -123,27 +125,40 @@ public class DeviceAnalogVariableListServiceImpl extends AbstractCrudService<Dev
 
     @Override
     public String variableListExport( Integer siteId,String variableName,Integer dataArea) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
+        SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Workbook workbook = null;
         File file = null;
+        final String[] err1 = {"导出文件失败"};
+        Page<DeviceAnalogVariableListOneVo> page1 = new Page<>(1, 10);
+        page1 = baseMapper.variableListExport(page1,siteId, variableName, dataArea);
         try {
+            List<DeviceAnalogVariableListOneVo>  variableList = page1.getRecords();
+            if (null == variableList || variableList.size() ==0){
+                err1[0] ="导出失败,监控设备未绑定或数据为空";
+                throw new BusinessException(err1[0]);
+            }
             ExportParams params = new ExportParams(null, "变量列表");
             workbook = ExcelExportUtil.exportBigExcel(params, DeviceAnalogVariableListExportVO.class,
                     (o, i) -> {
                         Page<DeviceAnalogVariableListOneVo> page = new Page<>(i, 30);
                         page = baseMapper.variableListExport(page,siteId, variableName, dataArea);
+
                         return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), DeviceAnalogVariableListOneVo.class, DeviceAnalogVariableListExportVO.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "变量列表", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "变量列表", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);
             } else {
-                throw new BusinessException("表格数据为空");
+                err1[0] ="表格数据为空";
+                throw new BusinessException(err1[0]);
             }
         } catch (Exception e) {
             log.error("导出文件失败", e);
-            throw new BusinessException("导出文件失败");
+//            err1[0] ="导出文件失败";
+            throw new BusinessException(err1[0]);
         } finally {
             if (workbook != null) {
                 try {

+ 5 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAttributeServiceImpl.java

@@ -37,6 +37,8 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -117,6 +119,8 @@ public class DeviceAttributeServiceImpl extends AbstractCrudService<DeviceAttrib
 
     @Override
     public String deviceAttributeExport(Integer id, Integer siteId) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
+        SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         Workbook workbook = null;
         File file = null;
@@ -135,7 +139,7 @@ public class DeviceAttributeServiceImpl extends AbstractCrudService<DeviceAttrib
                         return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), DeviceAttribute.class, DeviceAttributeExportVO.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "监控设备列表", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "监控设备列表", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);

+ 5 - 2
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceServiceImpl.java

@@ -40,6 +40,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -355,6 +356,7 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
 
     @Override
     public String deviceExport(String deviceName, Integer deviceType, Integer siteId) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
         SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Workbook workbook = null;
         File file = null;
@@ -400,7 +402,7 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
                         return new ArrayList<>(BeanMapperUtils.mapList(Active, DeviceOne.class, DeviceExportVO.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "通信设备列表", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "通信设备列表", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);
@@ -424,6 +426,7 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
 
     @Override
     public String correspondDeviceExport(String deviceName) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
         SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Workbook workbook = null;
         File file = null;
@@ -454,7 +457,7 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
                         return new ArrayList<>(BeanMapperUtils.mapList(Active, CorrespondDeviceTwoVO.class, CorrespondDeviceExportVO.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "通信设备列表", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "通信设备列表", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);

+ 3 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/DevopsWorkOrderServiceImpl.java

@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -711,6 +712,7 @@ public class DevopsWorkOrderServiceImpl extends AbstractCrudService<DevopsWorkOr
 
     @Override
     public String workloadStatisticsExport(Integer siteId,String startTime,String endTime){
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
         Workbook workbook = null;
         File file = null;
         try {
@@ -784,7 +786,7 @@ public class DevopsWorkOrderServiceImpl extends AbstractCrudService<DevopsWorkOr
                         return new ArrayList<>(BeanMapperUtils.mapList(Active1, ProcessingTimeVo.class, ProcessingTimeExportVO.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "工作量统计", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "工作量统计", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);

+ 431 - 13
fiveep-service/src/main/java/com/bizmatics/service/impl/HtAnalogDataServiceImpl.java

@@ -15,10 +15,7 @@ import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.common.spring.util.GlobalUtils;
 import com.bizmatics.common.spring.util.JsonUtils;
 import com.bizmatics.model.*;
-import com.bizmatics.model.vo.DataManagementOneVO;
-import com.bizmatics.model.vo.DataManagementVO;
-import com.bizmatics.model.vo.HtAnalogDataOneVo;
-import com.bizmatics.model.vo.HtAnalogDataVo;
+import com.bizmatics.model.vo.*;
 import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
 import com.bizmatics.service.*;
 import com.bizmatics.service.util.FieldEscapeUtils;
@@ -33,8 +30,13 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static com.bizmatics.service.impl.RtAnalogDataServiceImpl.getLastDayOfMonth;
 
 
 /**
@@ -194,25 +196,29 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
 
     @Override
     public TimeShareVO getTimeShare(Integer siteId, Integer type) {
-        TimeShareVO timeShareVO = new TimeShareVO();
+        AtomicReference<TimeShareVO> timeShareVO = new AtomicReference<>(new TimeShareVO());
         Date date = new Date();
         if (0 == type) {
-            HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, date, date);
-            Optional.ofNullable(hadSiteStatic).ifPresent(hads -> JsonUtils.fromJson(hads.getTimeShare(), timeShareVO.getClass()));
+            Date yeDay = DateUtils.addDays(date, -1);
+            Date yeStartDay = DateUtils.getDayStartTime(yeDay);
+            HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, yeStartDay, yeDay);
+            Optional.ofNullable(hadSiteStatic).ifPresent(hads -> {
+                timeShareVO.set(JsonUtils.fromJson(hads.getTimeShare(), TimeShareVO.class));
+            });
         } else {
             List<HadSiteStatic> list = hadSiteStaticService.list(siteId, DateUtils.getFirstDayOfMonth(date), date);
             for (HadSiteStatic hadSiteStatic : list) {
                 Optional.ofNullable(hadSiteStatic.getTimeShare())
                         .ifPresent(has -> {
                             TimeShareVO ts = JsonUtils.fromJson(has, TimeShareVO.class);
-                            timeShareVO.setFlat(Arith.add(timeShareVO.getFlat(), ts.getFlat()));
-                            timeShareVO.setPeak(Arith.add(timeShareVO.getPeak(), ts.getPeak()));
-                            timeShareVO.setNeed(Arith.add(timeShareVO.getNeed(), ts.getNeed()));
-                            timeShareVO.setGrain(Arith.add(timeShareVO.getGrain(), ts.getGrain()));
+                            timeShareVO.get().setFlat(Arith.add(timeShareVO.get().getFlat(), ts.getFlat()));
+                            timeShareVO.get().setPeak(Arith.add(timeShareVO.get().getPeak(), ts.getPeak()));
+                            timeShareVO.get().setNeed(Arith.add(timeShareVO.get().getNeed(), ts.getNeed()));
+                            timeShareVO.get().setGrain(Arith.add(timeShareVO.get().getGrain(), ts.getGrain()));
                         });
             }
         }
-        return timeShareVO;
+        return timeShareVO.get();
     }
 
     @Override
@@ -597,6 +603,7 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
 
     @Override
     public String monthlyReportExport(String deviceCode, String startTime, String endTime, int cycle) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
         Workbook workbook = null;
         File file = null;
         try {
@@ -608,7 +615,7 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
                         return new ArrayList<>(BeanMapperUtils.mapList(listOne, HtAnalogDataOneVo.class, HtAnalogDataTwoExportVo.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "用能月报", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "用能月报", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);
@@ -656,4 +663,415 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
         return listOne;
     }
 
+    @Override
+    public SingleLoopReportOneVo SingleLoopReportData(String deviceCode, Date time, int type){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
+        String startTime = null;
+        String endtime = null;
+        if (type == 1) {
+            startTime = sdf.format(time) + " 00:00:00";
+            endtime = sdf.format(time) + " 23:59:59";
+        } else {
+            startTime = sdf1.format(time) + "-01 00:00:00";
+            String time1 = sdf1.format(time) + "-01";
+            try {
+                Date yq = getLastDayOfMonth(sdf.parse(time1));
+                endtime = sdf.format(yq) + " 23:59:59";
+            } catch (Exception e) {
+                throw new BusinessException("时间错误");
+            }
+        }
+        List<SingleLoopReportVo> SingleLoopReportList = baseMapper.SingleLoopReportData(deviceCode,startTime,endtime);
+        if (CollectionUtils.isEmpty(SingleLoopReportList)){
+            SingleLoopReportOneVo singleLoopReportOneVo = null;
+            return singleLoopReportOneVo;
+//            throw new BusinessException("暂无数据");
+        }
+        LambdaQueryWrapper<HtAnalogData> adQuery = Wrappers.lambdaQuery();
+        adQuery.eq(HtAnalogData::getDeviceName, deviceCode)
+                .between(HtAnalogData::getDataTime, startTime, endtime);
+        List<HtAnalogData> RtAnalogDataList = this.list(adQuery);
+        if (CollectionUtils.isEmpty(RtAnalogDataList)) {
+            throw new BusinessException("da不存在");
+        }
+
+
+        return analysisCalculation(SingleLoopReportList,RtAnalogDataList);
+    }
+
+    public SingleLoopReportOneVo analysisCalculation(List<SingleLoopReportVo> SingleLoopReportList,List<HtAnalogData> RtAnalogDataList){
+        DecimalFormat df   = new DecimalFormat("######0.00");
+        List<Double> checkList = new ArrayList<>();
+        SingleLoopReportOneVo singleLoopReportOneVo = BeanMapperUtils.map(SingleLoopReportList.get(0), SingleLoopReportOneVo.class);
+
+        checkList.add(SingleLoopReportList.get(0).getAvgIa());
+        checkList.add(SingleLoopReportList.get(0).getAvgIb());
+        checkList.add(SingleLoopReportList.get(0).getAvgIc());
+        //电流不平衡(平均)
+        Double AvgElBalun = checkBalun(checkList) * 100;
+        singleLoopReportOneVo.setAvgElBalun(Double.valueOf(df.format(AvgElBalun)));
+        if (AvgElBalun<15){
+            singleLoopReportOneVo.setAvgElBalunStatus(true);
+        }else {
+            singleLoopReportOneVo.setAvgElBalunStatus(false);
+        }
+
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMaxIa());
+        checkList.add(SingleLoopReportList.get(0).getMaxIb());
+        checkList.add(SingleLoopReportList.get(0).getMaxIc());
+        //电流不平衡(最大)
+        Double MaxElBalun = checkBalun(checkList) * 100;
+        singleLoopReportOneVo.setMaxElBalun(Double.valueOf(df.format(MaxElBalun)));
+        if (MaxElBalun<15){
+            singleLoopReportOneVo.setMaxElBalunStatus(true);
+        }else {
+            singleLoopReportOneVo.setMaxElBalunStatus(false);
+        }
+
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMinIa());
+        checkList.add(SingleLoopReportList.get(0).getMinIb());
+        checkList.add(SingleLoopReportList.get(0).getMinIc());
+        //电流不平衡(最小)
+        Double MinElBalun = checkBalun(checkList) * 100;
+        singleLoopReportOneVo.setMinElBalun(Double.valueOf(df.format(MinElBalun)));
+        if (MinElBalun<15){
+            singleLoopReportOneVo.setMinElBalunStatus(true);
+        }else {
+            singleLoopReportOneVo.setMinElBalunStatus(false);
+        }
+        if (AvgElBalun<15&&MaxElBalun<15&&MinElBalun<15){
+            singleLoopReportOneVo.setElBalunStatus(true);
+        }else {
+            singleLoopReportOneVo.setElBalunStatus(false);
+        }
+
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getAvgUa());
+        checkList.add(SingleLoopReportList.get(0).getAvgUb());
+        checkList.add(SingleLoopReportList.get(0).getAvgUc());
+        //电压不平衡(平均)
+        Double AvgVtBalun = checkBalun(checkList) * 100;
+        singleLoopReportOneVo.setAvgVtBalun(Double.valueOf(df.format(AvgVtBalun)));
+        if (AvgVtBalun<15){
+            singleLoopReportOneVo.setAvgVtBalunStatus(true);
+        }else {
+            singleLoopReportOneVo.setAvgVtBalunStatus(false);
+        }
+
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMaxUa());
+        checkList.add(SingleLoopReportList.get(0).getMaxUb());
+        checkList.add(SingleLoopReportList.get(0).getMaxUc());
+        //电压不平衡(最大)
+        Double MaxVtBalun = checkBalun(checkList) * 100;
+        singleLoopReportOneVo.setMaxVtBalun(Double.valueOf(df.format(MaxVtBalun)));
+        if (MaxVtBalun<15){
+            singleLoopReportOneVo.setMaxVtBalunStatus(true);
+        }else {
+            singleLoopReportOneVo.setMaxVtBalunStatus(false);
+        }
+
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMinUa());
+        checkList.add(SingleLoopReportList.get(0).getMinUb());
+        checkList.add(SingleLoopReportList.get(0).getMinUc());
+        //电压不平衡(最小)
+        Double MinVtBalun = checkBalun(checkList) * 100;
+        singleLoopReportOneVo.setMinVtBalun(Double.valueOf(df.format(MinVtBalun)));
+        if (MinVtBalun<15){
+            singleLoopReportOneVo.setMinVtBalunStatus(true);
+        }else {
+            singleLoopReportOneVo.setMinVtBalunStatus(false);
+        }
+
+        if (AvgVtBalun<15&&MaxVtBalun<15&&MinVtBalun<15){
+            singleLoopReportOneVo.setVtBalunStatus(true);
+        }else {
+            singleLoopReportOneVo.setVtBalunStatus(false);
+        }
+
+
+        double voltageLevel = Double.parseDouble(singleLoopReportOneVo.getVoltageLevel());
+        double voltageLevelWanting = voltageLevel / 100 * 7;
+
+        //A相电压合格率(平均)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getAvgUa());
+        checkList.add(voltageLevel);
+        Double AvgUaQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setAvgUa(df.format(SingleLoopReportList.get(0).getAvgUa())+"kV("+AvgUaQR+"%)");
+        if (AvgUaQR<7.00){
+            singleLoopReportOneVo.setAvgUaStatus(true);
+        }else {
+            singleLoopReportOneVo.setAvgUaStatus(false);
+        }
+        //B相电压合格率(平均)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getAvgUb());
+        checkList.add(voltageLevel);
+        Double AvgUbQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setAvgUb(df.format(SingleLoopReportList.get(0).getAvgUb())+"kV("+AvgUbQR+"%)");
+        if (AvgUbQR<7.00){
+            singleLoopReportOneVo.setAvgUbStatus(true);
+        }else {
+            singleLoopReportOneVo.setAvgUbStatus(false);
+        }
+        //C相电压合格率(平均)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getAvgUc());
+        checkList.add(voltageLevel);
+        Double AvgUcQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setAvgUc(df.format(SingleLoopReportList.get(0).getAvgUc())+"kV("+AvgUcQR+"%)");
+        if (AvgUcQR<7.00){
+            singleLoopReportOneVo.setAvgUcStatus(true);
+        }else {
+            singleLoopReportOneVo.setAvgUcStatus(false);
+        }
+        //A相电压合格率(最大)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMaxUa());
+        checkList.add(voltageLevel);
+        Double MaxUaQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setMaxUa(df.format(SingleLoopReportList.get(0).getMaxUa())+"kV("+MaxUaQR+"%)");
+        if (MaxUaQR<7.00){
+            singleLoopReportOneVo.setMaxUaStatus(true);
+        }else {
+            singleLoopReportOneVo.setMaxUaStatus(false);
+        }
+        //B相电压合格率(最大)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMaxUb());
+        checkList.add(voltageLevel);
+        Double MaxUbQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setMaxUb(df.format(SingleLoopReportList.get(0).getMaxUb())+"kV("+MaxUbQR+"%)");
+        if (MaxUbQR<7.00){
+            singleLoopReportOneVo.setMaxUbStatus(true);
+        }else {
+            singleLoopReportOneVo.setMaxUbStatus(false);
+        }
+        //C相电压合格率(最大)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMaxUc());
+        checkList.add(voltageLevel);
+        Double MaxUcQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setMaxUc(df.format(SingleLoopReportList.get(0).getMaxUc())+"kV("+MaxUcQR+"%)");
+        if (MaxUcQR<7.00){
+            singleLoopReportOneVo.setMaxUcStatus(true);
+        }else {
+            singleLoopReportOneVo.setMaxUcStatus(false);
+        }
+        //A相电压合格率(最小)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMinUa());
+        checkList.add(voltageLevel);
+        Double MinUaQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setMinUa(df.format(SingleLoopReportList.get(0).getMinUa())+"kV("+MinUaQR+"%)");
+        if (MinUaQR<7.00){
+            singleLoopReportOneVo.setMinUaStatus(true);
+        }else {
+            singleLoopReportOneVo.setMinUaStatus(false);
+        }
+        //B相电压合格率(最小)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMinUb());
+        checkList.add(voltageLevel);
+        Double MinUbQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setMinUb(df.format(SingleLoopReportList.get(0).getMinUb())+"kV("+MinUbQR+"%)");
+        if (MinUbQR<7.00){
+            singleLoopReportOneVo.setMinUbStatus(true);
+        }else {
+            singleLoopReportOneVo.setMinUbStatus(false);
+        }
+        //C相电压合格率(最小)
+        checkList.clear();
+        checkList.add(SingleLoopReportList.get(0).getMinUc());
+        checkList.add(voltageLevel);
+        Double MinUcQR = Double.valueOf(df.format(VoltageQr(checkList,voltageLevel)));
+        singleLoopReportOneVo.setMinUc(df.format(SingleLoopReportList.get(0).getMinUc())+"kV("+MinUcQR+"%)");
+        if (MinUcQR<7.00){
+            singleLoopReportOneVo.setMinUcStatus(true);
+        }else {
+            singleLoopReportOneVo.setMinUcStatus(false);
+        }
+
+        if (AvgUaQR<7.00&&MaxUaQR<7.00&&MinUaQR<7.00){
+            singleLoopReportOneVo.setUaStatus(true);
+        }else {
+            singleLoopReportOneVo.setUaStatus(false);
+        }
+
+        if (AvgUbQR<7.00&&MaxUbQR<7.00&&MinUbQR<7.00){
+            singleLoopReportOneVo.setUbStatus(true);
+        }else {
+            singleLoopReportOneVo.setUbStatus(false);
+        }
+
+        if (AvgUcQR<7.00&&MaxUcQR<7.00&&MinUcQR<7.00){
+            singleLoopReportOneVo.setUcStatus(true);
+        }else {
+            singleLoopReportOneVo.setUcStatus(false);
+        }
+
+
+        //频率(平均)
+        Double cAvgF = 0.00;
+        if (SingleLoopReportList.get(0).getAvgF()>=50){
+            cAvgF = Double.valueOf(df.format(SingleLoopReportList.get(0).getAvgF()-50.00));
+        }else {
+            cAvgF = Double.valueOf(df.format(50.00 - SingleLoopReportList.get(0).getAvgF()));
+        }
+        singleLoopReportOneVo.setAvgF(df.format(SingleLoopReportList.get(0).getAvgF())+"Hz("+cAvgF+"Hz)");
+        if (SingleLoopReportList.get(0).getAvgF()<50.2&&SingleLoopReportList.get(0).getAvgF()>49.8){
+            singleLoopReportOneVo.setAvgFStatus(true);
+        }else {
+            singleLoopReportOneVo.setAvgFStatus(false);
+        }
+        //频率(最大)
+        Double cMaxF = 0.00;
+        if (SingleLoopReportList.get(0).getAvgF()>=50){
+            cMaxF = Double.valueOf(df.format( SingleLoopReportList.get(0).getMaxF()-50.00));
+        }else {
+            cMaxF = Double.valueOf(df.format(50.00 - SingleLoopReportList.get(0).getMaxF()));
+        }
+        singleLoopReportOneVo.setMaxF(df.format(SingleLoopReportList.get(0).getMaxF())+"Hz("+cMaxF+"Hz)");
+        if (SingleLoopReportList.get(0).getMaxF()<50.2&&SingleLoopReportList.get(0).getMaxF()>49.8){
+            singleLoopReportOneVo.setMaxFStatus(true);
+        }else {
+            singleLoopReportOneVo.setMaxFStatus(false);
+        }
+        //频率(最小)
+        Double cMinF = 0.00;
+        if (SingleLoopReportList.get(0).getAvgF()>=50){
+            cMinF = Double.valueOf(df.format(SingleLoopReportList.get(0).getMinF()-50.00));
+        }else {
+            cMinF = Double.valueOf(df.format(50.00 - SingleLoopReportList.get(0).getMinF()));
+        }
+
+        singleLoopReportOneVo.setMinF(df.format(SingleLoopReportList.get(0).getMinF())+"Hz("+cMinF+"Hz)");
+        if (SingleLoopReportList.get(0).getMinF()<50.2&&SingleLoopReportList.get(0).getMinF()>49.8){
+            singleLoopReportOneVo.setMinFStatus(true);
+        }else {
+            singleLoopReportOneVo.setMinFStatus(false);
+        }
+
+        if (singleLoopReportOneVo.getAvgFStatus()==true&&singleLoopReportOneVo.getMaxFStatus()==true&&singleLoopReportOneVo.getMaxFStatus()==true){
+            singleLoopReportOneVo.setFStatus(true);
+        }else {
+            singleLoopReportOneVo.setFStatus(false);
+        }
+        if (SingleLoopReportList.get(0).getCos()>0.85){
+            singleLoopReportOneVo.setCosStatus(true);
+        }else {
+            singleLoopReportOneVo.setCosStatus(false);
+        }
+
+        int OverrunUa = 0;
+        int OverrunUb = 0;
+        int OverrunUc = 0;
+        int OverrunF = 0;
+        int OverrunElBalun = 0;
+        int OverrunVtBalun = 0;
+        if (RtAnalogDataList.size()>0){
+            for (int i=0;i<RtAnalogDataList.size();i++){
+                checkList.clear();
+                checkList.add(RtAnalogDataList.get(i).getUa());
+                checkList.add(voltageLevel);
+                Double maxUa = checkList.stream().max(Double::compareTo).get();
+                Double minUa = checkList.stream().min(Double::compareTo).get();
+                Double wantingUa = Arith.sub(maxUa, minUa);
+                if (wantingUa<voltageLevelWanting){
+                    OverrunUa++;
+                }
+
+                checkList.clear();
+                checkList.add(RtAnalogDataList.get(i).getUb());
+                checkList.add(voltageLevel);
+                Double maxUb = checkList.stream().max(Double::compareTo).get();
+                Double minUb = checkList.stream().min(Double::compareTo).get();
+                Double wantingUb = Arith.sub(maxUb, minUb);
+                if (wantingUb<voltageLevelWanting){
+                    OverrunUb ++;
+                }
+
+                checkList.clear();
+                checkList.add(RtAnalogDataList.get(i).getUc());
+                checkList.add(voltageLevel);
+                Double maxUc = checkList.stream().max(Double::compareTo).get();
+                Double minUc = checkList.stream().min(Double::compareTo).get();
+                Double wantingUc = Arith.sub(maxUc, minUc);
+                if (wantingUc<voltageLevelWanting){
+                    OverrunUc ++;
+                }
+
+                if (RtAnalogDataList.get(i).getF()<50.2&&RtAnalogDataList.get(i).getF()>49.8){
+                    OverrunF ++;
+                }
+
+                checkList.clear();
+                checkList.add(RtAnalogDataList.get(i).getIa());
+                checkList.add(RtAnalogDataList.get(i).getIb());
+                checkList.add(RtAnalogDataList.get(i).getIc());
+                //电流不平衡
+                Double ElBalun = checkBalun(checkList);
+                if (ElBalun<0.15){
+                    OverrunElBalun ++;
+                }
+
+                checkList.clear();
+                checkList.add(RtAnalogDataList.get(i).getUa());
+                checkList.add(RtAnalogDataList.get(i).getUb());
+                checkList.add(RtAnalogDataList.get(i).getUc());
+                //电压不平衡
+                Double VtBalunQ = checkBalun(checkList);
+                if (VtBalunQ<0.15){
+                    OverrunVtBalun ++;
+                }
+
+
+            }
+        }
+        singleLoopReportOneVo.setProportionUa(singleLoopReportOneVo.getMeasuringPoints()-OverrunUa+"/"+singleLoopReportOneVo.getMeasuringPoints());
+        singleLoopReportOneVo.setProportionUb(singleLoopReportOneVo.getMeasuringPoints()-OverrunUb+"/"+singleLoopReportOneVo.getMeasuringPoints());
+        singleLoopReportOneVo.setProportionUc(singleLoopReportOneVo.getMeasuringPoints()-OverrunUc+"/"+singleLoopReportOneVo.getMeasuringPoints());
+        singleLoopReportOneVo.setProportionF(singleLoopReportOneVo.getMeasuringPoints()-OverrunF+"/"+singleLoopReportOneVo.getMeasuringPoints());
+        singleLoopReportOneVo.setProportionElBalun(singleLoopReportOneVo.getMeasuringPoints()-OverrunElBalun+"/"+singleLoopReportOneVo.getMeasuringPoints());
+        singleLoopReportOneVo.setProportionVtBalun(singleLoopReportOneVo.getMeasuringPoints()-OverrunVtBalun+"/"+singleLoopReportOneVo.getMeasuringPoints());
+        singleLoopReportOneVo.setQrUa(OverrunUa==0?00.00: Double.valueOf(df.format(Double.valueOf(OverrunUa)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())*100)));
+        singleLoopReportOneVo.setQrUb(OverrunUb==0?00.00: Double.valueOf(df.format(Double.valueOf(OverrunUb)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())*100)));
+        singleLoopReportOneVo.setQrUc(OverrunUc==0?00.00: Double.valueOf(df.format(Double.valueOf(OverrunUc)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())*100)));
+        singleLoopReportOneVo.setQrF(OverrunF==0?00.00: Double.valueOf(df.format(Double.valueOf(OverrunF)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())*100)));
+        singleLoopReportOneVo.setQrElBalun(OverrunElBalun==0?00.00: Double.valueOf(df.format(Double.valueOf(OverrunElBalun)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints()))));
+        singleLoopReportOneVo.setQrVtBalun(OverrunVtBalun==0?00.00: Double.valueOf(df.format(Double.valueOf(OverrunVtBalun)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints()))));
+        singleLoopReportOneVo.setVoltageLevelToplimit(voltageLevel+voltageLevelWanting);
+        singleLoopReportOneVo.setVoltageLevelLowerLimit(voltageLevel-voltageLevelWanting);
+        singleLoopReportOneVo.setMhz(50.00);
+        singleLoopReportOneVo.setFToplimit(50.2);
+        singleLoopReportOneVo.setFLowerLimit(49.8);
+        singleLoopReportOneVo.setAppraise(0.85);
+        singleLoopReportOneVo.setBalanceToplimit(15.00);
+        singleLoopReportOneVo.setBalanceLowerLimit(15.00);
+        return singleLoopReportOneVo;
+    }
+
+    public Double VoltageQr(List<Double> checkList,Double voltageLevel){
+        Double max = checkList.stream().max(Double::compareTo).get();
+        Double min = checkList.stream().min(Double::compareTo).get();
+        Double wanting = Arith.sub(max, min);
+        Double QR = wanting / voltageLevel * 100;
+        return QR;
+    }
+
+    public Double checkBalun(List<Double> list) {
+        long count = list.stream().filter(code -> 0.00 == code).count();
+        if (3 == count) {
+            return 0.00;
+        }
+        Double max = list.stream().max(Double::compareTo).get();
+        Double min = list.stream().min(Double::compareTo).get();
+        return Arith.div(Arith.sub(max, min), max);
+    }
+
 }

+ 184 - 51
fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java

@@ -11,6 +11,7 @@ import com.bizmatics.common.core.util.*;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.common.spring.util.GlobalUtils;
 import com.bizmatics.model.*;
+import com.bizmatics.model.vo.EvaluationReporVo;
 import com.bizmatics.persistence.mapper.RtAnalogDataMapper;
 import com.bizmatics.service.DeviceAttributeService;
 import com.bizmatics.service.DeviceService;
@@ -29,6 +30,8 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -115,7 +118,7 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
             return "次";
         } else if (name.endsWith("电度") || name.endsWith("有功")) {
             return "KWh";
-        }else if (name.endsWith("THD")){
+        } else if (name.endsWith("THD")) {
             return "%";
         }
         return "";
@@ -123,13 +126,14 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
 
     @Override
     public List<Map<String, Object>> getOne(Integer siteId) {
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         List<Map<String, Object>> list = new ArrayList<>();
-        Map<String, Object> radMap = baseMapper.getOneMap(siteId);
+        Map<String, Object> radMap = baseMapper.getOneMap(userId,siteId);
         Optional.ofNullable(radMap).ifPresent(rad -> {
             for (String name : rad.keySet()) {
                 Map<String, Object> map = new HashMap<>();
                 map.put("name", name);
-                map.put("value",rad.get(name)+""+addUnitOne(name));
+                map.put("value", rad.get(name) + "" + addUnitOne(name));
                 list.add(map);
             }
         });
@@ -145,50 +149,50 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
     @Override
     public RealScoreVO realScore(String deviceCode) {
         LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(RtAnalogData::getDeviceName,deviceCode);
+        queryWrapper.eq(RtAnalogData::getDeviceName, deviceCode);
         RtAnalogData rtAnalogData = getOne(queryWrapper);
         Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在"));
         //查询设备
         LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
-        deviceQuery.eq(Device::getDeviceCode,deviceCode);
+        deviceQuery.eq(Device::getDeviceCode, deviceCode);
         Device device = deviceService.getOne(deviceQuery);
         Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
         //查询sd
         LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
-        sdQuery.eq(SiteDynamicProperties::getSiteId,device.getSiteId());
+        sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId());
         SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
         Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
         LambdaQueryWrapper<DeviceAttribute> adQuery = Wrappers.lambdaQuery();
-        adQuery.eq(DeviceAttribute::getSiteId,device.getSiteId());
+        adQuery.eq(DeviceAttribute::getSiteId, device.getSiteId());
         List<DeviceAttribute> deviceAttributes = deviceAttributeService.list(adQuery);
-        if (CollectionUtils.isEmpty(deviceAttributes)){
+        if (CollectionUtils.isEmpty(deviceAttributes)) {
             throw new BusinessException("da不存在");
         }
         DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get();
-        return  fillRealScoreData(rtAnalogData,siteDynamicProperties,deviceAttribute);
+        return fillRealScoreData(rtAnalogData, siteDynamicProperties, deviceAttribute);
     }
 
     @Override
     public RealScoreOneVO realScoreOne(String deviceCode) {
         LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(RtAnalogData::getDeviceName,deviceCode);
+        queryWrapper.eq(RtAnalogData::getDeviceName, deviceCode);
         RtAnalogData rtAnalogData = getOne(queryWrapper);
         Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在"));
         //查询设备
         LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
-        deviceQuery.eq(Device::getDeviceCode,deviceCode);
+        deviceQuery.eq(Device::getDeviceCode, deviceCode);
         Device device = deviceService.getOne(deviceQuery);
         Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
         //查询sd
         LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
-        sdQuery.eq(SiteDynamicProperties::getSiteId,device.getSiteId());
+        sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId());
         SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
         Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
-        return  fillRealScoreDataOne(rtAnalogData,siteDynamicProperties);
+        return fillRealScoreDataOne(rtAnalogData, siteDynamicProperties);
     }
 
     @Override
-    public RealScoreOneVO fillRealScoreDataOne(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties){
+    public RealScoreOneVO fillRealScoreDataOne(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties) {
         List<Double> checkList = new ArrayList<>();
         RealScoreOneVO realScoreVo = BeanMapperUtils.map(rtAnalogData, RealScoreOneVO.class);
 
@@ -205,14 +209,14 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         checkList.add(realScoreVo.getUc());
         //ABC三相电压占比
         Double max = checkList.stream().max(Double::compareTo).get();
-        if(max==0.00){
+        if (max == 0.00) {
             realScoreVo.setUaPercentage(0.00);
             realScoreVo.setUbPercentage(0.00);
             realScoreVo.setUcPercentage(0.00);
-        }else {
-            realScoreVo.setUaPercentage(Arith.div(realScoreVo.getUa(),(max/100*20+max)*100));
-            realScoreVo.setUbPercentage(Arith.div(realScoreVo.getUb(),(max/100*20+max)*100));
-            realScoreVo.setUcPercentage(Arith.div(realScoreVo.getUc(),(max/100*20+max)*100));
+        } else {
+            realScoreVo.setUaPercentage(Arith.div(realScoreVo.getUa(), (max / 100 * 20 + max) * 100));
+            realScoreVo.setUbPercentage(Arith.div(realScoreVo.getUb(), (max / 100 * 20 + max) * 100));
+            realScoreVo.setUcPercentage(Arith.div(realScoreVo.getUc(), (max / 100 * 20 + max) * 100));
         }
 
 
@@ -221,25 +225,25 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         //当前频率
         realScoreVo.setF(realScoreVo.getF());
         //频率偏差
-        if (realScoreVo.getF()==0.00){
+        if (realScoreVo.getF() == 0.00) {
             realScoreVo.setFdeviation(0.00);
-        }else {
+        } else {
             checkList.clear();
             checkList.add(50.00);
             checkList.add(realScoreVo.getF());
             Double max1 = checkList.stream().max(Double::compareTo).get();
             Double min1 = checkList.stream().min(Double::compareTo).get();
-            realScoreVo.setFdeviation(Arith.sub(max1,min1)/50*100);
+            realScoreVo.setFdeviation(Arith.sub(max1, min1) / 50 * 100);
         }
-        if (realScoreVo.getP()==0.00){
+        if (realScoreVo.getP() == 0.00) {
             realScoreVo.setPpercentage(0.00);
-        }else {
-            realScoreVo.setPpercentage(Arith.div(realScoreVo.getP(),realScoreVo.getP()/100*20+realScoreVo.getP()));
+        } else {
+            realScoreVo.setPpercentage(Arith.div(realScoreVo.getP(), realScoreVo.getP() / 100 * 20 + realScoreVo.getP()));
         }
-        if (realScoreVo.getQ()==0.00){
+        if (realScoreVo.getQ() == 0.00) {
             realScoreVo.setQpercentage(0.00);
-        }else {
-            realScoreVo.setQpercentage(Arith.div(realScoreVo.getQ(),realScoreVo.getQ()/100*20+realScoreVo.getQ()));
+        } else {
+            realScoreVo.setQpercentage(Arith.div(realScoreVo.getQ(), realScoreVo.getQ() / 100 * 20 + realScoreVo.getQ()));
         }
 
         realScoreVo.setVoltageLevel(siteDynamicProperties.getVoltageLevel());
@@ -250,11 +254,11 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
      * 填充实时数据
      */
     @Override
-    public RealScoreVO fillRealScoreData(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties,DeviceAttribute deviceAttribute){
+    public RealScoreVO fillRealScoreData(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties, DeviceAttribute deviceAttribute) {
         List<Double> checkList = new ArrayList<>();
         Integer score = 0;
         RealScoreVO realScoreVo = BeanMapperUtils.map(rtAnalogData, RealScoreVO.class);
-        if (null == realScoreVo.getCos()){
+        if (null == realScoreVo.getCos()) {
             realScoreVo.setCos(0.00);
         }
         checkList.add(realScoreVo.getIa());
@@ -271,13 +275,13 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         //电压合格率
         double voltageLevel = Double.parseDouble(siteDynamicProperties.getVoltageLevel());
         realScoreVo.setUaQualified(Arith.sub(rtAnalogData.getUa(), voltageLevel));
-        realScoreVo.setUbQualified(Arith.sub(rtAnalogData.getUb(),voltageLevel));
+        realScoreVo.setUbQualified(Arith.sub(rtAnalogData.getUb(), voltageLevel));
         realScoreVo.setUcQualified(Arith.sub(rtAnalogData.getUc(), voltageLevel));
         //电流负载率
         Double ratedCurrent = deviceAttribute.getRatedCurrent();
-        realScoreVo.setIaLoad(Arith.div(realScoreVo.getIa(),ratedCurrent));
-        realScoreVo.setIbLoad(Arith.div(realScoreVo.getIb(),ratedCurrent));
-        realScoreVo.setIcLoad(Arith.div(realScoreVo.getIc(),ratedCurrent));
+        realScoreVo.setIaLoad(Arith.div(realScoreVo.getIa(), ratedCurrent));
+        realScoreVo.setIbLoad(Arith.div(realScoreVo.getIb(), ratedCurrent));
+        realScoreVo.setIcLoad(Arith.div(realScoreVo.getIc(), ratedCurrent));
         //计算分数
         //电压分数
         realScoreVo.setUaQ(computeUScore(realScoreVo.getUaQualified(), voltageLevel));
@@ -285,34 +289,34 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         realScoreVo.setUcQ(computeUScore(realScoreVo.getUcQualified(), voltageLevel));
         if (realScoreVo.getUaQ() && realScoreVo.getUbQ() && realScoreVo.getUcQ()) {
             realScoreVo.setUQ(true);
-            score+=20;
-        }else {
+            score += 20;
+        } else {
             realScoreVo.setUQ(false);
         }
         //电流分数
         realScoreVo.setIaLoadQ(realScoreVo.getIaLoad() <= 0.8);
         realScoreVo.setIbLoadQ(realScoreVo.getIbLoad() <= 0.8);
         realScoreVo.setIcLoadQ(realScoreVo.getIcLoad() <= 0.8);
-        if (realScoreVo.getIaLoadQ() && realScoreVo.getIbLoadQ() && realScoreVo.getIcLoadQ()){
+        if (realScoreVo.getIaLoadQ() && realScoreVo.getIbLoadQ() && realScoreVo.getIcLoadQ()) {
             realScoreVo.setILoadQ(true);
-            score+=20;
-        }else {
+            score += 20;
+        } else {
             realScoreVo.setILoadQ(false);
         }
         //电压平衡分数
         realScoreVo.setElBalunQ(realScoreVo.getElBalun() <= 0.15);
-        if (realScoreVo.getElBalunQ()){
-            score+=20;
+        if (realScoreVo.getElBalunQ()) {
+            score += 20;
         }
         //电流平衡分数
         realScoreVo.setVtBalunQ(realScoreVo.getVtBalun() <= 0.15);
-        if (realScoreVo.getVtBalunQ()){
-            score+=20;
+        if (realScoreVo.getVtBalunQ()) {
+            score += 20;
         }
         //功率
         realScoreVo.setCosQ(realScoreVo.getCos() <= 0.15);
-        if (realScoreVo.getCosQ()){
-            score+=20;
+        if (realScoreVo.getCosQ()) {
+            score += 20;
         }
         realScoreVo.setScore(score);
         return realScoreVo;
@@ -320,11 +324,12 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
 
     /**
      * 计算电压分数
+     *
      * @return
      */
-    public Boolean computeUScore(Double qualified,Double voltageLevel){
+    public Boolean computeUScore(Double qualified, Double voltageLevel) {
         double mul = Arith.mul(qualified, voltageLevel);
-        if (mul <= 0.07 && mul >= -0.07){
+        if (mul <= 0.07 && mul >= -0.07) {
             return true;
         }
         return false;
@@ -333,17 +338,18 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
 
     /**
      * 计算电流/电压不平衡
+     *
      * @param list
      * @return
      */
-    public Double checkBalun(List<Double> list){
+    public Double checkBalun(List<Double> list) {
         long count = list.stream().filter(code -> 0.00 == code).count();
-        if (3 == count){
+        if (3 == count) {
             return 0.00;
         }
         Double max = list.stream().max(Double::compareTo).get();
         Double min = list.stream().min(Double::compareTo).get();
-        return Arith.div(Arith.sub(max,min),max);
+        return Arith.div(Arith.sub(max, min), max);
     }
 
     /**
@@ -836,6 +842,7 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
 
     @Override
     public String DataReportExport(Integer siteId, Date startTime, Date endTime, String queryType) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
         Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         Workbook workbook = null;
         File file = null;
@@ -1079,7 +1086,7 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
             workbook = ExcelExportUtil.exportExcel(params, colList, list);
 
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "数据报表", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "数据报表", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);
@@ -1095,6 +1102,132 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         return file.getName();
     }
 
+    public static Date getLastDayOfMonth(Date sDate1) {
+        Calendar cDay1 = Calendar.getInstance();
+        cDay1.setTime(sDate1);
+        final int lastDay = cDay1.getActualMaximum(Calendar.DAY_OF_MONTH);
+        Date lastDate = cDay1.getTime();
+        lastDate.setDate(lastDay);
+        return lastDate;
+    }
+
+
+
+
+    @Override
+    public List<RealScoreVO> evaluationReport(int siteId, Date time, int type) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
+        String startTime = null;
+        String endtime = null;
+        if (type == 1) {
+            startTime = sdf.format(time) + " 00:00:00";
+            endtime = sdf.format(time) + " 23:59:59";
+        } else {
+            startTime = sdf1.format(time) + "-01 00:00:00";
+            String time1 = sdf1.format(time) + "-01";
+            try {
+                Date yq = getLastDayOfMonth(sdf.parse(time1));
+                endtime = sdf.format(yq) + " 23:59:59";
+            } catch (Exception e) {
+                throw new BusinessException("时间错误");
+            }
+        }
+
+        List<EvaluationReporVo> evaluationReporVo = baseMapper.evaluationReportList(siteId, startTime, endtime);
+        return fillRealScoreDataTwo(evaluationReporVo);
+    }
+
+    /**
+     * 计算电压分数2
+     *
+     * @return
+     */
+    public Boolean computeUScoreOne(Double qualified, Double voltageLevel) {
+//        double mul = Arith.mul(qualified, voltageLevel);
+        Double voltageLevels = voltageLevel+(voltageLevel / 100 * 7);
+        Double voltageLevelx = voltageLevel-(voltageLevel / 100 * 7);
+        if (voltageLevelx <= qualified && voltageLevels >= qualified) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public List<RealScoreVO> fillRealScoreDataTwo(List<EvaluationReporVo> evaluationReporVo) {
+        List<RealScoreVO> realScoreVoList = new ArrayList<>();
+        if (evaluationReporVo.size() > 0) {
+            for (int i = 0; i < evaluationReporVo.size(); i++) {
+                List<Double> checkList = new ArrayList<>();
+                Integer score = 0;
+                RealScoreVO realScoreVo = BeanMapperUtils.map(evaluationReporVo.get(i), RealScoreVO.class);
+                if (null == realScoreVo.getCos()) {
+                    realScoreVo.setCos(0.00);
+                }
+                checkList.clear();
+                checkList.add(realScoreVo.getIa());
+                checkList.add(realScoreVo.getIb());
+                checkList.add(realScoreVo.getIc());
+                //电流不平衡
+                realScoreVo.setElBalun(checkBalun(checkList));
+                checkList.clear();
+                checkList.add(realScoreVo.getUa());
+                checkList.add(realScoreVo.getUb());
+                checkList.add(realScoreVo.getUc());
+                //电压不平衡
+                realScoreVo.setVtBalun(checkBalun(checkList));
+                //电压合格率
+                double voltageLevel = Double.parseDouble(evaluationReporVo.get(i).getVoltageLevel());
+                realScoreVo.setUaQualified(Arith.sub(evaluationReporVo.get(i).getUa(), voltageLevel));
+                realScoreVo.setUbQualified(Arith.sub(evaluationReporVo.get(i).getUb(), voltageLevel));
+                realScoreVo.setUcQualified(Arith.sub(evaluationReporVo.get(i).getUc(), voltageLevel));
+                //电流负载率
+                Double ratedCurrent = evaluationReporVo.get(i).getRatedCurrent();
+                realScoreVo.setIaLoad(Arith.div(realScoreVo.getIa(), ratedCurrent));
+                realScoreVo.setIbLoad(Arith.div(realScoreVo.getIb(), ratedCurrent));
+                realScoreVo.setIcLoad(Arith.div(realScoreVo.getIc(), ratedCurrent));
+                //计算分数
+                //电压分数
+                realScoreVo.setUaQ(computeUScoreOne(realScoreVo.getUa(), voltageLevel));
+                realScoreVo.setUbQ(computeUScoreOne(realScoreVo.getUb(), voltageLevel));
+                realScoreVo.setUcQ(computeUScoreOne(realScoreVo.getUc(), voltageLevel));
+                if (realScoreVo.getUaQ() && realScoreVo.getUbQ() && realScoreVo.getUcQ()) {
+                    realScoreVo.setUQ(true);
+                    score += 20;
+                } else {
+                    realScoreVo.setUQ(false);
+                }
+                //电流分数
+                realScoreVo.setIaLoadQ(realScoreVo.getIaLoad() <= 0.8);
+                realScoreVo.setIbLoadQ(realScoreVo.getIbLoad() <= 0.8);
+                realScoreVo.setIcLoadQ(realScoreVo.getIcLoad() <= 0.8);
+                if (realScoreVo.getIaLoadQ() && realScoreVo.getIbLoadQ() && realScoreVo.getIcLoadQ()) {
+                    realScoreVo.setILoadQ(true);
+                    score += 20;
+                } else {
+                    realScoreVo.setILoadQ(false);
+                }
+                //电压平衡分数
+                realScoreVo.setElBalunQ(realScoreVo.getElBalun() <= 0.15);
+                if (realScoreVo.getElBalunQ()) {
+                    score += 20;
+                }
+                //电流平衡分数
+                realScoreVo.setVtBalunQ(realScoreVo.getVtBalun() <= 0.15);
+                if (realScoreVo.getVtBalunQ()) {
+                    score += 20;
+                }
+                //功率
+                realScoreVo.setCosQ(realScoreVo.getCos() <= 0.15);
+                if (realScoreVo.getCosQ()) {
+                    score += 20;
+                }
+                realScoreVo.setScore(score);
+                realScoreVoList.add(realScoreVo);
+            }
+        }
+        return realScoreVoList;
+    }
 
 //    @Override
 //    public String DataReportExport(Integer siteId,Date startTime, Date endTime,String queryType){

+ 3 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/RtSwitchDataServiceImpl.java

@@ -6,6 +6,7 @@ import com.bizmatics.persistence.mapper.AlarmPowerMapper;
 import com.bizmatics.persistence.mapper.RtSwitchDataMapper;
 import com.bizmatics.service.RtSwitchDataService;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
+import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -25,8 +26,9 @@ public class RtSwitchDataServiceImpl extends AbstractCrudService<RtSwitchDataMap
 
     @Override
     public List<Map<String, Object>> getOne(Integer siteId) {
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         List<Map<String, Object>> list = new ArrayList<>();
-        Map<String, Object> rsdMap = baseMapper.getOneMap(siteId);
+        Map<String, Object> rsdMap = baseMapper.getOneMap(userId,siteId);
         Optional.ofNullable(rsdMap).ifPresent(rad -> {
             for (String name:rad.keySet()) {
                 Map<String,Object> map = new HashMap<>();

+ 4 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/SitedtlServiceImpl.java

@@ -26,6 +26,8 @@ import org.springframework.stereotype.Service;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -74,6 +76,7 @@ public class SitedtlServiceImpl extends AbstractCrudService<SitedtlMapper, Sited
 
     @Override
     public String variableListExport(Integer siteId, String electricTestOverdue) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
         Workbook workbook = null;
         File file = null;
         try {
@@ -85,7 +88,7 @@ public class SitedtlServiceImpl extends AbstractCrudService<SitedtlMapper, Sited
                         return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), SitedtlVo.class, SitedtlExportVO.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "现场档案", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "现场档案", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);

+ 5 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/UserServiceImpl.java

@@ -40,4 +40,9 @@ public class UserServiceImpl extends AbstractCrudService<UserMapper, User> imple
         user.setUserPassword(encoder.encode(user.getUserPassword()));
         baseMapper.insert(user);
     }
+
+    @Override
+    public User getUser(String userId){
+        return baseMapper.selectOne(Wrappers.lambdaQuery(User.class).eq(User::getCreator, userId).eq(User::getEnable,1));
+    }
 }

+ 2 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/WcBlackoutPlanServiceImpl.java

@@ -100,6 +100,7 @@ public class WcBlackoutPlanServiceImpl extends AbstractCrudService<WcBlackoutPla
 
     @Override
     public String outagePlanListExport(String startTime, String endTime, Integer type) {
+        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
         Workbook workbook = null;
         File file = null;
         try {
@@ -111,7 +112,7 @@ public class WcBlackoutPlanServiceImpl extends AbstractCrudService<WcBlackoutPla
                         return new ArrayList<>(BeanMapperUtils.mapList(plannedOutageList, WcBlackoutPlanOneVo.class, WcBlackoutPlanOneExportVo.class));
                     }, null);
             if (null != workbook) {
-                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "停电计划列表", System.currentTimeMillis() + ""));
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "停电计划列表", dFormat.format(System.currentTimeMillis()) + ""));
                 FileUtils.createFile(file.getAbsolutePath());
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);

+ 35 - 28
fiveep-service/src/main/java/com/bizmatics/service/system/ISysUserService.java

@@ -1,19 +1,19 @@
 package com.bizmatics.service.system;
 
+import com.bizmatics.model.UserSite;
 import com.bizmatics.model.system.SysUser;
 
 import java.util.List;
 
 /**
  * 用户 业务层
- * 
+ *
  * @author yq
  */
-public interface ISysUserService
-{
+public interface ISysUserService {
     /**
      * 根据条件分页查询用户列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
@@ -21,7 +21,7 @@ public interface ISysUserService
 
     /**
      * 根据条件分页查询已分配用户角色列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
@@ -29,7 +29,7 @@ public interface ISysUserService
 
     /**
      * 根据条件分页查询未分配用户角色列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
@@ -37,7 +37,7 @@ public interface ISysUserService
 
     /**
      * 通过用户名查询用户
-     * 
+     *
      * @param userName 用户名
      * @return 用户对象信息
      */
@@ -45,15 +45,18 @@ public interface ISysUserService
 
     /**
      * 通过用户ID查询用户
-     * 
+     *
      * @param userId 用户ID
      * @return 用户对象信息
      */
     public SysUser selectUserById(Long userId);
 
+
+    public List<UserSite> selectUserSiteById(Long userId);
+
     /**
      * 根据用户ID查询用户所属角色组
-     * 
+     *
      * @param userName 用户名
      * @return 结果
      */
@@ -61,7 +64,7 @@ public interface ISysUserService
 
     /**
      * 根据用户ID查询用户所属岗位组
-     * 
+     *
      * @param userName 用户名
      * @return 结果
      */
@@ -69,7 +72,7 @@ public interface ISysUserService
 
     /**
      * 校验用户名称是否唯一
-     * 
+     *
      * @param userName 用户名称
      * @return 结果
      */
@@ -93,22 +96,24 @@ public interface ISysUserService
 
     /**
      * 校验用户是否允许操作
-     * 
+     *
      * @param user 用户信息
      */
     public void checkUserAllowed(SysUser user);
 
     /**
      * 新增用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
     public int insertUser(SysUser user);
 
+    public void insertUserSite(int userId, int siteId);
+
     /**
      * 注册用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -116,7 +121,7 @@ public interface ISysUserService
 
     /**
      * 修改用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -124,15 +129,15 @@ public interface ISysUserService
 
     /**
      * 用户授权角色
-     * 
-     * @param userId 用户ID
+     *
+     * @param userId  用户ID
      * @param roleIds 角色组
      */
     public void insertUserAuth(Long userId, Long[] roleIds);
 
     /**
      * 修改用户状态
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -140,7 +145,7 @@ public interface ISysUserService
 
     /**
      * 修改用户基本信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -148,16 +153,16 @@ public interface ISysUserService
 
     /**
      * 修改用户头像
-     * 
+     *
      * @param userName 用户名
-     * @param avatar 头像地址
+     * @param avatar   头像地址
      * @return 结果
      */
     public boolean updateUserAvatar(String userName, String avatar);
 
     /**
      * 重置用户密码
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -165,7 +170,7 @@ public interface ISysUserService
 
     /**
      * 重置用户密码
-     * 
+     *
      * @param userName 用户名
      * @param password 密码
      * @return 结果
@@ -174,7 +179,7 @@ public interface ISysUserService
 
     /**
      * 通过用户ID删除用户
-     * 
+     *
      * @param userId 用户ID
      * @return 结果
      */
@@ -182,18 +187,20 @@ public interface ISysUserService
 
     /**
      * 批量删除用户信息
-     * 
+     *
      * @param userIds 需要删除的用户ID
      * @return 结果
      */
     public int deleteUserByIds(Long[] userIds);
 
+    public int deleteUserByIds(Long userId);
+
     /**
      * 导入用户数据
-     * 
-     * @param userList 用户数据列表
+     *
+     * @param userList        用户数据列表
      * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
-     * @param operName 操作用户
+     * @param operName        操作用户
      * @return 结果
      */
     public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);

+ 30 - 0
fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysPermissionService.java

@@ -1,11 +1,15 @@
 package com.bizmatics.service.system.impl;
 
+import com.bizmatics.common.core.util.StringUtils;
+import com.bizmatics.model.User;
 import com.bizmatics.model.system.SysUser;
+import com.bizmatics.service.UserService;
 import com.bizmatics.service.system.ISysMenuService;
 import com.bizmatics.service.system.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.lang.reflect.Field;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -23,6 +27,9 @@ public class SysPermissionService
     @Autowired
     private ISysMenuService menuService;
 
+    @Autowired
+    private UserService userService;
+
     /**
      * 获取角色数据权限
      * 
@@ -52,11 +59,15 @@ public class SysPermissionService
      */
     public Set<String> getMenuPermission(SysUser user)
     {
+
         Set<String> perms = new HashSet<String>();
+        User userData=userService.getUser(user.getUserId().toString());
         // 管理员拥有所有权限
         if (user.isAdmin())
         {
             perms.add("*:*:*");
+        }else if (!checkObjAllFieldsIsNull(userData)){
+            perms.add("*:*:*");
         }
         else
         {
@@ -64,4 +75,23 @@ public class SysPermissionService
         }
         return perms;
     }
+
+    public static boolean checkObjAllFieldsIsNull(Object object) {
+        if (null == object) {
+            return true;
+        }
+        try {
+            for (Field f : object.getClass().getDeclaredFields()) {
+                f.setAccessible(true);
+                System.out.print(f.getName() + ":");
+                System.out.println(f.get(object));
+                if (f.get(object) != null && StringUtils.isNotBlank(f.get(object).toString())) {
+                    return false;
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return true;
+    }
 }

+ 3 - 0
fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysRoleServiceImpl.java

@@ -13,6 +13,7 @@ import com.bizmatics.persistence.mapper.system.SysRoleMenuMapper;
 import com.bizmatics.persistence.mapper.system.SysUserRoleMapper;
 import com.bizmatics.service.aop.DataScope;
 import com.bizmatics.service.system.ISysRoleService;
+import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -48,6 +49,8 @@ public class SysRoleServiceImpl implements ISysRoleService
     @DataScope(deptAlias = "d")
     public List<SysRole> selectRoleList(SysRole role)
     {
+        String createByOne = SecurityUtils.getLoginUser().getUser().getUserName();
+        role.setCreateByOne(createByOne);
         return roleMapper.selectRoleList(role);
     }
 

+ 127 - 142
fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysUserServiceImpl.java

@@ -2,8 +2,10 @@ package com.bizmatics.service.system.impl;
 
 import com.bizmatics.common.core.exception.BusinessException;
 import com.bizmatics.common.core.util.StringUtils;
+import com.bizmatics.model.UserSite;
 import com.bizmatics.model.constants.UserConstants;
 import com.bizmatics.model.system.*;
+import com.bizmatics.persistence.mapper.UserSiteMapper;
 import com.bizmatics.persistence.mapper.system.*;
 import com.bizmatics.service.aop.DataScope;
 import com.bizmatics.service.system.ISysConfigService;
@@ -21,12 +23,11 @@ import java.util.Objects;
 
 /**
  * 用户 业务层处理
- * 
+ *
  * @author yq
  */
 @Service
-public class SysUserServiceImpl implements ISysUserService
-{
+public class SysUserServiceImpl implements ISysUserService {
     private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
 
     @Autowired
@@ -47,86 +48,94 @@ public class SysUserServiceImpl implements ISysUserService
     @Autowired
     private ISysConfigService configService;
 
+    @Autowired
+    private UserSiteMapper userSiteMapper;
     /**
      * 根据条件分页查询用户列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
     @Override
     @DataScope(deptAlias = "d", userAlias = "u")
-    public List<SysUser> selectUserList(SysUser user)
-    {
+    public List<SysUser> selectUserList(SysUser user) {
+        String createBy = SecurityUtils.getLoginUser().getUser().getUserName();
+        user.setCreateByOne(createBy);
         return userMapper.selectUserList(user);
     }
 
     /**
      * 根据条件分页查询已分配用户角色列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
     @Override
     @DataScope(deptAlias = "d", userAlias = "u")
-    public List<SysUser> selectAllocatedList(SysUser user)
-    {
+    public List<SysUser> selectAllocatedList(SysUser user) {
         return userMapper.selectAllocatedList(user);
     }
 
     /**
      * 根据条件分页查询未分配用户角色列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
     @Override
     @DataScope(deptAlias = "d", userAlias = "u")
-    public List<SysUser> selectUnallocatedList(SysUser user)
-    {
+    public List<SysUser> selectUnallocatedList(SysUser user) {
         return userMapper.selectUnallocatedList(user);
     }
 
     /**
      * 通过用户名查询用户
-     * 
+     *
      * @param userName 用户名
      * @return 用户对象信息
      */
     @Override
-    public SysUser selectUserByUserName(String userName)
-    {
+    public SysUser selectUserByUserName(String userName) {
         return userMapper.selectUserByUserName(userName);
     }
 
     /**
      * 通过用户ID查询用户
-     * 
+     *
      * @param userId 用户ID
      * @return 用户对象信息
      */
     @Override
-    public SysUser selectUserById(Long userId)
-    {
+    public SysUser selectUserById(Long userId) {
         return userMapper.selectUserById(userId);
     }
 
+    /**
+     * 通过用户ID查询用户站点关联表
+     *
+     * @param userId 用户ID
+     * @return 用户对象信息
+     */
+    @Override
+    public List<UserSite> selectUserSiteById(Long userId) {
+        List<UserSite> userSiteList = userSiteMapper.selectUserSiteById(userId);
+        return userSiteList;
+    }
+
     /**
      * 查询用户所属角色组
-     * 
+     *
      * @param userName 用户名
      * @return 结果
      */
     @Override
-    public String selectUserRoleGroup(String userName)
-    {
+    public String selectUserRoleGroup(String userName) {
         List<SysRole> list = roleMapper.selectRolesByUserName(userName);
         StringBuffer idsStr = new StringBuffer();
-        for (SysRole role : list)
-        {
+        for (SysRole role : list) {
             idsStr.append(role.getRoleName()).append(",");
         }
-        if (StringUtils.isNotBlank(idsStr.toString()))
-        {
+        if (StringUtils.isNotBlank(idsStr.toString())) {
             return idsStr.substring(0, idsStr.length() - 1);
         }
         return idsStr.toString();
@@ -134,21 +143,18 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 查询用户所属岗位组
-     * 
+     *
      * @param userName 用户名
      * @return 结果
      */
     @Override
-    public String selectUserPostGroup(String userName)
-    {
+    public String selectUserPostGroup(String userName) {
         List<SysPost> list = postMapper.selectPostsByUserName(userName);
         StringBuffer idsStr = new StringBuffer();
-        for (SysPost post : list)
-        {
+        for (SysPost post : list) {
             idsStr.append(post.getPostName()).append(",");
         }
-        if (StringUtils.isNotEmpty(idsStr.toString()))
-        {
+        if (StringUtils.isNotEmpty(idsStr.toString())) {
             return idsStr.substring(0, idsStr.length() - 1);
         }
         return idsStr.toString();
@@ -156,16 +162,14 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 校验用户名称是否唯一
-     * 
+     *
      * @param userName 用户名称
      * @return 结果
      */
     @Override
-    public String checkUserNameUnique(String userName)
-    {
+    public String checkUserNameUnique(String userName) {
         int count = userMapper.checkUserNameUnique(userName);
-        if (count > 0)
-        {
+        if (count > 0) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -178,12 +182,10 @@ public class SysUserServiceImpl implements ISysUserService
      * @return
      */
     @Override
-    public String checkPhoneUnique(SysUser user)
-    {
+    public String checkPhoneUnique(SysUser user) {
         Long userId = Objects.isNull(user.getUserId()) ? -1L : user.getUserId();
         SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
-        if (Objects.nonNull(info) && info.getUserId().longValue() != userId.longValue())
-        {
+        if (Objects.nonNull(info) && info.getUserId().longValue() != userId.longValue()) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -196,12 +198,10 @@ public class SysUserServiceImpl implements ISysUserService
      * @return
      */
     @Override
-    public String checkEmailUnique(SysUser user)
-    {
+    public String checkEmailUnique(SysUser user) {
         Long userId = Objects.isNull(user.getUserId()) ? -1L : user.getUserId();
         SysUser info = userMapper.checkEmailUnique(user.getEmail());
-        if (Objects.nonNull(info) && info.getUserId().longValue() != userId.longValue())
-        {
+        if (Objects.nonNull(info) && info.getUserId().longValue() != userId.longValue()) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -209,28 +209,25 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 校验用户是否允许操作
-     * 
+     *
      * @param user 用户信息
      */
     @Override
-    public void checkUserAllowed(SysUser user)
-    {
-        if (Objects.nonNull(user.getUserId()) && user.isAdmin())
-        {
+    public void checkUserAllowed(SysUser user) {
+        if (Objects.nonNull(user.getUserId()) && user.isAdmin()) {
             throw new BusinessException("不允许操作超级管理员用户");
         }
     }
 
     /**
      * 新增保存用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
     @Override
     @Transactional
-    public int insertUser(SysUser user)
-    {
+    public int insertUser(SysUser user) {
         // 新增用户信息
         int rows = userMapper.insertUser(user);
         // 新增用户岗位关联
@@ -240,28 +237,39 @@ public class SysUserServiceImpl implements ISysUserService
         return rows;
     }
 
+    /**
+     * 用户点位关联表
+     *
+     * @param userId 用户ID
+     * @param siteId 站点ID
+     */
+    @Override
+    @Transactional
+    public void insertUserSite(int userId, int siteId) {
+        // 新增用户站点
+        userSiteMapper.insertUserSite(null, userId, siteId);
+    }
+
     /**
      * 注册用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
     @Override
-    public boolean registerUser(SysUser user)
-    {
+    public boolean registerUser(SysUser user) {
         return userMapper.insertUser(user) > 0;
     }
 
     /**
      * 修改保存用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
     @Override
     @Transactional
-    public int updateUser(SysUser user)
-    {
+    public int updateUser(SysUser user) {
         Long userId = user.getUserId();
         // 删除用户与角色关联
         userRoleMapper.deleteUserRoleByUserId(userId);
@@ -276,101 +284,91 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 用户授权角色
-     * 
-     * @param userId 用户ID
+     *
+     * @param userId  用户ID
      * @param roleIds 角色组
      */
     @Override
     @Transactional
-    public void insertUserAuth(Long userId, Long[] roleIds)
-    {
+    public void insertUserAuth(Long userId, Long[] roleIds) {
         userRoleMapper.deleteUserRoleByUserId(userId);
         insertUserRole(userId, roleIds);
     }
 
     /**
      * 修改用户状态
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
     @Override
-    public int updateUserStatus(SysUser user)
-    {
+    public int updateUserStatus(SysUser user) {
         return userMapper.updateUser(user);
     }
 
     /**
      * 修改用户基本信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
     @Override
-    public int updateUserProfile(SysUser user)
-    {
+    public int updateUserProfile(SysUser user) {
         return userMapper.updateUser(user);
     }
 
     /**
      * 修改用户头像
-     * 
+     *
      * @param userName 用户名
-     * @param avatar 头像地址
+     * @param avatar   头像地址
      * @return 结果
      */
     @Override
-    public boolean updateUserAvatar(String userName, String avatar)
-    {
+    public boolean updateUserAvatar(String userName, String avatar) {
         return userMapper.updateUserAvatar(userName, avatar) > 0;
     }
 
     /**
      * 重置用户密码
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
     @Override
-    public int resetPwd(SysUser user)
-    {
+    public int resetPwd(SysUser user) {
         return userMapper.updateUser(user);
     }
 
     /**
      * 重置用户密码
-     * 
+     *
      * @param userName 用户名
      * @param password 密码
      * @return 结果
      */
     @Override
-    public int resetUserPwd(String userName, String password)
-    {
+    public int resetUserPwd(String userName, String password) {
         return userMapper.resetUserPwd(userName, password);
     }
 
     /**
      * 新增用户角色信息
-     * 
+     *
      * @param user 用户对象
      */
-    public void insertUserRole(SysUser user)
-    {
+    public void insertUserRole(SysUser user) {
         Long[] roles = user.getRoleIds();
-        if (Objects.nonNull(roles))
-        {
+        if (Objects.nonNull(roles)) {
             // 新增用户与角色管理
             List<SysUserRole> list = new ArrayList<SysUserRole>();
-            for (Long roleId : roles)
-            {
+            for (Long roleId : roles) {
                 SysUserRole ur = new SysUserRole();
                 ur.setUserId(user.getUserId());
                 ur.setRoleId(roleId);
                 list.add(ur);
             }
-            if (list.size() > 0)
-            {
+            if (list.size() > 0) {
                 userRoleMapper.batchUserRole(list);
             }
         }
@@ -378,25 +376,21 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 新增用户岗位信息
-     * 
+     *
      * @param user 用户对象
      */
-    public void insertUserPost(SysUser user)
-    {
+    public void insertUserPost(SysUser user) {
         Long[] posts = user.getPostIds();
-        if (Objects.nonNull(posts))
-        {
+        if (Objects.nonNull(posts)) {
             // 新增用户与岗位管理
             List<SysUserPost> list = new ArrayList<SysUserPost>();
-            for (Long postId : posts)
-            {
+            for (Long postId : posts) {
                 SysUserPost up = new SysUserPost();
                 up.setUserId(user.getUserId());
                 up.setPostId(postId);
                 list.add(up);
             }
-            if (list.size() > 0)
-            {
+            if (list.size() > 0) {
                 userPostMapper.batchUserPost(list);
             }
         }
@@ -404,25 +398,21 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 新增用户角色信息
-     * 
-     * @param userId 用户ID
+     *
+     * @param userId  用户ID
      * @param roleIds 角色组
      */
-    public void insertUserRole(Long userId, Long[] roleIds)
-    {
-        if (Objects.nonNull(roleIds))
-        {
+    public void insertUserRole(Long userId, Long[] roleIds) {
+        if (Objects.nonNull(roleIds)) {
             // 新增用户与角色管理
             List<SysUserRole> list = new ArrayList<SysUserRole>();
-            for (Long roleId : roleIds)
-            {
+            for (Long roleId : roleIds) {
                 SysUserRole ur = new SysUserRole();
                 ur.setUserId(userId);
                 ur.setRoleId(roleId);
                 list.add(ur);
             }
-            if (list.size() > 0)
-            {
+            if (list.size() > 0) {
                 userRoleMapper.batchUserRole(list);
             }
         }
@@ -430,14 +420,13 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 通过用户ID删除用户
-     * 
+     *
      * @param userId 用户ID
      * @return 结果
      */
     @Override
     @Transactional
-    public int deleteUserById(Long userId)
-    {
+    public int deleteUserById(Long userId) {
         // 删除用户与角色关联
         userRoleMapper.deleteUserRoleByUserId(userId);
         // 删除用户与岗位表
@@ -447,16 +436,14 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 批量删除用户信息
-     * 
+     *
      * @param userIds 需要删除的用户ID
      * @return 结果
      */
     @Override
     @Transactional
-    public int deleteUserByIds(Long[] userIds)
-    {
-        for (Long userId : userIds)
-        {
+    public int deleteUserByIds(Long[] userIds) {
+        for (Long userId : userIds) {
             checkUserAllowed(new SysUser(userId));
         }
         // 删除用户与角色关联
@@ -466,19 +453,29 @@ public class SysUserServiceImpl implements ISysUserService
         return userMapper.deleteUserByIds(userIds);
     }
 
+    /**
+     * 批量删除用户站点关联表数据
+     *
+     * @param userId 需要删除的用户ID
+     * @return 结果
+     */
+    @Override
+    @Transactional
+    public int deleteUserByIds(Long userId) {
+        return userSiteMapper.deleteUserSiteById(userId);
+    }
+
     /**
      * 导入用户数据
-     * 
-     * @param userList 用户数据列表
+     *
+     * @param userList        用户数据列表
      * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
-     * @param operName 操作用户
+     * @param operName        操作用户
      * @return 结果
      */
     @Override
-    public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
-    {
-        if (Objects.isNull(userList) || userList.size() == 0)
-        {
+    public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
+        if (Objects.isNull(userList) || userList.size() == 0) {
             throw new BusinessException("导入用户数据不能为空!");
         }
         int successNum = 0;
@@ -486,48 +483,36 @@ public class SysUserServiceImpl implements ISysUserService
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
         String password = configService.selectConfigByKey("sys.user.initPassword");
-        for (SysUser user : userList)
-        {
-            try
-            {
+        for (SysUser user : userList) {
+            try {
                 // 验证是否存在这个用户
                 SysUser u = userMapper.selectUserByUserName(user.getUserName());
-                if (Objects.isNull(u))
-                {
+                if (Objects.isNull(u)) {
                     user.setPassword(SecurityUtils.encryptPassword(password));
                     user.setCreateBy(operName);
                     this.insertUser(user);
                     successNum++;
                     successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
-                }
-                else if (isUpdateSupport)
-                {
+                } else if (isUpdateSupport) {
                     user.setUpdateBy(operName);
                     this.updateUser(user);
                     successNum++;
                     successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
-                }
-                else
-                {
+                } else {
                     failureNum++;
                     failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
                 }
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
                 failureNum++;
                 String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
                 failureMsg.append(msg + e.getMessage());
                 log.error(msg, e);
             }
         }
-        if (failureNum > 0)
-        {
+        if (failureNum > 0) {
             failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
             throw new BusinessException(failureMsg.toString());
-        }
-        else
-        {
+        } else {
             successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
         }
         return successMsg.toString();

+ 10 - 0
fiveep-service/src/main/java/com/bizmatics/service/vo/RealScoreVO.java

@@ -12,6 +12,16 @@ import java.util.Date;
 @Data
 public class RealScoreVO {
 
+    /**
+     * 设备编号
+     */
+    private String deviceCode;
+
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+
     /**
      * A相电流
      */