Kaynağa Gözat

开始初始化数据 任务

tags/24080901
PoffyZhang 1 yıl önce
ebeveyn
işleme
124e3342b1
15 değiştirilmiş dosya ile 596 ekleme ve 0 silme
  1. +19
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/contants/TaskContant.java
  2. +58
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/InitProcessTask.java
  3. +20
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/contants/RegionContant.java
  4. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysFormController.java
  5. +39
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysProcdefController.java
  6. +86
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/convert/RegionConverter.java
  7. +46
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/Region.java
  8. +56
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/dto/RegionDTO.java
  9. +46
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/dto/RegionTreeDTO.java
  10. +53
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/vo/RegionTreeVO.java
  11. +35
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/RegionManage.java
  12. +16
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/RegionMapper.java
  13. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/RegionMapper.xml
  14. +51
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IRegionService.java
  15. +56
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/RegionServiceImpl.java

+ 19
- 0
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/contants/TaskContant.java Dosyayı Görüntüle

@@ -0,0 +1,19 @@
package com.ningdatech.pmapi.scheduler.contants;

import java.math.BigDecimal;

/**
* @author PoffyZhang
* @Classname TaskContant
* @Description
* @Date 2023/1/18 11:00
*/
public interface TaskContant {
class Host {
public static final String HOST_ZPF = "LAPTOP-NQGEQP03";
public static final String HOST_CMM2 = "DESKTOP-KN1L6HL";
public static final String HOST_CMM = "LAPTOP-PCISPN2O";

public static final String HOST_207 = "iZbp13nwyvib53j4j1p2xoZ";
}
}

+ 58
- 0
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/InitProcessTask.java Dosyayı Görüntüle

@@ -0,0 +1,58 @@
package com.ningdatech.pmapi.scheduler.task;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.pmapi.scheduler.contants.TaskContant;
import com.ningdatech.pmapi.sys.contants.RegionContant;
import com.ningdatech.pmapi.sys.entity.Region;
import com.ningdatech.pmapi.sys.service.IRegionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;

/**
* @author ZPF
* @description
* @since 2023/1/18 08:54
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class InitProcessTask {

private final IRegionService regionService;

// 定时更新车辆状态
@Scheduled(cron = "0 52 15 18 1 ?")
public void doTask() throws UnknownHostException {
if (TaskContant.Host.HOST_ZPF.equals(InetAddress.getLocalHost().getHostName())) {
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务开始");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
//1.查出丽水市下的 区县 分别去初始化 表单和流程配置数据
List<Region> regions = regionService.list(Wrappers.lambdaQuery(Region.class)
.eq(Region::getDeleted,Boolean.FALSE)
.eq(Region::getParentCode, RegionContant.LS_REGION_CODE));

if(CollUtil.isEmpty(regions)){
throw new BizException("丽水地区数据为空 任务结束!");
}

//2.首先插入表单默认配置
for(Region region : regions){
log.info("当前初始化的是 【{}】",region.getName());

}

stopWatch.stop();
log.info("=========== 更新车辆在线状态 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds());
}
}
}

+ 20
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/contants/RegionContant.java Dosyayı Görüntüle

@@ -0,0 +1,20 @@
package com.ningdatech.pmapi.sys.contants;

/**
* @Classname RegionContant
* @Description
* @Date 2023/1/18 9:37
* @Created by PoffyZhang
*/
public interface RegionContant {

public static final Integer FIRST_LEVEL = 1;

public static final Integer SECOND_LEVEL = 2;

public static final Integer THIRD_LEVEL = 3;

public static final Long EMPTY_PARENT_ID = 0L;
//丽水地区CODE
public static final String LS_REGION_CODE = "331100";
}

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysFormController.java Dosyayı Görüntüle

@@ -0,0 +1,10 @@
package com.ningdatech.pmapi.sys.controller;

/**
* @Classname SysProcdefController
* @Description
* @Date 2023/1/18 14:28
* @Author PoffyZhang
*/
public class SysFormController {
}

+ 39
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysProcdefController.java Dosyayı Görüntüle

@@ -0,0 +1,39 @@
package com.ningdatech.pmapi.sys.controller;

import com.ningdatech.basic.model.PageVo;
import com.wflow.bean.vo.OrgProcdefVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* @Classname SysProcdefController
* @Description
* @Date 2023/1/18 14:28
* @Author PoffyZhang
*/
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/sys/procdef")
@Api(value = "SysProcdef", tags = "系统管理-流程配置")
@RequiredArgsConstructor
public class SysProcdefController {

// private final

@ApiOperation(value = "系统流程配置列表", notes = "系统流程配置列表")
@GetMapping("/list")
public PageVo<OrgProcdefVo> list(@RequestParam String regionCode, @RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize) {
// return orgProcdefService.getOrgProcessByOrgCode(orgCode,pageNum,pageSize);
return PageVo.empty();
}

}

+ 86
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/convert/RegionConverter.java Dosyayı Görüntüle

@@ -0,0 +1,86 @@
package com.ningdatech.pmapi.sys.convert;

import cn.hutool.core.util.ObjectUtil;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.sys.entity.Region;
import com.ningdatech.pmapi.sys.entity.dto.RegionDTO;
import com.ningdatech.pmapi.sys.entity.dto.RegionTreeDTO;
import com.ningdatech.pmapi.sys.entity.vo.RegionTreeVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.tuple.Pair;

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

/**
* <p>
* RegionConverter
* </p>
*
* @author WendyYang
* @since 10:31 2022/10/12
*/
public class RegionConverter {

public static RegionDTO toRegionDTO(Region region) {
RegionDTO dto = new RegionDTO();
dto.setRegionLevel(region.getRegionLevel());
dto.setRegionName(region.getName());
dto.setParentCode(region.getParentCode());
dto.setRegionCode(region.getRegionCode());
dto.setId(region.getId());
dto.setDeleted(region.getDeleted());
dto.setGovUnit(region.getGovUnit());
dto.setParentId(region.getParentId());
dto.unionCode();
return dto;
}

public static List<RegionTreeDTO> toRegionTreeDTOList(List<RegionDTO> regionDTOList) {
if (CollectionUtils.isEmpty(regionDTOList)) {
return new ArrayList<>();
}
return regionDTOList.stream().map(RegionConverter::toRegionTreeDTO).collect(Collectors.toList());
}

public static RegionTreeDTO toRegionTreeDTO(RegionDTO regionDTO) {
RegionTreeDTO treeDto = new RegionTreeDTO();
treeDto.setLevel(regionDTO.getRegionLevel());
treeDto.setName(regionDTO.getRegionName());
treeDto.setParentCode(regionDTO.getParentCode());
treeDto.setRegionCode(regionDTO.getRegionCode());
treeDto.setUnionCode(regionDTO.getUnionCode());
treeDto.setId(regionDTO.getId());
treeDto.setDeleted(regionDTO.getDeleted());
treeDto.setGovUnit(regionDTO.getGovUnit());
return treeDto;
}

public static List<RegionTreeVO> toRegionTree(Long parentId, Map<Long, List<RegionDTO>> regions,
boolean showDeleted) {
List<RegionTreeVO> treeList = new ArrayList<>();
List<RegionDTO> children = regions.getOrDefault(parentId, Collections.emptyList());
for (RegionDTO region : children) {
if (!showDeleted && region.getDeleted()) {
continue;
}
RegionTreeVO treeNode = new RegionTreeVO();
treeNode.setRegionLevel(region.getRegionLevel());
treeNode.setName(region.getRegionName());
treeNode.setParentCode(region.getParentCode());
treeNode.setRegionCode(region.getRegionCode());
List<RegionDTO> regionList = regions.get(region.getId());
if (CollectionUtils.isNotEmpty(regionList)) {
treeNode.setChildren(toRegionTree(region.getId(), regions, showDeleted));
}
treeNode.setId(region.getId());
treeNode.setUnionCode(region.getUnionCode());
treeNode.setGovUnit(region.getGovUnit());
treeList.add(treeNode);
}
return treeList;
}
}

+ 46
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/Region.java Dosyayı Görüntüle

@@ -0,0 +1,46 @@
package com.ningdatech.pmapi.sys.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
* <p>
* Region - 地域实体
* </p>
*
* @author WendyYang
* @since 10:33 2022/10/12
*/
@Data
@TableName("nd_region")
public class Region implements Serializable {

private static final long serialVersionUID = 1L;

@TableId(value = "id", type = IdType.AUTO)
private Long id;

private String regionCode;

private String name;

private Integer regionLevel;

private String govUnit;

private String parentCode;

private Long parentId;

private LocalDateTime createOn;

private LocalDateTime updateOn;

private Boolean deleted;

}

+ 56
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/dto/RegionDTO.java Dosyayı Görüntüle

@@ -0,0 +1,56 @@
package com.ningdatech.pmapi.sys.entity.dto;

import lombok.Builder;
import lombok.Data;
import lombok.experimental.Tolerate;

/**
* @author liuxinxin
* @date 2022/7/22 上午9:12
*/
@Data
@Builder
public class RegionDTO {

@Tolerate
public RegionDTO() {
}

/**
* 区域码
*/
private String regionCode;

/**
* 地区名
*/
private String regionName;

/**
* 地区级别
*/
private Integer regionLevel;

/**
* 地区父级code 当parent_code 为 -1 时为顶级区域
*/
private String parentCode;

/**
* 唯一编码:regionCode##regionName##regionLevel
*/
private String unionCode;

private Long id;

private Boolean deleted;

private String govUnit;

private Long parentId;

public void unionCode() {
this.unionCode = String.format("%s##%s##%s", this.regionCode, this.regionName, this.regionLevel);
}

}

+ 46
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/dto/RegionTreeDTO.java Dosyayı Görüntüle

@@ -0,0 +1,46 @@
package com.ningdatech.pmapi.sys.entity.dto;

import lombok.Data;

import java.util.List;

/**
* @author liuxinxin
* @date 2022/7/22 上午9:08
*/
@Data
public class RegionTreeDTO {

/**
* 区域码
*/
private String regionCode;

/**
* 地区名
*/
private String name;

/**
* 地区级别
*/
private Integer level;

/**
* 地区父级code 当parent_code 为 -1 时为顶级区域
*/
private String parentCode;

private String unionCode;

private List<RegionTreeDTO> children;

private Long id;

private String mapData;

private Boolean deleted;

private String govUnit;

}

+ 53
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/vo/RegionTreeVO.java Dosyayı Görüntüle

@@ -0,0 +1,53 @@
package com.ningdatech.pmapi.sys.entity.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
* <p>
* RegionTreeVO
* </p>
*
* @author WendyYang
* @since 10:35 2022/10/12
*/
@Data
@ToString(callSuper = true)
@ApiModel(value = "RegionTreeVO", description = "区域树状结构VO")
public class RegionTreeVO {

private Long id;

@ApiModelProperty("区域码")
@NotBlank(message = "地区编码不能为空")
private String regionCode;

@ApiModelProperty("地区名")
@NotBlank(message = "地区名称不能为空")
private String name;

@ApiModelProperty("级别")
@NotNull(message = "级别不能为空")
private Integer regionLevel;

@ApiModelProperty("区域级别")
@NotBlank(message = "区域级别不能为空")
private String govUnit;

@ApiModelProperty("地区父级编码:-1为顶级区域")
@NotBlank(message = "地区父级编码不能为空")
private String parentCode;

@ApiModelProperty("子区域")
private List<RegionTreeVO> children;

@ApiModelProperty("唯一编码:regionCode##name##level")
private String unionCode;

}

+ 35
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/RegionManage.java Dosyayı Görüntüle

@@ -0,0 +1,35 @@
package com.ningdatech.pmapi.sys.manage;

import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.sys.convert.RegionConverter;
import com.ningdatech.pmapi.sys.entity.dto.RegionDTO;
import com.ningdatech.pmapi.sys.entity.vo.RegionTreeVO;
import com.ningdatech.pmapi.sys.service.IRegionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;

/**
* <p>
* RegionManage
* </p>
*
* @author ZPF
* @since 10:39 2023/1/18
*/
@Component
@RequiredArgsConstructor
public class RegionManage {

private final IRegionService regionService;

private final static Long ROOT_PARENT_ID = 1L;

public List<RegionTreeVO> getRegionTree() {
List<RegionDTO> regions = regionService.queryAll();
Map<Long, List<RegionDTO>> regionMap = CollUtils.group(regions, RegionDTO::getParentId);
return RegionConverter.toRegionTree(ROOT_PARENT_ID, regionMap, false);
}

}

+ 16
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/RegionMapper.java Dosyayı Görüntüle

@@ -0,0 +1,16 @@
package com.ningdatech.pmapi.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ningdatech.pmapi.sys.entity.Region;

/**
* <p>
* Mapper 接口
* </p>
*
* @author ZPF
* @since 2023-1-18
*/
public interface RegionMapper extends BaseMapper<Region> {

}

+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/RegionMapper.xml Dosyayı Görüntüle

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ningdatech.pmapi.sys.mapper.RegionMapper">

</mapper>

+ 51
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IRegionService.java Dosyayı Görüntüle

@@ -0,0 +1,51 @@
package com.ningdatech.pmapi.sys.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.pmapi.sys.entity.Region;
import com.ningdatech.pmapi.sys.entity.dto.RegionDTO;

import java.util.List;

/**
* <p>
* 地域管理 服务类
* </p>
*
* @author zpf
* @since 2023-1-18
*/
public interface IRegionService extends IService<Region> {

/**
* 查询所有区域
*
* @return 所有区域
*/
List<RegionDTO> queryAll();

/**
* 查询大于等与该级别的所有区域
*
* @param regionLevel
* @return 区域集合
*/
List<RegionDTO> listGeLevel(int regionLevel);

/**
* 是否为父节点
*
* @param regionId 区域ID
* @return boolean
**/
boolean isParentRegion(Long regionId);

/**
* 获取当前区域的本级
*
* @param parentId 区域ID
* @param regionCode 区域code
* @return 区域ID
**/
Long getRegionIdByParentIdWithSameRegionCode(Long parentId, String regionCode);

}

+ 56
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/RegionServiceImpl.java Dosyayı Görüntüle

@@ -0,0 +1,56 @@
package com.ningdatech.pmapi.sys.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.sys.convert.RegionConverter;
import com.ningdatech.pmapi.sys.entity.Region;
import com.ningdatech.pmapi.sys.entity.dto.RegionDTO;
import com.ningdatech.pmapi.sys.mapper.RegionMapper;
import com.ningdatech.pmapi.sys.service.IRegionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* <p>
* 服务实现类
* </p>
*
* @author zpf
* @since 2023-1-18
*/
@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements IRegionService {

@Override
public List<RegionDTO> queryAll() {
List<Region> allRegions = this.lambdaQuery().ne(Region::getId, -1).list();
return CollUtils.convert(allRegions, RegionConverter::toRegionDTO);
}

@Override
public List<RegionDTO> listGeLevel(int regionLevel) {
List<Region> regionsByLevel = lambdaQuery().ne(Region::getId, -1)
.le(Region::getRegionLevel, regionLevel).list();
return CollUtils.convert(regionsByLevel, RegionConverter::toRegionDTO);
}

@Override
public boolean isParentRegion(Long regionId) {
return baseMapper.exists(Wrappers.lambdaQuery(Region.class)
.eq(Region::getParentId, regionId)
.eq(Region::getDeleted, false));
}

@Override
public Long getRegionIdByParentIdWithSameRegionCode(Long parentId, String regionCode) {
return baseMapper.selectOne(Wrappers.lambdaQuery(Region.class)
.eq(Region::getParentId, parentId)
.eq(Region::getRegionCode, regionCode)
.eq(Region::getDeleted, false))
.getId();
}


}

Yükleniyor…
İptal
Kaydet