巡检点bug修复

This commit is contained in:
guo 2023-08-18 17:39:26 +08:00
parent 72264b5104
commit 5fb8b2dce3
8 changed files with 255 additions and 90 deletions

View File

@ -6,12 +6,15 @@ import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.mqtt.bean.PushPayload; import com.zhgd.mqtt.bean.PushPayload;
import com.zhgd.mqtt.server.IMqttSender; import com.zhgd.mqtt.server.IMqttSender;
import com.zhgd.xmgl.modules.basicdata.entity.CompanyConfig; import com.zhgd.xmgl.modules.basicdata.entity.CompanyConfig;
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser; import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper; import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
import com.zhgd.xmgl.modules.basicdata.service.ICompanyConfigService; import com.zhgd.xmgl.modules.basicdata.service.ICompanyConfigService;
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
import com.zhgd.xmgl.modules.project.entity.ProjectVideoConfig; import com.zhgd.xmgl.modules.project.entity.ProjectVideoConfig;
import com.zhgd.xmgl.modules.project.service.IProjectService; import com.zhgd.xmgl.modules.project.service.IProjectService;
import com.zhgd.xmgl.push.service.UniPushService; import com.zhgd.xmgl.push.service.UniPushService;
import com.zhgd.xmgl.util.DateUtil;
import com.zhgd.xmgl.util.HikVideoUtil; import com.zhgd.xmgl.util.HikVideoUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
@ -36,6 +39,8 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Component @Component
public class AsyncCommon { public class AsyncCommon {
@Autowired
private INoticeService noticeService;
@Autowired @Autowired
private SystemUserMapper systemUserMapper; private SystemUserMapper systemUserMapper;
@Autowired @Autowired
@ -121,6 +126,7 @@ public class AsyncCommon {
List<SystemUser> systemUserList = systemUserMapper.selectList(Wrappers.lambdaQuery(SystemUser.class).in(SystemUser::getUserId, userIdSet)); List<SystemUser> systemUserList = systemUserMapper.selectList(Wrappers.lambdaQuery(SystemUser.class).in(SystemUser::getUserId, userIdSet));
if (CollUtil.isNotEmpty(systemUserList)) { if (CollUtil.isNotEmpty(systemUserList)) {
sendMq(title, msg, itemType, systemUserList); sendMq(title, msg, itemType, systemUserList);
addNotice(title, msg, itemType, systemUserList);
Map<String, List<SystemUser>> snUserMap = systemUserList.stream().filter(user -> user.getClientId() != null).collect(Collectors.groupingBy(SystemUser::getSn)); Map<String, List<SystemUser>> snUserMap = systemUserList.stream().filter(user -> user.getClientId() != null).collect(Collectors.groupingBy(SystemUser::getSn));
for (Map.Entry<String, List<SystemUser>> snUserListEntry : snUserMap.entrySet()) { for (Map.Entry<String, List<SystemUser>> snUserListEntry : snUserMap.entrySet()) {
asyncAiAnalyse.sendAppNotice(snUserListEntry.getKey(), title, msg, snUserListEntry.getValue(), payload); asyncAiAnalyse.sendAppNotice(snUserListEntry.getKey(), title, msg, snUserListEntry.getValue(), payload);
@ -131,6 +137,17 @@ public class AsyncCommon {
} }
} }
private void addNotice(String title, String msg, String itemType, List<SystemUser> systemUserList) {
for (SystemUser systemUser : systemUserList) {
Notice notice = new Notice();
notice.setType("19");
notice.setMsg(msg);
notice.setAccountId(systemUser.getUserId());
notice.setTitle(title);
notice.setSendTime(DateUtil.formatDateTime(new Date()));
noticeService.addNotice(notice, false);
}
}
/** /**
* 发给mq信息给相关的用户 * 发给mq信息给相关的用户

View File

@ -1,55 +1,68 @@
package com.zhgd.xmgl.modules.basicdata.entity; package com.zhgd.xmgl.modules.basicdata.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/** /**
* @Description: 消息通知 * @Description: 消息通知
* @author pds * @author pds
* @date 2020-12-24 * @date 2020-12-24
* @version V1.0 * @version V1.0
*/ */
@Data @Data
@TableName("notice") @TableName("notice")
@ApiModel(value="Notice实体类",description="Notice") @ApiModel(value = "Notice实体类", description = "Notice")
public class Notice implements Serializable { public class Notice implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**消息通知*/ /**
* 消息通知
*/
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value="消息通知") @ApiModelProperty(value = "消息通知")
private java.lang.Long id ; private java.lang.Long id;
/**类型1考勤提醒2人员报警,3车辆4混凝土监测5卸料平台6配电箱7扬尘,8视频9标养室,10安全检查,11质量检查,12塔吊,13升降机,14电表,15水表,16访客,17,防疫人员通知18访客通知*/ /**
@Excel(name = "类型1考勤提醒2人员报警,3车辆4混凝土监测5卸料平台6配电箱7扬尘,8视频9标养室,10安全检查,11质量检查,12塔吊,13升降机,14电表,15水表,16访客,17,防疫人员通知18访客通知", width = 15) * 类型1考勤提醒2人员报警,3车辆4混凝土监测5卸料平台6配电箱7扬尘,8视频9标养室,10安全检查,11质量检查,12塔吊,13升降机,14电表,15水表,16访客,17,防疫人员通知18访客通知,19巡检点
@ApiModelProperty(value="类型1考勤提醒2人员报警,3车辆4混凝土监测5卸料平台6配电箱7扬尘,8视频9标养室,10安全检查,11质量检查,12塔吊,13升降机,14电表,15水表,16访客,17,防疫人员通知18访客通知") */
private java.lang.String type ; @Excel(name = "类型1考勤提醒2人员报警,3车辆4混凝土监测5卸料平台6配电箱7扬尘,8视频9标养室,10安全检查,11质量检查,12塔吊,13升降机,14电表,15水表,16访客,17,防疫人员通知18访客通知,19巡检点", width = 15)
/**消息内容*/ @ApiModelProperty(value = "类型1考勤提醒2人员报警,3车辆4混凝土监测5卸料平台6配电箱7扬尘,8视频9标养室,10安全检查,11质量检查,12塔吊,13升降机,14电表,15水表,16访客,17,防疫人员通知18访客通知,19巡检点")
@Excel(name = "消息内容", width = 15) private java.lang.String type;
@ApiModelProperty(value="消息内容") /**
private java.lang.String msg ; * 消息内容
/**推送到的账号ID*/ */
@Excel(name = "推送到的账号ID", width = 15) @Excel(name = "消息内容", width = 15)
@ApiModelProperty(value="推送到的账号ID") @ApiModelProperty(value = "消息内容")
private java.lang.String msg;
private java.lang.Long accountId ; /**
/**标题*/ * 推送到的账号ID
@Excel(name = "标题", width = 15) */
@ApiModelProperty(value="标题") @Excel(name = "推送到的账号ID", width = 15)
private java.lang.String title ; @ApiModelProperty(value = "推送到的账号ID")
/**图片路径*/
@Excel(name = "图片路径", width = 15) private java.lang.Long accountId;
@ApiModelProperty(value="图片路径") /**
private java.lang.String imageUrl ; * 标题
/**推送的时间*/ */
@Excel(name = "推送的时间", width = 15) @Excel(name = "标题", width = 15)
@ApiModelProperty(value="推送的时间") @ApiModelProperty(value = "标题")
private java.lang.String sendTime ; private java.lang.String title;
/**
* 图片路径
*/
@Excel(name = "图片路径", width = 15)
@ApiModelProperty(value = "图片路径")
private java.lang.String imageUrl;
/**
* 推送的时间
*/
@Excel(name = "推送的时间", width = 15)
@ApiModelProperty(value = "推送的时间")
private java.lang.String sendTime;
} }

View File

@ -50,46 +50,15 @@ public class CheckingPointController {
@ApiOperation(value = " 新建巡检点", notes = "新建巡检点") @ApiOperation(value = " 新建巡检点", notes = "新建巡检点")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<CheckingPoint> add(@RequestBody CheckingPoint checkingPoint) { public Result add(@RequestBody CheckingPoint checkingPoint) {
Result<CheckingPoint> result = new Result<>(); checkingPointService.add(checkingPoint);
try { return Result.ok();
checkingPointService.save(checkingPoint);
// 生成指定url对应的二维码到文件宽和高都是300像素
String url = UUID.randomUUID() + ".jpg";
String path = basePath + url;
log.info(path);
checkingPoint.setQrCode(url);
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(checkingPoint));
jsonObject.put("checkingPointId", checkingPoint.getId());
jsonObject.remove("id");
QrCodeUtil.generate(JSON.toJSONString(jsonObject), 300, 300, FileUtil.file(path));
checkingPointService.updateById(checkingPoint);
result.successMsg(MessageUtil.get("addSucess"));
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
result.error500(MessageUtil.get("failErr"));
}
return result;
} }
@ApiOperation(value = "更新巡检点", notes = "更新巡检点") @ApiOperation(value = "更新巡检点", notes = "更新巡检点")
@PostMapping(value = "/edit") @PostMapping(value = "/edit")
public Result<CheckingPoint> edit(@RequestBody CheckingPoint checkingPoint) { public Result edit(@RequestBody CheckingPoint checkingPoint) {
// 生成指定url对应的二维码到文件宽和高都是300像素 checkingPointService.edit(checkingPoint);
String url = UUID.randomUUID() + ".jpg";
String path = basePath + url;
log.info(path);
checkingPoint.setQrCode(url);
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(checkingPoint));
jsonObject.put("checkingPointId", checkingPoint.getId());
jsonObject.remove("id");
QrCodeUtil.generate(JSON.toJSONString(jsonObject), 300, 300, FileUtil.file(path));
checkingPointService.updateById(checkingPoint);
return Result.ok(); return Result.ok();
} }
@ -108,12 +77,9 @@ public class CheckingPointController {
@ApiOperation(value = "删除巡检点", notes = "删除巡检点") @ApiOperation(value = "删除巡检点", notes = "删除巡检点")
@GetMapping(value = "/delete") @GetMapping(value = "/delete")
@ApiImplicitParam(name = "id", value = "巡检点id", paramType = "query", dataType = "long") @ApiImplicitParam(name = "id", value = "巡检点id", paramType = "query", dataType = "long")
public Result<CheckingPoint> deleteProjectBim(Long id) { public Result deleteProjectBim(Long id) {
Result<CheckingPoint> result = new Result<>(); checkingPointService.deleteProjectBim(id);
checkingPointInfoService.remove(new LambdaQueryWrapper<CheckingPointInfo>().eq(CheckingPointInfo::getCheckingPointId, id)); return Result.ok();
checkingPointService.removeById(id);
result.successMsg(MessageUtil.get("deleteSucess"));
return result;
} }
/** /**
@ -130,6 +96,6 @@ public class CheckingPointController {
}) })
@GetMapping(value = "/checkLocation") @GetMapping(value = "/checkLocation")
public Result<Boolean> checkLocation(Long id, Long userId, Double longitude, Double latitude) { public Result<Boolean> checkLocation(Long id, Long userId, Double longitude, Double latitude) {
return Result.success(checkingPointService.checkLocation(id,userId, longitude, latitude)); return Result.success(checkingPointService.checkLocation(id, userId, longitude, latitude));
} }
} }

View File

@ -82,12 +82,7 @@ public class CheckingPointInfoController {
@PostMapping(value = "/edit") @PostMapping(value = "/edit")
public Result<CheckingPointInfo> edit(@RequestBody CheckingPointInfo checkingPointInfo) { public Result<CheckingPointInfo> edit(@RequestBody CheckingPointInfo checkingPointInfo) {
Result<CheckingPointInfo> result = new Result<>(); Result<CheckingPointInfo> result = new Result<>();
if (Objects.equals(checkingPointInfo.getHandleDone(), 1)) { checkingPointInfoService.edit(checkingPointInfo);
UserInfo userInfo = SecurityUtils.getUser();
checkingPointInfo.setOperateId(userInfo.getUserId());
checkingPointInfo.setOperateTime(new Date());
}
checkingPointInfoService.updateById(checkingPointInfo);
result.setSuccess(true); result.setSuccess(true);
return result; return result;
} }
@ -96,9 +91,7 @@ public class CheckingPointInfoController {
@ApiImplicitParam(name = "id", value = "巡检点记录ID", paramType = "query", required = true, dataType = "Integer") @ApiImplicitParam(name = "id", value = "巡检点记录ID", paramType = "query", required = true, dataType = "Integer")
@PostMapping(value = "/delete") @PostMapping(value = "/delete")
public Result<CheckingPointInfo> delete(@RequestBody String id) { public Result<CheckingPointInfo> delete(@RequestBody String id) {
JSONObject jsonObject = JSON.parseObject(id, JSONObject.class); checkingPointInfoService.delete(id);
id = String.valueOf(jsonObject.get("id"));
checkingPointInfoService.removeById(id);
return Result.ok(); return Result.ok();
} }

View File

@ -26,4 +26,8 @@ public interface CheckingPointInfoService extends IService<CheckingPointInfo> {
List<CheckingPointInfo> selectAllList(); List<CheckingPointInfo> selectAllList();
void add(CheckingPointInfo checkingPointInfo); void add(CheckingPointInfo checkingPointInfo);
void edit(CheckingPointInfo checkingPointInfo);
void delete(String id);
} }

View File

@ -22,4 +22,10 @@ public interface CheckingPointService extends IService<CheckingPoint> {
* @return * @return
*/ */
Boolean checkLocation(Long id, Long userId, Double longitude, Double latitude); Boolean checkLocation(Long id, Long userId, Double longitude, Double latitude);
void add(CheckingPoint checkingPoint);
void edit(CheckingPoint checkingPoint);
void deleteProjectBim(Long id);
} }

View File

@ -1,23 +1,36 @@
package com.zhgd.xmgl.modules.checking.service.impl; package com.zhgd.xmgl.modules.checking.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
import com.zhgd.xmgl.modules.checking.controller.dto.CheckingPointInfoPageDto; import com.zhgd.xmgl.modules.checking.controller.dto.CheckingPointInfoPageDto;
import com.zhgd.xmgl.modules.checking.entity.CheckingPoint;
import com.zhgd.xmgl.modules.checking.entity.CheckingPointAlarm; import com.zhgd.xmgl.modules.checking.entity.CheckingPointAlarm;
import com.zhgd.xmgl.modules.checking.entity.CheckingPointInfo; import com.zhgd.xmgl.modules.checking.entity.CheckingPointInfo;
import com.zhgd.xmgl.modules.checking.enums.PointStatusEnum; import com.zhgd.xmgl.modules.checking.enums.PointStatusEnum;
import com.zhgd.xmgl.modules.checking.mapper.CheckingPointInfoMapper; import com.zhgd.xmgl.modules.checking.mapper.CheckingPointInfoMapper;
import com.zhgd.xmgl.modules.checking.mapper.CheckingPointMapper;
import com.zhgd.xmgl.modules.checking.service.CheckingPointAlarmService; import com.zhgd.xmgl.modules.checking.service.CheckingPointAlarmService;
import com.zhgd.xmgl.modules.checking.service.CheckingPointInfoService; import com.zhgd.xmgl.modules.checking.service.CheckingPointInfoService;
import com.zhgd.xmgl.modules.checking.service.CheckingPointService; import com.zhgd.xmgl.modules.checking.service.CheckingPointService;
import com.zhgd.xmgl.modules.project.service.IProjectService; import com.zhgd.xmgl.modules.project.service.IProjectService;
import com.zhgd.xmgl.security.entity.UserInfo;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author 邱平毅 * @author 邱平毅
@ -28,9 +41,14 @@ import java.util.List;
@Service @Service
@Slf4j @Slf4j
public class CheckingPointInfoServiceImpl extends ServiceImpl<CheckingPointInfoMapper, CheckingPointInfo> implements CheckingPointInfoService { public class CheckingPointInfoServiceImpl extends ServiceImpl<CheckingPointInfoMapper, CheckingPointInfo> implements CheckingPointInfoService {
@Autowired
SystemUserMapper systemUserMapper;
@Autowired
INoticeService noticeService;
@Autowired
CheckingPointMapper checkingPointMapper;
@Autowired @Autowired
CheckingPointInfoMapper checkingPointInfoMapper; CheckingPointInfoMapper checkingPointInfoMapper;
@Autowired @Autowired
CheckingPointAlarmService checkingPointAlarmService; CheckingPointAlarmService checkingPointAlarmService;
@Autowired @Autowired
@ -63,6 +81,68 @@ public class CheckingPointInfoServiceImpl extends ServiceImpl<CheckingPointInfoM
if (checkingPointInfo.getStatus() == PointStatusEnum.ABNORMAL.getId()) { if (checkingPointInfo.getStatus() == PointStatusEnum.ABNORMAL.getId()) {
checkingPointAlarmService.save(new CheckingPointAlarm(checkingPointId, checkingPointInfo.getAlarmDetails(), checkingPointInfo.getAlarmImage())); checkingPointAlarmService.save(new CheckingPointAlarm(checkingPointId, checkingPointInfo.getAlarmDetails(), checkingPointInfo.getAlarmImage()));
} }
CheckingPoint checkingPoint = checkingPointMapper.selectById(checkingPointInfo.getCheckingPointId());
//通知
List<String> userIds = StrUtil.split(checkingPoint.getNoticeUserIds(), ",");
for (String userId : userIds) {
SystemUser systemUser = systemUserMapper.selectById(userId);
noticeService.addUserNotice(Long.valueOf(userId),
String.format("新增巡检点记录,巡检点名称为%s巡检位置为%s巡检时间为%s巡检人员为%s巡检状态为%s请注意。",
checkingPoint.getCheckingPointName(), checkingPoint.getPosition(), DateUtil.formatDateTime(checkingPoint.getCreateDate()), systemUser.getRealName(), getStatus(checkingPointInfo.getStatus())),
"巡检点记录新增", "19");
}
}
@Override
public void edit(CheckingPointInfo checkingPointInfo) {
if (Objects.equals(checkingPointInfo.getHandleDone(), 1)) {
UserInfo userInfo = SecurityUtils.getUser();
checkingPointInfo.setOperateId(userInfo.getUserId());
checkingPointInfo.setOperateTime(new Date());
}
updateById(checkingPointInfo);
CheckingPointInfo cpi = checkingPointInfoMapper.selectById(checkingPointInfo.getId());
CheckingPoint checkingPoint = checkingPointMapper.selectById(cpi.getCheckingPointId());
//通知
List<String> userIds = StrUtil.split(checkingPoint.getNoticeUserIds(), ",");
for (String userId : userIds) {
SystemUser systemUser = systemUserMapper.selectById(userId);
noticeService.addUserNotice(Long.valueOf(userId),
String.format("编辑巡检点记录,巡检点名称为%s巡检位置为%s巡检时间为%s巡检人员为%s巡检状态为%s请注意。",
checkingPoint.getCheckingPointName(), checkingPoint.getPosition(), DateUtil.formatDateTime(cpi.getCreateDate()), systemUser.getRealName(), getStatus(cpi.getStatus())),
"巡检点记录编辑", "19");
}
}
@Override
public void delete(String id) {
CheckingPointInfo cpi = checkingPointInfoMapper.selectById(id);
JSONObject jsonObject = JSON.parseObject(id, JSONObject.class);
id = String.valueOf(jsonObject.get("id"));
removeById(id);
CheckingPoint checkingPoint = checkingPointMapper.selectById(cpi.getCheckingPointId());
//通知
List<String> userIds = StrUtil.split(checkingPoint.getNoticeUserIds(), ",");
for (String userId : userIds) {
SystemUser systemUser = systemUserMapper.selectById(userId);
noticeService.addUserNotice(Long.valueOf(userId),
String.format("删除巡检点记录,巡检点名称为%s巡检位置为%s巡检时间为%s巡检人员为%s巡检状态为%s请注意。",
checkingPoint.getCheckingPointName(), checkingPoint.getPosition(), DateUtil.formatDateTime(cpi.getCreateDate()), systemUser.getRealName(), getStatus(cpi.getStatus())),
"巡检点记录删除", "19");
}
}
private String getStatus(Integer status) {
//1正常 2异常
if (status == null) {
return null;
}
switch (status) {
case 1:
return "正常";
case 2:
return "异常";
}
return null;
} }
} }

View File

@ -1,18 +1,33 @@
package com.zhgd.xmgl.modules.checking.service.impl; package com.zhgd.xmgl.modules.checking.service.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gexin.fastjson.JSON;
import com.gexin.fastjson.JSONObject;
import com.zhgd.exception.PromptException; import com.zhgd.exception.PromptException;
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
import com.zhgd.xmgl.modules.checking.entity.CheckingPoint; import com.zhgd.xmgl.modules.checking.entity.CheckingPoint;
import com.zhgd.xmgl.modules.checking.entity.CheckingPointInfo;
import com.zhgd.xmgl.modules.checking.entity.qo.ProjectSnQO; import com.zhgd.xmgl.modules.checking.entity.qo.ProjectSnQO;
import com.zhgd.xmgl.modules.checking.mapper.CheckingPointInfoMapper;
import com.zhgd.xmgl.modules.checking.mapper.CheckingPointMapper; import com.zhgd.xmgl.modules.checking.mapper.CheckingPointMapper;
import com.zhgd.xmgl.modules.checking.service.CheckingPointService; import com.zhgd.xmgl.modules.checking.service.CheckingPointService;
import com.zhgd.xmgl.util.DateUtil;
import com.zhgd.xmgl.util.RegionUtil; import com.zhgd.xmgl.util.RegionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.UUID;
/** /**
* @author 邱平毅 * @author 邱平毅
* @ClassName CheckingPointServiceImpl * @ClassName CheckingPointServiceImpl
@ -20,9 +35,17 @@ import org.springframework.stereotype.Service;
* @Version 1.0 * @Version 1.0
*/ */
@Service @Service
@Slf4j
public class CheckingPointServiceImpl extends ServiceImpl<CheckingPointMapper, CheckingPoint> implements CheckingPointService { public class CheckingPointServiceImpl extends ServiceImpl<CheckingPointMapper, CheckingPoint> implements CheckingPointService {
@Autowired
CheckingPointInfoMapper checkingPointInfoMapper;
@Autowired @Autowired
CheckingPointMapper checkingPointMapper; CheckingPointMapper checkingPointMapper;
@Autowired
INoticeService noticeService;
@Value("${basePath}")
String basePath;
@Override @Override
public IPage<CheckingPoint> selectCheckingPointPage(ProjectSnQO projectSnQO) { public IPage<CheckingPoint> selectCheckingPointPage(ProjectSnQO projectSnQO) {
@ -44,4 +67,67 @@ public class CheckingPointServiceImpl extends ServiceImpl<CheckingPointMapper, C
} }
return true; return true;
} }
@Override
public void add(CheckingPoint checkingPoint) {
save(checkingPoint);
// 生成指定url对应的二维码到文件宽和高都是300像素
String url = UUID.randomUUID() + ".jpg";
String path = basePath + url;
log.info(path);
checkingPoint.setQrCode(url);
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(checkingPoint));
jsonObject.put("checkingPointId", checkingPoint.getId());
jsonObject.remove("id");
QrCodeUtil.generate(JSON.toJSONString(jsonObject), 300, 300, FileUtil.file(path));
updateById(checkingPoint);
//通知
List<String> userIds = StrUtil.split(checkingPoint.getNoticeUserIds(), ",");
for (String userId : userIds) {
noticeService.addUserNotice(Long.valueOf(userId),
String.format("新增巡检点,巡检点名称为%s巡检位置为%s巡检创建时间为%s请注意。", checkingPoint.getCheckingPointName(), checkingPoint.getPosition(), DateUtil.formatDateTime(checkingPoint.getCreateDate())),
"巡检点新增", "19");
}
}
@Override
public void edit(CheckingPoint checkingPoint) {
// 生成指定url对应的二维码到文件宽和高都是300像素
String url = UUID.randomUUID() + ".jpg";
String path = basePath + url;
log.info(path);
checkingPoint.setQrCode(url);
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(checkingPoint));
jsonObject.put("checkingPointId", checkingPoint.getId());
jsonObject.remove("id");
QrCodeUtil.generate(JSON.toJSONString(jsonObject), 300, 300, FileUtil.file(path));
updateById(checkingPoint);
//通知
List<String> userIds = StrUtil.split(checkingPoint.getNoticeUserIds(), ",");
for (String userId : userIds) {
noticeService.addUserNotice(Long.valueOf(userId),
String.format("修改巡检点,巡检点名称为%s巡检位置为%s巡检创建时间为%s请注意。", checkingPoint.getCheckingPointName(), checkingPoint.getPosition(), DateUtil.formatDateTime(checkingPoint.getCreateDate())),
"巡检点修改", "19");
}
}
@Override
public void deleteProjectBim(Long id) {
CheckingPoint checkingPoint = checkingPointMapper.selectById(id);
checkingPointInfoMapper.delete(new LambdaQueryWrapper<CheckingPointInfo>().eq(CheckingPointInfo::getCheckingPointId, id));
removeById(id);
//通知
List<String> userIds = StrUtil.split(checkingPoint.getNoticeUserIds(), ",");
for (String userId : userIds) {
noticeService.addUserNotice(Long.valueOf(userId),
String.format("删除巡检点,巡检点名称为%s巡检位置为%s巡检创建时间为%s请注意。", checkingPoint.getCheckingPointName(), checkingPoint.getPosition(), DateUtil.formatDateTime(checkingPoint.getCreateDate())),
"巡检点删除", "19");
}
}
} }