Commit 6ba89545 by landerliang@163.com

新增定时自动下载签章上传检测报告

parent 172565c4
...@@ -82,4 +82,23 @@ public class QuartzJob extends BaseEntity implements Serializable { ...@@ -82,4 +82,23 @@ public class QuartzJob extends BaseEntity implements Serializable {
@NotBlank @NotBlank
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String description; private String description;
}
\ No newline at end of file
@ApiModelProperty("部门id")
private Long deptId;
@ApiModelProperty("环保系统账号")
private String account;
@ApiModelProperty("环保系统密码")
private String password;
@ApiModelProperty("授权人签章名称")
private String snName1;
@ApiModelProperty("批准人签章名称")
private String snName2;
@ApiModelProperty("公章名称")
private String snName3;
}
...@@ -30,9 +30,13 @@ public class JobQueryCriteria { ...@@ -30,9 +30,13 @@ public class JobQueryCriteria {
@Query(type = Query.Type.INNER_LIKE) @Query(type = Query.Type.INNER_LIKE)
private String jobName; private String jobName;
@Query(type = Query.Type.EQUAL)
private Long deptId;
@Query @Query
private Boolean isSuccess; private Boolean isSuccess;
@Query(type = Query.Type.BETWEEN) @Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime; private List<Timestamp> createTime;
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package me.zhengjie.modules.quartz.service.impl; package me.zhengjie.modules.quartz.service.impl;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.quartz.domain.QuartzJob; import me.zhengjie.modules.quartz.domain.QuartzJob;
...@@ -25,12 +26,16 @@ import me.zhengjie.modules.quartz.repository.QuartzLogRepository; ...@@ -25,12 +26,16 @@ import me.zhengjie.modules.quartz.repository.QuartzLogRepository;
import me.zhengjie.modules.quartz.service.QuartzJobService; import me.zhengjie.modules.quartz.service.QuartzJobService;
import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria; import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria;
import me.zhengjie.modules.quartz.utils.QuartzManage; import me.zhengjie.modules.quartz.utils.QuartzManage;
import me.zhengjie.modules.system.domain.vo.SysUserVo;
import me.zhengjie.modules.system.repository.UserMapper;
import me.zhengjie.utils.*; import me.zhengjie.utils.*;
import org.quartz.CronExpression; import org.quartz.CronExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
...@@ -47,14 +52,22 @@ public class QuartzJobServiceImpl implements QuartzJobService { ...@@ -47,14 +52,22 @@ public class QuartzJobServiceImpl implements QuartzJobService {
private final QuartzLogRepository quartzLogRepository; private final QuartzLogRepository quartzLogRepository;
private final QuartzManage quartzManage; private final QuartzManage quartzManage;
private final RedisUtils redisUtils; private final RedisUtils redisUtils;
@Autowired
private UserMapper userMapper;
@Override @Override
public Object queryAll(JobQueryCriteria criteria, Pageable pageable){ public Object queryAll(JobQueryCriteria criteria, Pageable pageable){
SysUserVo sysUserVo = userMapper.selectById(SecurityUtils.getCurrentUserId());
AssertUtil.isNotNull(sysUserVo,"登录身份已失效请重新登录");
criteria.setDeptId(sysUserVo.getDeptId());
return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable)); return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
} }
@Override @Override
public Object queryAllLog(JobQueryCriteria criteria, Pageable pageable){ public Object queryAllLog(JobQueryCriteria criteria, Pageable pageable){
SysUserVo sysUserVo = userMapper.selectById(SecurityUtils.getCurrentUserId());
AssertUtil.isNotNull(sysUserVo,"登录身份已失效请重新登录");
criteria.setDeptId(sysUserVo.getDeptId());
return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable)); return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
} }
...@@ -81,6 +94,10 @@ public class QuartzJobServiceImpl implements QuartzJobService { ...@@ -81,6 +94,10 @@ public class QuartzJobServiceImpl implements QuartzJobService {
if (!CronExpression.isValidExpression(resources.getCronExpression())){ if (!CronExpression.isValidExpression(resources.getCronExpression())){
throw new BadRequestException("cron表达式格式错误"); throw new BadRequestException("cron表达式格式错误");
} }
Long currentUserId = SecurityUtils.getCurrentUserId();
SysUserVo sysUserVo = userMapper.selectById(currentUserId);
AssertUtil.isNotNull(sysUserVo,"登录身份已失效,请重新登录");
resources.setDeptId(sysUserVo.getDeptId());
resources = quartzJobRepository.save(resources); resources = quartzJobRepository.save(resources);
quartzManage.addJob(resources); quartzManage.addJob(resources);
} }
...@@ -133,22 +150,24 @@ public class QuartzJobServiceImpl implements QuartzJobService { ...@@ -133,22 +150,24 @@ public class QuartzJobServiceImpl implements QuartzJobService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void executionSubJob(String[] tasks) throws InterruptedException { public void executionSubJob(String[] tasks) throws InterruptedException {
for (String id : tasks) { for (String id : tasks) {
QuartzJob quartzJob = findById(Long.parseLong(id)); if(StrUtil.isNotBlank(id)){
// 执行任务 QuartzJob quartzJob = findById(Long.parseLong(id));
String uuid = IdUtil.simpleUUID(); // 执行任务
quartzJob.setUuid(uuid); String uuid = IdUtil.simpleUUID();
// 执行任务 quartzJob.setUuid(uuid);
execution(quartzJob); // 执行任务
// 获取执行状态,如果执行失败则停止后面的子任务执行 execution(quartzJob);
Boolean result = (Boolean) redisUtils.get(uuid); // 获取执行状态,如果执行失败则停止后面的子任务执行
while (result == null) { Boolean result = (Boolean) redisUtils.get(uuid);
// 休眠5秒,再次获取子任务执行情况 while (result == null) {
Thread.sleep(5000); // 休眠5秒,再次获取子任务执行情况
result = (Boolean) redisUtils.get(uuid); Thread.sleep(5000);
} result = (Boolean) redisUtils.get(uuid);
if(!result){ }
redisUtils.del(uuid); if(!result){
break; redisUtils.del(uuid);
break;
}
} }
} }
} }
......
package me.zhengjie.modules.quartz.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.system.service.ReportService;
import me.zhengjie.utils.AssertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 检测报告相关定时任务
* @author Lander
*/
@Slf4j
@Component
public class ReportTask {
@Autowired
private ReportService reportService;
public void run(String param){
log.info(">>> 开始自动爬取新的检测报告进行下载、签章、上传");
JSONObject jsonObject = JSON.parseObject(param);
log.info(">>> 环保账户: {}, 环保密码:{}, 授权人签名盘符:{}, 批准人签名盘符:{}, 公章签名盘符:{}",
jsonObject.getString("account"),jsonObject.getString("password"),
jsonObject.getString("snKey1"),jsonObject.getString("snKey2"),jsonObject.getString("snKey3"));
AssertUtil.isNotNull(jsonObject.get("account"),"缺少环保系统账户,自动任务执行终止!");
AssertUtil.isNotNull(jsonObject.get("password"),"缺少环保系统密码,自动任务执行终止!");
AssertUtil.isNotNull(jsonObject.get("snKey1"),"缺少授权人签名盘符,自动任务执行终止!");
AssertUtil.isNotNull(jsonObject.get("snKey2"),"缺少批准人签名盘符,自动任务执行终止!");
AssertUtil.isNotNull(jsonObject.get("snKey3"),"缺少公章签名盘符,自动任务执行终止!");
reportService.autoDownloadAndSignAndUploadReport(jsonObject.getString("account"),jsonObject.getString("password"),
jsonObject.getString("snKey1"),jsonObject.getString("snKey2"),jsonObject.getString("snKey3"));
}
}
...@@ -55,7 +55,7 @@ public class ExecutionJob extends QuartzJobBean { ...@@ -55,7 +55,7 @@ public class ExecutionJob extends QuartzJobBean {
QuartzLogRepository quartzLogRepository = SpringContextHolder.getBean(QuartzLogRepository.class); QuartzLogRepository quartzLogRepository = SpringContextHolder.getBean(QuartzLogRepository.class);
QuartzJobService quartzJobService = SpringContextHolder.getBean(QuartzJobService.class); QuartzJobService quartzJobService = SpringContextHolder.getBean(QuartzJobService.class);
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
String uuid = quartzJob.getUuid(); String uuid = quartzJob.getUuid();
QuartzLog log = new QuartzLog(); QuartzLog log = new QuartzLog();
...@@ -108,8 +108,8 @@ public class ExecutionJob extends QuartzJobBean { ...@@ -108,8 +108,8 @@ public class ExecutionJob extends QuartzJobBean {
if(quartzJob.getEmail() != null){ if(quartzJob.getEmail() != null){
EmailService emailService = SpringContextHolder.getBean(EmailService.class); EmailService emailService = SpringContextHolder.getBean(EmailService.class);
// 邮箱报警 // 邮箱报警
EmailVo emailVo = taskAlarm(quartzJob, ThrowableUtil.getStackTrace(e)); /*EmailVo emailVo = taskAlarm(quartzJob, ThrowableUtil.getStackTrace(e));
emailService.send(emailVo, emailService.find()); emailService.send(emailVo, emailService.find());*/
} }
} finally { } finally {
quartzLogRepository.save(log); quartzLogRepository.save(log);
......
...@@ -24,6 +24,9 @@ public class ReportPageQueryVo { ...@@ -24,6 +24,9 @@ public class ReportPageQueryVo {
@ApiModelProperty("检测完成结束时间") @ApiModelProperty("检测完成结束时间")
private String endTime; private String endTime;
@ApiModelProperty("是否未上传文件")
private Integer isZero;
@ApiModelProperty("当前页") @ApiModelProperty("当前页")
private Integer currNo; private Integer currNo;
......
...@@ -70,7 +70,7 @@ public class TestReportVo { ...@@ -70,7 +70,7 @@ public class TestReportVo {
private String BusinessKey; private String BusinessKey;
@ApiModelProperty("PDF文件数") @ApiModelProperty("PDF文件数")
private Integer PDFCount; private String PDFCount;
@ApiModelProperty("所属站点") @ApiModelProperty("所属站点")
private String siteName; private String siteName;
......
package me.zhengjie.modules.system.domain.vo.task;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 自动下载签章上传报告错误日志
* @author Lander
*/
@TableName("t_task_error_log")
@Data
public class TaskErrorVo {
@TableId(type = IdType.AUTO)
@ApiModelProperty("自增ID")
private Integer id;
@ApiModelProperty("记录日期")
private Date createTime;
@ApiModelProperty("错误信息")
private String errMsg;
}
package me.zhengjie.modules.system.repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import me.zhengjie.modules.system.domain.vo.task.TaskErrorVo;
import org.springframework.stereotype.Repository;
/**
* t_task_error_log
* @author Lander
*/
@Repository
public interface TaskErrorMapper extends BaseMapper<TaskErrorVo> {
}
package me.zhengjie.modules.system.service; package me.zhengjie.modules.system.service;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
...@@ -16,8 +15,10 @@ import me.zhengjie.modules.system.domain.vo.SysUserVo; ...@@ -16,8 +15,10 @@ import me.zhengjie.modules.system.domain.vo.SysUserVo;
import me.zhengjie.modules.system.domain.vo.report.*; import me.zhengjie.modules.system.domain.vo.report.*;
import me.zhengjie.modules.system.domain.vo.signature.SignReportVo; import me.zhengjie.modules.system.domain.vo.signature.SignReportVo;
import me.zhengjie.modules.system.domain.vo.signature.SignatureVo; import me.zhengjie.modules.system.domain.vo.signature.SignatureVo;
import me.zhengjie.modules.system.domain.vo.task.TaskErrorVo;
import me.zhengjie.modules.system.repository.DeptMapper; import me.zhengjie.modules.system.repository.DeptMapper;
import me.zhengjie.modules.system.repository.ReportPdfMapper; import me.zhengjie.modules.system.repository.ReportPdfMapper;
import me.zhengjie.modules.system.repository.TaskErrorMapper;
import me.zhengjie.modules.system.repository.UserMapper; import me.zhengjie.modules.system.repository.UserMapper;
import me.zhengjie.modules.system.util.CarReportUtil; import me.zhengjie.modules.system.util.CarReportUtil;
import me.zhengjie.utils.AssertUtil; import me.zhengjie.utils.AssertUtil;
...@@ -35,7 +36,6 @@ import org.springframework.web.client.RestTemplate; ...@@ -35,7 +36,6 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder; import sun.misc.BASE64Encoder;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -65,14 +65,17 @@ public class ReportService { ...@@ -65,14 +65,17 @@ public class ReportService {
private static List<TestReportVo> reportVoList; private static List<TestReportVo> reportVoList;
private final TaskErrorMapper taskErrorMapper;
@Autowired @Autowired
public ReportService(UserMapper userMapper, DeptMapper deptMapper, CarReportUtil carReportUtil, ReportPdfMapper reportPdfMapper, SignatureService signatureService, RestTemplate restTemplate) { public ReportService(UserMapper userMapper, DeptMapper deptMapper, CarReportUtil carReportUtil, ReportPdfMapper reportPdfMapper, SignatureService signatureService, RestTemplate restTemplate, TaskErrorMapper taskErrorMapper) {
this.userMapper = userMapper; this.userMapper = userMapper;
this.deptMapper = deptMapper; this.deptMapper = deptMapper;
this.carReportUtil = carReportUtil; this.carReportUtil = carReportUtil;
this.reportPdfMapper = reportPdfMapper; this.reportPdfMapper = reportPdfMapper;
this.signatureService = signatureService; this.signatureService = signatureService;
this.restTemplate = restTemplate; this.restTemplate = restTemplate;
this.taskErrorMapper = taskErrorMapper;
} }
//调试用 //调试用
...@@ -83,7 +86,7 @@ public class ReportService { ...@@ -83,7 +86,7 @@ public class ReportService {
.VIN("2142435346475678") .VIN("2142435346475678")
.IUIDATE("2020-06-13 11:07:12.2345") .IUIDATE("2020-06-13 11:07:12.2345")
.ESignNo("1000001").DetectStartTime("2020-06-13T10:38:07").DetectEndTime("2020-06-13T12:38:07") .ESignNo("1000001").DetectStartTime("2020-06-13T10:38:07").DetectEndTime("2020-06-13T12:38:07")
.InspectionReportNo("450107690120200529155024739").IUTYPE("A").NewVDCT("1").PDFCount(4).siteName("金盾西乡塘检测站") .InspectionReportNo("450107690120200529155024739").IUTYPE("A").NewVDCT("1").PDFCount("4").siteName("金盾西乡塘检测站")
.SceneCode("1231").UniqueString("450107690120200529155024739").VDCT("1").VehicleID("1231313213123").VerifyResult("1").VLPN("测试11111").VLPNColor("蓝") .SceneCode("1231").UniqueString("450107690120200529155024739").VDCT("1").VehicleID("1231313213123").VerifyResult("1").VLPN("测试11111").VLPNColor("蓝")
.StationCode("4501001").build() .StationCode("4501001").build()
...@@ -91,6 +94,80 @@ public class ReportService { ...@@ -91,6 +94,80 @@ public class ReportService {
} }
/** /**
* 自动下载检测报告并签章上传
*/
public void autoDownloadAndSignAndUploadReport(String account,String password,String snKey1,String snKey2,String snKey3,
String snName1,String snName2,String snName3){
try {
List<TestReportVo> testReportVos = carReportUtil.taskReportList(account, password);
for(TestReportVo testReportVo:testReportVos){
//根据报告编码查询数据库是否已下载 未下载则进行自动下载签章和上传
ReportPdfVo reportPdfVo = reportPdfMapper.selectOne(new QueryWrapper<ReportPdfVo>().lambda().eq(ReportPdfVo::getReportNum, testReportVo.getInspectionNum()));
if(reportPdfVo == null){
log.info(">> 当前自动爬取的检测报告车牌号:{}, 检测状态:{}, 检测报告单号:{}", testReportVo.getVLPN(),testReportVo.getNewVDCT(), testReportVo.getInspectionNum());
ReportDetailsReqVo reportDetailsReqVo = new ReportDetailsReqVo();
reportDetailsReqVo.setCarNum(testReportVo.getVLPN());
reportDetailsReqVo.setReportNum(testReportVo.getInspectionNum());
//下载报告pdf 并写入数据库
reportPdfVo = new ReportPdfVo();
String pdfPath = carReportUtil.downloadReport(account, password, reportDetailsReqVo);
reportPdfVo.setPath(pdfPath);
reportPdfVo.setVehicleId(testReportVo.getVehicleID());
reportPdfVo.setUniqueString(testReportVo.getUniqueString());
reportPdfVo.setReportName(testReportVo.getInspectionNum());
reportPdfVo.setReportNum(testReportVo.getInspectionNum());
reportPdfVo.setBusinessKey(testReportVo.getBusinessKey());
reportPdfVo.setCreateTime(DateUtil.date());
reportPdfVo.setCarNum(testReportVo.getVLPN());
reportPdfMapper.insert(reportPdfVo);
//根据snKey查询签章信息
SignatureVo signatureVo1 = signatureService.getBySnKey(snKey1);
AssertUtil.isNotNull(signatureVo1,"找不到snKey为: " + snKey1 + "的签名章");
SignatureVo signatureVo2 = signatureService.getBySnKey(snKey2);
AssertUtil.isNotNull(signatureVo2,"找不到snKey为: " + snKey2 + "的签名章");
SignatureVo signatureVo3 = signatureService.getBySnKey(snKey3);
AssertUtil.isNotNull(signatureVo3,"找不到snKey为: " + snKey3 + "的公章");
//进行签章
CarSignatureReqVo carSignatureReqVo = new CarSignatureReqVo();
carSignatureReqVo.setReportPdfVo(reportPdfVo);
carSignatureReqVo.setSignature1(signatureVo1);
carSignatureReqVo.setSignature2(signatureVo2);
carSignatureReqVo.setSignature3(signatureVo3);
HttpEntity<CarSignatureReqVo> httpEntity = new HttpEntity<>(carSignatureReqVo);
ResponseEntity<ResultVo> responseEntity = this.restTemplate.exchange(
carSignatureUrl,
HttpMethod.POST,
httpEntity,
ResultVo.class);
AssertUtil.isTrue(responseEntity.getStatusCode() == HttpStatus.OK && responseEntity.getBody().getData()!=null,responseEntity.getBody().getErrMsg());
//更新数据库的报告详情
ReportPdfVo reportPdfVos = JSONUtil.toBean(JSONUtil.toJsonPrettyStr(responseEntity.getBody().getData()), ReportPdfVo.class);
reportPdfMapper.updateById(reportPdfVos);
//上传文件
carReportUtil.uploadReportPost(account,password,reportPdfVo);
}
}
} catch (Exception e) {
//记录错误信息
log.error(e.getCause().getMessage());
TaskErrorVo taskErrorVo = new TaskErrorVo();
taskErrorVo.setCreateTime(DateUtil.date());
taskErrorVo.setErrMsg(e.getCause().getMessage());
taskErrorMapper.insert(taskErrorVo);
}
}
/**
* 根据检测报告id查询pdf并进行Base64转换 * 根据检测报告id查询pdf并进行Base64转换
* @param reportPdfId * @param reportPdfId
* @return * @return
......
...@@ -39,6 +39,14 @@ public class SignatureService { ...@@ -39,6 +39,14 @@ public class SignatureService {
this.userMapper = userMapper; this.userMapper = userMapper;
} }
/**
* 根据snKey查询签章信息
* @param snKey
* @return
*/
public SignatureVo getBySnKey(String snKey){
return signatureMapper.selectOne(new QueryWrapper<SignatureVo>().lambda().eq(SignatureVo::getSnKey,snKey));
}
/** /**
* 查询全部部门信息 * 查询全部部门信息
......
...@@ -17,11 +17,14 @@ package me.zhengjie.modules.system.service.impl; ...@@ -17,11 +17,14 @@ package me.zhengjie.modules.system.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.Dept; import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.domain.vo.signature.SignatureVo;
import me.zhengjie.modules.system.repository.RoleRepository; import me.zhengjie.modules.system.repository.RoleRepository;
import me.zhengjie.modules.system.repository.SignatureMapper;
import me.zhengjie.modules.system.repository.UserRepository; import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.modules.system.service.dto.DeptDto; import me.zhengjie.modules.system.service.dto.DeptDto;
import me.zhengjie.modules.system.service.dto.DeptQueryCriteria; import me.zhengjie.modules.system.service.dto.DeptQueryCriteria;
...@@ -55,6 +58,7 @@ public class DeptServiceImpl implements DeptService { ...@@ -55,6 +58,7 @@ public class DeptServiceImpl implements DeptService {
private final UserRepository userRepository; private final UserRepository userRepository;
private final RedisUtils redisUtils; private final RedisUtils redisUtils;
private final RoleRepository roleRepository; private final RoleRepository roleRepository;
private final SignatureMapper signatureMapper;
@Override @Override
public List<DeptDto> queryAll(DeptQueryCriteria criteria, Boolean isQuery) throws Exception { public List<DeptDto> queryAll(DeptQueryCriteria criteria, Boolean isQuery) throws Exception {
...@@ -242,6 +246,12 @@ public class DeptServiceImpl implements DeptService { ...@@ -242,6 +246,12 @@ public class DeptServiceImpl implements DeptService {
if(roleRepository.countByDepts(deptIds) > 0){ if(roleRepository.countByDepts(deptIds) > 0){
throw new BadRequestException("所选部门存在角色关联,请解除后再试!"); throw new BadRequestException("所选部门存在角色关联,请解除后再试!");
} }
/*deptDtos.forEach(deptDto -> {
if(signatureMapper.selectCount(new QueryWrapper<SignatureVo>().lambda().eq(SignatureVo::getDeptId,deptDto)) > 0){
throw new BadRequestException("所选部门存在签章关联,请删除后再试!");
}
});*/
} }
private void updateSubCnt(Long deptId){ private void updateSubCnt(Long deptId){
...@@ -278,4 +288,4 @@ public class DeptServiceImpl implements DeptService { ...@@ -278,4 +288,4 @@ public class DeptServiceImpl implements DeptService {
redisUtils.delByKeys("data::user:",users.stream().map(User::getId).collect(Collectors.toSet())); redisUtils.delByKeys("data::user:",users.stream().map(User::getId).collect(Collectors.toSet()));
redisUtils.del("dept::id:" + id); redisUtils.del("dept::id:" + id);
} }
} }
\ No newline at end of file
...@@ -102,6 +102,8 @@ public class CarReportUtil { ...@@ -102,6 +102,8 @@ public class CarReportUtil {
Map<String,Object> formData = new HashMap<>(); Map<String,Object> formData = new HashMap<>();
AssertUtil.isTrue(FileUtil.exist(reportPdfVo.getPath()),"未扫描到当前检测报告文件");
//检测报告上传 //检测报告上传
formData.put("contentType","multipart/form-data; boundary=----------ae0ei4Ef1gL6GI3GI3KM7gL6Ef1gL6"); formData.put("contentType","multipart/form-data; boundary=----------ae0ei4Ef1gL6GI3GI3KM7gL6Ef1gL6");
formData.put("Filename",FileUtil.file(reportPdfVo.getPath()).getName()); formData.put("Filename",FileUtil.file(reportPdfVo.getPath()).getName());
...@@ -404,6 +406,16 @@ public class CarReportUtil { ...@@ -404,6 +406,16 @@ public class CarReportUtil {
stationCodvO.setVals(Arrays.asList(stationCode)); stationCodvO.setVals(Arrays.asList(stationCode));
conditionVoList.add(stationCodvO); conditionVoList.add(stationCodvO);
//是否过滤已上传的
if(reportPageQueryVo.getIsZero() == 1){
ConditionVo carNumVo=new ConditionVo();
carNumVo.setFld(MyContext.VDCT_FLD);
carNumVo.setFldtype(MyContext.FLD_TYPE);
carNumVo.setOp(MyContext.VDCT_OP);
carNumVo.setVals(Arrays.asList("0"));
conditionVoList.add(carNumVo);
}
//如果车牌号不为空 //如果车牌号不为空
if(StrUtil.isNotBlank(reportPageQueryVo.getCarNum())){ if(StrUtil.isNotBlank(reportPageQueryVo.getCarNum())){
ConditionVo carNumVo=new ConditionVo(); ConditionVo carNumVo=new ConditionVo();
...@@ -414,6 +426,8 @@ public class CarReportUtil { ...@@ -414,6 +426,8 @@ public class CarReportUtil {
conditionVoList.add(carNumVo); conditionVoList.add(carNumVo);
} }
//如果车主姓名不为空 //如果车主姓名不为空
if(StrUtil.isNotBlank(reportPageQueryVo.getOwnerName())){ if(StrUtil.isNotBlank(reportPageQueryVo.getOwnerName())){
ConditionVo ownerNameVo=new ConditionVo(); ConditionVo ownerNameVo=new ConditionVo();
...@@ -714,4 +728,98 @@ public class CarReportUtil { ...@@ -714,4 +728,98 @@ public class CarReportUtil {
return testReportVoIPage; return testReportVoIPage;
} }
/**
* 获取最新五条检测报告
* @param stationCode
* @param cookies
* @return
*/
public List<TestReportVo> topReportList(String stationCode, Object [] cookies){
//构造分页查询检测报告参数对象
FldsVo fldsVo=new FldsVo();
List<ConditionVo> conditionVoList=new ArrayList<>();
//只检索当前站点报告
ConditionVo stationCodvO=new ConditionVo();
stationCodvO.setFld(MyContext.STATIONCODE_FLD);
stationCodvO.setFldtype(MyContext.FLD_TYPE);
stationCodvO.setOp(MyContext.STATONCODE_OP);
stationCodvO.setVals(Arrays.asList(stationCode));
conditionVoList.add(stationCodvO);
//开始检索 按照检测时间倒叙 目前只检索最新的5条
QueryDataVo queryDataVo=new QueryDataVo(MyContext.INSPEC_TABLE,
MyContext.PHOTO_TABLE_NAME,MyContext.PHOTO_WHERE,fldsVo.getFld(),conditionVoList,null,5);
JSONObject body = JSONUtil.createObj();
body.put("data",queryDataVo);
body.put("rows",5);
body.put("page",1);
body.put("sort","DetectEndTime");
body.put("order","DESC");
//请求检索车检报告
String queryResult = HttpRequest.post(likeUrl).form(body).header("Cookie", cookies[0].toString() + ";" + cookies[1].toString() + ";" + cookies[2].toString())
.execute().body();
if(!StrUtil.isNotBlank(queryResult)){
log.warn(">> 检索无结果返回");
}
if(queryResult.contains("html")){
log.error(">> 请求参数错误");
}
//将结果转vo对象
InspecPageVo pageVo = JSONUtil.toBean(queryResult, InspecPageVo.class);
return pageVo.getRows();
}
/**
* 获取最新5条检测报告 (给定时任务使用)
* @param username
* @param password
* @return
* @throws InterruptedException
*/
public List<TestReportVo> taskReportList (String username,String password) {
//登录环保检测系统
WebDriver driver = loginEp(username, password,null);
WebElement inspecReportBtn = driver.findElement(new By.ById("mainMenuTree_3_a"));
AssertUtil.isNotNull(inspecReportBtn,"抓取报告单菜单失败");
String[] reportA = inspecReportBtn.getAttribute("onclick").split("/");
//抓取当前登录用户的站点名称
WebElement stationSpan = driver.findElement(new By.ById("orgName"));
AssertUtil.isNotBlank(stationSpan.getText(),"获取不到当前用户的站点名称");
Object[] cookies = driver.manage().getCookies().toArray();
//获取所有站点信息
String stationJsonStr = HttpUtil.createGet(getStationUrl + System.currentTimeMillis())
.header("Cookie", cookies[0].toString() + ";" + cookies[1].toString() + ";" + cookies[2].toString()).execute().body();
AssertUtil.isNotBlank(stationJsonStr,"获取不到所有站点信息");
JSONArray stationList = JSONUtil.parseArray(stationJsonStr);
String stationCode = "";
for (Object station:stationList){
JSONObject stat = (JSONObject) station;
if(stat.getStr("Name").equals(stationSpan.getText())){
stationCode = stat.getStr("Code");
}
}
AssertUtil.isNotBlank(stationCode,"获取不到当前用户的站点编码");
List<TestReportVo> testReportVoIPage = topReportList(stationCode, cookies);
testReportVoIPage.forEach(testReportVo -> {
testReportVo.setSiteName(stationSpan.getText());
});
return testReportVoIPage;
}
} }
...@@ -56,6 +56,11 @@ public class MyContext { ...@@ -56,6 +56,11 @@ public class MyContext {
//车牌号检索 fld //车牌号检索 fld
public static final String VLPN_FLD = "VLPN"; public static final String VLPN_FLD = "VLPN";
//文件个数检索 fld
public static final String VDCT_FLD = "VDCT";
//文件个数 op
public static final String VDCT_OP = "=";
//燃料种类 fld //燃料种类 fld
public static final String FUEL_TYPE_FLD = "FuelType"; public static final String FUEL_TYPE_FLD = "FuelType";
//燃料种类 op //燃料种类 op
......
...@@ -90,3 +90,4 @@ uploadFilePath: C:\\reptiles\\uploadPicture\\ ...@@ -90,3 +90,4 @@ uploadFilePath: C:\\reptiles\\uploadPicture\\
signature: signature:
carSignature: carSignature:
url: http://127.0.0.1:9988/car-signature/start url: http://127.0.0.1:9988/car-signature/start
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment