Browse Source

fit:值班人员定时任务抽取数据v1

master
pengwei 5 months ago
parent
commit
9098366f5c
  1. 59
      src/main/java/com/biutag/supervision/job/Job.java
  2. 7
      src/main/java/com/biutag/supervision/mapper/SupRotaMapper.java
  3. 16
      src/main/java/com/biutag/supervision/mapper/ZhkshDutyScheduleDcMapper.java
  4. 51
      src/main/java/com/biutag/supervision/pojo/entity/SupRota.java
  5. 60
      src/main/java/com/biutag/supervision/pojo/entity/ZhkshDutyScheduleDc.java
  6. 8
      src/main/java/com/biutag/supervision/service/SupRotaService.java
  7. 7
      src/main/java/com/biutag/supervision/service/ZhkshDutyScheduleDcService.java
  8. 7
      src/main/resources/application-prod.yml

59
src/main/java/com/biutag/supervision/job/Job.java

@ -1,29 +1,34 @@
package com.biutag.supervision.job;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.stream.CollectorUtil;
import cn.hutool.core.util.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.biutag.supervision.constants.enums.ComfortStatus;
import com.biutag.supervision.constants.enums.ProcessingStatusEnum;
import com.biutag.supervision.constants.enums.RpcApplyTypeEnum;
import com.biutag.supervision.mapper.DwdAsjZfbaAjjbxxMapper;
import com.biutag.supervision.mapper.DwdAsjZfbaWfrwfxxMapper;
import com.biutag.supervision.mapper.RpcInfringerResultMapper;
import com.biutag.supervision.mapper.SupDepartMapper;
import com.biutag.supervision.mapper.*;
import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.service.*;
import com.biutag.supervision.util.CommonUtil;
import com.biutag.supervision.util.TimeUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static com.biutag.supervision.util.TimeUtil.SECONDS_OF_A_DAY;
@ -38,6 +43,8 @@ public class Job {
private final BusinessDepartService businessDepartService;
private final SupExternalDepartService externalDepartService;
// 更新办理超时
@Scheduled(fixedRate = 600000)
public void updateHandleTimeout() {
@ -248,4 +255,48 @@ public class Job {
});
}
private ZhkshDutyScheduleDcMapper zhkshDutyScheduleDcMapper;
private SupRotaMapper supRotaMapper;
//每天一次 00:20:00
//值班人员
@Scheduled(cron = "0 20 00 * * ?")
public void operator(){
log.info("operator--------------------");
log.info("值班人员抓取中---------------------");
//1、值班人员数据获取
LocalDate startTime = LocalDate.now();
LocalDate endTime = startTime.plusMonths(1);
List<ZhkshDutyScheduleDc> zhkshDutyScheduleDcs = zhkshDutyScheduleDcMapper.selectList(startTime,endTime);
if(CollectionUtil.isEmpty(zhkshDutyScheduleDcs)){
log.warn("无值班人员");
return;
}
//获取库中已有的值班数据(符合时间条件)
List<SupRota> rotas= supRotaMapper.selectList(new LambdaQueryWrapper<SupRota>().between(SupRota::getStartTime,startTime,endTime));
//剔除已录入过的数据
if(CollectionUtil.isNotEmpty(rotas)){
List<String> rotaIds = rotas.stream().map(SupRota::getScheduleId).toList();
zhkshDutyScheduleDcs=zhkshDutyScheduleDcs.stream().filter(x-> !rotaIds.contains(x.getScheduleId())).toList();
}
List<SupRota> supRotaList = CommonUtil.copyBeanList(zhkshDutyScheduleDcs,SupRota.class);
//2、值班人员数据处理
supRotaList.forEach(s->{
//获取数字督察一体系统对应的id
List<SupExternalDepart> supExternalDeparts= externalDepartService.list(
new LambdaQueryWrapper<SupExternalDepart>()
.eq(SupExternalDepart::getExternalId,s.getDeptCode())
);
if(CollectionUtil.isEmpty(supExternalDeparts)){
log.info("值班人员对应的值班单位不存在");
}else{
SupExternalDepart depart = supExternalDeparts.get(0);
s.setDeptCode(depart.getInternalId());
s.setDeptName(depart.getInternalName());
}
});
//3、值班人员转存
supRotaMapper.insert(supRotaList);
log.info("值班数据录入完成");
}
}

7
src/main/java/com/biutag/supervision/mapper/SupRotaMapper.java

@ -0,0 +1,7 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.SupRota;
public interface SupRotaMapper extends BaseMapper<SupRota> {
}

16
src/main/java/com/biutag/supervision/mapper/ZhkshDutyScheduleDcMapper.java

@ -0,0 +1,16 @@
package com.biutag.supervision.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.ZhkshDutyScheduleDc;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDate;
import java.util.List;
@DS("zbdm")
public interface ZhkshDutyScheduleDcMapper extends BaseMapper<ZhkshDutyScheduleDc> {
@Select(" SELECT * FROM 'CSGA110'.'V_ZHKSH_DUTY_SCHEDULE DC' " +
" where start_time between #{startTime} and #{endTime} ")
List<ZhkshDutyScheduleDc> selectList(LocalDate startTime,LocalDate endTime);
}

51
src/main/java/com/biutag/supervision/pojo/entity/SupRota.java

@ -0,0 +1,51 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class SupRota {
@TableId
private String id;
//值班人员
@TableField("rota_person_name")
private String rotaPersonName;
//值班人员警号
@TableField("police_code")
private String policeCode;
//值班身份证
@TableField("id_code")
private String idCode;
//值班时间
@TableField("rota_time")
private Date rotaTime;
//单位
@TableField("dept_name")
private String deptName;
//单位id
@TableField("dept_code")
private String deptCode;
//值班岗位
@TableField("rota_station")
private String rotaStation;
//值班岗位code
@TableField("post_code")
private String postCode;
//值班开始时间
@TableField("start_time")
private Date startTime;
//值班结束时间
@TableField("end_time")
private Date endTime;
//电话
@TableField("phone")
private String phone;
@TableField("schedule_id")
private String scheduleId;
}

60
src/main/java/com/biutag/supervision/pojo/entity/ZhkshDutyScheduleDc.java

@ -0,0 +1,60 @@
package com.biutag.supervision.pojo.entity;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class ZhkshDutyScheduleDc {
@TableField("SCHEDULE_ID")
private String scheduleId;
//单位id
@TableField("DEPT_CODE")
private String deptCode;
//单位名称
@TableField("DEPT_NAME")
private String deptName;
//值班时间
@TableField("ROTA_TIME")
private DateTime rotaTime;
//值班人名称
@TableField("ROTA_PERSON_NAME")
private String rotaPersonName;
//值班人身份证
@TableField("ID_CODE")
private String idCode;
//值班人警号
@TableField("POLICE_CODE")
private String policeCode;
//值班人联系方式
@TableField("PHONE")
private String phone;
//警务通联系方式
@TableField("JWT_PHONE")
private String jwtPhone;
//值班岗类型
@TableField("ROTA_STATION")
private String rotaStation;
//值班岗类型code
@TableField("POST_CODE")
private String postCode;
//值班类型
@TableField("PARENT_POST_CODE")
private String parentPostCode;
//开始时间
@TableField("START_TIME")
private Date startTime;
//结束时间
@TableField("END_TIME")
private Date endTime;
@TableField("DEVICE_CODE")
private String deviceCode;
@TableField("DEVICE_TYPE")
private String deviceType;
}

8
src/main/java/com/biutag/supervision/service/SupRotaService.java

@ -0,0 +1,8 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.mapper.SupRotaMapper;
import com.biutag.supervision.pojo.entity.SupRota;
public class SupRotaService extends ServiceImpl<SupRotaMapper, SupRota> {
}

7
src/main/java/com/biutag/supervision/service/ZhkshDutyScheduleDcService.java

@ -0,0 +1,7 @@
package com.biutag.supervision.service;
import org.springframework.stereotype.Service;
@Service
public class ZhkshDutyScheduleDcService {
}

7
src/main/resources/application-prod.yml

@ -44,7 +44,12 @@ spring:
url: jdbc:mysql://65.47.6.109:3306/wvp2?serverTimezone=GMT%2B8&useSSL=false
username: root
password: ip12341234
zbdm:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: dm.jdbc.driver.DmDriver
url: jdbc:dm://65.32.34.9:5237?SCHEMA=JSDZ_4GDB
username: dczd_cx
password: dczd#110110
druid:
min-evictable-idle-time-millis: 300000
test-on-borrow: false

Loading…
Cancel
Save