From 655e7960bc6ceeea9f9252becb7e0cc5fd267c40 Mon Sep 17 00:00:00 2001 From: wj <347312259@qq.com> Date: Thu, 11 May 2023 16:31:12 +0800 Subject: [PATCH 1/8] 11 --- psdc-ui/src/views/analyse/nhfx/index.vue | 10 +- psdc-ui/src/views/analyse/nhtj/index.vue | 300 ++++++++++++++++++++- psdc-ui/src/views/bigview/index.vue | 19 +- psdc-ui/src/views/control/manual/index.vue | 123 +++++++-- psdc-ui/src/views/control/timer/index.vue | 226 +++++++++++++++- 5 files changed, 643 insertions(+), 35 deletions(-) diff --git a/psdc-ui/src/views/analyse/nhfx/index.vue b/psdc-ui/src/views/analyse/nhfx/index.vue index a89cb93..8e60d74 100644 --- a/psdc-ui/src/views/analyse/nhfx/index.vue +++ b/psdc-ui/src/views/analyse/nhfx/index.vue @@ -1,10 +1,18 @@ diff --git a/psdc-ui/src/views/bigview/index.vue b/psdc-ui/src/views/bigview/index.vue index 4036821..43cd513 100644 --- a/psdc-ui/src/views/bigview/index.vue +++ b/psdc-ui/src/views/bigview/index.vue @@ -2,7 +2,7 @@

电能替代分布式控制试验平台

- 返回后台 + 返回后台
@@ -149,14 +149,15 @@ // import {ref,reactive} from 'vue' import {getTemperature} from '../../api/bigview/bigview' -// getWendu(); +getWendu(); -// const wendi1 = ref(0) -// function getWendu(){ -// getTemperature().then((res)=>{ -// console.log(res.data.data) -// }) -// } +const wendi1 = ref(0) +function getWendu(){ + console.log('请求接口') + getTemperature().then((res)=>{ + console.log(res.data) + }) +} @@ -281,7 +282,7 @@ import {getTemperature} from '../../api/bigview/bigview' .my3D_img{ width: 100%; height: 100%; - padding: 20px 60px 0 60px; + padding: 20px 70px 0 70px; img{ width: 100%; height: 100%; diff --git a/psdc-ui/src/views/control/manual/index.vue b/psdc-ui/src/views/control/manual/index.vue index 45619ba..d00109d 100644 --- a/psdc-ui/src/views/control/manual/index.vue +++ b/psdc-ui/src/views/control/manual/index.vue @@ -1,6 +1,6 @@ @@ -284,9 +346,9 @@ const onSubmit3 = () => { } } .control_table{ + position: relative; width: 100%; height: 90%; - border: 1px solid red; } } } @@ -306,5 +368,20 @@ const onSubmit3 = () => { ::v-deep .el-input__inner{ color: #f3ffff; } +::v-deep .el-pagination{ + position: absolute; + bottom: 10px; + left: 50%; + transform: translateX(-50%); +} +::v-deep .el-pagination__total{ + color: #f3ffff; +} +::v-deep .el-pagination__jump{ + color: #f3ffff; +} +::v-deep .el-pager{ + margin: 0 5px; +} diff --git a/psdc-ui/src/views/control/timer/index.vue b/psdc-ui/src/views/control/timer/index.vue index 1db90ce..916a378 100644 --- a/psdc-ui/src/views/control/timer/index.vue +++ b/psdc-ui/src/views/control/timer/index.vue @@ -1,16 +1,240 @@ From b3f86390d4bfad2cb5ad00dc179533f773ba5bb0 Mon Sep 17 00:00:00 2001 From: jiminglei <836545853@qq.com> Date: Thu, 11 May 2023 16:39:40 +0800 Subject: [PATCH 2/8] 11 --- psdc-ui/src/views/emonitor/db/index.vue | 180 +++++++++++++++- psdc-ui/src/views/emonitor/drgl/index.vue | 32 ++- psdc-ui/src/views/emonitor/frdl/index.vue | 224 +++++++++++++++++-- psdc-ui/src/views/emonitor/kqyrb/index.vue | 239 +++++++++++++++++++-- psdc-ui/src/views/emonitor/wdcgq/index.vue | 73 ++++++- psdc-ui/src/views/emonitor/xrgl/index.vue | 239 +++++++++++++++++++-- 6 files changed, 923 insertions(+), 64 deletions(-) diff --git a/psdc-ui/src/views/emonitor/db/index.vue b/psdc-ui/src/views/emonitor/db/index.vue index f49338e..f48ef9e 100644 --- a/psdc-ui/src/views/emonitor/db/index.vue +++ b/psdc-ui/src/views/emonitor/db/index.vue @@ -35,17 +35,13 @@
当前功率
-
- pic -
+
当前功率总览
-
- pic -
+
@@ -53,16 +49,178 @@
今日用电量总览
-
- pic -
+
- diff --git a/psdc-ui/src/views/emonitor/drgl/index.vue b/psdc-ui/src/views/emonitor/drgl/index.vue index a660c78..9a84059 100644 --- a/psdc-ui/src/views/emonitor/drgl/index.vue +++ b/psdc-ui/src/views/emonitor/drgl/index.vue @@ -95,6 +95,7 @@ export default { }, yAxis: { type: 'value', + name: "kWh", splitLine:{ show:true, lineStyle:{ @@ -112,7 +113,7 @@ export default { }, series: [ { - name: "用户量", + name: "日用电量", type: "bar", data: [5, 20, 36, 10, 10, 20], itemStyle:{ @@ -141,6 +142,7 @@ export default { }, yAxis: { type: 'value', + name: "kWh", splitLine:{ show:true, lineStyle:{ @@ -158,7 +160,7 @@ export default { }, series: [ { - name: "用户量", + name: "月用电量", type: "bar", data: [5, 20, 36, 10, 10, 20], itemStyle:{ @@ -187,6 +189,7 @@ export default { }, yAxis: { type: 'value', + name: "kW", splitLine:{ show:true, lineStyle:{ @@ -204,7 +207,7 @@ export default { }, series: [ { - name: "用户量", + name: "当前功率", type: "line", data: [5, 20, 36, 10, 10, 20], itemStyle:{ @@ -219,6 +222,12 @@ export default { myChart4.setOption({ title: {}, tooltip: {}, + legend: { + data: ['进水', '出水'], + textStyle:{ + color:'#BEC3DA' + } + }, textStyle:{ color:'#BEC3DA' }, @@ -233,6 +242,7 @@ export default { }, yAxis: { type: 'value', + name: "℃", splitLine:{ show:true, lineStyle:{ @@ -250,12 +260,22 @@ export default { }, series: [ { - name: "用户量", - type: "line", - data: [5, 20, 36, 10, 10, 20], + name: '进水', + type: 'line', + stack: 'Total', + itemStyle:{ + color:'#2F8EE0' + }, + data: [120, 132, 101, 134, 90, 230, 210] + }, + { + name: '出水', + type: 'line', + stack: 'Total', itemStyle:{ color:'#2F8EE0' }, + data: [220, 182, 191, 234, 290, 330, 310] }, ], }); diff --git a/psdc-ui/src/views/emonitor/frdl/index.vue b/psdc-ui/src/views/emonitor/frdl/index.vue index b76f813..a14818e 100644 --- a/psdc-ui/src/views/emonitor/frdl/index.vue +++ b/psdc-ui/src/views/emonitor/frdl/index.vue @@ -38,40 +38,236 @@
日用电量
-
- pic -
+
月用电量
-
- pic -
+
当前功率
-
- pic -
+
当前温度
-
- pic -
+
- diff --git a/psdc-ui/src/views/emonitor/kqyrb/index.vue b/psdc-ui/src/views/emonitor/kqyrb/index.vue index d6f00b6..3dcb56c 100644 --- a/psdc-ui/src/views/emonitor/kqyrb/index.vue +++ b/psdc-ui/src/views/emonitor/kqyrb/index.vue @@ -42,40 +42,251 @@
日用电量
-
- pic -
+
月用电量
-
- pic -
+
当前功率
-
- pic -
+
当前温度
-
- pic -
+
- diff --git a/psdc-ui/src/views/emonitor/wdcgq/index.vue b/psdc-ui/src/views/emonitor/wdcgq/index.vue index e6a39cb..289628b 100644 --- a/psdc-ui/src/views/emonitor/wdcgq/index.vue +++ b/psdc-ui/src/views/emonitor/wdcgq/index.vue @@ -64,16 +64,79 @@
实时温度总览
-
- pic -
+
- diff --git a/psdc-ui/src/views/emonitor/xrgl/index.vue b/psdc-ui/src/views/emonitor/xrgl/index.vue index d6f00b6..b9f77d5 100644 --- a/psdc-ui/src/views/emonitor/xrgl/index.vue +++ b/psdc-ui/src/views/emonitor/xrgl/index.vue @@ -42,40 +42,251 @@
日用电量
-
- pic -
+
月用电量
-
- pic -
+
当前功率
-
- pic -
+
当前温度
-
- pic -
+
- From 46f117ee4c4c76d4b1f04600b474aa78f8eebe2e Mon Sep 17 00:00:00 2001 From: XMnhwj_BackTechnologyDevelopment <3512363680@qq.com> Date: Thu, 11 May 2023 17:24:20 +0800 Subject: [PATCH 3/8] =?UTF-8?q?2023-05-11=2017:23:36=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86=E7=9A=84=E5=A2=9E=E3=80=81?= =?UTF-8?q?=E5=88=A0=E3=80=81=E6=94=B9=E3=80=81=E6=9F=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/psdc/entity/PsdcDevice.java | 2 +- .../com/psdc/mapper/PsdcDeviceMapper.java | 9 +- .../com/psdc/service/IPsdcDeviceService.java | 16 +- .../service/impl/PsdcDeviceServiceImpl.java | 21 +- .../mapper/business/PsdcDeviceMapper.xml | 10 +- .../java/com/psdc/mapper/SysUserMapper.java | 4 +- .../psdc/service/impl/SysUserServiceImpl.java | 201 +++++++----------- .../resources/mapper/system/SysUserMapper.xml | 7 + .../manager/PsdcDeviceController.java | 96 +++++++++ 9 files changed, 219 insertions(+), 147 deletions(-) create mode 100644 psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java diff --git a/psdc-business/src/main/java/com/psdc/entity/PsdcDevice.java b/psdc-business/src/main/java/com/psdc/entity/PsdcDevice.java index b7bc197..2b1e570 100644 --- a/psdc-business/src/main/java/com/psdc/entity/PsdcDevice.java +++ b/psdc-business/src/main/java/com/psdc/entity/PsdcDevice.java @@ -33,7 +33,7 @@ public class PsdcDevice { /** 安装地址 */ private String deviceAddress ; /** 启用时间 */ - private Date startTime ; + private String startTime ; /** 设备状态:1-未激活,2-禁用,3-在线,4-离线 */ private Integer deviceStatus ; /** 图片地址 */ diff --git a/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java b/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java index 2ed5229..f52cab9 100644 --- a/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java +++ b/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java @@ -36,10 +36,9 @@ public interface PsdcDeviceMapper{ * 分页查询指定行数据 * * @param psdcDevice 查询条件 - * @param pageable 分页对象 * @return 对象列表 */ - List queryAllByLimit(PsdcDevice psdcDevice, @Param("pageable") Pageable pageable); + List queryAllByLimit(PsdcDevice psdcDevice); /** * 统计总行数 * @@ -64,10 +63,10 @@ public interface PsdcDeviceMapper{ /** * 通过主键删除数据 * - * @param deviceId 主键 + * @param deviceIds 主键 * @return 影响行数 */ - int deleteById(Integer deviceId); + int deleteById(@Param(value = "deviceIds") Long[] deviceIds); /** * 根据用户id查询设备 @@ -82,5 +81,5 @@ public interface PsdcDeviceMapper{ * @return */ int updateDevRunStatusByDevId(@Param(value = "deviceId") Integer deviceId, - @Param(value = "runStatus") Integer runStatus); + @Param(value = "runStatus") Integer runStatus); } \ No newline at end of file diff --git a/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java b/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java index f392c0f..22e4d30 100644 --- a/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java +++ b/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java @@ -38,7 +38,15 @@ public interface IPsdcDeviceService { * @param psdcDevice 实例对象 * @return 实例对象 */ - PsdcDevice insert(PsdcDevice psdcDevice); + Integer insert(PsdcDevice psdcDevice); + + /** + * 分页查询指定行数据 + * + * @param psdcDevice 查询条件 + * @return 对象列表 + */ + List queryAllByLimit(PsdcDevice psdcDevice); /** * 更新数据 @@ -46,14 +54,14 @@ public interface IPsdcDeviceService { * @param psdcDevice 实例对象 * @return 实例对象 */ - PsdcDevice update(PsdcDevice psdcDevice); + Integer update(PsdcDevice psdcDevice); /** * 通过主键删除数据 * - * @param deviceId 主键 + * @param deviceIds 主键 * @return 是否成功 */ - boolean deleteById(Integer deviceId); + boolean deleteById(Long[] deviceIds); /** * 更新设备状态 diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java index d81fc2d..f5529da 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java @@ -70,9 +70,13 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService{ * @param psdcDevice 实例对象 * @return 实例对象 */ - public PsdcDevice insert(PsdcDevice psdcDevice){ - psdcDeviceMapper.insert(psdcDevice); - return psdcDevice; + public Integer insert(PsdcDevice psdcDevice){ + return psdcDeviceMapper.insert(psdcDevice); + } + + @Override + public List queryAllByLimit(PsdcDevice psdcDevice) { + return psdcDeviceMapper.queryAllByLimit(psdcDevice); } /** @@ -81,19 +85,18 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService{ * @param psdcDevice 实例对象 * @return 实例对象 */ - public PsdcDevice update(PsdcDevice psdcDevice){ - psdcDeviceMapper.update(psdcDevice); - return queryById(psdcDevice.getDeviceId()); + public Integer update(PsdcDevice psdcDevice){ + return psdcDeviceMapper.update(psdcDevice); } /** * 通过主键删除数据 * - * @param deviceId 主键 + * @param deviceIds 主键 * @return 是否成功 */ - public boolean deleteById(Integer deviceId){ - int total = psdcDeviceMapper.deleteById(deviceId); + public boolean deleteById(Long[] deviceIds){ + int total = psdcDeviceMapper.deleteById(deviceIds); return total > 0; } diff --git a/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml index 2ed7128..eea3970 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml @@ -145,7 +145,6 @@ and update_time = #{updateTime} - limit #{pageable.offset}, #{pageable.pageSize} @@ -249,7 +248,7 @@ device_status = #{deviceStatus}, - and device_runstatus = #{deviceRunstatus} + device_runstatus = #{deviceRunstatus}, photo_url = #{photoUrl}, @@ -263,7 +262,7 @@ update_by = #{updateBy}, - + update_time = #{updateTime}, @@ -272,7 +271,10 @@ - delete from psdc_device where device_id = #{deviceId} + delete from psdc_device where device_id in + + #{id} + diff --git a/psdc-system/src/main/java/com/psdc/mapper/SysUserMapper.java b/psdc-system/src/main/java/com/psdc/mapper/SysUserMapper.java index 0393f82..6d3e5b7 100644 --- a/psdc-system/src/main/java/com/psdc/mapper/SysUserMapper.java +++ b/psdc-system/src/main/java/com/psdc/mapper/SysUserMapper.java @@ -19,7 +19,9 @@ public interface SysUserMapper * @param sysUser 用户信息 * @return 用户信息集合信息 */ - public List selectUserList(SysUser sysUser); + List selectUserList(SysUser sysUser); + + List selectUserList2(); /** * 根据条件分页查询已配用户角色列表 diff --git a/psdc-system/src/main/java/com/psdc/service/impl/SysUserServiceImpl.java b/psdc-system/src/main/java/com/psdc/service/impl/SysUserServiceImpl.java index da2e339..54ac623 100644 --- a/psdc-system/src/main/java/com/psdc/service/impl/SysUserServiceImpl.java +++ b/psdc-system/src/main/java/com/psdc/service/impl/SysUserServiceImpl.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import javax.validation.Validator; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -27,12 +28,11 @@ import com.psdc.service.ISysUserService; /** * 用户 业务层处理 - * + * * @author */ @Service -public class SysUserServiceImpl implements ISysUserService -{ +public class SysUserServiceImpl implements ISysUserService { private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); @Autowired @@ -52,76 +52,72 @@ public class SysUserServiceImpl implements ISysUserService /** * 根据条件分页查询用户列表 - * + * * @param user 用户信息 * @return 用户信息集合信息 */ @Override - public List selectUserList(SysUser user) - { + public List selectUserList(SysUser user) { + if (null == user){ + return userMapper.selectUserList2(); + } return userMapper.selectUserList(user); } /** * 根据条件分页查询已分配用户角色列表 - * + * * @param user 用户信息 * @return 用户信息集合信息 */ @Override - public List selectAllocatedList(SysUser user) - { + public List selectAllocatedList(SysUser user) { return userMapper.selectAllocatedList(user); } /** * 根据条件分页查询未分配用户角色列表 - * + * * @param user 用户信息 * @return 用户信息集合信息 */ @Override - public List selectUnallocatedList(SysUser user) - { + public List 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); } /** * 查询用户所属角色组 - * + * * @param userName 用户名 * @return 结果 */ @Override - public String selectUserRoleGroup(String userName) - { + public String selectUserRoleGroup(String userName) { List list = roleMapper.selectRolesByUserName(userName); - if (CollectionUtils.isEmpty(list)) - { + if (CollectionUtils.isEmpty(list)) { return StringUtils.EMPTY; } return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(",")); @@ -130,17 +126,15 @@ public class SysUserServiceImpl implements ISysUserService /** * 校验用户名称是否唯一 - * + * * @param user 用户信息 * @return 结果 */ @Override - public boolean checkUserNameUnique(SysUser user) - { + public boolean checkUserNameUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkUserNameUnique(user.getUserName()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -153,12 +147,10 @@ public class SysUserServiceImpl implements ISysUserService * @return */ @Override - public boolean checkPhoneUnique(SysUser user) - { + public boolean checkPhoneUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -171,12 +163,10 @@ public class SysUserServiceImpl implements ISysUserService * @return */ @Override - public boolean checkEmailUnique(SysUser user) - { + public boolean checkEmailUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkEmailUnique(user.getEmail()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -184,33 +174,28 @@ public class SysUserServiceImpl implements ISysUserService /** * 校验用户是否允许操作 - * + * * @param user 用户信息 */ @Override - public void checkUserAllowed(SysUser user) - { - if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) - { + public void checkUserAllowed(SysUser user) { + if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { throw new ServiceException("不允许操作超级管理员用户"); } } /** * 校验用户是否有数据权限 - * + * * @param userId 用户id */ @Override - public void checkUserDataScope(Long userId) - { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) - { + public void checkUserDataScope(Long userId) { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) { SysUser user = new SysUser(); user.setUserId(userId); List users = SpringUtils.getAopProxy(this).selectUserList(user); - if (StringUtils.isEmpty(users)) - { + if (StringUtils.isEmpty(users)) { throw new ServiceException("没有权限访问用户数据!"); } } @@ -218,14 +203,13 @@ public class SysUserServiceImpl implements ISysUserService /** * 新增保存用户信息 - * + * * @param user 用户信息 * @return 结果 */ @Override @Transactional - public int insertUser(SysUser user) - { + public int insertUser(SysUser user) { // 新增用户信息 int rows = userMapper.insertUser(user); // 新增用户与角色管理 @@ -235,26 +219,24 @@ public class SysUserServiceImpl implements ISysUserService /** * 注册用户信息 - * + * * @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); @@ -265,105 +247,95 @@ 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) { this.insertUserRole(user.getUserId(), user.getRoleIds()); } /** * 新增用户角色信息 - * - * @param userId 用户ID + * + * @param userId 用户ID * @param roleIds 角色组 */ - public void insertUserRole(Long userId, Long[] roleIds) - { - if (StringUtils.isNotEmpty(roleIds)) - { + public void insertUserRole(Long userId, Long[] roleIds) { + if (StringUtils.isNotEmpty(roleIds)) { // 新增用户与角色管理 List list = new ArrayList(roleIds.length); - for (Long roleId : roleIds) - { + for (Long roleId : roleIds) { SysUserRole ur = new SysUserRole(); ur.setUserId(userId); ur.setRoleId(roleId); @@ -375,14 +347,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); return userMapper.deleteUserById(userId); @@ -390,16 +361,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)); checkUserDataScope(userId); } @@ -410,17 +379,15 @@ public class SysUserServiceImpl implements ISysUserService /** * 导入用户数据 - * - * @param userList 用户数据列表 + * + * @param userList 用户数据列表 * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 - * @param operName 操作用户 + * @param operName 操作用户 * @return 结果 */ @Override - public String importUser(List userList, Boolean isUpdateSupport, String operName) - { - if (StringUtils.isNull(userList) || userList.size() == 0) - { + public String importUser(List userList, Boolean isUpdateSupport, String operName) { + if (StringUtils.isNull(userList) || userList.size() == 0) { throw new ServiceException("导入用户数据不能为空!"); } int successNum = 0; @@ -428,23 +395,18 @@ 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 (StringUtils.isNull(u)) - { + if (StringUtils.isNull(u)) { BeanValidators.validateWithException(validator, user); user.setPassword(SecurityUtils.encryptPassword(password)); user.setCreateBy(operName); this.insertUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); - } - else if (isUpdateSupport) - { + } else if (isUpdateSupport) { BeanValidators.validateWithException(validator, user); checkUserAllowed(user); checkUserDataScope(user.getUserId()); @@ -452,28 +414,21 @@ public class SysUserServiceImpl implements ISysUserService this.updateUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 更新成功"); - } - else - { + } else { failureNum++; failureMsg.append("
" + failureNum + "、账号 " + user.getUserName() + " 已存在"); } - } - catch (Exception e) - { + } catch (Exception e) { failureNum++; String msg = "
" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; failureMsg.append(msg + e.getMessage()); log.error(msg, e); } } - if (failureNum > 0) - { + if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); throw new ServiceException(failureMsg.toString()); - } - else - { + } else { successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); } return successMsg.toString(); diff --git a/psdc-system/src/main/resources/mapper/system/SysUserMapper.xml b/psdc-system/src/main/resources/mapper/system/SysUserMapper.xml index d877029..8cda44d 100644 --- a/psdc-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/psdc-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -64,6 +64,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+ +