Browse Source

新增基础数据模块数据导入4

main
sjh 1 year ago
parent
commit
3e01462e93
  1. 2
      src/main/java/com/biutag/supervision/job/Job.java
  2. 2
      src/main/java/com/biutag/supervision/mapper/GBaseCJDMapper.java
  3. 2
      src/main/java/com/biutag/supervision/mapper/GBaseJJDMapper.java
  4. 18
      src/main/java/com/biutag/supervision/mapper/SupDepartMapper.java
  5. 3
      src/main/java/com/biutag/supervision/pojo/entity/BusinessDepart.java
  6. 3
      src/main/java/com/biutag/supervision/pojo/entity/BusinessPolice.java
  7. 4
      src/main/java/com/biutag/supervision/pojo/entity/GBaseCJD.java
  8. 4
      src/main/java/com/biutag/supervision/pojo/entity/GBaseJJD.java
  9. 2
      src/main/java/com/biutag/supervision/pojo/model/BusinessPoliceModel.java
  10. 79
      src/main/java/com/biutag/supervision/service/BusinessDepartService.java
  11. 75
      src/main/java/com/biutag/supervision/service/BusinessPoliceService.java
  12. 4
      src/main/resources/application-dev.yml
  13. 3
      src/main/resources/application-prod.yml
  14. 2
      src/main/resources/mapper/GBaseCJDMapper.xml
  15. 2
      src/main/resources/mapper/GBaseJJDMapper.xml

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

@ -64,7 +64,7 @@ public class Job {
} }
// 更新办理超时 // 更新办理超时
@Scheduled(fixedRate = 600000) // @Scheduled(fixedRate = 600000)
public void updateHandleTimeout() { public void updateHandleTimeout() {
List<Negative> list = negativeService.list(new LambdaQueryWrapper<Negative>() List<Negative> list = negativeService.list(new LambdaQueryWrapper<Negative>()
.isNotNull(Negative::getCompleteDate) .isNotNull(Negative::getCompleteDate)

2
src/main/java/com/biutag/supervision/mapper/GBaseCJDMapper.java

@ -1,5 +1,6 @@
package com.biutag.supervision.mapper; package com.biutag.supervision.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.Constants;
@ -9,6 +10,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@DS("slave2")
@Mapper @Mapper
public interface GBaseCJDMapper extends BaseMapper<GBaseCJD> { public interface GBaseCJDMapper extends BaseMapper<GBaseCJD> {
List<GBaseCJD> selectCJDList(@Param(Constants.WRAPPER) QueryWrapper<GBaseCJD> queryWrapper); List<GBaseCJD> selectCJDList(@Param(Constants.WRAPPER) QueryWrapper<GBaseCJD> queryWrapper);

2
src/main/java/com/biutag/supervision/mapper/GBaseJJDMapper.java

@ -1,5 +1,6 @@
package com.biutag.supervision.mapper; package com.biutag.supervision.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.Constants;
@ -9,6 +10,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@DS("slave2")
@Mapper @Mapper
public interface GBaseJJDMapper extends BaseMapper<GBaseJJD> { public interface GBaseJJDMapper extends BaseMapper<GBaseJJD> {
List<GBaseJJD> selectJJDList(@Param(Constants.WRAPPER) QueryWrapper<GBaseJJD> queryWrapper); List<GBaseJJD> selectJJDList(@Param(Constants.WRAPPER) QueryWrapper<GBaseJJD> queryWrapper);

18
src/main/java/com/biutag/supervision/mapper/SupDepartMapper.java

@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.SupDepart; import com.biutag.supervision.pojo.entity.SupDepart;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
public interface SupDepartMapper extends BaseMapper<SupDepart> { public interface SupDepartMapper extends BaseMapper<SupDepart> {
@Select("select d.* from sup_depart d left join sup_depart_jwpy t on d.code = t.depart_code where t.code = #{departCode}") @Select("select d.* from sup_depart d left join sup_depart_jwpy t on d.code = t.depart_code where t.code = #{departCode}")
@ -12,4 +15,19 @@ public interface SupDepartMapper extends BaseMapper<SupDepart> {
@Select("select max(id) from sup_depart") @Select("select max(id) from sup_depart")
Integer getMaxId(); Integer getMaxId();
@Select("<script>"
+ "SELECT domain_name, id FROM sup_depart WHERE domain_name IN "
+ "<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>"
+ "#{item}"
+ "</foreach>"
+ "</script>")
List<Map<String, Object>> getIdsByDepartIds(List<String> departIds);
@Select("<script>"
+ "SELECT code, id FROM sup_depart WHERE code IN "
+ "<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>"
+ "#{item}"
+ "</foreach>"
+ "</script>")
List<Map<String, Object>> getIdsByCode(List<String> departIds);
} }

3
src/main/java/com/biutag/supervision/pojo/entity/BusinessDepart.java

@ -7,6 +7,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
@Setter @Setter
@Getter @Getter
@ -18,7 +19,7 @@ public class BusinessDepart {
// 日期(天) // 日期(天)
@TableField("date") @TableField("date")
private LocalDateTime date; private Date date;
// 单位ID // 单位ID
@TableField("depart_id") @TableField("depart_id")

3
src/main/java/com/biutag/supervision/pojo/entity/BusinessPolice.java

@ -7,6 +7,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
@Setter @Setter
@Getter @Getter
@ -18,7 +19,7 @@ public class BusinessPolice {
// 日期(天) // 日期(天)
@TableField("date") @TableField("date")
private LocalDateTime date; private Date date;
// 警员姓名 // 警员姓名
@TableField("police_name") @TableField("police_name")

4
src/main/java/com/biutag/supervision/pojo/entity/GBaseCJD.java

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.time.LocalDateTime; import java.util.Date;
@Setter @Setter
@Getter @Getter
@ -18,7 +18,7 @@ public class GBaseCJD {
// 处警时间 // 处警时间
@TableField("cjsj") @TableField("cjsj")
private LocalDateTime cjsj; private Date cjsj;
// 处理完毕人编号 // 处理完毕人编号
@TableField("clwbrbh") @TableField("clwbrbh")

4
src/main/java/com/biutag/supervision/pojo/entity/GBaseJJD.java

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.time.LocalDateTime; import java.util.Date;
@Setter @Setter
@Getter @Getter
@ -18,7 +18,7 @@ public class GBaseJJD {
// 创建时间 // 创建时间
@TableField("cjsj") @TableField("cjsj")
private LocalDateTime cjsj; private Date cjsj;
// 管辖单位代码 // 管辖单位代码
@TableField("gxdwdm") @TableField("gxdwdm")

2
src/main/java/com/biutag/supervision/pojo/model/BusinessPoliceModel.java

@ -10,7 +10,7 @@ public class BusinessPoliceModel {
private String policeName; private String policeName;
// 警号 // 警号
private Integer empNo; private String empNo;
// 单位名称 // 单位名称
private String departName; private String departName;

79
src/main/java/com/biutag/supervision/service/BusinessDepartService.java

@ -12,15 +12,15 @@ import com.biutag.supervision.pojo.entity.GBaseJJD;
import com.biutag.supervision.pojo.model.BusinessPoliceModel; import com.biutag.supervision.pojo.model.BusinessPoliceModel;
import com.biutag.supervision.pojo.param.BusinessQueryParam; import com.biutag.supervision.pojo.param.BusinessQueryParam;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.executor.BatchResult; import org.apache.ibatis.executor.BatchResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, BusinessDepart> { public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, BusinessDepart> {
@ -33,15 +33,29 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
private final BusinessLogMapper businessLogMapper; private final BusinessLogMapper businessLogMapper;
private final SupDepartMapper supDepartMapper;
public Page<BusinessPoliceModel> page(BusinessQueryParam businessQueryParam) { public Page<BusinessPoliceModel> page(BusinessQueryParam businessQueryParam) {
if (businessQueryParam.getDepartName()!=null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) { // if (businessQueryParam.getDepartName()!=null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) {
List<Date> happenTime = new ArrayList<>(); // LocalDate start = LocalDate.parse("2024-05-23");
Date start = Date.from(LocalDateTime.parse("2024-01-01T00:00:00", DateTimeFormatter.ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant()); // LocalDate end = LocalDate.parse("2024-10-14");
Date end = Date.from(LocalDateTime.parse("2024-10-14T23:59:59", DateTimeFormatter.ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant()); // for (LocalDate date = start; !date.isAfter(end); date = date.plusDays(1)) {
happenTime.add(start); // List<Date> happenTime = new ArrayList<>();
happenTime.add(end); // Date startDate = Date.from(date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
generate(happenTime); // Date endDate = Date.from(date.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant());
} // happenTime.add(startDate);
// happenTime.add(endDate);
// generate(happenTime);
// log.info("已经导入{}的单位数据", date.format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
// }
// } else if (businessQueryParam.getDepartName() != null && businessQueryParam.getDepartName().equals("开始导入今天所有的数据")) {
// List<Date> happenTime = new ArrayList<>();
// Date start = Date.from(LocalDateTime.parse("2024-05-22T00:00:00", DateTimeFormatter.ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant());
// Date end = Date.from(LocalDateTime.parse("2024-05-22T10:59:59", DateTimeFormatter.ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant());
// happenTime.add(start);
// happenTime.add(end);
// generate(happenTime);
// }
QueryWrapper<BusinessPoliceModel> queryWrapper = new QueryWrapper<>(); QueryWrapper<BusinessPoliceModel> queryWrapper = new QueryWrapper<>();
queryWrapper queryWrapper
.like(StrUtil.isNotBlank(businessQueryParam.getDepartName()), "depart_name", businessQueryParam.getDepartName()) .like(StrUtil.isNotBlank(businessQueryParam.getDepartName()), "depart_name", businessQueryParam.getDepartName())
@ -57,14 +71,41 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
public void generate(List<Date> happenTime) { public void generate(List<Date> happenTime) {
List<BusinessDepart> businessDepartList = new ArrayList<>(); List<BusinessDepart> businessDepartList = new ArrayList<>();
List<GBaseJJD> gBaseJJDSList = selectJJDList(happenTime); List<GBaseJJD> gBaseJJDSList = selectJJDList(happenTime);
List<String> departIds = gBaseJJDSList.stream().map(GBaseJJD::getGxdwdm).toList(); if (gBaseJJDSList.isEmpty()) {
List<Map<String, Object>> resultList = statisticsDepartMapper.getGroupIdsByDepartIds(departIds); businessLogMapper.insert(new BusinessLog().setType("单位业务数据").setNum(0).setCreateTime(LocalDateTime.now()));
log.info("{}没有单位数据", happenTime.get(0));
return;
}
List<String> departIds = gBaseJJDSList.stream().map(GBaseJJD::getGxdwdm).collect(Collectors.toList());// 430100221100
List<Map<String, Object>> idsByDepartIds = supDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011
List<Map<String, Object>> idsByCode = supDepartMapper.getIdsByCode(departIds);
Map<String, String> resultMap2 = idsByDepartIds.stream().collect(Collectors.toMap(map -> (String) map.get("domain_name"), map -> (String) map.get("id")));
List<String> values = resultMap2.values().stream().filter(Objects::nonNull).toList();// 1011
Map<String, String> resultMap3 = idsByCode.stream().collect(Collectors.toMap(map -> (String) map.get("code"), map -> (String) map.get("id")));
List<String> values3 = resultMap3.values().stream().filter(Objects::nonNull).toList();// 1011
List<Map<String, Object>> resultList = new ArrayList<>();
if (!values.isEmpty()) {
resultList = statisticsDepartMapper.getGroupIdsByDepartIds(values);
}
List<Map<String, Object>> resultList2 = new ArrayList<>();
if (!values3.isEmpty()) {
resultList2 = statisticsDepartMapper.getGroupIdsByDepartIds(values3);
}
if (resultList.isEmpty() && resultList2.isEmpty()) {
businessLogMapper.insert(new BusinessLog().setType("单位业务数据").setNum(0).setCreateTime(LocalDateTime.now()));
log.info("{}没有单位数据", happenTime.get(0));
return;
}
Map<String, Long> resultMap = resultList.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId"))); Map<String, Long> resultMap = resultList.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId")));
Map<String, Long> resultMap4 = resultList2.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId")));
List<Long> groupIds = new ArrayList<>(); List<Long> groupIds = new ArrayList<>();
for (GBaseJJD gBaseJJD : gBaseJJDSList) { for (GBaseJJD gBaseJJD : gBaseJJDSList) {
Long groupId = resultMap.get(gBaseJJD.getGxdwdm()); Long groupId = resultMap.get(resultMap2.get(gBaseJJD.getGxdwdm()));
if (groupId == null) {
groupId = resultMap4.get(resultMap2.get(gBaseJJD.getGxdwdm()));
}
groupIds.add(groupId); groupIds.add(groupId);
BusinessDepart businessDepart = getBusinessDepart(gBaseJJD, groupId); BusinessDepart businessDepart = getBusinessDepart(happenTime, gBaseJJD, groupId);
businessDepartList.add(businessDepart); businessDepartList.add(businessDepart);
} }
List<Map<Long, Object>> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds); List<Map<Long, Object>> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds);
@ -73,14 +114,16 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
businessDepart.setGroupName(names.get(businessDepart.getGroupId())); businessDepart.setGroupName(names.get(businessDepart.getGroupId()));
businessDepart.setCreateTime(LocalDateTime.now()); businessDepart.setCreateTime(LocalDateTime.now());
} }
log.info("单位业务数据准备插入:{}", businessDepartList.size());
List<BatchResult> insert = baseMapper.insert(businessDepartList); List<BatchResult> insert = baseMapper.insert(businessDepartList);
log.info("单位业务数据插入成功");
int actualNum = (int) Arrays.stream(insert.get(0).getUpdateCounts()).parallel().filter(num -> num != 0).count(); int actualNum = (int) Arrays.stream(insert.get(0).getUpdateCounts()).parallel().filter(num -> num != 0).count();
businessLogMapper.insert(new BusinessLog().setType("单位业务数据").setNum(gBaseJJDSList.size()).setActualNum(actualNum).setCreateTime(LocalDateTime.now())); businessLogMapper.insert(new BusinessLog().setType("单位业务数据").setNum(gBaseJJDSList.size()).setActualNum(actualNum).setCreateTime(LocalDateTime.now()));
} }
private static BusinessDepart getBusinessDepart(GBaseJJD gBaseJJD, Long groupId) { private static BusinessDepart getBusinessDepart(List<Date> happenTime, GBaseJJD gBaseJJD, Long groupId) {
BusinessDepart businessDepart = new BusinessDepart(); BusinessDepart businessDepart = new BusinessDepart();
businessDepart.setDate(gBaseJJD.getCjsj()); businessDepart.setDate(happenTime.get(0));
businessDepart.setDepartId(gBaseJJD.getGxdwdm()); businessDepart.setDepartId(gBaseJJD.getGxdwdm());
businessDepart.setDepartName(gBaseJJD.getGxdwmc()); businessDepart.setDepartName(gBaseJJD.getGxdwmc());
businessDepart.setGroupId(groupId); businessDepart.setGroupId(groupId);
@ -101,7 +144,9 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
public List<GBaseJJD> selectJJDList(List<Date> happenTime) { public List<GBaseJJD> selectJJDList(List<Date> happenTime) {
QueryWrapper<GBaseJJD> queryWrapper = new QueryWrapper<>(); QueryWrapper<GBaseJJD> queryWrapper = new QueryWrapper<>();
queryWrapper.between("cjsj", happenTime.get(0), happenTime.get(1)); queryWrapper.between("cjsj", happenTime.get(0), happenTime.get(1));
queryWrapper.groupBy("gxdwdm", "gxdwmc", "cjsj"); queryWrapper.notLikeRight("jqxzdm", "11");
queryWrapper.notLikeRight("jqxzdm", "99");
queryWrapper.groupBy("gxdwdm", "gxdwmc");
return gBaseJJDMapper.selectJJDList(queryWrapper); return gBaseJJDMapper.selectJJDList(queryWrapper);
} }
} }

75
src/main/java/com/biutag/supervision/service/BusinessPoliceService.java

@ -12,17 +12,17 @@ import com.biutag.supervision.pojo.entity.GBaseCJD;
import com.biutag.supervision.pojo.model.BusinessPoliceModel; import com.biutag.supervision.pojo.model.BusinessPoliceModel;
import com.biutag.supervision.pojo.param.BusinessQueryParam; import com.biutag.supervision.pojo.param.BusinessQueryParam;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.executor.BatchResult; import org.apache.ibatis.executor.BatchResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, BusinessPolice> { public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, BusinessPolice> {
@ -35,18 +35,37 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
private final BusinessLogMapper businessLogMapper; private final BusinessLogMapper businessLogMapper;
private final BusinessDepartService businessDepartService;
private final SupDepartMapper supDepartMapper;
public Page<BusinessPoliceModel> page(BusinessQueryParam businessQueryParam) { public Page<BusinessPoliceModel> page(BusinessQueryParam businessQueryParam) {
if (businessQueryParam.getDepartName()!=null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) { // if (businessQueryParam.getDepartName()!=null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) {
List<Date> happenTime = new ArrayList<>(); // LocalDate start = LocalDate.parse("2024-01-01");
Date start = Date.from(LocalDateTime.parse("2024-01-01T00:00:00", DateTimeFormatter.ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant()); // LocalDate end = LocalDate.parse("2024-10-14");
Date end = Date.from(LocalDateTime.parse("2024-10-14T23:59:59", DateTimeFormatter.ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant()); //
happenTime.add(start); // for (LocalDate date = start; !date.isAfter(end); date = date.plusDays(1)) {
happenTime.add(end); // List<Date> happenTime = new ArrayList<>();
generate(happenTime); // Date startDate = Date.from(date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
} // Date endDate = Date.from(date.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant());
// happenTime.add(startDate);
// happenTime.add(endDate);
// generate(happenTime);
// log.info("已经导入{}的个人数据", date.format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
// businessDepartService.generate(happenTime);
// log.info("已经导入{}的单位数据", date.format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
// }
// } else if (businessQueryParam.getDepartName() != null && businessQueryParam.getDepartName().equals("开始导入今天所有的数据")) {
// List<Date> happenTime = new ArrayList<>();
// Date start = Date.from(LocalDateTime.parse("2024-01-01T00:00:00", DateTimeFormatter.ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant());
// Date end = Date.from(LocalDateTime.parse("2024-01-01T09:59:59", DateTimeFormatter.ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant());
// happenTime.add(start);
// happenTime.add(end);
// generate(happenTime);
// }
String empNo = ""; String empNo = "";
if (businessQueryParam.getEmpNo() != null && !businessQueryParam.getEmpNo().isEmpty()) { if (businessQueryParam.getEmpNo() != null && !businessQueryParam.getEmpNo().isEmpty()) {
empNo = String.valueOf(Integer.parseInt(businessQueryParam.getEmpNo())); empNo = businessQueryParam.getEmpNo();
} }
QueryWrapper<BusinessPoliceModel> queryWrapper = new QueryWrapper<>(); QueryWrapper<BusinessPoliceModel> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StrUtil.isNotBlank(businessQueryParam.getPoliceName()), "police_name", businessQueryParam.getPoliceName()) queryWrapper.like(StrUtil.isNotBlank(businessQueryParam.getPoliceName()), "police_name", businessQueryParam.getPoliceName())
@ -64,17 +83,34 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
public void generate(List<Date> happenTime) { public void generate(List<Date> happenTime) {
List<BusinessPolice> businessPoliceList = new ArrayList<>(); List<BusinessPolice> businessPoliceList = new ArrayList<>();
List<GBaseCJD> gBaseCJDSList = selectCJDList(happenTime); List<GBaseCJD> gBaseCJDSList = selectCJDList(happenTime);
List<String> departIds = gBaseCJDSList.stream().map(GBaseCJD::getCjdxssdwdm).toList(); if (gBaseCJDSList.isEmpty()) {
List<Map<String, Object>> resultList = statisticsDepartMapper.getGroupIdsByDepartIds(departIds); log.info("{}没有个人数据", happenTime.get(0));
businessLogMapper.insert(new BusinessLog().setType("个人业务数据").setNum(0).setCreateTime(LocalDateTime.now()));
return;
}
List<String> departIds = gBaseCJDSList.stream().map(GBaseCJD::getCjdxssdwdm).collect(Collectors.toList());
List<Map<String, Object>> idsByDepartIds = supDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011
List<Map<String, Object>> idsByCode = supDepartMapper.getIdsByCode(departIds);
Map<String, String> resultMap2 = idsByDepartIds.stream().collect(Collectors.toMap(map -> (String) map.get("domain_name"), map -> (String) map.get("id")));
List<String> values = resultMap2.values().stream().filter(Objects::nonNull).toList();// 1011
Map<String, String> resultMap3 = idsByCode.stream().collect(Collectors.toMap(map -> (String) map.get("code"), map -> (String) map.get("id")));
List<String> values3 = resultMap3.values().stream().filter(Objects::nonNull).toList();// 1011
List<Map<String, Object>> resultList = statisticsDepartMapper.getGroupIdsByDepartIds(values);
List<Map<String, Object>> resultList2 = statisticsDepartMapper.getGroupIdsByDepartIds(values3);
Map<String, Long> resultMap = resultList.stream().collect(Collectors.toMap( Map<String, Long> resultMap = resultList.stream().collect(Collectors.toMap(
map -> (String) map.get("departId"), map -> (String) map.get("departId"),
map -> (Long) map.get("groupId") map -> (Long) map.get("groupId")
)); ));
Map<String, Long> resultMap4 = resultList2.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId")));
List<Long> groupIds = new ArrayList<>(); List<Long> groupIds = new ArrayList<>();
for (GBaseCJD gBaseCJD : gBaseCJDSList) { for (GBaseCJD gBaseCJD : gBaseCJDSList) {
Long groupId = resultMap.get(gBaseCJD.getCjdxssdwdm()); Long groupId = resultMap.get(resultMap2.get(gBaseCJD.getCjdxssdwdm()));
if (groupId == null) {
groupId = resultMap4.get(resultMap2.get(gBaseCJD.getCjdxssdwdm()));
}
groupIds.add(groupId); groupIds.add(groupId);
BusinessPolice businessPolice = getBusinessPolice(gBaseCJD, groupId); BusinessPolice businessPolice = getBusinessPolice(happenTime, gBaseCJD, groupId);
businessPoliceList.add(businessPolice); businessPoliceList.add(businessPolice);
} }
List<Map<Long, Object>> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds); List<Map<Long, Object>> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds);
@ -86,14 +122,16 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
businessPolice.setGroupName(names.get(businessPolice.getGroupId())); businessPolice.setGroupName(names.get(businessPolice.getGroupId()));
businessPolice.setCreateTime(LocalDateTime.now()); businessPolice.setCreateTime(LocalDateTime.now());
} }
log.info("个人业务数据准备插入:{}", businessPoliceList.size());
List<BatchResult> insert = baseMapper.insert(businessPoliceList); List<BatchResult> insert = baseMapper.insert(businessPoliceList);
log.info("个人业务数据插入成功");
int actualNum = (int) Arrays.stream(insert.get(0).getUpdateCounts()).parallel().filter(num -> num != 0).count(); int actualNum = (int) Arrays.stream(insert.get(0).getUpdateCounts()).parallel().filter(num -> num != 0).count();
businessLogMapper.insert(new BusinessLog().setType("个人业务数据").setNum(gBaseCJDSList.size()).setActualNum(actualNum).setCreateTime(LocalDateTime.now())); businessLogMapper.insert(new BusinessLog().setType("个人业务数据").setNum(gBaseCJDSList.size()).setActualNum(actualNum).setCreateTime(LocalDateTime.now()));
} }
private static BusinessPolice getBusinessPolice(GBaseCJD gBaseCJD, Long groupId) { private static BusinessPolice getBusinessPolice(List<Date> happenTime, GBaseCJD gBaseCJD, Long groupId) {
BusinessPolice businessPolice = new BusinessPolice(); BusinessPolice businessPolice = new BusinessPolice();
businessPolice.setDate(gBaseCJD.getCjsj()); businessPolice.setDate(happenTime.get(0));
businessPolice.setDepartId(gBaseCJD.getCjdxssdwdm()); businessPolice.setDepartId(gBaseCJD.getCjdxssdwdm());
businessPolice.setDepartName(gBaseCJD.getCjdxssdwmc()); businessPolice.setDepartName(gBaseCJD.getCjdxssdwmc());
businessPolice.setGroupId(groupId); businessPolice.setGroupId(groupId);
@ -116,8 +154,9 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
@DS("slave2") @DS("slave2")
public List<GBaseCJD> selectCJDList(List<Date> happenTime) { public List<GBaseCJD> selectCJDList(List<Date> happenTime) {
QueryWrapper<GBaseCJD> queryWrapper = new QueryWrapper<>(); QueryWrapper<GBaseCJD> queryWrapper = new QueryWrapper<>();
queryWrapper.isNotNull("clwbrxm");
queryWrapper.between("cjsj", happenTime.get(0), happenTime.get(1)); queryWrapper.between("cjsj", happenTime.get(0), happenTime.get(1));
queryWrapper.groupBy("clwbrxm", "clwbrbh", "cjdxssdwdm", "cjdxssdwmc", "cjsj"); queryWrapper.groupBy("clwbrxm", "clwbrbh", "cjdxssdwdm", "cjdxssdwmc");
return gBaseCJDMapper.selectCJDList(queryWrapper); return gBaseCJDMapper.selectCJDList(queryWrapper);
} }

4
src/main/resources/application-dev.yml

@ -48,6 +48,10 @@ spring:
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
fdfs: fdfs:
tracker-list: #TrackerList参数,支持多个 tracker-list: #TrackerList参数,支持多个
- 172.31.217.20:32060 - 172.31.217.20:32060

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

@ -33,11 +33,14 @@ spring:
time-between-eviction-runs-millis: 60000 time-between-eviction-runs-millis: 60000
max-pool-prepared-statement-per-connection-size: 20 max-pool-prepared-statement-per-connection-size: 20
max-active: 100 max-active: 100
# druid监控全局配置 # druid监控全局配置
druid: druid:
stat-view-servlet: stat-view-servlet:
enabled: true enabled: true
url-pattern: /druid/* url-pattern: /druid/*
wall:
multi-statement-allow: true
data: data:
redis: redis:
host: 65.47.6.109 host: 65.47.6.109

2
src/main/resources/mapper/GBaseCJDMapper.xml

@ -5,7 +5,7 @@
<mapper namespace="com.biutag.supervision.mapper.GBaseCJDMapper"> <mapper namespace="com.biutag.supervision.mapper.GBaseCJDMapper">
<select id="selectCJDList" resultType="com.biutag.supervision.pojo.entity.GBaseCJD"> <select id="selectCJDList" resultType="com.biutag.supervision.pojo.entity.GBaseCJD">
select count(clwbrxm) as clwbrxmTotal, clwbrxm, clwbrbh, cjdxssdwdm, cjdxssdwmc, cjsj select count(clwbrxm) as clwbrxmTotal, clwbrxm, clwbrbh, cjdxssdwdm, cjdxssdwmc
from dwd_asj_zhtx_cjd from dwd_asj_zhtx_cjd
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}
</select> </select>

2
src/main/resources/mapper/GBaseJJDMapper.xml

@ -5,7 +5,7 @@
<mapper namespace="com.biutag.supervision.mapper.GBaseJJDMapper"> <mapper namespace="com.biutag.supervision.mapper.GBaseJJDMapper">
<select id="selectJJDList" resultType="com.biutag.supervision.pojo.entity.GBaseJJD"> <select id="selectJJDList" resultType="com.biutag.supervision.pojo.entity.GBaseJJD">
select count(jjdbh) as jjdbhTotal, gxdwdm, gxdwmc, cjsj select count(jjdbh) as jjdbhTotal, gxdwdm, gxdwmc
from dwd_asj_zhtx_jjd from dwd_asj_zhtx_jjd
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}
</select> </select>

Loading…
Cancel
Save