Browse Source

Merge branch 'develop' of gitadmin/tuoheng_telecomumale into release

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
8e1e5526d4
29 changed files with 1037 additions and 433 deletions
  1. +10
    -6
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/config/common/CommonConfig.java
  2. +5
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java
  3. +6
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/QuestionType.java
  4. +8
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/status/UpdateInspectionStatusService.java
  5. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/IReportServiceImpl.java
  6. +96
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportByAutoService.java
  7. +133
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportByManualService.java
  8. +5
    -96
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportService.java
  9. +35
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportServiceImpl.java
  10. +50
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/AutoGenerateWorkorderService.java
  11. +42
    -107
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java
  12. +62
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/NoticeWeChatMiniProgramService.java
  13. +124
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/SaveAccidentDataService.java
  14. +42
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/WxMessageRequest.java
  15. +1
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/WorkorderServiceImpl.java
  16. +137
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderByAutoService.java
  17. +212
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderByManualService.java
  18. +7
    -198
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderService.java
  19. +39
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderServiceImpl.java
  20. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-dev.yml
  21. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/application-local.yml
  22. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-prod.yml
  23. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/application-test.yml
  24. +1
    -1
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/wx/WxMessageRequest.java
  25. +5
    -5
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java
  26. +2
    -2
      tuoheng-service/tuoheng-miniprogram/src/main/resources/application-dev.yml
  27. +2
    -2
      tuoheng-service/tuoheng-miniprogram/src/main/resources/application-local.yml
  28. +2
    -2
      tuoheng-service/tuoheng-miniprogram/src/main/resources/application-prod.yml
  29. +2
    -2
      tuoheng-service/tuoheng-miniprogram/src/main/resources/application-test.yml

+ 10
- 6
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/config/common/CommonConfig.java View File

@@ -49,9 +49,9 @@ public class CommonConfig {
public static String airportURL;

/**
* 小程序地址
* 小程序url
*/
public static String minprogramUrl;
public static String wechatURL;

/**
* 小程序 appId
@@ -90,6 +90,7 @@ public class CommonConfig {

/**
* 小程序 templateId赋值
*
* @param tempId
*/
@Value("${wx.templateId}")
@@ -97,7 +98,6 @@ public class CommonConfig {
templateId = tempId;
}


/**
* 图片域名赋值
*
@@ -150,6 +150,7 @@ public class CommonConfig {

/**
* 飞手平台
*
* @param url 不同环境对应不同的url
*/
@Value("${tuoheng.pilot-url}")
@@ -159,6 +160,7 @@ public class CommonConfig {

/**
* OICD平台
*
* @param url 不同环境对应不同的url
*/
@Value("${tuoheng.oidc-url}")
@@ -168,6 +170,7 @@ public class CommonConfig {

/**
* 机场url
*
* @param url
*/
@Value("${tuoheng.airport-url}")
@@ -177,11 +180,12 @@ public class CommonConfig {

/**
* 小程序url
*
* @param url
*/
@Value("${tuoheng.minprogram-url}")
public void minprogramUrl(String url) {
minprogramUrl = url;
@Value("${tuoheng.wechat-url}")
public void wechatURL(String url) {
wechatURL = url;
}

}

+ 5
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java View File

@@ -19,6 +19,11 @@ public interface SystemConstant {
*/
String GAO_DE_URL = "https://restapi.amap.com/v3/geocode/regeo";

/**
* 推送微信消息
*/
String API_WEIXIN_SEND_MESSAGE = "/weiXin/send/message";

/**
* 机场平台:获取机场列表接口
*/
@@ -70,9 +75,4 @@ public interface SystemConstant {
*/
String API_AIRPORT_LOCATION = "/api/airportInterface/getLocationById";

/**
* 小程序消息推送
*/
String MESSAGE_PUSH = "//weiXin/send/message";

}

+ 6
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/QuestionType.java View File

@@ -15,6 +15,7 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
@TableName("th_question_type")
public class QuestionType extends BaseEntity {

private static final long serialVersionUID = 1L;

/**
@@ -42,11 +43,14 @@ public class QuestionType extends BaseEntity {
*/
private Integer isShow;

/**
* 是否生成工单:0:否(默认) 1:是
*/
private Integer isGenerateWorkorder;

/**
* 事故问题:0:否 1是
*/
private Integer accidentQuestion;



}

+ 8
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/status/UpdateInspectionStatusService.java View File

@@ -10,6 +10,8 @@ import com.tuoheng.admin.enums.code.inspection.EditInspectionStatusCodeEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.request.inspection.MissionStatusRequest;
import com.tuoheng.admin.service.report.IReportService;
import com.tuoheng.admin.service.report.generate.GenerateReportService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,6 +40,9 @@ public class UpdateInspectionStatusService {
@Autowired
private UpdateWaittStatusService updateWaittStatusService;

@Autowired
private GenerateReportService generateReportService;

/**
* 添加任务
*
@@ -66,6 +71,9 @@ public class UpdateInspectionStatusService {
log.info("修改任务状态业务接口:修改待执行状态");
status = InspectionStatusEnum.FLIGHT_COMPLETED.getCode();
updateWaittStatusService.updateWaittStatus(inspection);

// 任务完成后自动生成报告
generateReportService.generateByAuto(inspection);
}

this.updateEmergencyStatus(inspection, status);

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/IReportServiceImpl.java View File

@@ -46,7 +46,7 @@ public class IReportServiceImpl implements IReportService{
*/
@Override
public JsonResult generate(String id) {
return generateReportService.generate(id);
return generateReportService.generateByManual(id);
}

/**

+ 96
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportByAutoService.java View File

@@ -0,0 +1,96 @@
package com.tuoheng.admin.service.report.generate;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.ReportConverMapper;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.Report;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.code.report.GenerateReportCodeEnum;
import com.tuoheng.admin.mapper.InspectionFileHandleMapper;
import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.ReportMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;

/**
* 任务完成自动生成报告业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-09
*/
@Slf4j
@Service
public class GenerateReportByAutoService {

@Autowired
private ReportMapper reportMapper;

/**
* 生成报告
*
* @return
*/
public JsonResult generate(Inspection inspection) {
log.info("进入任务完成自动生成报告");
Report report = this.buildReport(inspection);

JsonResult result = this.addReport(report);
if (0 != result.getCode()) {
log.info("自动生成报告业务:添加报告记录失败:{}", result.getMsg());
throw new ServiceException("自动生成报告业务:添加报告记录失败");
}
return JsonResult.success();
}

/**
*
* 生成报告实体
*
* @param inspection
*/
private Report buildReport(Inspection inspection) {
Report report = ReportConverMapper.INSTANCE.fromInspectionToReport(inspection);
// 任务编号:XJBG+日期+3位排序数字
String code = DateUtils.generateCode("XJBG");
report.setId("");
report.setReportCode(code);
report.setTenantId(inspection.getTenantId());
report.setInspectionId(inspection.getId());
report.setInspectionCode(inspection.getCode());
report.setInspectionName(inspection.getName());
report.setCreateUser("");
report.setCreateTime(DateUtils.now());
return report;
}

/**
*
* 添加报告
* 每次生成报告,将上一次生成的报告给覆盖,因此直接将上次的删除,重新添加一条
*
* @param report
*/
private JsonResult addReport(Report report) {
Report reportTmp = reportMapper.selectOne(Wrappers.<Report>lambdaQuery()
.eq(Report::getInspectionId, report.getInspectionId())
.eq(Report::getMark, MarkEnum.VALID.getCode()));
if (null != reportTmp) {
reportMapper.deleteById(reportTmp.getId());
}
Integer rowCount = reportMapper.insert(report);
if (rowCount <= 0) {
log.info("自动生成报告业务:添加报告记录失败");
return JsonResult.error(GenerateReportCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateReportCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 133
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportByManualService.java View File

@@ -0,0 +1,133 @@
package com.tuoheng.admin.service.report.generate;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.ReportConverMapper;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.Report;
import com.tuoheng.admin.enums.code.report.GenerateReportCodeEnum;
import com.tuoheng.admin.mapper.InspectionFileHandleMapper;
import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.ReportMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 生成报告业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-09
*/
@Slf4j
@Service
public class GenerateReportByManualService {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private InspectionFileHandleMapper inspectionFileHandleMapper;

@Autowired
private ReportMapper reportMapper;

/**
* 生成报告
*
* @return
*/
public JsonResult generate(String id) {
log.info("进入生成报告业务");
String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId();

JsonResult result = this.check(id);
if (0 != result.getCode()) {
log.info("生成报告业务:校验参数失败:{}", result.getMsg());
return result;
}
Inspection inspection = (Inspection) result.getData();

Report report = this.buildReport(userId, tenantId, inspection);

result = this.addReport(report);
if (0 != result.getCode()) {
log.info("生成报告业务:添加报告记录失败:{}", result.getMsg());
return result;
}

return JsonResult.success(report);
}

/**
* 检查
*
* @param id
* @return
*/
private JsonResult check(String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(GenerateReportCodeEnum.INSPECTION_ID_IS_NULL.getCode(), GenerateReportCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
}
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getId, id)
.eq(Inspection::getMark, 1));
if (null == inspection) {
return JsonResult.error(GenerateReportCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), GenerateReportCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(inspection);
}

/**
*
* 生成报告实体
*
* @param inspection
*/
private Report buildReport(String userId, String tenantId, Inspection inspection) {
Report report = ReportConverMapper.INSTANCE.fromInspectionToReport(inspection);
// 任务编号:XJBG+日期+3位排序数字
String code = DateUtils.generateCode("XJBG");
report.setId("");
report.setReportCode(code);
report.setTenantId(tenantId);
report.setInspectionId(inspection.getId());
report.setInspectionCode(inspection.getCode());
report.setInspectionName(inspection.getName());
report.setCreateUser(userId);
report.setCreateTime(DateUtils.now());
return report;
}

/**
*
* 添加报告
* 每次生成报告,将上一次生成的报告给覆盖,因此直接将上次的删除,重新添加一条
*
* @param report
*/
private JsonResult addReport(Report report) {
Report reportTmp = reportMapper.selectOne(Wrappers.<Report>lambdaQuery()
.eq(Report::getInspectionId, report.getInspectionId())
.eq(Report::getMark, 1));
if (null != reportTmp) {
reportMapper.deleteById(reportTmp.getId());

}
Integer rowCount = reportMapper.insert(report);
if (rowCount <= 0) {
log.info("生成报告业务:添加报告记录失败");
return JsonResult.error(GenerateReportCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateReportCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 5
- 96
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportService.java View File

@@ -27,110 +27,19 @@ import java.util.stream.Collectors;
* @team tuoheng
* @date 2022-12-09
*/
@Slf4j
@Service
public class GenerateReportService {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private InspectionFileHandleMapper inspectionFileHandleMapper;

@Autowired
private ReportMapper reportMapper;
public interface GenerateReportService {

/**
* 生成报告
* 手动生成报告
*
* @return
*/
public JsonResult generate(String id) {
log.info("进入生成报告业务");
String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId();

JsonResult result = this.check(id);
if (0 != result.getCode()) {
log.info("生成报告业务:校验参数失败:{}", result.getMsg());
return result;
}
Inspection inspection = (Inspection) result.getData();
JsonResult generateByManual(String id);

Report report = this.buildReport(userId, tenantId, inspection);

result = this.addReport(report);
if (0 != result.getCode()) {
log.info("生成报告业务:添加报告记录失败:{}", result.getMsg());
return result;
}

return JsonResult.success(report);
}

/**
* 检查
*
* @param id
* @return
*/
private JsonResult check(String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(GenerateReportCodeEnum.INSPECTION_ID_IS_NULL.getCode(), GenerateReportCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
}
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getId, id)
.eq(Inspection::getMark, 1));
if (null == inspection) {
return JsonResult.error(GenerateReportCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), GenerateReportCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(inspection);
}

/**
*
* 生成报告实体
*
* @param inspection
*/
private Report buildReport(String userId, String tenantId, Inspection inspection) {
Report report = ReportConverMapper.INSTANCE.fromInspectionToReport(inspection);
// 任务编号:XJBG+日期+3位排序数字
String code = DateUtils.generateCode("XJBG");
report.setId("");
report.setReportCode(code);
report.setTenantId(tenantId);
report.setInspectionId(inspection.getId());
report.setInspectionCode(inspection.getCode());
report.setInspectionName(inspection.getName());
report.setCreateUser(userId);
report.setCreateTime(DateUtils.now());
return report;
}

/**
*
* 添加报告
* 每次生成报告,将上一次生成的报告给覆盖,因此直接将上次的删除,重新添加一条
*
* @param report
* 自动生成工单
*/
private JsonResult addReport(Report report) {
Report reportTmp = reportMapper.selectOne(Wrappers.<Report>lambdaQuery()
.eq(Report::getInspectionId, report.getInspectionId())
.eq(Report::getMark, 1));
if (null != reportTmp) {
reportMapper.deleteById(reportTmp.getId());
JsonResult generateByAuto(Inspection inspection);

}
Integer rowCount = reportMapper.insert(report);
if (rowCount <= 0) {
log.info("生成报告业务:添加报告记录失败");
return JsonResult.error(GenerateReportCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateReportCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 35
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportServiceImpl.java View File

@@ -0,0 +1,35 @@
package com.tuoheng.admin.service.report.generate;

import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 生成报告业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-06-27
*/
@Slf4j
@Service
public class GenerateReportServiceImpl implements GenerateReportService {

@Autowired
private GenerateReportByManualService generateReportByManualService;

@Autowired
private GenerateReportByAutoService generateReportByAutoService;

@Override
public JsonResult generateByManual(String id) {
return generateReportByManualService.generate(id);
}

@Override
public JsonResult generateByAuto(Inspection inspection) {
return generateReportByAutoService.generate(inspection);
}
}

+ 50
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/AutoGenerateWorkorderService.java View File

@@ -0,0 +1,50 @@
package com.tuoheng.admin.service.third.dsp;

import cn.hutool.core.collection.CollectionUtil;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.QuestionType;
import com.tuoheng.admin.service.workorder.generate.GenerateWorkorderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class AutoGenerateWorkorderService {

@Autowired
private GenerateWorkorderService generateWorkorderService;

/**
* 自动生成工单
*
* @param inspectionFileList
* @return
*/
@Transactional
public void generate(Inspection inspection, Map<String, QuestionType> questionTypeMap, List<InspectionFile> inspectionFileList) {
log.info("调用自动生成工单....");
List<InspectionFile> inspectionFileListTmp = new ArrayList<>();
for (InspectionFile inspectionFile : inspectionFileList) {
QuestionType questionType = questionTypeMap.get(inspectionFile.getQuestionCode());
if (0 == questionType.getIsGenerateWorkorder()) {
// 该问题不用自动生成工单
continue;
}
inspectionFileListTmp.add(inspectionFile);
}

if (CollectionUtil.isEmpty(inspectionFileListTmp)) {
return;
}
generateWorkorderService.generateByAuto(inspection, inspectionFileListTmp);
}

}

+ 42
- 107
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java View File

@@ -1,11 +1,11 @@
package com.tuoheng.admin.service.third.dsp;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.*;
@@ -24,11 +24,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -47,9 +43,6 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
@Autowired
private BusinessMapper businessMapper;

@Autowired
private TenantMapper tenantMapper;

@Autowired
private InspectionMapper inspectionMapper;

@@ -71,9 +64,6 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
@Autowired
private WebSocketService webSocketService;

@Autowired
private DeptMapper deptMapper;

@Autowired
private LiveChannelMapper liveChannelMapper;

@@ -81,7 +71,14 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
private DeliverStreamingService deliverStreamingService;

@Autowired
private RestTemplate restTemplate;
private SaveAccidentDataService saveAccidentDataService;

@Autowired
private AutoGenerateWorkorderService autoGenerateWorkorderService;

@Autowired
private NoticeWeChatMiniProgramService noticeWeChatMiniProgramService;


/**
* 保存DSP回调数据
@@ -173,7 +170,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
log.info("以下为本地问题图片信息:");
log.info(JSON.toJSONString(dspCallbackRequest.getQuestionFiles()));
List<QuestionFile> questionFiles = dspCallbackRequest.getQuestionFiles();
if (!CollectionUtils.isEmpty(questionFiles)) {
if (!CollectionUtil.isEmpty(questionFiles)) {
log.info("问题图片处理开始, 图片数量:{}", questionFiles.size());
// 坐标
boolean online_condition = AiAnalyseTypeEnum.ONLINE.getCode() == inspection.getIsLive();
@@ -186,7 +183,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
.notLike(online_condition, FlightData::getLat, "E-")
.notLike(online_condition, FlightData::getLat, "0.0")
.orderByDesc(FlightData::getTimestamp));
if (!CollectionUtils.isEmpty(flightDataList)) {
if (!CollectionUtil.isEmpty(flightDataList)) {
log.info("飞行坐标大小:{}", flightDataList.size());
}
List<InspectionFile> thirstyQuestionFiles = questionFiles.stream().map(questionFile -> {
@@ -285,24 +282,43 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
//对应急类型问题进行处理
Map<String, QuestionType> questionTypeMap = this.getStringQuestionTypeMap();
QuestionType questionType = questionTypeMap.get(questionFile.getQuestionCode());
log.info("问题对应的code={}",questionFile.getQuestionCode());
log.info("问题对应的问题类型questionType={}",questionType);
if(0 == questionType.getIsShow()){
log.info("问题对应的code={}", questionFile.getQuestionCode());
log.info("问题对应的问题类型questionType={}", questionType);
if (0 == questionType.getIsShow()) {
inspectionFile.setMark(MarkEnum.NOTVALID.getCode());
log.info("修改问题mark值mark={}",inspectionFile.getMark());
}else {
log.info("修改问题mark值mark={}", inspectionFile.getMark());
} else {
inspectionFile.setMark(MarkEnum.VALID.getCode());
}
return inspectionFile;
}).collect(Collectors.toList());

// 先判断是否第一次生成问题,通过问题表中是否有数据来判断
Integer count = inspectionFileMapper.selectCount(new LambdaQueryWrapper<InspectionFile>()
.eq(InspectionFile::getInspectionId, inspection.getId())
.eq(InspectionFile::getMark, MarkEnum.VALID.getCode()));

log.info("批量插入问题图片数据");
CommonUtils.batchOperate((x) -> inspectionFileMapper.addBatch(x), thirstyQuestionFiles, 1000);

log.info("调用saveAccidentData方法保存应急记录数据...");
Boolean result = this.saveAccidentData(thirstyQuestionFiles);
log.info("预警数据入库完成,result={}",result);
Map<String, QuestionType> questionTypeMap = getStringQuestionTypeMap();

log.info("调用saveAccidentData方法保存应急记录数据...");
Boolean result = saveAccidentDataService.saveAccidentData(questionTypeMap, thirstyQuestionFiles);
log.info("预警数据入库完成,result={}", result);

// 生成工单
autoGenerateWorkorderService.generate(inspection, questionTypeMap, thirstyQuestionFiles);

// 通知小程序
if (count <= 0) {
// 该任务第一次产生问题,通知小程序
if (CollectionUtil.isNotEmpty(thirstyQuestionFiles) && thirstyQuestionFiles.size() > 0) {
InspectionFile inspectionFile = thirstyQuestionFiles.get(0);
QuestionType questionType = questionTypeMap.get(inspectionFile.getQuestionId());
noticeWeChatMiniProgramService.notice(inspection, questionType);
}
}
}
//释放通道
if (4 == inspection.getAnalyseStatus() || 5 == inspection.getAnalyseStatus() || 6 == inspection.getAnalyseStatus()) {
@@ -311,7 +327,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
.eq(LiveChannel::getInspectionId, inspectionId)
.eq(LiveChannel::getMark, 1));
// 释放小程序选择的通道
if(null != liveChannel)
if (null != liveChannel)
deliverStreamingService.deliver(liveChannel.getChannelCode());
}

@@ -319,90 +335,9 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
}


/**
* 应急记录数据入库
*
* @param inspectionFileList
* @return
*/
@Transactional
Boolean saveAccidentData(List<InspectionFile> inspectionFileList) {
log.info("调用保存应急数据方法,应急数据入库开始....");
List<Accident> accidentList = new ArrayList<>();
Map<String, QuestionType> questionTypeMap = getStringQuestionTypeMap();
for (InspectionFile inspectionFile : inspectionFileList) {
QuestionType questionType = questionTypeMap.get(inspectionFile.getQuestionCode());
if (0 == questionType.getAccidentQuestion()) {
// 非事故问题,不用添加到事故表
continue;
}
Accident accident = new Accident();
//问题类型为应急类型时添加数据
accident.setTenantId(inspectionFile.getTenantId());
accident.setInspectionId(inspectionFile.getInspectionId());
accident.setInspectionFileId(inspectionFile.getId());
//根据巡检任务查询对应的公路id
Inspection inspection = inspectionMapper.selectById(inspectionFile.getInspectionId());
if (ObjectUtils.isNotEmpty(inspection)) {
accident.setChannelId(inspection.getChannelId());
accident.setChannelName(inspection.getChannelName());
accident.setLegId(inspection.getLegId());
accident.setLegName(inspection.getLegName());

//根据巡检任务类型判断当前应急事故类型flag设值
if (2 == inspection.getType()) {
accident.setSource(SourcesEnum.ACCIDENT.getCode());
} else {
// 该巡检任务存在应急任务,将后面发现的预警直接设置为不展示
Inspection emergencyInspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getEmergencyDataInspectionId, inspectionFile.getInspectionId())
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtils.isNotEmpty(emergencyInspection)) {
accident.setSource(SourcesEnum.ACCIDENT.getCode());
} else {
accident.setSource(SourcesEnum.INSPECTION_ACCIDENT.getCode());
}
}
String deptId = inspection.getDeptId();
accident.setDeptId(deptId);
//根据部门id查询部门名称
Dept dept = deptMapper.selectById(deptId);
if(ObjectUtil.isNotNull(dept)){
if(StringUtils.isNotEmpty(dept.getName())){
accident.setDeptName(dept.getName());
}
}
}

//航道代号
Channel channel = channelMapper.selectById(inspection.getChannelId());
if (ObjectUtils.isNotEmpty(channel)) {
accident.setChannelCode(channel.getCode());
}
accident.setQuestionId(inspectionFile.getQuestionId());
accident.setQuestionCode(inspectionFile.getQuestionCode());
accident.setQuestionName(inspectionFile.getQuestionName());
accident.setLongitude(inspectionFile.getLongitude());
accident.setLatitude(inspectionFile.getLatitude());
accident.setStatus(AccidentStatusEnum.UNTREATED.getCode());
accident.setCreateUser(inspectionFile.getCreateUser());
accident.setCreateTime(inspectionFile.getCreateTime());
accidentList.add(accident);
}
//产生的应急事故数据入库
Boolean result = false;
for (Accident accident : accidentList) {
result = accidentService.save(accident);
//数据发生变化推送通知
webSocketService.accidentNotice(accident.getTenantId());
}

return result;
//return accidentService.saveBatch(accidentList);
}

/**
* 根据问题类型封装成map
*
* @return
*/
private Map<String, QuestionType> getStringQuestionTypeMap() {
@@ -423,7 +358,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
* @return 当前飞行对象
*/
private FlightData getFlightDataByTime(List<FlightData> flightDataList, long time) {
if (CollectionUtils.isEmpty(flightDataList)) {
if (CollectionUtil.isEmpty(flightDataList)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取无人机飞行坐标失败!");
}
List<FlightData> flightData = flightDataList.stream().filter(data -> {
@@ -435,7 +370,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
return false;
}
}).collect(Collectors.toList());
if (CollectionUtils.isEmpty(flightData)) {
if (CollectionUtil.isEmpty(flightData)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取无人机飞行坐标失败!");
}
return flightData.get(0);

+ 62
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/NoticeWeChatMiniProgramService.java View File

@@ -0,0 +1,62 @@
package com.tuoheng.admin.service.third.dsp;

import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.QuestionType;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.service.workorder.generate.GenerateWorkorderService;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
public class NoticeWeChatMiniProgramService {

@Autowired
private UserMapper userMapper;

/**
* 通知微信小程序
*
* @param inspection
* @param questionType
*
* @return
*/
@Transactional
public void notice(Inspection inspection, QuestionType questionType) {
log.info("任务发现第一个问题,推送给微信小程序:inspection:{}, questionType:{}", inspection.getId(), questionType);

String url = CommonConfig.wechatURL + SystemConstant.API_WEIXIN_SEND_MESSAGE;
JSONObject jsonObject = new JSONObject();
jsonObject.put("tenantId", inspection.getTenantId());
jsonObject.put("inspectionId", inspection.getId());
jsonObject.put("questionName", questionType.getName());
jsonObject.put("questionDesc", questionType.getContent());
jsonObject.put("createTime", DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"));

log.info("任务发现第一个问题,推送给微信小程序:url:{}", url);
log.info("任务发现第一个问题,推送给微信小程序:jsonObject:{}", jsonObject);

String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
if (StringUtils.isEmpty(airPortStr)) {
log.info("任务发现第一个问题,推送给微信小程序:返回数据为空");
throw new com.aliyun.oss.ServiceException("微信小程序返回数据为空");
}
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (0 != jsonResult.getCode()) {
log.info("任务发现第一个问题,推送给微信小程序:返回失败,jsonResult:{}", jsonResult.getMsg());
throw new ServiceException("推送给微信小程序,返回失败");
}
log.info("任务发现第一个问题,推送给微信小程序:成功,inspection:{}, questionType:{}", inspection.getId(), questionType);
}
}

+ 124
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/SaveAccidentDataService.java View File

@@ -0,0 +1,124 @@
package com.tuoheng.admin.service.third.dsp;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.AccidentStatusEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.SourcesEnum;
import com.tuoheng.admin.mapper.ChannelMapper;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.service.accident.IAccidentService;
import com.tuoheng.admin.websocket.WebSocketService;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class SaveAccidentDataService {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private ChannelMapper channelMapper;

@Autowired
private IAccidentService accidentService;

@Autowired
private WebSocketService webSocketService;

@Autowired
private DeptMapper deptMapper;

/**
* 应急记录数据入库
*
* @param inspectionFileList
* @return
*/
@Transactional
public Boolean saveAccidentData(Map<String, QuestionType> questionTypeMap, List<InspectionFile> inspectionFileList) {
log.info("调用保存应急数据方法,应急数据入库开始....");
List<Accident> accidentList = new ArrayList<>();
for (InspectionFile inspectionFile : inspectionFileList) {
QuestionType questionType = questionTypeMap.get(inspectionFile.getQuestionCode());
if (0 == questionType.getAccidentQuestion()) {
// 非事故问题,不用添加到事故表
continue;
}
Accident accident = new Accident();
//问题类型为应急类型时添加数据
accident.setTenantId(inspectionFile.getTenantId());
accident.setInspectionId(inspectionFile.getInspectionId());
accident.setInspectionFileId(inspectionFile.getId());
//根据巡检任务查询对应的公路id
Inspection inspection = inspectionMapper.selectById(inspectionFile.getInspectionId());
if (ObjectUtils.isNotEmpty(inspection)) {
accident.setChannelId(inspection.getChannelId());
accident.setChannelName(inspection.getChannelName());
accident.setLegId(inspection.getLegId());
accident.setLegName(inspection.getLegName());

//根据巡检任务类型判断当前应急事故类型flag设值
if (2 == inspection.getType()) {
accident.setSource(SourcesEnum.ACCIDENT.getCode());
} else {
// 该巡检任务存在应急任务,将后面发现的预警直接设置为不展示
Inspection emergencyInspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getEmergencyDataInspectionId, inspectionFile.getInspectionId())
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtils.isNotEmpty(emergencyInspection)) {
accident.setSource(SourcesEnum.ACCIDENT.getCode());
} else {
accident.setSource(SourcesEnum.INSPECTION_ACCIDENT.getCode());
}
}
String deptId = inspection.getDeptId();
accident.setDeptId(deptId);
//根据部门id查询部门名称
Dept dept = deptMapper.selectById(deptId);
if(ObjectUtil.isNotNull(dept)){
if(StringUtils.isNotEmpty(dept.getName())){
accident.setDeptName(dept.getName());
}
}
}

//航道代号
Channel channel = channelMapper.selectById(inspection.getChannelId());
if (ObjectUtils.isNotEmpty(channel)) {
accident.setChannelCode(channel.getCode());
}
accident.setQuestionId(inspectionFile.getQuestionId());
accident.setQuestionCode(inspectionFile.getQuestionCode());
accident.setQuestionName(inspectionFile.getQuestionName());
accident.setLongitude(inspectionFile.getLongitude());
accident.setLatitude(inspectionFile.getLatitude());
accident.setStatus(AccidentStatusEnum.UNTREATED.getCode());
accident.setCreateUser(inspectionFile.getCreateUser());
accident.setCreateTime(inspectionFile.getCreateTime());
accidentList.add(accident);
}
//产生的应急事故数据入库
Boolean result = false;
for (Accident accident : accidentList) {
result = accidentService.save(accident);
//数据发生变化推送通知
webSocketService.accidentNotice(accident.getTenantId());
}
return result;
//return accidentService.saveBatch(accidentList);
}

}

+ 42
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/WxMessageRequest.java View File

@@ -0,0 +1,42 @@
package com.tuoheng.admin.service.third.dsp;

import lombok.Data;

/**
* @Author ChengWang
* @Date 2023/6/26
*/
@Data
public class WxMessageRequest {

/**
* 租户id
*/
private String tenantId;

/**
* 任务id
*/
private String inspectionId;

/**
* 问题id
*/
private String questionId;

/**
* 问题标题
*/
private String questionName;

/**
* 问题描述
*/
private String questionDesc;

/**
* 上报时间
*/
private String createTime;

}

+ 1
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/WorkorderServiceImpl.java View File

@@ -38,11 +38,10 @@ public class WorkorderServiceImpl implements IWorkorderService {

@Override
public JsonResult generate(List<String> idList) {
return generateWorkorderService.generate(idList);
return generateWorkorderService.generateByManual(idList);
}

/**
*
* 查询工单分页列表
*
* @param request

+ 137
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderByAutoService.java View File

@@ -0,0 +1,137 @@
package com.tuoheng.admin.service.workorder.generate;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.WorkOrderStatusEnum;
import com.tuoheng.admin.enums.code.workorder.GenerateWorkorderCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 生成工单业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Slf4j
@Service
public class GenerateWorkorderByAutoService {

@Autowired
private InspectionMapper inspectionMapper;
@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private WorkOrderMapper workOrderMapper;

@Autowired
private WorkOrderFileMapper workOrderFileMapper;

/**
* 产生问题时自动生成工单
*
* @param inspection
* @param inspectionFileList
*
* @return
*/
@Transactional
public JsonResult generate(Inspection inspection, List<InspectionFile> inspectionFileList) {
log.info("进入自动生成工单业务");

List<String> inspectionIdList = inspectionFileList.stream().map(o -> o.getInspectionId()).collect(Collectors.toList());

WorkOrder workOrder = this.insertWorkOrder(inspection);

this.insertWorkOrderFile(workOrder, inspectionIdList);

this.updateInspectionFileStatus(inspectionIdList);

return JsonResult.success();
}

/**
*
* 添加工单
*
*/
private WorkOrder insertWorkOrder(Inspection inspection) {
WorkOrder workOrder = new WorkOrder();
String code = DateUtils.generateCode("XJGD");
workOrder.setCode(code);
workOrder.setTenantId(inspection.getTenantId());
workOrder.setDeptId(inspection.getDeptId());
workOrder.setStatus(WorkOrderStatusEnum.WAIT.getCode());
workOrder.setDistributionId(""); // 分配人员
workOrder.setCreateUser("");
workOrder.setCreateTime(DateUtils.now());
Integer rowCount = workOrderMapper.insert(workOrder);
if (rowCount <= 0) {
log.info("添加工单表失败");
}
return workOrder;
}

/**
*
* 添加工单子表
*
*/
private void insertWorkOrderFile(WorkOrder workOrder, List<String> idList) {
List<WorkOrderFile> workOrderFileList = new ArrayList<>();
WorkOrderFile workOrderFile;
for (String id : idList) {
workOrderFile = new WorkOrderFile();
workOrderFile.setTenantId(workOrder.getTenantId());
workOrderFile.setWorkOrderId(workOrder.getId());
workOrderFile.setInspectionFileId(id);
workOrderFileList.add(workOrderFile);
}

if (CollectionUtil.isEmpty(workOrderFileList)) {
return;
}
Integer rowCount = workOrderFileMapper.insertBatch(workOrderFileList);
if (rowCount <= 0) {
log.info("添加工单子表失败");
}
}

/**
*
* 问题状态,改为已生成工单
*
* @param idList
*/
private JsonResult updateInspectionFileStatus(List<String> idList) {
Map<String, Object> map = new HashMap<>();
map.put("status", InspectionFileStatusEnum.GENERATE_ORDER.getCode());
map.put("updateUser", "");
map.put("updateTime", DateUtils.now());
map.put("idList", idList);

Integer rowCount = inspectionFileMapper.updateByIdList(map);
if (rowCount <= 0) {
log.info("修改任务问题状态, 确认失败");
return JsonResult.error(GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 212
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderByManualService.java View File

@@ -0,0 +1,212 @@
package com.tuoheng.admin.service.workorder.generate;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.WorkOrderStatusEnum;
import com.tuoheng.admin.enums.code.workorder.GenerateWorkorderCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 生成工单业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Slf4j
@Service
public class GenerateWorkorderByManualService {

@Autowired
private UserMapper userMapper;

@Autowired
private InspectionMapper inspectionMapper;
@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private WorkOrderMapper workOrderMapper;

@Autowired
private WorkOrderFileMapper workOrderFileMapper;

/**
* 生成工单
* 1)、判断参数
* 1.1)、判断参数
* 1.2)、判断权限
* 2)、添加到工单表
* 3)、添加到工单子表
* 4)、修改任务问题状态,改为已生成工单
*
* @param idList
* @return
*/
@Transactional
public JsonResult generate(List<String> idList) {
log.info("进入手动生成工单业务, idList:{}", idList);
String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId();
JsonResult result = this.check(idList);
if (0 != result.getCode()) {
log.info("手动生成工单业务:校验失败:{}", result.getMsg());
return result;
}
List<InspectionFile> inspectionFileList = (List<InspectionFile>) result.getData();
List<String> inspectionIdList = inspectionFileList.stream().map(o -> o.getInspectionId()).collect(Collectors.toList());
List<Inspection> inspectionList = inspectionMapper.selectBatchIds(inspectionIdList);
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId)
.eq(User::getId, userId)
.eq(User::getMark, 1));
result = checkPermission(user, inspectionList);

if (0 != result.getCode()) {
log.info("进入生成工单务:校验权限失败:{}", result.getMsg());
return result;
}

WorkOrder workOrder = this.insertWorkOrder(user);

this.insertWorkOrderFile(workOrder, idList);

this.updateInspectionFileStatus(userId, idList);

return JsonResult.success();
}

/**
* 检查参数
*
* @param idList
* @return
*/
private JsonResult check(List<String> idList) {
// 判断任务问题id是否为空
if (CollectionUtil.isEmpty(idList)) {
return JsonResult.error(GenerateWorkorderCodeEnum.ID_LIST_IS_NULL.getCode(), GenerateWorkorderCodeEnum.ID_LIST_IS_NULL.getMsg());
}
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectBatchIds(idList);
if (CollectionUtil.isEmpty(inspectionFileList)) {
return JsonResult.error(GenerateWorkorderCodeEnum.INSPECTION_FILE_ID_LIST_IS_NOT_EXIST.getCode(), GenerateWorkorderCodeEnum.INSPECTION_FILE_ID_LIST_IS_NOT_EXIST.getMsg());
}
for (InspectionFile inspectionFile : inspectionFileList) {
if (inspectionFile.getStatus() != InspectionFileStatusEnum.CONFIRMED.getCode()) {
return JsonResult.error(GenerateWorkorderCodeEnum.INCLUDE_NO_CONFIRMED_INSPECTION.getCode(), GenerateWorkorderCodeEnum.INCLUDE_NO_CONFIRMED_INSPECTION.getMsg());
}
}
return JsonResult.success(inspectionFileList);
}

/**
* 判断是否有生成工单权限
* 1)、超级管理员可选择所有部门问题生成工单
* 2)、部门管理员仅可生成本部门工单,无法生成子部门工单
* 3)、普通用户无生成工单权限
*
* @param user
* @param inspectionList
* @return
*/
private JsonResult checkPermission(User user, List<Inspection> inspectionList) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return JsonResult.success(user);
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
for (Inspection inspection : inspectionList) {
if (!user.getDeptId().equals(inspection.getDeptId())) {
return JsonResult.error(GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getCode(), GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getMsg());
}
}
return JsonResult.success(user);
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
return JsonResult.error(GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getCode(), GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getMsg());
}
return JsonResult.error();
}

/**
*
* 添加工单
*
*/
private WorkOrder insertWorkOrder(User user) {
WorkOrder workOrder = new WorkOrder();
String code = DateUtils.generateCode("XJGD");
workOrder.setCode(code);
workOrder.setTenantId(user.getTenantId());
workOrder.setDeptId(user.getDeptId());
workOrder.setStatus(WorkOrderStatusEnum.WAIT.getCode());
workOrder.setDistributionId(user.getId()); // 分配人员
workOrder.setCreateUser(user.getId());
workOrder.setCreateTime(DateUtils.now());
Integer rowCount = workOrderMapper.insert(workOrder);
if (rowCount <= 0) {
log.info("添加工单表失败");
}
return workOrder;
}

/**
*
* 添加工单子表
*
*/
private void insertWorkOrderFile(WorkOrder workOrder, List<String> idList) {
List<WorkOrderFile> workOrderFileList = new ArrayList<>();
WorkOrderFile workOrderFile;
for (String id : idList) {
workOrderFile = new WorkOrderFile();
workOrderFile.setTenantId(workOrder.getTenantId());
workOrderFile.setWorkOrderId(workOrder.getId());
workOrderFile.setInspectionFileId(id);
workOrderFileList.add(workOrderFile);
}

if (CollectionUtil.isEmpty(workOrderFileList)) {
return;
}
Integer rowCount = workOrderFileMapper.insertBatch(workOrderFileList);
if (rowCount <= 0) {
log.info("添加工单子表失败");
}
}

/**
*
* 问题状态,改为已生成工单
*
* @param userId
* @param idList
*/
private JsonResult updateInspectionFileStatus(String userId, List<String> idList) {
Map<String, Object> map = new HashMap<>();
map.put("status", InspectionFileStatusEnum.GENERATE_ORDER.getCode());
map.put("updateUser", userId);
map.put("updateTime", DateUtils.now());
map.put("idList", idList);

Integer rowCount = inspectionFileMapper.updateByIdList(map);
if (rowCount <= 0) {
log.info("修改任务问题状态, 确认失败");
return JsonResult.error(GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 7
- 198
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderService.java View File

@@ -1,212 +1,21 @@
package com.tuoheng.admin.service.workorder.generate;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.WorkOrderStatusEnum;
import com.tuoheng.admin.enums.code.workorder.GenerateWorkorderCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 生成工单业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Slf4j
@Service
public class GenerateWorkorderService {

@Autowired
private UserMapper userMapper;

@Autowired
private InspectionMapper inspectionMapper;
@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private WorkOrderMapper workOrderMapper;

@Autowired
private WorkOrderFileMapper workOrderFileMapper;

/**
* 生成工单
* 1)、判断参数
* 1.1)、判断参数
* 1.2)、判断权限
* 2)、添加到工单表
* 3)、添加到工单子表
* 4)、修改任务问题状态,改为已生成工单
*
* @param idList
* @return
*/
@Transactional
public JsonResult generate(List<String> idList) {
log.info("进入生成工单业务, idList:{}", idList);
String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId();
JsonResult result = this.check(idList);
if (0 != result.getCode()) {
log.info("进入生成工单业务:校验失败:{}", result.getMsg());
return result;
}
List<InspectionFile> inspectionFileList = (List<InspectionFile>) result.getData();
List<String> inspectionIdList = inspectionFileList.stream().map(o -> o.getInspectionId()).collect(Collectors.toList());
List<Inspection> inspectionList = inspectionMapper.selectBatchIds(inspectionIdList);
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId)
.eq(User::getId, userId)
.eq(User::getMark, 1));
result = checkPermission(user, inspectionList);

if (0 != result.getCode()) {
log.info("进入生成工单务:校验权限失败:{}", result.getMsg());
return result;
}

WorkOrder workOrder = this.insertWorkOrder(user);

this.insertWorkOrderFile(workOrder, idList);

this.updateInspectionFileStatus(userId, idList);

return JsonResult.success();
}

/**
* 检查参数
*
* @param idList
* @return
*/
private JsonResult check(List<String> idList) {
// 判断任务问题id是否为空
if (CollectionUtil.isEmpty(idList)) {
return JsonResult.error(GenerateWorkorderCodeEnum.ID_LIST_IS_NULL.getCode(), GenerateWorkorderCodeEnum.ID_LIST_IS_NULL.getMsg());
}
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectBatchIds(idList);
if (CollectionUtil.isEmpty(inspectionFileList)) {
return JsonResult.error(GenerateWorkorderCodeEnum.INSPECTION_FILE_ID_LIST_IS_NOT_EXIST.getCode(), GenerateWorkorderCodeEnum.INSPECTION_FILE_ID_LIST_IS_NOT_EXIST.getMsg());
}
for (InspectionFile inspectionFile : inspectionFileList) {
if (inspectionFile.getStatus() != InspectionFileStatusEnum.CONFIRMED.getCode()) {
return JsonResult.error(GenerateWorkorderCodeEnum.INCLUDE_NO_CONFIRMED_INSPECTION.getCode(), GenerateWorkorderCodeEnum.INCLUDE_NO_CONFIRMED_INSPECTION.getMsg());
}
}
return JsonResult.success(inspectionFileList);
}
public interface GenerateWorkorderService {

/**
* 判断是否有生成工单权限
* 1)、超级管理员可选择所有部门问题生成工单
* 2)、部门管理员仅可生成本部门工单,无法生成子部门工单
* 3)、普通用户无生成工单权限
*
* @param user
* @param inspectionList
* @return
* 手动生成工单
*/
private JsonResult checkPermission(User user, List<Inspection> inspectionList) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return JsonResult.success(user);
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
for (Inspection inspection : inspectionList) {
if (!user.getDeptId().equals(inspection.getDeptId())) {
return JsonResult.error(GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getCode(), GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getMsg());
}
}
return JsonResult.success(user);
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
return JsonResult.error(GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getCode(), GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getMsg());
}
return JsonResult.error();
}

/**
*
* 添加工单
*
*/
private WorkOrder insertWorkOrder(User user) {
WorkOrder workOrder = new WorkOrder();
String code = DateUtils.generateCode("XJGD");
workOrder.setCode(code);
workOrder.setTenantId(user.getTenantId());
workOrder.setDeptId(user.getDeptId());
workOrder.setStatus(WorkOrderStatusEnum.WAIT.getCode());
workOrder.setDistributionId(user.getId()); // 分配人员
workOrder.setCreateUser(user.getId());
workOrder.setCreateTime(DateUtils.now());
Integer rowCount = workOrderMapper.insert(workOrder);
if (rowCount <= 0) {
log.info("添加工单表失败");
}
return workOrder;
}

/**
*
* 添加工单子表
*
*/
private void insertWorkOrderFile(WorkOrder workOrder, List<String> idList) {
List<WorkOrderFile> workOrderFileList = new ArrayList<>();
WorkOrderFile workOrderFile;
for (String id : idList) {
workOrderFile = new WorkOrderFile();
workOrderFile.setTenantId(workOrder.getTenantId());
workOrderFile.setWorkOrderId(workOrder.getId());
workOrderFile.setInspectionFileId(id);
workOrderFileList.add(workOrderFile);
}

if (CollectionUtil.isEmpty(workOrderFileList)) {
return;
}
Integer rowCount = workOrderFileMapper.insertBatch(workOrderFileList);
if (rowCount <= 0) {
log.info("添加工单子表失败");
}
}
JsonResult generateByManual(List<String> idList);

/**
*
* 问题状态,改为已生成工单
*
* @param userId
* @param idList
* 自动生成工单
*/
private JsonResult updateInspectionFileStatus(String userId, List<String> idList) {
Map<String, Object> map = new HashMap<>();
map.put("status", InspectionFileStatusEnum.GENERATE_ORDER.getCode());
map.put("updateUser", userId);
map.put("updateTime", DateUtils.now());
map.put("idList", idList);
JsonResult generateByAuto(Inspection inspection, List<InspectionFile> inspectionFileList);

Integer rowCount = inspectionFileMapper.updateByIdList(map);
if (rowCount <= 0) {
log.info("修改任务问题状态, 确认失败");
return JsonResult.error(GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 39
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderServiceImpl.java View File

@@ -0,0 +1,39 @@
package com.tuoheng.admin.service.workorder.generate;

import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 生成工单业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Slf4j
@Service
public class GenerateWorkorderServiceImpl implements GenerateWorkorderService {

@Autowired
private GenerateWorkorderByManualService generateWorkorderByManualService;

@Autowired
private GenerateWorkorderByAutoService generateWorkorderByAutoService;


@Override
public JsonResult generateByManual(List<String> idList) {
return generateWorkorderByManualService.generate(idList);
}

@Override
public JsonResult generateByAuto(Inspection inspection, List<InspectionFile> inspectionFileList) {
return generateWorkorderByAutoService.generate(inspection, inspectionFileList);
}
}

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-dev.yml View File

@@ -158,6 +158,8 @@ tuoheng:
pilot-url: http://192.168.11.11:7011/pilot/web/
#airport配置地址
airport-url: http://192.168.11.22:9060
#小程序配置地址
wechat-url: http://192.168.11.11:9151
# 文件配置
uploads:
#上传的服务器上的映射文件夹

+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/resources/application-local.yml View File

@@ -170,7 +170,8 @@ tuoheng:
pilot-url: http://192.168.11.241:7011/pilot/web/
#airport配置地址
airport-url: http://192.168.11.22:9060

#小程序配置地址
wechat-url: http://192.168.11.11:9151
# 文件配置
uploads:
#上传的服务器上的映射文件夹

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-prod.yml View File

@@ -159,6 +159,8 @@ tuoheng:
pilot-url: https://pilot.t-aaron.com/pilot/web/
#airport配置地址
airport-url: https://airport.t-aaron.com
#小程序配置地址
wechat-url: https://telecomumale-miniprogram.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹

+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/resources/application-test.yml View File

@@ -159,7 +159,8 @@ tuoheng:
pilot-url: http://172.15.1.11:7011/pilot/web/
#airport配置地址
airport-url: https://airport-test.t-aaron.com

#小程序配置地址
wechat-url: https://telecomumale-miniprogram-test.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹

+ 1
- 1
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/wx/WxMessageRequest.java View File

@@ -32,7 +32,7 @@ public class WxMessageRequest {
/**
*问题标题
*/
private String inspectionName;
private String questionName;

/**
* 问题描述

+ 5
- 5
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java View File

@@ -185,7 +185,7 @@ public class WxServiceImpl implements IWxService {
ResponseEntity<String> responseEntity = null;
try {
data.put("time12",new TemplateMinDto(wxMessageRequest.getCreateTime()));
data.put("thing4",new TemplateMinDto(wxMessageRequest.getInspectionName()));
data.put("thing4",new TemplateMinDto(wxMessageRequest.getQuestionName()));
data.put("thing13",new TemplateMinDto(wxMessageRequest.getQuestionDesc()));
param.setData(data);

@@ -243,13 +243,13 @@ public class WxServiceImpl implements IWxService {
if(StringUtils.isEmpty(wxMessageRequest.getInspectionId())){
return JsonResult.error(WeiXinRequestEnum.INSPECTION_ID_IS_NULL.getCode(),WeiXinRequestEnum.INSPECTION_ID_IS_NULL.getMsg());
}
if(StringUtils.isEmpty(wxMessageRequest.getQuestionId())){
return JsonResult.error(WeiXinRequestEnum.QUESTION_ID_IS_NULL.getCode(),WeiXinRequestEnum.QUESTION_ID_IS_NULL.getMsg());
}
// if(StringUtils.isEmpty(wxMessageRequest.getQuestionId())){
// return JsonResult.error(WeiXinRequestEnum.QUESTION_ID_IS_NULL.getCode(),WeiXinRequestEnum.QUESTION_ID_IS_NULL.getMsg());
// }
if(StringUtils.isEmpty(wxMessageRequest.getCreateTime())){
return JsonResult.error(WeiXinRequestEnum.CREATE_TIME_IS_NULL.getCode(),WeiXinRequestEnum.CREATE_TIME_IS_NULL.getMsg());
}
if(StringUtils.isEmpty(wxMessageRequest.getInspectionName())){
if(StringUtils.isEmpty(wxMessageRequest.getQuestionName())){
return JsonResult.error(WeiXinRequestEnum.INSPECTION_NAME_NOT_EXIST.getCode(),WeiXinRequestEnum.INSPECTION_NAME_NOT_EXIST.getMsg());
}
if(StringUtils.isEmpty(wxMessageRequest.getQuestionDesc())){

+ 2
- 2
tuoheng-service/tuoheng-miniprogram/src/main/resources/application-dev.yml View File

@@ -81,8 +81,8 @@ tuoheng:
pilot-url: http://192.168.11.11:7011/pilot/web/
#airport配置地址
airport-url: http://192.168.11.22:9060
#微信小程序地址
minprogram-url: http://192.168.11.11:9151
#小程序配置地址
wechat-url: http://192.168.11.11:9151
# 文件配置
uploads:
#上传的服务器上的映射文件夹

+ 2
- 2
tuoheng-service/tuoheng-miniprogram/src/main/resources/application-local.yml View File

@@ -84,8 +84,8 @@ tuoheng:
pilot-url: http://192.168.11.11:7011/pilot/web/
#airport配置地址
airport-url: http://192.168.11.22:9060
#微信小程序地址
minprogram-url: https://telecomumale-miniprogram-test.t-aaron.com
#小程序配置地址
wechat-url: http://192.168.11.11:9151
# 文件配置
uploads:
#上传的服务器上的映射文件夹

+ 2
- 2
tuoheng-service/tuoheng-miniprogram/src/main/resources/application-prod.yml View File

@@ -81,8 +81,8 @@ tuoheng:
pilot-url: http://192.168.11.11:7011/pilot/web/
#airport配置地址
airport-url: https://airport.t-aaron.com
#微信小程序地址
minprogram-url: https://telecomumale-miniprogram.t-aaron.com
#小程序配置地址
wechat-url: https://telecomumale-miniprogram.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹

+ 2
- 2
tuoheng-service/tuoheng-miniprogram/src/main/resources/application-test.yml View File

@@ -81,8 +81,8 @@ tuoheng:
pilot-url: http://192.168.11.11:7011/pilot/web/
#airport配置地址
airport-url: https://airport-test.t-aaron.com
#微信小程序地址
minprogram-url: https://telecomumale-miniprogram-test.t-aaron.com
#小程序配置地址
wechat-url: https://telecomumale-miniprogram-test.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹

Loading…
Cancel
Save