|
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|