提交修改 下一步进行机构用户登录改造

This commit is contained in:
LEED
2025-05-28 17:17:20 +08:00
parent 9fccd0bb43
commit 3bac43403b
7 changed files with 127 additions and 7 deletions

View File

@@ -51,6 +51,24 @@ public class SysLoginController
private IAppPreferencesService appPreferencesService;
/**
* 登录方法
*
* @param loginBody 登录信息
* @return 结果
*/
// @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;
// }
/**
* 登录方法
*

View File

@@ -7,6 +7,10 @@ package com.xinda.common.core.domain.model;
*/
public class LoginBody
{
/**
* 机构ID
*/
private Long deptId;
/**
* 用户名
*/
@@ -42,6 +46,14 @@ public class LoginBody
*/
private String smsCode;
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getSmsCode() {
return smsCode;
}

View File

@@ -119,6 +119,7 @@ public class SysLoginService {
return tokenService.createToken(loginUser);
}
/**
* 第三方验证后,调用登录方法
*
@@ -233,4 +234,6 @@ public class SysLoginService {
// 生成token
return tokenService.createToken(loginUser);
}
}

View File

@@ -1,7 +1,16 @@
package com.xinda.itsm.service.impl;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.Calendar;
import java.util.List;
import java.util.function.Consumer;
import com.xinda.common.utils.DateUtils;
import com.xinda.itsm.domain.InspectionRecord;
import com.xinda.itsm.mapper.InspectionRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xinda.itsm.mapper.InspectionPlanMapper;
@@ -19,7 +28,8 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService
{
@Autowired
private InspectionPlanMapper inspectionPlanMapper;
@Autowired
private InspectionRecordMapper inspectionRecordMapper;
/**
* 查询巡检计划
*
@@ -53,8 +63,17 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService
@Override
public int insertInspectionPlan(InspectionPlan inspectionPlan)
{
inspectionPlan.setCreateTime(DateUtils.getNowDate());
return inspectionPlanMapper.insertInspectionPlan(inspectionPlan);
int num = inspectionPlanMapper.insertInspectionPlan(inspectionPlan);
// 收集日期范围内的所有日期
List<Date> dateList = new ArrayList<>();
processDateRange(inspectionPlan.getStartDate(), inspectionPlan.getEndDate(), dateList::add);
for(Date date : dateList){
InspectionRecord inspectionRecord = getBasicRecord(inspectionPlan, date, "");
inspectionRecordMapper.insertInspectionRecord(inspectionRecord);
}
return num;
}
/**
@@ -93,4 +112,44 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService
{
return inspectionPlanMapper.deleteInspectionPlanById(id);
}
/**
* 处理指定日期范围内的每一天使用java.util.Date类型
* @param startDate 开始日期
* @param endDate 结束日期
* @param dateConsumer 处理每一天的函数式接口
*/
public static void processDateRange(Date startDate, Date endDate, Consumer<Date> dateConsumer) {
// 验证日期顺序
if (startDate.after(endDate)) {
throw new IllegalArgumentException("开始日期不能晚于结束日期");
}
// 使用Calendar进行日期计算
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
Date currentDate = startDate;
while (!currentDate.after(endDate)) {
dateConsumer.accept(currentDate);
// 增加一天
calendar.add(Calendar.DAY_OF_MONTH, 1);
currentDate = calendar.getTime();
}
}
private InspectionRecord getBasicRecord(InspectionPlan inspectionPlan, Date now, String cycle) {
InspectionRecord record = new InspectionRecord();
record.setPlanName(inspectionPlan.getPlanName());
record.setPlanContent(inspectionPlan.getPlanContent());
record.setProjectName(inspectionPlan.getProjectName());
record.setPlanTime(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, now) + " " + inspectionPlan.getSetTime()));
record.setInspectionPerson(inspectionPlan.getInspectionPerson());
record.setPlanId(inspectionPlan.getId());
record.setUserId(inspectionPlan.getUserId());
record.setInspectionCycle(cycle);
record.setCycle(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, now));
return record;
}
}

View File

@@ -46,6 +46,8 @@ public class Alert extends BaseEntity {
@Excel(name = "告警状态", readConverterExp = "1=-启动2-停止")
private Integer status;
private Integer type;
/**
* 通知方式 格式:"1,2,3"
*/
@@ -106,6 +108,14 @@ public class Alert extends BaseEntity {
this.notifyTemplateList = notifyTemplateList;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public List<Scene> getScenes() {
return scenes;
}

View File

@@ -243,8 +243,12 @@ public class AlertServiceImpl implements IAlertService {
alertMapper.deleteAlertSceneByAlertIds(alertIds);
}
// 将 List<Long> 转换为 Long[]
Long[] sceneIds = alertMapper.selectSceneByAlert(alertIds).toArray(new Long[0]);
sceneService.deleteSceneBySceneIds(sceneIds);
List<Long> sceneIdList= alertMapper.selectSceneByAlert(alertIds);
if(sceneIdList.size()>0){
Long[] sceneIds = convertToList(sceneIdList);
sceneService.deleteSceneBySceneIds(sceneIds);
}
// 批量删除告警场景
alertMapper.deleteAlertSceneByAlertIds(alertIds);
// 批量删除告警通知模版配置
@@ -253,6 +257,15 @@ public class AlertServiceImpl implements IAlertService {
return alertMapper.deleteAlertByAlertIds(alertIds);
}
public Long[] convertToList(List<Long> sceneIdList) {
if (sceneIdList == null) {
return new Long[0]; // 返回空数组而非 null
}
return sceneIdList.toArray(new Long[0]);
}
/**
* 删除设备告警信息
*

View File

@@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="alertName" column="alert_name" />
<result property="alertLevel" column="alert_level" />
<result property="status" column="status" />
<result property="type" column="type" />
<result property="notify" column="notify" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@@ -45,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAlertVo">
select alert_id, alert_name, alert_level, status, notify, create_by, create_time, update_by, update_time, remark, tenant_id, tenant_name,serial_number from iot_alert
select alert_id, alert_name, alert_level, status,type, notify, create_by, create_time, update_by, update_time, remark, tenant_id, tenant_name,serial_number from iot_alert
</sql>
<select id="selectScenesByAlertId" parameterType="Long" resultMap="AlertSceneResult">
@@ -60,12 +61,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectAlertList" parameterType="Alert" resultMap="AlertResult">
select p.alert_id, p.alert_name, p.alert_level, p.status, p.notify, p.create_by, p.create_time,
select p.alert_id, p.alert_name, p.alert_level, p.status, p.type,p.notify, p.create_by, p.create_time,
p.update_by, p.update_time, p.remark, p.tenant_id, p.tenant_name,p.serial_number from iot_alert p
<where>
<if test="alertName != null and alertName != ''"> and p.alert_name like concat('%', #{alertName}, '%')</if>
<if test="alertLevel != null "> and p.alert_level = #{alertLevel}</if>
<if test="status != null "> and p.status = #{status}</if>
<if test="type != null "> and p.type = #{type}</if>
<if test="notify != null and notify != ''"> and p.notify = #{notify}</if>
<if test="tenantId != null "> and p.tenant_id = #{tenantId}</if>
<!-- <if test="deptId != null ">-->
@@ -99,7 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectNotifyTemplateListByAlertId" resultType="com.xinda.notify.domain.NotifyTemplate">
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
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
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
where a.alert_id = #{alertId}
@@ -124,6 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alertName != null and alertName != ''">alert_name,</if>
<if test="alertLevel != null">alert_level,</if>
<if test="status != null">status,</if>
<if test="type != null">type,</if>
<if test="notify != null">notify,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
@@ -138,6 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alertName != null and alertName != ''">#{alertName},</if>
<if test="alertLevel != null">#{alertLevel},</if>
<if test="status != null">#{status},</if>
<if test="type != null">#{type},</if>
<if test="notify != null">#{notify},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
@@ -156,6 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alertName != null and alertName != ''">alert_name = #{alertName},</if>
<if test="alertLevel != null">alert_level = #{alertLevel},</if>
<if test="status != null">status = #{status},</if>
<if test="type != null">type = #{type},</if>
<if test="notify != null">notify = #{notify},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>