1、增加单位图标管理

2、修改机构登录
3、订单问题处理
4、完善组态绑定及删除关联
This commit is contained in:
LEED
2025-06-22 10:33:36 +08:00
parent 3bac43403b
commit b2cee8aeb7
40 changed files with 1367 additions and 86 deletions

View File

@@ -0,0 +1,110 @@
package com.xinda.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinda.common.annotation.Log;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.enums.BusinessType;
import com.xinda.system.domain.SysInfo;
import com.xinda.system.service.ISysInfoService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;
/**
* 系统配置Controller
*
* @author kerwincui
* @date 2025-05-29
*/
@RestController
@RequestMapping("/system/sysInfo")
@Api(tags = "系统配置")
public class SysInfoController extends BaseController
{
@Autowired
private ISysInfoService sysInfoService;
/**
* 查询系统配置列表
*/
@PreAuthorize("@ss.hasPermi('system:sysInfo:list')")
@GetMapping("/list")
@ApiOperation("查询系统配置列表")
public TableDataInfo list(SysInfo sysInfo)
{
startPage();
List<SysInfo> list = sysInfoService.selectSysInfoList(sysInfo);
return getDataTable(list);
}
/**
* 导出系统配置列表
*/
@ApiOperation("导出系统配置列表")
@PreAuthorize("@ss.hasPermi('system:sysInfo:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysInfo sysInfo)
{
List<SysInfo> list = sysInfoService.selectSysInfoList(sysInfo);
ExcelUtil<SysInfo> util = new ExcelUtil<SysInfo>(SysInfo.class);
util.exportExcel(response, list, "系统配置数据");
}
/**
* 获取系统配置详细信息
*/
@GetMapping(value = "/getSysInfo")
@ApiOperation("获取系统配置详细信息")
public AjaxResult getSysInfo()
{
Long id = 1L;
return success(sysInfoService.selectSysInfoById(id));
}
// /**
// * 新增系统配置
// */
// @PreAuthorize("@ss.hasPermi('system:sysInfo:add')")
// @PostMapping
// @ApiOperation("新增系统配置")
// public AjaxResult add(@RequestBody SysInfo sysInfo)
// {
// return toAjax(sysInfoService.insertSysInfo(sysInfo));
// }
/**
* 修改系统配置
*/
@PreAuthorize("@ss.hasPermi('system:sysInfo:edit')")
@PutMapping
@ApiOperation("修改系统配置")
public AjaxResult edit(@RequestBody SysInfo sysInfo)
{
return toAjax(sysInfoService.updateSysInfo(sysInfo));
}
// /**
// * 删除系统配置
// */
// @PreAuthorize("@ss.hasPermi('system:sysInfo:remove')")
// @DeleteMapping("/{ids}")
// @ApiOperation("删除系统配置")
// public AjaxResult remove(@PathVariable Long[] ids)
// {
// return toAjax(sysInfoService.deleteSysInfoByIds(ids));
// }
}

View File

@@ -57,35 +57,35 @@ public class SysLoginController
* @param loginBody 登录信息 * @param loginBody 登录信息
* @return 结果 * @return 结果
*/ */
// @ApiOperation("机构用户登录") @ApiOperation("机构用户登录")
// @PostMapping("/deptLogin")
// public AjaxResult deptLogin(HttpServletRequest request, @RequestBody LoginBody loginBody)
// {
// AjaxResult ajax = AjaxResult.success();
// // 生成令牌
// String token = loginService.deptLogin(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
// loginBody.getUuid(), loginBody.getSourceType(), request.getHeader(LANGUAGE));
// ajax.put(Constants.TOKEN, token);
// return ajax;
// }
/**
* 登录方法
*
* @param loginBody 登录信息
* @return 结果
*/
@ApiOperation("用户登录")
@PostMapping("/login") @PostMapping("/login")
public AjaxResult login(HttpServletRequest request, @RequestBody LoginBody loginBody) public AjaxResult login(HttpServletRequest request, @RequestBody LoginBody loginBody)
{ {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
// 生成令牌 // 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), String token = loginService.login(loginBody.getDeptId(),loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid(), loginBody.getSourceType(), request.getHeader(LANGUAGE)); loginBody.getUuid(), loginBody.getSourceType(), request.getHeader(LANGUAGE));
ajax.put(Constants.TOKEN, token); ajax.put(Constants.TOKEN, token);
return ajax; return ajax;
} }
//
// /**
// * 登录方法
// *
// * @param loginBody 登录信息
// * @return 结果
// */
// @ApiOperation("用户登录")
// @PostMapping("/login")
// public AjaxResult login(HttpServletRequest request, @RequestBody LoginBody loginBody)
// {
// AjaxResult ajax = AjaxResult.success();
// // 生成令牌
// String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
// loginBody.getUuid(), loginBody.getSourceType(), request.getHeader(LANGUAGE));
// ajax.put(Constants.TOKEN, token);
// return ajax;
// }
/** /**
* 获取用户信息 * 获取用户信息

View File

@@ -41,7 +41,7 @@ public class SysSmsController extends BaseController
/** /**
* 查询系统消息列表 * 查询系统消息列表
*/ */
@PreAuthorize("@ss.hasPermi('system:sms:list')") //@PreAuthorize("@ss.hasPermi('system:sms:list')")
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("查询系统消息列表") @ApiOperation("查询系统消息列表")
public TableDataInfo list(SysSms sysSms) public TableDataInfo list(SysSms sysSms)
@@ -55,7 +55,7 @@ public class SysSmsController extends BaseController
* 导出系统消息列表 * 导出系统消息列表
*/ */
@ApiOperation("导出系统消息列表") @ApiOperation("导出系统消息列表")
@PreAuthorize("@ss.hasPermi('system:sms:export')") // @PreAuthorize("@ss.hasPermi('system:sms:export')")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, SysSms sysSms) public void export(HttpServletResponse response, SysSms sysSms)
{ {
@@ -67,7 +67,7 @@ public class SysSmsController extends BaseController
/** /**
* 获取系统消息详细信息 * 获取系统消息详细信息
*/ */
@PreAuthorize("@ss.hasPermi('system:sms:query')") // @PreAuthorize("@ss.hasPermi('system:sms:query')")
@GetMapping(value = "/{smsId}") @GetMapping(value = "/{smsId}")
@ApiOperation("获取系统消息详细信息") @ApiOperation("获取系统消息详细信息")
public AjaxResult getInfo(@PathVariable("smsId") Long smsId) public AjaxResult getInfo(@PathVariable("smsId") Long smsId)

View File

@@ -132,6 +132,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/dueros").permitAll() .antMatchers("/dueros").permitAll()
.antMatchers("/ws/alert/**").permitAll() .antMatchers("/ws/alert/**").permitAll()
.antMatchers("/system/dept/orgList").permitAll() .antMatchers("/system/dept/orgList").permitAll()
.antMatchers("/system/sysInfo/getSysInfo").permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()

View File

@@ -0,0 +1,16 @@
//package com.xinda.framework.web.service;
//
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
//
//public class CustomAuthenticationToken extends UsernamePasswordAuthenticationToken {
// private final Long deptId;
//
// public CustomAuthenticationToken(String username, String password, Long deptId) {
// super(username, password);
// this.deptId = deptId;
// }
//
// public Long getDeptId() {
// return deptId;
// }
//}

View File

@@ -71,7 +71,108 @@ public class SysLoginService {
* @param uuid 唯一标识 * @param uuid 唯一标识
* @return 结果 * @return 结果
*/ */
public String login(String username, String password, String code, String uuid, Integer sourceType, String language) { // public String login(String username, String password, String code, String uuid, Integer sourceType, String language) {
// boolean captchaEnabled = configService.selectCaptchaEnabled();
// // 验证码开关
// if (captchaEnabled) {
// validateCaptcha(username, code, uuid);
// }
// // 用户验证
// Authentication authentication = null;
// try {
// UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
// AuthenticationContextHolder.setContext(authenticationToken);
// // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
// authentication = authenticationManager.authenticate(authenticationToken);
// } catch (Exception e) {
// if (e instanceof BadCredentialsException) {
// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
// throw new UserPasswordNotMatchException();
// } else {
// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
// throw new ServiceException(e.getMessage());
// }
// } finally {
// AuthenticationContextHolder.clearContext();
// }
// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
// LoginUser loginUser = (LoginUser) authentication.getPrincipal();
// // 移动端、小程序限制终端用户登录
// Long deptId = loginUser.getDeptId();
// if (null != sourceType && 1 == sourceType && null == deptId) {
// throw new ServiceException("web端只允许租户登录");
// }
//// if (!"admin".equals(loginUser.getUsername()) && null != sourceType) {
//// Long deptId = loginUser.getDeptId();
//// if (1 == sourceType && null == deptId) {
//// throw new ServiceException("web端只允许租户登录");
//// }
//// if (1 != sourceType && null != deptId) {
//// throw new ServiceException("只允许终端用户登录!");
//// }
//// }
// SysDept sysDept = sysDeptService.selectDeptById(deptId);
// recordLoginInfo(loginUser.getUserId());
// loginUser.setLanguage(language);
// loginUser.setDeptUserId(sysDept.getDeptUserId());
// // 生成token
// return tokenService.createToken(loginUser);
// }
// public String login(Long deptId,String username, String password, String code, String uuid, Integer sourceType, String language) {
// boolean captchaEnabled = configService.selectCaptchaEnabled();
// // 验证码开关
// if (captchaEnabled) {
// validateCaptcha(username, code, uuid);
// }
// // 用户验证
// Authentication authentication = null;
// try {
// // 创建包含机构ID的认证令牌
// CustomAuthenticationToken authenticationToken = new CustomAuthenticationToken(username, password, deptId);
// AuthenticationContextHolder.setContext(authenticationToken);
// // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
// authentication = authenticationManager.authenticate(authenticationToken);
// } catch (Exception e) {
// if (e instanceof BadCredentialsException) {
// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username,Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
// throw new UserPasswordNotMatchException();
// } else {
// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
// throw new ServiceException(e.getMessage());
// }
// } finally {
// AuthenticationContextHolder.clearContext();
// }
// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
// LoginUser loginUser = (LoginUser) authentication.getPrincipal();
// // 移动端、小程序限制终端用户登录
//// Long deptId = loginUser.getDeptId();
// // 移动端、小程序限制终端用户登录(保留原有逻辑)
// Long userDeptId = loginUser.getDeptId();
// if (null != sourceType && 1 == sourceType && null == userDeptId) {
// throw new ServiceException("web端只允许租户登录");
// }
//// if (!"admin".equals(loginUser.getUsername()) && null != sourceType) {
//// Long deptId = loginUser.getDeptId();
//// if (1 == sourceType && null == deptId) {
//// throw new ServiceException("web端只允许租户登录");
//// }
//// if (1 != sourceType && null != deptId) {
//// throw new ServiceException("只允许终端用户登录!");
//// }
//// }
// SysDept sysDept = sysDeptService.selectDeptById(userDeptId);
// recordLoginInfo(loginUser.getUserId());
// loginUser.setLanguage(language);
// loginUser.setDeptUserId(sysDept.getDeptUserId());
// // 生成token
// return tokenService.createToken(loginUser);
// }
public String login(Long deptId,String username, String password, String code, String uuid, Integer sourceType, String language) {
boolean captchaEnabled = configService.selectCaptchaEnabled(); boolean captchaEnabled = configService.selectCaptchaEnabled();
// 验证码开关 // 验证码开关
if (captchaEnabled) { if (captchaEnabled) {
@@ -81,6 +182,8 @@ public class SysLoginService {
Authentication authentication = null; Authentication authentication = null;
try { try {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password); UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
// 将机构ID添加到认证细节中
authenticationToken.setDetails(deptId);
AuthenticationContextHolder.setContext(authenticationToken); AuthenticationContextHolder.setContext(authenticationToken);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(authenticationToken); authentication = authenticationManager.authenticate(authenticationToken);
@@ -98,8 +201,8 @@ public class SysLoginService {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal(); LoginUser loginUser = (LoginUser) authentication.getPrincipal();
// 移动端、小程序限制终端用户登录 // 移动端、小程序限制终端用户登录
Long deptId = loginUser.getDeptId(); Long userDeptId = loginUser.getDeptId();
if (null != sourceType && 1 == sourceType && null == deptId) { if (null != sourceType && 1 == sourceType && null == userDeptId) {
throw new ServiceException("web端只允许租户登录"); throw new ServiceException("web端只允许租户登录");
} }
// if (!"admin".equals(loginUser.getUsername()) && null != sourceType) { // if (!"admin".equals(loginUser.getUsername()) && null != sourceType) {
@@ -111,7 +214,7 @@ public class SysLoginService {
// throw new ServiceException("只允许终端用户登录!"); // throw new ServiceException("只允许终端用户登录!");
// } // }
// } // }
SysDept sysDept = sysDeptService.selectDeptById(deptId); SysDept sysDept = sysDeptService.selectDeptById(userDeptId);
recordLoginInfo(loginUser.getUserId()); recordLoginInfo(loginUser.getUserId());
loginUser.setLanguage(language); loginUser.setLanguage(language);
loginUser.setDeptUserId(sysDept.getDeptUserId()); loginUser.setDeptUserId(sysDept.getDeptUserId());
@@ -119,7 +222,6 @@ public class SysLoginService {
return tokenService.createToken(loginUser); return tokenService.createToken(loginUser);
} }
/** /**
* 第三方验证后,调用登录方法 * 第三方验证后,调用登录方法
* *

View File

@@ -1,8 +1,11 @@
package com.xinda.framework.web.service; package com.xinda.framework.web.service;
import com.xinda.framework.security.context.AuthenticationContextHolder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
@@ -36,11 +39,18 @@ public class UserDetailsServiceImpl implements UserDetailsService
@Override @Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
{ {
SysUser user = userService.selectUserByUserName(username); // 获取当前正在处理的认证请求从AuthenticationManager传递过来的
Authentication authentication = AuthenticationContextHolder.getContext();
// 获取机构ID从认证令牌的details中获取
Long deptId = null;
if (authentication != null && authentication.getDetails() instanceof Long) {
deptId = (Long) authentication.getDetails();
}
SysUser user = userService.selectUserByUserNameAndDeptId(username,deptId);
if (StringUtils.isNull(user)) if (StringUtils.isNull(user))
{ {
log.info("登录用户:{} 不存在.", username); log.info("登录用户:{} 在机构ID: {} 下不存在.", username, deptId);
throw new ServiceException("登录用户:" + username + " 不存在"); throw new UsernameNotFoundException("登录用户:" + username + " 不存在或机构ID错误");
} }
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
{ {
@@ -58,6 +68,68 @@ public class UserDetailsServiceImpl implements UserDetailsService
return createLoginUser(user); return createLoginUser(user);
} }
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
// {
// SysUser user = userService.selectUserByUserName(username);
// if (StringUtils.isNull(user))
// {
// log.info("登录用户:{} 不存在.", username);
// throw new ServiceException("登录用户:" + username + " 不存在");
// }
// else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
// {
// log.info("登录用户:{} 已被删除.", username);
// throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
// }
// else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
// {
// log.info("登录用户:{} 已被停用.", username);
// throw new ServiceException("对不起,您的账号:" + username + " 已停用");
// }
//
// passwordService.validate(user);
//
// return createLoginUser(user);
// }
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// // 获取当前正在处理的认证请求从AuthenticationManager传递过来的
// Authentication authentication = AuthenticationContextHolder.getContext();
// Long deptId = null;
//
// if (authentication instanceof CustomAuthenticationToken) {
// deptId = ((CustomAuthenticationToken) authentication).getDeptId();
// }
//
// if (deptId == null) {
// throw new ServiceException("登录请求缺少机构信息");
// }
//
// return loadUserByUsernameAndDept(username, deptId);
// }
// public UserDetails loadUserByUsernameAndDept(String username, Long deptId) {
// SysUser user = userService.selectUserByUserNameAndDeptId(username, deptId);
//
// if (StringUtils.isNull(user)) {
// log.info("登录用户:{} 在机构 {} 下不存在.", username, deptId);
// throw new ServiceException("登录用户:" + username + " 在指定机构下不存在");
// } else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
// log.info("登录用户:{} 在机构 {} 下已被删除.", username, deptId);
// throw new ServiceException("对不起,您的账号:" + username + " 在机构下已被删除");
// } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
// log.info("登录用户:{} 在机构 {} 下已被停用.", username, deptId);
// throw new ServiceException("对不起,您的账号:" + username + " 在机构下已停用");
// }
//
// passwordService.validate(user);
// return createLoginUser(user);
// }
public UserDetails createLoginUser(SysUser user) public UserDetails createLoginUser(SysUser user)
{ {
return new LoginUser(user.getUserId(), user.getDeptId(), user.getLanguage(), user, permissionService.getMenuPermission(user)); return new LoginUser(user.getUserId(), user.getDeptId(), user.getLanguage(), user, permissionService.getMenuPermission(user));

View File

@@ -96,7 +96,8 @@ public class DeviceStatusConsumer {
// if (device.getGroupId().equals(0L) || device.getGroupId() == null) { // if (device.getGroupId().equals(0L) || device.getGroupId() == null) {
if (device.getAgenciesId() == null) { if (device.getAgenciesId() == null) {
//设置删除状态 todo //设置删除状态 todo
device.setDelFlag("2"); // device.setDelFlag("2");
deviceService.deleteDeviceByDeviceId(device.getDeviceId());
} }
} }
} }

View File

@@ -61,7 +61,7 @@ private static final long serialVersionUID = 1L;
@Excel(name = "巡检人") @Excel(name = "巡检人")
@ApiModelProperty("巡检人") @ApiModelProperty("巡检人")
private String inspectionPerson; private String inspectionPerson;
private String inspection;
/** 巡检人id */ /** 巡检人id */
@Excel(name = "巡检人id") @Excel(name = "巡检人id")
@ApiModelProperty("巡检人id") @ApiModelProperty("巡检人id")

View File

@@ -46,13 +46,13 @@ private static final long serialVersionUID = 1L;
private String projectName; private String projectName;
/** 计划巡检时间 */ /** 计划巡检时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "计划巡检时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "计划巡检时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("计划巡检时间") @ApiModelProperty("计划巡检时间")
private Date planTime; private Date planTime;
/** 实际巡检时间 */ /** 实际巡检时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "实际巡检时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "实际巡检时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("实际巡检时间") @ApiModelProperty("实际巡检时间")
private Date inspectionTime; private Date inspectionTime;

View File

@@ -57,6 +57,8 @@ private static final long serialVersionUID = 1L;
@ApiModelProperty("完成人") @ApiModelProperty("完成人")
private String finishBy; private String finishBy;
private String respon;
/** 附件 */ /** 附件 */
@Excel(name = "附件") @Excel(name = "附件")
@ApiModelProperty("附件") @ApiModelProperty("附件")

View File

@@ -8,6 +8,7 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import com.xinda.common.core.domain.model.LoginUser;
import com.xinda.common.utils.DateUtils; import com.xinda.common.utils.DateUtils;
import com.xinda.itsm.domain.InspectionRecord; import com.xinda.itsm.domain.InspectionRecord;
import com.xinda.itsm.mapper.InspectionRecordMapper; import com.xinda.itsm.mapper.InspectionRecordMapper;
@@ -17,6 +18,8 @@ import com.xinda.itsm.mapper.InspectionPlanMapper;
import com.xinda.itsm.domain.InspectionPlan; import com.xinda.itsm.domain.InspectionPlan;
import com.xinda.itsm.service.IInspectionPlanService; import com.xinda.itsm.service.IInspectionPlanService;
import static com.xinda.common.utils.SecurityUtils.getLoginUser;
/** /**
* 巡检计划Service业务层处理 * 巡检计划Service业务层处理
* *
@@ -63,7 +66,7 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService
@Override @Override
public int insertInspectionPlan(InspectionPlan inspectionPlan) public int insertInspectionPlan(InspectionPlan inspectionPlan)
{ {
LoginUser loginUser = getLoginUser();
inspectionPlan.setCreateTime(DateUtils.getNowDate()); inspectionPlan.setCreateTime(DateUtils.getNowDate());
int num = inspectionPlanMapper.insertInspectionPlan(inspectionPlan); int num = inspectionPlanMapper.insertInspectionPlan(inspectionPlan);
// 收集日期范围内的所有日期 // 收集日期范围内的所有日期
@@ -71,6 +74,8 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService
processDateRange(inspectionPlan.getStartDate(), inspectionPlan.getEndDate(), dateList::add); processDateRange(inspectionPlan.getStartDate(), inspectionPlan.getEndDate(), dateList::add);
for(Date date : dateList){ for(Date date : dateList){
InspectionRecord inspectionRecord = getBasicRecord(inspectionPlan, date, ""); InspectionRecord inspectionRecord = getBasicRecord(inspectionPlan, date, "");
inspectionRecord.setCreateTime(DateUtils.getNowDate());
inspectionRecord.setCreateBy(loginUser.getUsername());
inspectionRecordMapper.insertInspectionRecord(inspectionRecord); inspectionRecordMapper.insertInspectionRecord(inspectionRecord);
} }
return num; return num;

View File

@@ -1,6 +1,8 @@
package com.xinda.itsm.service.impl; package com.xinda.itsm.service.impl;
import java.util.List; import java.util.List;
import com.xinda.common.core.domain.model.LoginUser;
import com.xinda.common.utils.DateUtils; import com.xinda.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -8,6 +10,8 @@ import com.xinda.itsm.mapper.InspectionRecordMapper;
import com.xinda.itsm.domain.InspectionRecord; import com.xinda.itsm.domain.InspectionRecord;
import com.xinda.itsm.service.IInspectionRecordService; import com.xinda.itsm.service.IInspectionRecordService;
import static com.xinda.common.utils.SecurityUtils.getLoginUser;
/** /**
* 巡检记录Service业务层处理 * 巡检记录Service业务层处理
* *
@@ -53,7 +57,9 @@ public class InspectionRecordServiceImpl implements IInspectionRecordService
@Override @Override
public int insertInspectionRecord(InspectionRecord inspectionRecord) public int insertInspectionRecord(InspectionRecord inspectionRecord)
{ {
LoginUser loginUser = getLoginUser();
inspectionRecord.setCreateTime(DateUtils.getNowDate()); inspectionRecord.setCreateTime(DateUtils.getNowDate());
inspectionRecord.setCreateBy(loginUser.getUsername());
return inspectionRecordMapper.insertInspectionRecord(inspectionRecord); return inspectionRecordMapper.insertInspectionRecord(inspectionRecord);
} }

View File

@@ -95,18 +95,65 @@ public class ItsmServiceImpl implements ItsmService {
Date finish = DateUtils.addMonths(start, i + 1); Date finish = DateUtils.addMonths(start, i + 1);
StateCountVo repairCountVo = new StateCountVo(); StateCountVo repairCountVo = new StateCountVo();
long repairTotal = repairs.stream().filter(r->r.getUpdateTime().after(begin) && r.getUpdateTime().before(finish)).count(); long repairTotal = repairs.stream()
long repairCompleted = repairs.stream().filter(r->r.getOrderStatus().equals(RepairOrderStatus.COMPLETED.getCode()) .filter(Objects::nonNull) // 过滤掉null元素
&& r.getUpdateTime().after(begin) && r.getUpdateTime().before(finish)).count(); .filter(r -> {
Date updateTime = r.getUpdateTime();
// 检查updateTime是否为null
return updateTime != null &&
updateTime.after(begin) &&
updateTime.before(finish);
})
.count();
// long repairTotal = repairs.stream().filter(r->r.getUpdateTime().after(begin) && r.getUpdateTime().before(finish)).count();
long repairCompleted = repairs.stream()
.filter(Objects::nonNull) // 过滤掉null元素
.filter(r -> {
String orderStatus = r.getOrderStatus();
Date updateTime = r.getUpdateTime();
// 检查orderStatus和updateTime是否为null
return orderStatus != null &&
orderStatus.equals(RepairOrderStatus.COMPLETED.getCode()) &&
updateTime != null &&
updateTime.after(begin) &&
updateTime.before(finish);
})
.count();
// long repairCompleted = repairs.stream().filter(r->r.getOrderStatus().equals(RepairOrderStatus.COMPLETED.getCode())
// && r.getUpdateTime().after(begin) && r.getUpdateTime().before(finish)).count();
repairCountVo.setTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM,begin)); repairCountVo.setTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM,begin));
repairCountVo.setFinished(repairCompleted); repairCountVo.setFinished(repairCompleted);
repairCountVo.setUnfinished(repairTotal-repairCompleted); repairCountVo.setUnfinished(repairTotal-repairCompleted);
repairCounts.add(repairCountVo); repairCounts.add(repairCountVo);
StateCountVo inspectionCountVo = new StateCountVo(); StateCountVo inspectionCountVo = new StateCountVo();
long inspectionTotal = inspections.stream().filter(r->r.getUpdateTime().after(begin) && r.getUpdateTime().before(finish)).count(); // 修复inspectionTotal计数
long inspectionCompleted = inspections.stream().filter(r->r.getInspectionStatus().equals(InspectionRecordStatus.COMPLETED.getCode()) long inspectionTotal = inspections.stream()
&& r.getUpdateTime().after(begin) && r.getUpdateTime().before(finish)).count(); .filter(Objects::nonNull) // 过滤掉null元素
.filter(r -> {
Date updateTime = r.getUpdateTime();
return updateTime != null &&
updateTime.after(begin) &&
updateTime.before(finish);
})
.count();
// 修复inspectionCompleted计数
long inspectionCompleted = inspections.stream()
.filter(Objects::nonNull) // 过滤掉null元素
.filter(r -> {
String status = r.getInspectionStatus();
Date updateTime = r.getUpdateTime();
return status != null &&
status.equals(InspectionRecordStatus.COMPLETED.getCode()) &&
updateTime != null &&
updateTime.after(begin) &&
updateTime.before(finish);
})
.count();
// long inspectionTotal = inspections.stream().filter(r->r.getUpdateTime().after(begin) && r.getUpdateTime().before(finish)).count();
// long inspectionCompleted = inspections.stream().filter(r->r.getInspectionStatus().equals(InspectionRecordStatus.COMPLETED.getCode())
// && r.getUpdateTime().after(begin) && r.getUpdateTime().before(finish)).count();
inspectionCountVo.setTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM,begin)); inspectionCountVo.setTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM,begin));
inspectionCountVo.setFinished(inspectionCompleted); inspectionCountVo.setFinished(inspectionCompleted);
inspectionCountVo.setUnfinished(inspectionTotal-inspectionCompleted); inspectionCountVo.setUnfinished(inspectionTotal-inspectionCompleted);

View File

@@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="endDate" column="end_date" /> <result property="endDate" column="end_date" />
<result property="inspectionCycle" column="inspection_cycle" /> <result property="inspectionCycle" column="inspection_cycle" />
<result property="inspectionPerson" column="inspection_person" /> <result property="inspectionPerson" column="inspection_person" />
<result property="inspection" column="inspection" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="setDate" column="set_date" /> <result property="setDate" column="set_date" />
<result property="setTime" column="set_time" /> <result property="setTime" column="set_time" />
@@ -24,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectInspectionPlanVo"> <sql id="selectInspectionPlanVo">
select id, plan_name, plan_content, project_name, start_date, end_date, inspection_cycle, inspection_person, user_id, set_date, set_time, status, create_by, create_time, update_by, update_time from inspection_plan select id, plan_name, plan_content, project_name, start_date, end_date, inspection_cycle, inspection_person,inspection, user_id, set_date, set_time, status, create_by, create_time, update_by, update_time from inspection_plan
</sql> </sql>
<select id="selectInspectionPlanList" parameterType="InspectionPlan" resultMap="InspectionPlanResult"> <select id="selectInspectionPlanList" parameterType="InspectionPlan" resultMap="InspectionPlanResult">
@@ -37,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endDate != null "> and end_date = #{endDate}</if> <if test="endDate != null "> and end_date = #{endDate}</if>
<if test="inspectionCycle != null and inspectionCycle != ''"> and inspection_cycle = #{inspectionCycle}</if> <if test="inspectionCycle != null and inspectionCycle != ''"> and inspection_cycle = #{inspectionCycle}</if>
<if test="inspectionPerson != null and inspectionPerson != ''"> and inspection_person = #{inspectionPerson}</if> <if test="inspectionPerson != null and inspectionPerson != ''"> and inspection_person = #{inspectionPerson}</if>
<if test="inspection!= null and inspection != ''"> and inspection = #{inspection}</if>
<if test="userId != null and userId != ''"> and user_id = #{userId}</if> <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
<if test="setDate != null and setDate != ''"> and set_date = #{setDate}</if> <if test="setDate != null and setDate != ''"> and set_date = #{setDate}</if>
<if test="setTime != null and setTime != ''"> and set_time = #{setTime}</if> <if test="setTime != null and setTime != ''"> and set_time = #{setTime}</if>
@@ -60,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endDate != null">end_date,</if> <if test="endDate != null">end_date,</if>
<if test="inspectionCycle != null">inspection_cycle,</if> <if test="inspectionCycle != null">inspection_cycle,</if>
<if test="inspectionPerson != null">inspection_person,</if> <if test="inspectionPerson != null">inspection_person,</if>
<if test="inspection!= null">inspection,</if>
<if test="userId != null">user_id,</if> <if test="userId != null">user_id,</if>
<if test="setDate != null">set_date,</if> <if test="setDate != null">set_date,</if>
<if test="setTime != null">set_time,</if> <if test="setTime != null">set_time,</if>
@@ -78,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endDate != null">#{endDate},</if> <if test="endDate != null">#{endDate},</if>
<if test="inspectionCycle != null">#{inspectionCycle},</if> <if test="inspectionCycle != null">#{inspectionCycle},</if>
<if test="inspectionPerson != null">#{inspectionPerson},</if> <if test="inspectionPerson != null">#{inspectionPerson},</if>
<if test="inspection != null">#{inspection},</if>
<if test="userId != null">#{userId},</if> <if test="userId != null">#{userId},</if>
<if test="setDate != null">#{setDate},</if> <if test="setDate != null">#{setDate},</if>
<if test="setTime != null">#{setTime},</if> <if test="setTime != null">#{setTime},</if>
@@ -99,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endDate != null">end_date = #{endDate},</if> <if test="endDate != null">end_date = #{endDate},</if>
<if test="inspectionCycle != null">inspection_cycle = #{inspectionCycle},</if> <if test="inspectionCycle != null">inspection_cycle = #{inspectionCycle},</if>
<if test="inspectionPerson != null">inspection_person = #{inspectionPerson},</if> <if test="inspectionPerson != null">inspection_person = #{inspectionPerson},</if>
<if test="inspection != null">inspection = #{inspection},</if>
<if test="userId != null">user_id = #{userId},</if> <if test="userId != null">user_id = #{userId},</if>
<if test="setDate != null">set_date = #{setDate},</if> <if test="setDate != null">set_date = #{setDate},</if>
<if test="setTime != null">set_time = #{setTime},</if> <if test="setTime != null">set_time = #{setTime},</if>

View File

@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="assignTime" column="assign_time" /> <result property="assignTime" column="assign_time" />
<result property="finishTime" column="finish_time" /> <result property="finishTime" column="finish_time" />
<result property="finishBy" column="finish_by" /> <result property="finishBy" column="finish_by" />
<result property="respon" column="respon" />
<result property="annex" column="annex" /> <result property="annex" column="annex" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="orderStatus" column="order_status" /> <result property="orderStatus" column="order_status" />
@@ -23,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectRepairOrderVo"> <sql id="selectRepairOrderVo">
select id, order_no, order_content, project_name, assign_time, finish_time, finish_by, annex, user_id, order_status, order_remark, create_by, create_time, update_by, update_time from repair_order select id, order_no, order_content, project_name, assign_time, finish_time, finish_by,respon, annex, user_id, order_status, order_remark, create_by, create_time, update_by, update_time from repair_order
</sql> </sql>
<select id="selectRepairOrderList" parameterType="RepairOrder" resultMap="RepairOrderResult"> <select id="selectRepairOrderList" parameterType="RepairOrder" resultMap="RepairOrderResult">
@@ -35,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="assignTime != null "> and assign_time = #{assignTime}</if> <if test="assignTime != null "> and assign_time = #{assignTime}</if>
<if test="finishTime != null "> and finish_time = #{finishTime}</if> <if test="finishTime != null "> and finish_time = #{finishTime}</if>
<if test="finishBy != null and finishBy != ''"> and finish_by = #{finishBy}</if> <if test="finishBy != null and finishBy != ''"> and finish_by = #{finishBy}</if>
<if test="respon != null and respon != ''"> and respon = #{respon}</if>
<if test="annex != null and annex != ''"> and annex = #{annex}</if> <if test="annex != null and annex != ''"> and annex = #{annex}</if>
<if test="userId != null "> and user_id = #{userId}</if> <if test="userId != null "> and user_id = #{userId}</if>
<if test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if> <if test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if>
@@ -57,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="assignTime != null">assign_time,</if> <if test="assignTime != null">assign_time,</if>
<if test="finishTime != null">finish_time,</if> <if test="finishTime != null">finish_time,</if>
<if test="finishBy != null">finish_by,</if> <if test="finishBy != null">finish_by,</if>
<if test="respon != null">respon,</if>
<if test="annex != null">annex,</if> <if test="annex != null">annex,</if>
<if test="userId != null">user_id,</if> <if test="userId != null">user_id,</if>
<if test="orderStatus != null">order_status,</if> <if test="orderStatus != null">order_status,</if>
@@ -74,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="assignTime != null">#{assignTime},</if> <if test="assignTime != null">#{assignTime},</if>
<if test="finishTime != null">#{finishTime},</if> <if test="finishTime != null">#{finishTime},</if>
<if test="finishBy != null">#{finishBy},</if> <if test="finishBy != null">#{finishBy},</if>
<if test="respon != null">#{respon},</if>
<if test="annex != null">#{annex},</if> <if test="annex != null">#{annex},</if>
<if test="userId != null">#{userId},</if> <if test="userId != null">#{userId},</if>
<if test="orderStatus != null">#{orderStatus},</if> <if test="orderStatus != null">#{orderStatus},</if>
@@ -94,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="assignTime != null">assign_time = #{assignTime},</if> <if test="assignTime != null">assign_time = #{assignTime},</if>
<if test="finishTime != null">finish_time = #{finishTime},</if> <if test="finishTime != null">finish_time = #{finishTime},</if>
<if test="finishBy != null">finish_by = #{finishBy},</if> <if test="finishBy != null">finish_by = #{finishBy},</if>
<if test="respon != null">respon = #{respon},</if>
<if test="annex != null">annex = #{annex},</if> <if test="annex != null">annex = #{annex},</if>
<if test="userId != null">user_id = #{userId},</if> <if test="userId != null">user_id = #{userId},</if>
<if test="orderStatus != null">order_status = #{orderStatus},</if> <if test="orderStatus != null">order_status = #{orderStatus},</if>

View File

@@ -0,0 +1,110 @@
package com.xinda.data.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinda.common.annotation.Log;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.enums.BusinessType;
import com.xinda.iot.domain.UnitIcon;
import com.xinda.iot.service.IUnitIconService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;
/**
* 单位图标Controller
*
* @author kerwincui
* @date 2025-06-04
*/
@RestController
@RequestMapping("/iot/icon")
@Api(tags = "单位图标")
public class UnitIconController extends BaseController
{
@Autowired
private IUnitIconService unitIconService;
/**
* 查询单位图标列表
*/
//@PreAuthorize("@ss.hasPermi('iot:icon:list')")
@GetMapping("/list")
@ApiOperation("查询单位图标列表")
public TableDataInfo list(UnitIcon unitIcon)
{
startPage();
List<UnitIcon> list = unitIconService.selectUnitIconList(unitIcon);
return getDataTable(list);
}
/**
* 导出单位图标列表
*/
@ApiOperation("导出单位图标列表")
@PreAuthorize("@ss.hasPermi('iot:icon:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, UnitIcon unitIcon)
{
List<UnitIcon> list = unitIconService.selectUnitIconList(unitIcon);
ExcelUtil<UnitIcon> util = new ExcelUtil<UnitIcon>(UnitIcon.class);
util.exportExcel(response, list, "单位图标数据");
}
/**
* 获取单位图标详细信息
*/
// @PreAuthorize("@ss.hasPermi('iot:icon:query')")
@GetMapping(value = "/{id}")
@ApiOperation("获取单位图标详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(unitIconService.selectUnitIconById(id));
}
/**
* 新增单位图标
*/
@PreAuthorize("@ss.hasPermi('iot:icon:add')")
@PostMapping
@ApiOperation("新增单位图标")
public AjaxResult add(@RequestBody UnitIcon unitIcon)
{
return toAjax(unitIconService.insertUnitIcon(unitIcon));
}
/**
* 修改单位图标
*/
@PreAuthorize("@ss.hasPermi('iot:icon:edit')")
@PutMapping
@ApiOperation("修改单位图标")
public AjaxResult edit(@RequestBody UnitIcon unitIcon)
{
return toAjax(unitIconService.updateUnitIcon(unitIcon));
}
/**
* 删除单位图标
*/
@PreAuthorize("@ss.hasPermi('iot:icon:remove')")
@DeleteMapping("/{ids}")
@ApiOperation("删除单位图标")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(unitIconService.deleteUnitIconByIds(ids));
}
}

View File

@@ -5,13 +5,13 @@ spring:
timeout: 10000 timeout: 10000
# 以下为单机配置 # 以下为单机配置
# [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1 # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
host: redis host: 127.0.0.1
# [必须修改] 端口号 # [必须修改] 端口号
port: 6379 port: 6379
# [可选] 数据库 DB # [可选] 数据库 DB
database: 0 database: 0
# [可选] 访问密码,若你的redis服务器没有设置密码就不需要用密码去连接 # [可选] 访问密码,若你的redis服务器没有设置密码就不需要用密码去连接
password: xinda password: iot@1234
# 以下为集群配置 # 以下为集群配置
# cluster: # cluster:
# nodes: 192.168.1.242:7001 # nodes: 192.168.1.242:7001
@@ -27,12 +27,12 @@ server:
# HTTPS配置 默认不开启 # HTTPS配置 默认不开启
ssl: ssl:
# 是否开启HTTPS访问 默认关闭 # 是否开启HTTPS访问 默认关闭
enabled: false # enabled: false
# enabled: true enabled: true
# 证书文件路径您需要使用实际的证书名称替换domain_name.jks。 # 证书文件路径您需要使用实际的证书名称替换domain_name.jks。
key-store: classpath:xinda.online.jks key-store: classpath:xinda.online.jks
# 证书密码 修改为对应密码 # 证书密码 修改为对应密码
key-store-password: xinda key-store-password: 123456
# 证书类型, 默认为jks根据实际修改 # 证书类型, 默认为jks根据实际修改
key-store-type: JKS key-store-type: JKS

View File

@@ -71,4 +71,6 @@ public interface ScadaDeviceBindMapper
List<ScadaBindDeviceSimVO> listDeviceSimByGuid(String guid); List<ScadaBindDeviceSimVO> listDeviceSimByGuid(String guid);
List<ScadaDeviceBind> selectScadaDeviceBindListByIds(List<String> guidList); List<ScadaDeviceBind> selectScadaDeviceBindListByIds(List<String> guidList);
int deleteScadaDeviceBindByGuid(@Param("scadaGuid") String scadaGuid);
} }

View File

@@ -107,7 +107,8 @@ public interface ScadaMapper
void updateSceneModelGuid( @Param("sceneModelId") Long sceneModelId, @Param("guid") String guid); void updateSceneModelGuid( @Param("sceneModelId") Long sceneModelId, @Param("guid") String guid);
void updateDeviceGuid( @Param("serialNumber") String serialNumber, @Param("guid") String guid); void updateDeviceGuid( @Param("serialNumber") String serialNumber, @Param("guid") String guid);
void resetDeviceGuid(@Param("guid") String guid);
void resetProductGuid(@Param("guid") String guid);
void deleteProductByGuids(List<String> guids); void deleteProductByGuids(List<String> guids);
void deleteSceneModelByGuids(List<String> guids); void deleteSceneModelByGuids(List<String> guids);
@@ -117,4 +118,7 @@ public interface ScadaMapper
Long selectSceneModelByGuid(String guid); Long selectSceneModelByGuid(String guid);
String selectSerialNumberByGuid(String guid); String selectSerialNumberByGuid(String guid);
Long selectDeptIdBySn(@Param("serialNumber") String serialNumber);
} }

View File

@@ -15,6 +15,7 @@ import com.xinda.common.utils.MessageUtils;
import com.xinda.common.utils.StringUtils; import com.xinda.common.utils.StringUtils;
import com.xinda.common.utils.bean.BeanUtils; import com.xinda.common.utils.bean.BeanUtils;
import com.xinda.common.utils.file.FileUploadUtils; import com.xinda.common.utils.file.FileUploadUtils;
import com.xinda.iot.domain.Device;
import com.xinda.iot.domain.DeviceLog; import com.xinda.iot.domain.DeviceLog;
import com.xinda.iot.domain.EventLog; import com.xinda.iot.domain.EventLog;
import com.xinda.iot.domain.FunctionLog; import com.xinda.iot.domain.FunctionLog;
@@ -32,6 +33,7 @@ import com.xinda.scada.service.IScadaService;
import com.xinda.scada.vo.*; import com.xinda.scada.vo.*;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -145,13 +147,18 @@ public class ScadaServiceImpl implements IScadaService
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
scadaVO.setGuid(uuid.toString()); scadaVO.setGuid(uuid.toString());
Scada scada = ScadaConvert.INSTANCE.convertScada(scadaVO); Scada scada = ScadaConvert.INSTANCE.convertScada(scadaVO);
scada.setDeptId(user.getDept().getDeptId()); // scada.setDeptId(user.getDept().getDeptId());
scada.setDeptId(scadaMapper.selectDeptIdBySn(scadaVO.getSerialNumber()));
int result = scadaMapper.insertScada(scada); int result = scadaMapper.insertScada(scada);
if (result >0){ if (result >0){
if (ScadaTypeEnum.PRODUCT_TEMPLATE.getType().equals(scadaVO.getType())) { if (ScadaTypeEnum.PRODUCT_TEMPLATE.getType().equals(scadaVO.getType())) {
scadaMapper.updateProductGuid(scadaVO.getProductId(), uuid.toString()); scadaMapper.updateProductGuid(scadaVO.getProductId(), uuid.toString());
} }
if (ScadaTypeEnum.SCENE_MODEL.getType().equals(scadaVO.getType())) { if (ScadaTypeEnum.SCENE_MODEL.getType().equals(scadaVO.getType())) {
ScadaDeviceBind scadaDeviceBind = new ScadaDeviceBind();
scadaDeviceBind.setSerialNumber(scadaVO.getSerialNumber());
scadaDeviceBind.setScadaGuid(uuid.toString());
scadaDeviceBindMapper.insertScadaDeviceBind(scadaDeviceBind);
scadaMapper.updateDeviceGuid(scadaVO.getSerialNumber(), uuid.toString()); scadaMapper.updateDeviceGuid(scadaVO.getSerialNumber(), uuid.toString());
} }
return AjaxResult.success(uuid.toString()); return AjaxResult.success(uuid.toString());
@@ -238,8 +245,18 @@ public class ScadaServiceImpl implements IScadaService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int deleteScadaByIds(Long[] ids) public int deleteScadaByIds(Long[] ids)
{ {
for(Long id:ids){
Scada scada = scadaMapper.selectScadaById(id);
if(ScadaTypeEnum.SCENE_MODEL.getType().equals(scada.getType())){
scadaMapper.resetDeviceGuid(scada.getGuid());
}else{
scadaMapper.resetProductGuid(scada.getGuid());
}
scadaDeviceBindMapper.deleteScadaDeviceBindByGuid(scada.getGuid());
}
return scadaMapper.deleteScadaByIds(ids); return scadaMapper.deleteScadaByIds(ids);
} }

View File

@@ -90,6 +90,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from scada_device_bind where id = #{id} delete from scada_device_bind where id = #{id}
</delete> </delete>
<delete id="deleteScadaDeviceBindByGuid" parameterType="java.lang.String">
delete from scada_device_bind where scada_guid = #{scadaGuid}
</delete>
<delete id="deleteScadaDeviceBindByIds" parameterType="String"> <delete id="deleteScadaDeviceBindByIds" parameterType="String">
delete from scada_device_bind where id in delete from scada_device_bind where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">

View File

@@ -339,6 +339,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and del_flag = '0' and del_flag = '0'
</select> </select>
<select id="selectDeptIdBySn" resultType="java.lang.Long">
select agencies_id
from iot_device
where serial_number = #{serial_number}
and del_flag = '0'
</select>
<select id="selectSceneModelByGuid" resultType="java.lang.Long"> <select id="selectSceneModelByGuid" resultType="java.lang.Long">
select scene_model_id select scene_model_id
from scene_model from scene_model
@@ -351,7 +358,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set guid = #{guid} set guid = #{guid}
where product_id = #{productId} where product_id = #{productId}
</update> </update>
<update id="resetProductGuid">
UPDATE iot_product
SET guid = NULL
WHERE guid =#{guid}
</update>
<update id="updateSceneModelGuid"> <update id="updateSceneModelGuid">
update scene_model update scene_model
set guid = #{guid} set guid = #{guid}
@@ -363,6 +374,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set guid = #{guid,jdbcType=VARCHAR} set guid = #{guid,jdbcType=VARCHAR}
where serial_number = #{serialNumber,jdbcType=VARCHAR} where serial_number = #{serialNumber,jdbcType=VARCHAR}
</update> </update>
<update id="resetDeviceGuid">
update iot_device
set guid = NULL
where guid = #{guid,jdbcType=VARCHAR}
</update>
<update id="deleteSceneModelByGuids"> <update id="deleteSceneModelByGuids">
update scene_model update scene_model

View File

@@ -0,0 +1,41 @@
package com.xinda.iot.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xinda.common.annotation.Excel;
import com.xinda.common.core.domain.BaseEntity;
/**
* 单位图标对象 iot_unit_icon
*
* @author kerwincui
* @date 2025-06-04
*/
@ApiModel(value = "UnitIcon",description = "单位图标 iot_unit_icon")
@Data
public class UnitIcon extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id唯一标识 */
private Long id;
/** 单位说明 */
@Excel(name = "单位说明")
@ApiModelProperty("单位说明")
private String unitDesc;
/** 单位 */
@Excel(name = "单位")
@ApiModelProperty("单位")
private String unitName;
/** 路径 */
@Excel(name = "路径")
@ApiModelProperty("路径")
private String resourceUrl;
}

View File

@@ -0,0 +1,61 @@
package com.xinda.iot.mapper;
import java.util.List;
import com.xinda.iot.domain.UnitIcon;
/**
* 单位图标Mapper接口
*
* @author kerwincui
* @date 2025-06-04
*/
public interface UnitIconMapper
{
/**
* 查询单位图标
*
* @param id 单位图标主键
* @return 单位图标
*/
public UnitIcon selectUnitIconById(Long id);
/**
* 查询单位图标列表
*
* @param unitIcon 单位图标
* @return 单位图标集合
*/
public List<UnitIcon> selectUnitIconList(UnitIcon unitIcon);
/**
* 新增单位图标
*
* @param unitIcon 单位图标
* @return 结果
*/
public int insertUnitIcon(UnitIcon unitIcon);
/**
* 修改单位图标
*
* @param unitIcon 单位图标
* @return 结果
*/
public int updateUnitIcon(UnitIcon unitIcon);
/**
* 删除单位图标
*
* @param id 单位图标主键
* @return 结果
*/
public int deleteUnitIconById(Long id);
/**
* 批量删除单位图标
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteUnitIconByIds(Long[] ids);
}

View File

@@ -0,0 +1,61 @@
package com.xinda.iot.service;
import java.util.List;
import com.xinda.iot.domain.UnitIcon;
/**
* 单位图标Service接口
*
* @author kerwincui
* @date 2025-06-04
*/
public interface IUnitIconService
{
/**
* 查询单位图标
*
* @param id 单位图标主键
* @return 单位图标
*/
public UnitIcon selectUnitIconById(Long id);
/**
* 查询单位图标列表
*
* @param unitIcon 单位图标
* @return 单位图标集合
*/
public List<UnitIcon> selectUnitIconList(UnitIcon unitIcon);
/**
* 新增单位图标
*
* @param unitIcon 单位图标
* @return 结果
*/
public int insertUnitIcon(UnitIcon unitIcon);
/**
* 修改单位图标
*
* @param unitIcon 单位图标
* @return 结果
*/
public int updateUnitIcon(UnitIcon unitIcon);
/**
* 批量删除单位图标
*
* @param ids 需要删除的单位图标主键集合
* @return 结果
*/
public int deleteUnitIconByIds(Long[] ids);
/**
* 删除单位图标信息
*
* @param id 单位图标主键
* @return 结果
*/
public int deleteUnitIconById(Long id);
}

View File

@@ -277,8 +277,10 @@ public class SocialLoginServiceImpl implements ISocialLoginService {
throw new ServiceException("该账号已经绑定其他微信,请先解绑后重试!"); throw new ServiceException("该账号已经绑定其他微信,请先解绑后重试!");
} }
// 生成令牌 // 生成令牌
String token = sysLoginService.login(bindLoginBody.getUsername(), bindLoginBody.getPassword(), bindLoginBody.getCode(), String token = sysLoginService.login(bindLoginBody.getDeptId(),bindLoginBody.getUsername(), bindLoginBody.getPassword(), bindLoginBody.getCode(),
bindLoginBody.getUuid(), null, language); bindLoginBody.getUuid(), null, language);
// String token = sysLoginService.login(bindLoginBody.getUsername(), bindLoginBody.getPassword(), bindLoginBody.getCode(),
// bindLoginBody.getUuid(), null, language);
LoginUser loginUser = tokenService.getLoginUserByToken(token); LoginUser loginUser = tokenService.getLoginUserByToken(token);
//绑定和更新 //绑定和更新
SocialUser updateSocialUser = new SocialUser(); SocialUser updateSocialUser = new SocialUser();

View File

@@ -0,0 +1,96 @@
package com.xinda.iot.service.impl;
import java.util.List;
import com.xinda.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xinda.iot.mapper.UnitIconMapper;
import com.xinda.iot.domain.UnitIcon;
import com.xinda.iot.service.IUnitIconService;
/**
* 单位图标Service业务层处理
*
* @author kerwincui
* @date 2025-06-04
*/
@Service
public class UnitIconServiceImpl implements IUnitIconService
{
@Autowired
private UnitIconMapper unitIconMapper;
/**
* 查询单位图标
*
* @param id 单位图标主键
* @return 单位图标
*/
@Override
public UnitIcon selectUnitIconById(Long id)
{
return unitIconMapper.selectUnitIconById(id);
}
/**
* 查询单位图标列表
*
* @param unitIcon 单位图标
* @return 单位图标
*/
@Override
public List<UnitIcon> selectUnitIconList(UnitIcon unitIcon)
{
return unitIconMapper.selectUnitIconList(unitIcon);
}
/**
* 新增单位图标
*
* @param unitIcon 单位图标
* @return 结果
*/
@Override
public int insertUnitIcon(UnitIcon unitIcon)
{
unitIcon.setCreateTime(DateUtils.getNowDate());
return unitIconMapper.insertUnitIcon(unitIcon);
}
/**
* 修改单位图标
*
* @param unitIcon 单位图标
* @return 结果
*/
@Override
public int updateUnitIcon(UnitIcon unitIcon)
{
unitIcon.setUpdateTime(DateUtils.getNowDate());
return unitIconMapper.updateUnitIcon(unitIcon);
}
/**
* 批量删除单位图标
*
* @param ids 需要删除的单位图标主键
* @return 结果
*/
@Override
public int deleteUnitIconByIds(Long[] ids)
{
return unitIconMapper.deleteUnitIconByIds(ids);
}
/**
* 删除单位图标信息
*
* @param id 单位图标主键
* @return 结果
*/
@Override
public int deleteUnitIconById(Long id)
{
return unitIconMapper.deleteUnitIconById(id);
}
}

View File

@@ -101,7 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectNotifyTemplateListByAlertId" resultType="com.xinda.notify.domain.NotifyTemplate"> <select id="selectNotifyTemplateListByAlertId" resultType="com.xinda.notify.domain.NotifyTemplate">
select n.id, n.service_code,n.msg_params,n.status,n.type, n.name, n.channel_id, n.channel_type, n.provider, n.create_by, n.create_time, n.update_by, n.update_time, n.del_flag, n.tenant_id, n.tenant_name, c.name channelName select n.id, n.service_code,n.msg_params,n.status, n.name, n.channel_id, n.channel_type, n.provider, n.create_by, n.create_time, n.update_by, n.update_time, n.del_flag, n.tenant_id, n.tenant_name, c.name channelName
from iot_alert_notify_template a left join notify_template n on a.notify_template_id = n.id from iot_alert_notify_template a left join notify_template n on a.notify_template_id = n.id
left join notify_channel c on n.channel_id = c.id left join notify_channel c on n.channel_id = c.id
where a.alert_id = #{alertId} where a.alert_id = #{alertId}

View File

@@ -68,37 +68,72 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where log_id = #{logId} where log_id = #{logId}
</select> </select>
<!-- <select id="selectCategoryLogCount" parameterType="com.xinda.iot.domain.Device" resultType="com.xinda.iot.model.DeviceStatistic">-->
<!-- SELECT-->
<!-- (select count(log_id)-->
<!-- from iot_device_log-->
<!-- <where>-->
<!-- <if test="1==1"> and log_type=1</if>-->
<!-- <if test="tenantId != null and tenantId != 0"> and user_id = #{tenantId}</if>-->
<!-- </where>-->
<!-- ) as propertyCount,-->
<!-- (select count(id)-->
<!-- from iot_function_log-->
<!-- <where>-->
<!-- <if test="1==1"> and fun_type=2</if>-->
<!-- <if test="tenantId != null and tenantId != 0"> and user_id = #{tenantId}</if>-->
<!-- </where>-->
<!-- ) as functionCount,-->
<!-- (select count(log_id)-->
<!-- from iot_event_log-->
<!-- <where>-->
<!-- <if test="1==1"> and log_type=3</if>-->
<!-- <if test="tenantId != null and tenantId != 0"> and user_id = #{tenantId}</if>-->
<!-- </where>-->
<!-- ) as eventCount,-->
<!-- (select count(log_id)-->
<!-- from iot_device_log-->
<!-- <where>-->
<!-- <if test="1==1"> and log_type=1 and is_monitor=1</if>-->
<!-- <if test="tenantId != null and tenantId != 0"> and user_id = #{tenantId}</if>-->
<!-- </where>-->
<!-- ) as monitorCount-->
<!-- limit 1-->
<!-- </select>-->
<select id="selectCategoryLogCount" parameterType="com.xinda.iot.domain.Device" resultType="com.xinda.iot.model.DeviceStatistic"> <select id="selectCategoryLogCount" parameterType="com.xinda.iot.domain.Device" resultType="com.xinda.iot.model.DeviceStatistic">
SELECT SELECT
(select count(log_id) SUM(CASE WHEN type = 'property' THEN cnt ELSE 0 END) AS propertyCount,
from iot_device_log SUM(CASE WHEN type = 'function' THEN cnt ELSE 0 END) AS functionCount,
<where> SUM(CASE WHEN type = 'event' THEN cnt ELSE 0 END) AS eventCount,
<if test="1==1"> and log_type=1</if> SUM(CASE WHEN type = 'monitor' THEN cnt ELSE 0 END) AS monitorCount
FROM (
SELECT 'property' AS type, COUNT(log_id) AS cnt
FROM iot_device_log
WHERE log_type = 1
<if test="tenantId != null and tenantId != 0">and user_id = #{tenantId}</if> <if test="tenantId != null and tenantId != 0">and user_id = #{tenantId}</if>
</where>
) as propertyCount, UNION ALL
(select count(id)
from iot_function_log SELECT 'function' AS type, COUNT(id) AS cnt
<where> FROM iot_function_log
<if test="1==1"> and fun_type=2</if> WHERE fun_type = 2
<if test="tenantId != null and tenantId != 0">and user_id = #{tenantId}</if> <if test="tenantId != null and tenantId != 0">and user_id = #{tenantId}</if>
</where>
) as functionCount, UNION ALL
(select count(log_id)
from iot_event_log SELECT 'event' AS type, COUNT(log_id) AS cnt
<where> FROM iot_event_log
<if test="1==1"> and log_type=3</if> WHERE log_type = 3
<if test="tenantId != null and tenantId != 0">and user_id = #{tenantId}</if> <if test="tenantId != null and tenantId != 0">and user_id = #{tenantId}</if>
</where>
) as eventCount, UNION ALL
(select count(log_id)
from iot_device_log SELECT 'monitor' AS type, COUNT(log_id) AS cnt
<where> FROM iot_device_log
<if test="1==1"> and log_type=1 and is_monitor=1</if> WHERE log_type = 1 AND is_monitor = 1
<if test="tenantId != null and tenantId != 0">and user_id = #{tenantId}</if> <if test="tenantId != null and tenantId != 0">and user_id = #{tenantId}</if>
</where> ) AS subquery;
) as monitorCount
limit 1
</select> </select>
<insert id="insertDeviceLog" parameterType="com.xinda.iot.domain.DeviceLog" useGeneratedKeys="true" keyProperty="logId"> <insert id="insertDeviceLog" parameterType="com.xinda.iot.domain.DeviceLog" useGeneratedKeys="true" keyProperty="logId">

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xinda.iot.mapper.UnitIconMapper">
<resultMap type="UnitIcon" id="UnitIconResult">
<result property="id" column="id" />
<result property="unitDesc" column="unit_desc" />
<result property="unitName" column="unit_name" />
<result property="resourceUrl" column="resource_url" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectUnitIconVo">
select id, unit_desc, unit_name, resource_url, create_by, create_time, update_by, update_time from iot_unit_icon
</sql>
<select id="selectUnitIconList" parameterType="UnitIcon" resultMap="UnitIconResult">
<include refid="selectUnitIconVo"/>
<where>
<if test="unitDesc != null and unitDesc != ''"> and unit_desc like concat('%', #{unitDesc}, '%')</if>
<if test="unitName != null and unitName != ''"> and unit_name = #{unitName}</if>
<if test="resourceUrl != null and resourceUrl != ''"> and resource_url = #{resourceUrl}</if>
</where>
</select>
<select id="selectUnitIconById" parameterType="Long" resultMap="UnitIconResult">
<include refid="selectUnitIconVo"/>
where id = #{id}
</select>
<insert id="insertUnitIcon" parameterType="UnitIcon" useGeneratedKeys="true" keyProperty="id">
insert into iot_unit_icon
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unitDesc != null">unit_desc,</if>
<if test="unitName != null">unit_name,</if>
<if test="resourceUrl != null">resource_url,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="unitDesc != null">#{unitDesc},</if>
<if test="unitName != null">#{unitName},</if>
<if test="resourceUrl != null">#{resourceUrl},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateUnitIcon" parameterType="UnitIcon">
update iot_unit_icon
<trim prefix="SET" suffixOverrides=",">
<if test="unitDesc != null">unit_desc = #{unitDesc},</if>
<if test="unitName != null">unit_name = #{unitName},</if>
<if test="resourceUrl != null">resource_url = #{resourceUrl},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUnitIconById" parameterType="Long">
delete from iot_unit_icon where id = #{id}
</delete>
<delete id="deleteUnitIconByIds" parameterType="String">
delete from iot_unit_icon where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,41 @@
package com.xinda.system.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xinda.common.annotation.Excel;
import com.xinda.common.core.domain.BaseEntity;
/**
* 系统配置对象 sys_info
*
* @author kerwincui
* @date 2025-05-29
*/
@ApiModel(value = "SysInfo",description = "系统配置 sys_info")
@Data
public class SysInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id唯一标识 */
private Long id;
/** 登录标题名称 */
@Excel(name = "登录标题名称")
@ApiModelProperty("登录标题名称")
private String loginName;
/** 首页标题名称 */
@Excel(name = "首页标题名称")
@ApiModelProperty("首页标题名称")
private String indexName;
/** LOGO */
@Excel(name = "LOGO")
@ApiModelProperty("LOGO")
private String logoUrl;
}

View File

@@ -0,0 +1,61 @@
package com.xinda.system.mapper;
import java.util.List;
import com.xinda.system.domain.SysInfo;
/**
* 系统配置Mapper接口
*
* @author kerwincui
* @date 2025-05-29
*/
public interface SysInfoMapper
{
/**
* 查询系统配置
*
* @param id 系统配置主键
* @return 系统配置
*/
public SysInfo selectSysInfoById(Long id);
/**
* 查询系统配置列表
*
* @param sysInfo 系统配置
* @return 系统配置集合
*/
public List<SysInfo> selectSysInfoList(SysInfo sysInfo);
/**
* 新增系统配置
*
* @param sysInfo 系统配置
* @return 结果
*/
public int insertSysInfo(SysInfo sysInfo);
/**
* 修改系统配置
*
* @param sysInfo 系统配置
* @return 结果
*/
public int updateSysInfo(SysInfo sysInfo);
/**
* 删除系统配置
*
* @param id 系统配置主键
* @return 结果
*/
public int deleteSysInfoById(Long id);
/**
* 批量删除系统配置
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSysInfoByIds(Long[] ids);
}

View File

@@ -44,6 +44,7 @@ public interface SysUserMapper
*/ */
public SysUser selectUserByUserName(String userName); public SysUser selectUserByUserName(String userName);
SysUser selectUserByUserNameAndDeptId(@Param("userName")String userName, @Param("deptId") Long deptId);
/** /**
* 通过用户ID查询用户 * 通过用户ID查询用户
* *
@@ -109,7 +110,7 @@ public interface SysUserMapper
* @return 结果 * @return 结果
*/ */
public SysUser checkUserNameUnique(String userName); public SysUser checkUserNameUnique(String userName);
public SysUser checkDeptUserNameUnique(@Param("userName") String userName, @Param("deptId") Long deptId);
/** /**
* 校验手机号码是否唯一 * 校验手机号码是否唯一
* *
@@ -183,4 +184,5 @@ public interface SysUserMapper
*/ */
List<SysUser> selectByDeptId(Long deptId); List<SysUser> selectByDeptId(Long deptId);
} }

View File

@@ -0,0 +1,61 @@
package com.xinda.system.service;
import java.util.List;
import com.xinda.system.domain.SysInfo;
/**
* 系统配置Service接口
*
* @author kerwincui
* @date 2025-05-29
*/
public interface ISysInfoService
{
/**
* 查询系统配置
*
* @param id 系统配置主键
* @return 系统配置
*/
public SysInfo selectSysInfoById(Long id);
/**
* 查询系统配置列表
*
* @param sysInfo 系统配置
* @return 系统配置集合
*/
public List<SysInfo> selectSysInfoList(SysInfo sysInfo);
/**
* 新增系统配置
*
* @param sysInfo 系统配置
* @return 结果
*/
public int insertSysInfo(SysInfo sysInfo);
/**
* 修改系统配置
*
* @param sysInfo 系统配置
* @return 结果
*/
public int updateSysInfo(SysInfo sysInfo);
/**
* 批量删除系统配置
*
* @param ids 需要删除的系统配置主键集合
* @return 结果
*/
public int deleteSysInfoByIds(Long[] ids);
/**
* 删除系统配置信息
*
* @param id 系统配置主键
* @return 结果
*/
public int deleteSysInfoById(Long id);
}

View File

@@ -256,4 +256,5 @@ public interface ISysUserService
*/ */
List<SysUser> selectByDeptId(); List<SysUser> selectByDeptId();
SysUser selectUserByUserNameAndDeptId(String username, Long deptId);
} }

View File

@@ -0,0 +1,103 @@
package com.xinda.system.service.impl;
import java.util.List;
import com.xinda.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xinda.system.mapper.SysInfoMapper;
import com.xinda.system.domain.SysInfo;
import com.xinda.system.service.ISysInfoService;
/**
* 系统配置Service业务层处理
*
* @author kerwincui
* @date 2025-05-29
*/
@Service
public class SysInfoServiceImpl implements ISysInfoService
{
@Autowired
private SysInfoMapper sysInfoMapper;
/**
* 查询系统配置
*
* @param id 系统配置主键
* @return 系统配置
*/
@Override
public SysInfo selectSysInfoById(Long id)
{
return sysInfoMapper.selectSysInfoById(id);
}
/**
* 查询系统配置列表
*
* @param sysInfo 系统配置
* @return 系统配置
*/
@Override
public List<SysInfo> selectSysInfoList(SysInfo sysInfo)
{
return sysInfoMapper.selectSysInfoList(sysInfo);
}
/**
* 新增系统配置
*
* @param sysInfo 系统配置
* @return 结果
*/
@Override
public int insertSysInfo(SysInfo sysInfo)
{
sysInfo.setCreateTime(DateUtils.getNowDate());
return sysInfoMapper.insertSysInfo(sysInfo);
}
/**
* 修改系统配置
*
* @param sysInfo 系统配置
* @return 结果
*/
@Override
public int updateSysInfo(SysInfo sysInfo)
{
Long id = 1L;
if(sysInfo.getId()!=null){
sysInfo.setUpdateTime(DateUtils.getNowDate());
return sysInfoMapper.updateSysInfo(sysInfo);
}else{
sysInfo.setId(id);
sysInfo.setCreateTime(DateUtils.getNowDate());
return sysInfoMapper.insertSysInfo(sysInfo);
}
}
/**
* 批量删除系统配置
*
* @param ids 需要删除的系统配置主键
* @return 结果
*/
@Override
public int deleteSysInfoByIds(Long[] ids)
{
return sysInfoMapper.deleteSysInfoByIds(ids);
}
/**
* 删除系统配置信息
*
* @param id 系统配置主键
* @return 结果
*/
@Override
public int deleteSysInfoById(Long id)
{
return sysInfoMapper.deleteSysInfoById(id);
}
}

View File

@@ -131,6 +131,19 @@ public class SysUserServiceImpl implements ISysUserService
return userMapper.selectUserByUserName(userName); return userMapper.selectUserByUserName(userName);
} }
/**
* 通过用户名查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
// @Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userName", unless = "#result == null")
@Override
public SysUser selectUserByUserNameAndDeptId(String userName, Long deptId)
{
return userMapper.selectUserByUserNameAndDeptId(userName,deptId);
}
/** /**
* 通过用户ID查询用户 * 通过用户ID查询用户
* *
@@ -190,7 +203,8 @@ public class SysUserServiceImpl implements ISysUserService
public String checkUserNameUnique(SysUser user) public String checkUserNameUnique(SysUser user)
{ {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkUserNameUnique(user.getUserName()); SysUser info = userMapper.checkDeptUserNameUnique(user.getUserName(),user.getDeptId());
// 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.NOT_UNIQUE;

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xinda.system.mapper.SysInfoMapper">
<resultMap type="SysInfo" id="SysInfoResult">
<result property="id" column="id" />
<result property="loginName" column="login_name" />
<result property="indexName" column="index_name" />
<result property="logoUrl" column="logo_url" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectSysInfoVo">
select id, login_name, index_name, logo_url, create_by, create_time, update_by, update_time from sys_info
</sql>
<select id="selectSysInfoList" parameterType="SysInfo" resultMap="SysInfoResult">
<include refid="selectSysInfoVo"/>
<where>
<if test="loginName != null and loginName != ''"> and login_name like concat('%', #{loginName}, '%')</if>
<if test="indexName != null and indexName != ''"> and index_name like concat('%', #{indexName}, '%')</if>
<if test="logoUrl != null and logoUrl != ''"> and logo_url = #{logoUrl}</if>
</where>
</select>
<select id="selectSysInfoById" parameterType="Long" resultMap="SysInfoResult">
<include refid="selectSysInfoVo"/>
where id = #{id}
</select>
<insert id="insertSysInfo" parameterType="SysInfo">
insert into sys_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="loginName != null">login_name,</if>
<if test="indexName != null">index_name,</if>
<if test="logoUrl != null">logo_url,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="loginName != null">#{loginName},</if>
<if test="indexName != null">#{indexName},</if>
<if test="logoUrl != null">#{logoUrl},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateSysInfo" parameterType="SysInfo">
update sys_info
<trim prefix="SET" suffixOverrides=",">
<if test="loginName != null">login_name = #{loginName},</if>
<if test="indexName != null">index_name = #{indexName},</if>
<if test="logoUrl != null">logo_url = #{logoUrl},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysInfoById" parameterType="Long">
delete from sys_info where id = #{id}
</delete>
<delete id="deleteSysInfoByIds" parameterType="String">
delete from sys_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -140,6 +140,12 @@
where u.user_name = #{userName} and u.del_flag = '0' where u.user_name = #{userName} and u.del_flag = '0'
</select> </select>
<select id="selectUserByUserNameAndDeptId" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.dept_id = #{deptId} and u.del_flag = '0'
</select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult"> <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.user_id = #{userId} where u.user_id = #{userId}
@@ -149,6 +155,11 @@
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1 select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
</select> </select>
<select id="checkDeptUserNameUnique" resultMap="SysUserResult">
select user_id, user_name from sys_user where user_name = #{userName} and dept_id = #{deptId} and del_flag = '0' limit 1
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult"> <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1 select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
</select> </select>