Sfoglia il codice sorgente

核心业务 列表

tags/24080901
PoffyZhang 1 anno fa
parent
commit
b8084f6af0
11 ha cambiato i file con 275 aggiunte e 2 eliminazioni
  1. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java
  2. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java
  3. +16
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/mapper/ProjectCoreBizMapper.java
  4. +52
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/entity/ProjectCoreBiz.java
  5. +21
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/service/IProjectCoreBizService.java
  6. +21
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/service/impl/ProjectCoreBizServiceImpl.java
  7. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java
  8. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/OrganizationTreeVO.java
  9. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/ResOrganizationListVO.java
  10. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/ProjectCodeContant.java
  11. +144
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java

+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java Vedi File

@@ -87,6 +87,11 @@ public interface BizConst {
int MAX_EXPORT_COUNT = 5000;

String RESPONSE_KEY_DATA = "data";
String RESPONSE_KEY_ID = "id";
String RESPONSE_KEY_DING_CODE = "dingCode";
String RESPONSE_KEY_MATTER_NAME = "matterName";
String RESPONSE_KEY_ORG_NAME = "orgName";
String RESPONSE_KEY_USER_STATE = "userState";
String ORG_NAME = "organizationName";
String ORG_CODE = "organizationCode";



+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java Vedi File

@@ -5,6 +5,7 @@ import com.ningdatech.pmapi.irs.model.dto.ForwardDTO;
import com.ningdatech.pmapi.projectdeclared.manage.IrsManage;
import com.ningdatech.pmapi.projectdeclared.model.vo.IrsApplicationVO;
import com.ningdatech.pmapi.projectdeclared.model.vo.PiotTasksVO;
import com.ningdatech.pmapi.scheduler.task.SynProjectCoreBizTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;
import java.net.UnknownHostException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

@@ -35,6 +37,8 @@ public class IrsController {

private final IrsManage irsManage;

private final SynProjectCoreBizTask projectCoreBizTask;

@ApiOperation(value = "irs应用列表", notes = "irs应用列表")
@WebLog("irs应用列表")
@GetMapping("/application-list")
@@ -54,4 +58,10 @@ public class IrsController {
public String getCreditCode() throws NoSuchAlgorithmException, UnsupportedEncodingException {
return irsManage.getCreditCode();
}

@ApiOperation(value = "强制刷新核心业务", notes = "强制刷新核心业务")
@GetMapping("/refresh-core-biz")
public void refreshCoreBiz() throws UnknownHostException {
projectCoreBizTask.doTask();
}
}

+ 16
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/mapper/ProjectCoreBizMapper.java Vedi File

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

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz;

/**
* <p>
* Mapper 接口
* </p>
*
* @author zpf
* @since 2023-09-13
*/
public interface ProjectCoreBizMapper extends BaseMapper<ProjectCoreBiz> {

}

+ 52
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/entity/ProjectCoreBiz.java Vedi File

@@ -0,0 +1,52 @@
package com.ningdatech.pmapi.irs.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

/**
* @Classname ProjectCoreBiz
* @Description
* @Date 2023/9/13 15:33
* @Author PoffyZhang
*/
@Data
@TableName("nd_project_core_biz")
@ApiModel(value = "项目核心业务对象")
public class ProjectCoreBiz {
@TableId(type = IdType.AUTO)
@ApiModelProperty("主键")
private Long id;

@ApiModelProperty("创建时间")
private LocalDateTime createOn;

@ApiModelProperty("修改时间")
private LocalDateTime updateOn;

@ApiModelProperty("irs那边的ID")
private Long irsId;

@ApiModelProperty("生成的业务编号")
private String matterCode;

@ApiModelProperty("业务名")
private String matterName;

@ApiModelProperty("企业名")
private String orgName;

@ApiModelProperty("企业钉code")
private String orgCode;

@ApiModelProperty("区域名")
private String areaName;

@ApiModelProperty("状态")
private String userState;
}

+ 21
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/service/IProjectCoreBizService.java Vedi File

@@ -0,0 +1,21 @@
package com.ningdatech.pmapi.irs.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.pmapi.gov.entity.BelongOrg;
import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz;

import java.util.Collection;
import java.util.List;

/**
* <p>
* 服务类
* </p>
*
* @author Zpf
* @since 2023-09-13
*/
public interface IProjectCoreBizService extends IService<ProjectCoreBiz> {


}

+ 21
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/service/impl/ProjectCoreBizServiceImpl.java Vedi File

@@ -0,0 +1,21 @@
package com.ningdatech.pmapi.irs.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.pmapi.irs.mapper.ProjectCoreBizMapper;
import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz;
import com.ningdatech.pmapi.irs.service.IProjectCoreBizService;
import org.springframework.stereotype.Service;

/**
* <p>
* 服务实现类
* </p>
*
* @author zpf
* @since 2023-09-13
*/
@Service
public class ProjectCoreBizServiceImpl extends ServiceImpl<ProjectCoreBizMapper, ProjectCoreBiz>
implements IProjectCoreBizService {

}

+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java Vedi File

@@ -55,4 +55,5 @@ public class DingOrganization implements Serializable {

private String status;

private String unifiedSocialCreditCode;
}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/OrganizationTreeVO.java Vedi File

@@ -36,6 +36,6 @@ public class OrganizationTreeVO {
// @ApiModelProperty(value = "是否为叶子节点")
// private Boolean isLeaf;
//
// @ApiModelProperty(value = "联合唯一字段方便页面使用(name##organizationCode)")
// private String unionCode;
@ApiModelProperty(value = "社会同一信用代码")
private String unifiedSocialCreditCode;;
}

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/ResOrganizationListVO.java Vedi File

@@ -35,4 +35,6 @@ public class ResOrganizationListVO {
@ApiModelProperty("是否为上级条线主管单位")
private Boolean isSuperiorLineCompetentUnit;

@ApiModelProperty("社会统一信用代码")
private String unifiedSocialCreditCode;
}

+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/ProjectCodeContant.java Vedi File

@@ -13,4 +13,5 @@ public interface ProjectCodeContant {
String PROJECT_TYPE_PREFIX = "0";

String SHUZI_5 = "%05d";
String SHUZI_4 = "%04d";
}

+ 144
- 0
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java Vedi File

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

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.ding.constants.DingOrganizationContant;
import com.ningdatech.pmapi.irs.manage.ProjectIrsManage;
import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz;
import com.ningdatech.pmapi.irs.service.IProjectCoreBizService;
import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import com.ningdatech.pmapi.projectdeclared.contants.ProjectCodeContant;
import com.ningdatech.zwdd.client.ZwddClient;
import com.ningdatech.zwdd.model.dto.DingOrgInfoDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
* @author ZPF
* @since 2023/09/13 18:16
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class SynProjectCoreBizTask {

@Value("${hostname}")
public String HOST;

@Value("${spring.profiles.active}")
public String active;

@Autowired
private IProjectCoreBizService projectCoreBizService;

@Autowired
private IDingOrganizationService organizationService;

@Autowired
private ZwddClient zwddClient;

@Autowired
private ProjectIrsManage projectIrsManage;

/**
* 前置机每天晚上10点自动清空,第二天早上6点获取数据
* 定时同步前置机数据 每天1点开始执行一次
*
*/
@Scheduled(cron = "0 0 2 * * ?")
public void doTask() throws UnknownHostException {
if (!HOST.equals(InetAddress.getLocalHost().getHostName())) {
log.info("定时器没开启或者host不对! {}:{}",
HOST,InetAddress.getLocalHost().getHostName());
return;
}

log.info("同步项目核心业务开始=====");
StopWatch stopWatch = new StopWatch();
stopWatch.start();

List<DingOrganization> orgs = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
.in(DingOrganization::getTypeCode, Lists.newArrayList(DingOrganizationContant.UNIT_TYPE
, DingOrganizationContant.GOV_TEMPORARY)));

log.info("总共需要同步 orgs size :{}",orgs.size());

for(DingOrganization organization : orgs){
GenericResult<DingOrgInfoDTO> dingResult = zwddClient.getOrganizationByCode(organization.getOrganizationCode());
if(dingResult.isSuccess()){
DingOrgInfoDTO data = dingResult.getData();
String unifiedSocialCreditCode = data.getUnifiedSocialCreditCode();
if(StringUtils.isNotBlank(unifiedSocialCreditCode)){
organization.setUnifiedSocialCreditCode(unifiedSocialCreditCode);
organizationService.updateById(organization);
}

//去请求IRS接口
JSONObject jsonObject = projectIrsManage.searchCoreBiz(null, organization.getOrganizationCode(), 1000, 1);
JSONArray jsonArray = jsonObject.getJSONArray(BizConst.RESPONSE_KEY_DATA);
if(CollUtil.isNotEmpty(jsonArray)){
jsonArray.forEach(j -> {
JSONObject jsonData = JSON.parseObject(JSON.toJSONString(j));
ProjectCoreBiz coreBiz = new ProjectCoreBiz();
//
Long irsId = jsonData.getLong(BizConst.RESPONSE_KEY_ID);
String dingCode = jsonData.getString(BizConst.RESPONSE_KEY_DING_CODE);
String matterName = jsonData.getString(BizConst.RESPONSE_KEY_MATTER_NAME);
String orgName = jsonData.getString(BizConst.RESPONSE_KEY_ORG_NAME);
String userState = jsonData.getString(BizConst.RESPONSE_KEY_USER_STATE);

ProjectCoreBiz old = projectCoreBizService.getOne(Wrappers.lambdaQuery(ProjectCoreBiz.class)
.eq(ProjectCoreBiz::getIrsId, irsId)
.last(BizConst.LIMIT_1));

if(Objects.nonNull(old)){
coreBiz.setId(old.getId());
}else{
coreBiz.setCreateOn(LocalDateTime.now());
}
coreBiz.setIrsId(irsId);
coreBiz.setMatterName(matterName);
coreBiz.setOrgCode(dingCode);
coreBiz.setOrgName(orgName);
coreBiz.setUserState(userState);
projectCoreBizService.saveOrUpdate(coreBiz);
coreBiz.setMatterCode(genirate(unifiedSocialCreditCode,coreBiz.getId()));
projectCoreBizService.updateById(coreBiz);
});
}
}
}
stopWatch.stop();
log.info("同步项目核心业务结束====={}s",stopWatch.getTotalTimeSeconds());
}

/**
* 生成 编号
* @param unifiedSocialCreditCode
* @param id
* @return
*/
private String genirate(String unifiedSocialCreditCode, Long id) {
String formatId = String.format(ProjectCodeContant.SHUZI_4, id);
return unifiedSocialCreditCode + formatId;
}

}

Loading…
Annulla
Salva