Merge branch 'master' into feature/REQ-2413
This commit is contained in:
commit
e610d9a426
1
pom.xml
1
pom.xml
@ -26,6 +26,7 @@
|
||||
<module>riven-server</module>
|
||||
<module>riven-api</module>
|
||||
<module>integration-test</module>
|
||||
<module>riven-third</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.riven.client.domain.SyncInvokeReq;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyDeptDTO;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyUserDTO;
|
||||
import cn.axzo.riven.client.req.ThirdPartyUserReq;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 三方平台同步API
|
||||
@ -30,4 +32,22 @@ public interface ThirdPartySyncApi {
|
||||
|
||||
@GetMapping("api/sync/getUser/{syncDataId}")
|
||||
ApiResult<ThirdPartyUserDTO> getUserById(@PathVariable Long syncDataId);
|
||||
|
||||
/**
|
||||
* 同一个号码可能会存在多个同步信息
|
||||
*
|
||||
* @param phone 电话号码
|
||||
* @return 三方信息列表
|
||||
*/
|
||||
@GetMapping("api/sync/getUsersByPhone/{phone}")
|
||||
ApiResult<List<ThirdPartyUserDTO>> getUserInfosByPhone(@PathVariable String phone);
|
||||
|
||||
/**
|
||||
* 根据参数查询用户信息
|
||||
*
|
||||
* @param req 请求参数
|
||||
* @return 三方信息列表
|
||||
*/
|
||||
@PostMapping("api/sync/getThirdPartyUsers")
|
||||
ApiResult<List<ThirdPartyUserDTO>> getUserInfos(@RequestBody ThirdPartyUserReq req);
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.axzo.riven.client.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class ThirdPartyUserReq {
|
||||
|
||||
|
||||
/**
|
||||
* 三方平台UID
|
||||
*/
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 三方用户ID
|
||||
*/
|
||||
private String userId;
|
||||
}
|
||||
@ -30,6 +30,12 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo</groupId>
|
||||
<artifactId>riven-third</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-web-spring-boot-starter</artifactId>
|
||||
@ -66,7 +72,10 @@
|
||||
<groupId>cn.axzo.basics</groupId>
|
||||
<artifactId>basics-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.basics</groupId>
|
||||
<artifactId>basics-domainless-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework.rocketmq</groupId>
|
||||
<artifactId>axzo-common-rocketmq</artifactId>
|
||||
|
||||
@ -4,11 +4,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootApplication(scanBasePackages = "cn.axzo")
|
||||
@EnableFeignClients(basePackages = {"cn.axzo"})
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext run = SpringApplication.run(Application.class, args);
|
||||
|
||||
@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @author: ZhanSiHu
|
||||
* @date: 2023/11/23 10:53
|
||||
*/
|
||||
@MapperScan(value = {"cn.axzo.riven.repository.mapper"})
|
||||
@MapperScan(value = {"cn.axzo.riven.repository.mapper","cn.axzo.riven.third.dao.mapper"})
|
||||
@Configuration
|
||||
public class RivenConfig {
|
||||
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
package cn.axzo.riven.controller;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.pokonyan.util.TraceSupplier;
|
||||
import cn.axzo.riven.client.domain.SyncInvokeReq;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyDeptDTO;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyUserDTO;
|
||||
import cn.axzo.riven.client.feign.ThirdPartySyncApi;
|
||||
import cn.axzo.riven.client.req.ThirdPartyUserReq;
|
||||
import cn.axzo.riven.service.ThirdPartySyncManageService;
|
||||
import cn.axzo.riven.service.ThirdPartySyncService;
|
||||
import io.netty.util.concurrent.CompleteFuture;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 三方平台同步API
|
||||
@ -45,4 +42,15 @@ public class ThirdPartySyncController implements ThirdPartySyncApi {
|
||||
public ApiResult<ThirdPartyUserDTO> getUserById(Long syncDataId) {
|
||||
return ApiResult.ok(thirdPartySyncManageService.getUserById(syncDataId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<List<ThirdPartyUserDTO>> getUserInfosByPhone(String phone) {
|
||||
return ApiResult.ok(thirdPartySyncManageService.getUserInfosByPhone(phone));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<List<ThirdPartyUserDTO>> getUserInfos(ThirdPartyUserReq req) {
|
||||
return ApiResult.ok(thirdPartySyncManageService.getUserInfos(req));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,9 @@ package cn.axzo.riven.service;
|
||||
import cn.axzo.riven.client.domain.SyncInvokeReq;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyDeptDTO;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyUserDTO;
|
||||
import cn.axzo.riven.client.req.ThirdPartyUserReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据同步管理服务
|
||||
@ -17,4 +20,8 @@ public interface ThirdPartySyncManageService {
|
||||
ThirdPartyDeptDTO getDeptById(Long syncDataId);
|
||||
|
||||
ThirdPartyUserDTO getUserById(Long syncDataId);
|
||||
|
||||
List<ThirdPartyUserDTO> getUserInfosByPhone(String phone);
|
||||
|
||||
List<ThirdPartyUserDTO> getUserInfos(ThirdPartyUserReq req);
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package cn.axzo.riven.service;
|
||||
|
||||
import cn.axzo.riven.client.domain.SyncInvokeReq;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyDeptDTO;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyUserDTO;
|
||||
import cn.axzo.riven.model.ThirdPartySyncContext;
|
||||
import cn.axzo.riven.model.dto.request.ThirdPartySyncJobParam;
|
||||
import cn.axzo.riven.repository.entity.ThirdPartyCredential;
|
||||
|
||||
@ -7,6 +7,7 @@ import cn.axzo.pokonyan.util.TraceSupplier;
|
||||
import cn.axzo.riven.client.domain.SyncInvokeReq;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyDeptDTO;
|
||||
import cn.axzo.riven.client.domain.ThirdPartyUserDTO;
|
||||
import cn.axzo.riven.client.req.ThirdPartyUserReq;
|
||||
import cn.axzo.riven.common.util.Throws;
|
||||
import cn.axzo.riven.model.ThirdPartySyncContext;
|
||||
import cn.axzo.riven.repository.entity.ThirdPartyCredential;
|
||||
@ -19,10 +20,13 @@ import cn.axzo.riven.service.ThirdPartySyncManageService;
|
||||
import cn.axzo.riven.service.ThirdPartySyncService;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -122,4 +126,31 @@ public class ThirdPartySyncManageServiceImpl implements ThirdPartySyncManageServ
|
||||
}
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThirdPartyUserDTO> getUserInfosByPhone(String phone) {
|
||||
if (StrUtil.isBlank(phone)) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
List<ThirdPartyUser> userList = thirdPartyUserDao.list(new LambdaQueryWrapper<ThirdPartyUser>()
|
||||
.eq(ThirdPartyUser::getUserPhone, phone));
|
||||
if (userList == null) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
return userList.stream().map(u -> BeanMapper.copyBean(u, ThirdPartyUserDTO.class)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThirdPartyUserDTO> getUserInfos(ThirdPartyUserReq req) {
|
||||
if (req == null) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
List<ThirdPartyUser> userList = thirdPartyUserDao.list(new LambdaQueryWrapper<ThirdPartyUser>()
|
||||
.eq(StringUtils.isNotBlank(req.getUnionId()), ThirdPartyUser::getUnionId, req.getUnionId())
|
||||
.eq(StringUtils.isNotBlank(req.getUserId()), ThirdPartyUser::getUserId, req.getUserId()));
|
||||
if (userList == null) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
return userList.stream().map(u -> BeanMapper.copyBean(u, ThirdPartyUserDTO.class)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,10 @@ spring:
|
||||
config:
|
||||
server-addr: ${NACOS_HOST:https://dev-nacos.axzo.cn}:${NACOS_PORT:443}
|
||||
file-extension: yaml
|
||||
# local的namespace
|
||||
namespace: ${NACOS_NAMESPACE_ID:f82179f1-81a9-41a1-a489-4f9ab5660a6e}
|
||||
#dev的namespace
|
||||
# namespace: ${NACOS_NAMESPACE_ID:35eada10-9574-4db8-9fea-bc6a4960b6c7}
|
||||
prefix: ${spring.application.name}
|
||||
profiles:
|
||||
active: ${NACOS_PROFILES_ACTIVE:local}
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
package cn.axzo.riven.test.taizhou;
|
||||
|
||||
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
||||
import cn.axzo.basics.profiles.api.vo.profiles.WorkerProfileUpdateVo;
|
||||
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.basic.WorkerProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.request.QueryPersonProfileByIdOrPhoneDto;
|
||||
import cn.axzo.basics.profiles.dto.request.WorkerUpdateDto;
|
||||
import cn.axzo.basics.profiles.dto.response.v2.PersonUpdateVO;
|
||||
import cn.axzo.riven.config.FeignConfiguration;
|
||||
import cn.axzo.riven.third.job.ThirdCreateUserJob;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.Profiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/26 16:52
|
||||
*/
|
||||
|
||||
@SpringBootTest(classes = AxzoUserProfileServiceApiTest.class)
|
||||
@Import({FeignAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, FeignConfiguration.class})
|
||||
@EnableFeignClients(clients = UserProfileServiceApi.class)
|
||||
public class AxzoUserProfileServiceApiTest {
|
||||
|
||||
@Autowired
|
||||
private UserProfileServiceApi userProfileServiceApi;
|
||||
|
||||
/**
|
||||
* 需要将bootstrap.yml中环境切换为dev,才可以进行测试
|
||||
*/
|
||||
@Test
|
||||
public void test(){
|
||||
|
||||
String phone = "15008222059";
|
||||
|
||||
CommonResponse<WorkerProfileDto> response = userProfileServiceApi.createWorkerByPhone(phone);
|
||||
|
||||
System.out.println(JSON.toJSON(response));
|
||||
|
||||
QueryPersonProfileByIdOrPhoneDto query = new QueryPersonProfileByIdOrPhoneDto();
|
||||
query.setPhones(new ArrayList<>());
|
||||
query.getPhones().add(phone);
|
||||
|
||||
CommonResponse<List<PersonProfileDto>> response1 = userProfileServiceApi.findPersonProfileListByIdOrPhone(query);
|
||||
|
||||
System.out.println(JSON.toJSON(response1));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1(){
|
||||
|
||||
// String phone = "15008222058";
|
||||
|
||||
PersonUpdateVO vo = new PersonUpdateVO();
|
||||
vo.setPersonId(9000400416L);
|
||||
|
||||
vo.setRealName("孙海");
|
||||
// vo.getUpdate().get
|
||||
|
||||
CommonResponse<Object> response = userProfileServiceApi.updatePersonDetail(vo);
|
||||
|
||||
System.out.println(JSON.toJSON(response));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package cn.axzo.riven.test.taizhou;
|
||||
|
||||
import cn.axzo.riven.third.job.TaiZhouProjectPersonJob;
|
||||
import cn.axzo.riven.third.taizhou.entity.TaiZhouThirdProjectExt;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 18:21
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class TaiZhouJobTest {
|
||||
|
||||
@Autowired
|
||||
private TaiZhouProjectPersonJob job;
|
||||
|
||||
@Test
|
||||
public void jobTest() throws Exception {
|
||||
|
||||
job.execute(null);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
TaiZhouThirdProjectExt ext =new TaiZhouThirdProjectExt();
|
||||
ext.setBagsBH("91320191MA20WCL28A");
|
||||
ext.setDataNumber("1e16b370-2b25-4c99spark2020-9ff3-eb47b80a51e6");
|
||||
System.out.println(JSON.toJSON(ext));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.axzo.riven.test.taizhou;
|
||||
|
||||
import cn.axzo.riven.third.job.TaiZhouProjectSyncJob;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/28 14:02
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class TaiZhouProjectSyncJobTest {
|
||||
|
||||
@Autowired
|
||||
private TaiZhouProjectSyncJob syncJob;
|
||||
|
||||
@Test
|
||||
public void syncJobTest() throws Exception {
|
||||
|
||||
syncJob.execute(null);
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,114 @@
|
||||
package cn.axzo.riven.test.taizhou;
|
||||
|
||||
import cn.axzo.riven.third.taizhou.config.TaiZhouConfig;
|
||||
import cn.axzo.riven.third.taizhou.rpc.TaiZhouRpc;
|
||||
import cn.axzo.riven.third.taizhou.rpc.req.TaiZhouParamReq;
|
||||
import cn.axzo.riven.third.taizhou.rpc.req.TaiZhouPhoneReq;
|
||||
import cn.axzo.riven.third.taizhou.rpc.req.TaiZhouWorkerHmcReq;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TaiZhouPhoneRes;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TaiZhouPrjWorkerRes;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TaiZhouWorkerRes;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TazZhouProjectRes;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 10:28
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class TaiZhouRpcTest {
|
||||
|
||||
@Autowired
|
||||
private TaiZhouRpc taiZhouRpc;
|
||||
|
||||
@Autowired
|
||||
private TaiZhouConfig config;
|
||||
|
||||
@Test
|
||||
public void GetWorkerHmcTest() {
|
||||
|
||||
TaiZhouWorkerHmcReq req = new TaiZhouWorkerHmcReq();
|
||||
req.setDataNumber("1e16b370-2b25-4c99spark2020-9ff3-eb47b80a51e6");//项目数据指纹
|
||||
// req.setDataNumber("14");//项目数据指纹
|
||||
req.setBagsBH("91320191MA20WCL28A");//考勤供应商登记编号
|
||||
req.setRyzt("");
|
||||
List<TaiZhouPrjWorkerRes> list = taiZhouRpc.GetWorkerHmc(req);
|
||||
|
||||
System.out.println(JSONUtil.toJsonStr(list));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void gBWorkerTest() {
|
||||
|
||||
TaiZhouParamReq req = new TaiZhouParamReq();
|
||||
req.setDataNumber("1e16b370-2b25-4c99spark2020-9ff3-eb47b80a51e6");//项目数据指纹
|
||||
// req.setDataNumber("14");//项目数据指纹
|
||||
req.setBagsBH("91320191MA20WCL28A");//考勤供应商登记编号
|
||||
List<TaiZhouWorkerRes> list = taiZhouRpc.gBWorker(req);
|
||||
|
||||
System.out.println(JSONUtil.toJsonStr(list));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void GetProjectTest() {
|
||||
|
||||
TaiZhouParamReq req = new TaiZhouParamReq();
|
||||
req.setDataNumber("1e16b370-2b25-4c99spark2020-9ff3-eb47b80a51e6");//项目数据指纹
|
||||
// req.setDataNumber("14");//项目数据指纹
|
||||
req.setBagsBH("91320191MA20WCL28A");//考勤供应商登记编号
|
||||
List<TazZhouProjectRes> list = taiZhouRpc.GetProject(req);
|
||||
|
||||
System.out.println(JSONUtil.toJsonStr(list));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWorkerPhoneNumberTest() {
|
||||
|
||||
TaiZhouPhoneReq req = new TaiZhouPhoneReq();
|
||||
req.setWorkerId("pZN3qyscDlrjWjcf/El2h163%2BaQev3ZaKXUInR6GFBs=");//工人唯一编号
|
||||
req.setProjectNo("1e16b370-2b25-4c99spark2020-9ff3-eb47b80a51e6");//项目数据指纹
|
||||
List<TaiZhouPhoneRes> list = taiZhouRpc.getWorkerPhoneNumber(req);
|
||||
|
||||
|
||||
System.out.println(JSONUtil.toJsonStr(list));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getWorkerPhoneNumberTestPro() {
|
||||
|
||||
//需要将请求地址,密钥等等更换才可以测试
|
||||
TaiZhouPhoneReq req = new TaiZhouPhoneReq();
|
||||
req.setWorkerId("FiOheCTPHZGdpfKJ7XB6G8rqN7SgKv9s/jeRFDOnaKE=");//工人唯一编号
|
||||
req.setProjectNo("760069f1-7bef-44e4spark2020-ad36-3747039a5a6e");//项目数据指纹
|
||||
List<TaiZhouPhoneRes> list = taiZhouRpc.getWorkerPhoneNumber(req);
|
||||
|
||||
System.out.println(JSONUtil.toJsonStr(list));
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
String phone = "w3ma5YcmlnXj3e6o4Kj1GQ==";
|
||||
// phone = "IF%2BrN59YgDJYV5dlH/tcLw==";
|
||||
// phone = "jdKwv0%2BkalDCHH9uGN3EvA==";
|
||||
// phone = "8JuDpMcD%2BC2btXm/8UQOd3JENgZNbKYfeKdD7MwS9ro=";//项目ID,无法解密
|
||||
// phone="pZN3qyscDlrjWjcf/El2h163%2BaQev3ZaKXUInR6GFBs=";//工人ID,无法解密
|
||||
phone = URLDecoder.decode(phone, "UTF-8");
|
||||
|
||||
System.out.println(phone);
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.axzo.riven.test.taizhou;
|
||||
|
||||
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
||||
import cn.axzo.riven.config.FeignConfiguration;
|
||||
import cn.axzo.riven.third.job.ThirdCreateUserJob;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/27 10:58
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class ThirdCreateUserJobTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ThirdCreateUserJob thirdCreateUserJob;
|
||||
|
||||
@Test
|
||||
public void jobTest() throws Exception {
|
||||
|
||||
thirdCreateUserJob.execute(null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
76
riven-third/pom.xml
Normal file
76
riven-third/pom.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>riven</artifactId>
|
||||
<groupId>cn.axzo</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>riven-third</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<!-- <maven.compiler.source>17</maven.compiler.source>-->
|
||||
<!-- <maven.compiler.target>17</maven.compiler.target>-->
|
||||
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
|
||||
<!-- <org.projectlombok.version>1.18.16</org.projectlombok.version>-->
|
||||
<!-- <org.mapstruct.version>1.4.2.Final</org.mapstruct.version>-->
|
||||
<!-- <lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>-->
|
||||
<!-- <!–不打包发布server模块–>-->
|
||||
<!-- <maven.test.skip>true</maven.test.skip>-->
|
||||
<!-- <maven.install.skip>true</maven.install.skip>-->
|
||||
<!-- <maven.deploy.skip>true</maven.deploy.skip>-->
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.basics</groupId>
|
||||
<artifactId>basics-profiles-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework.data</groupId>
|
||||
<artifactId>axzo-data-mybatis-plus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-context</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>5.3.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-common-domain</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.70</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,116 @@
|
||||
package cn.axzo.riven.third.common;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.Security;
|
||||
|
||||
/**
|
||||
* AES加密工具类
|
||||
*
|
||||
* @author ZFB
|
||||
*/
|
||||
public class AesUtil {
|
||||
|
||||
/**
|
||||
* // 算法名称
|
||||
*/
|
||||
private static final String KEY_ALGORITHM = "AES";
|
||||
|
||||
/**
|
||||
* // 加解密算法/模式/填充方式
|
||||
*/
|
||||
private static final String ALGORITHM_MODE_PADDING = "AES/CBC/PKCS7Padding";
|
||||
|
||||
private static Cipher cipher;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
static {
|
||||
try {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
cipher = Cipher.getInstance(ALGORITHM_MODE_PADDING);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*
|
||||
* @param value 待加密的字符串
|
||||
* @param key appid对应的密钥secret
|
||||
* @return 加密后的字符串
|
||||
* @author ZFB
|
||||
*/
|
||||
public static String encrypt(String value, String key) {
|
||||
try {
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), KEY_ALGORITHM);
|
||||
String initVector = key.substring(0, 16);
|
||||
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
|
||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
|
||||
byte[] encrypted = cipher.doFinal(value.getBytes());
|
||||
return Base64.encodeBase64String(encrypted);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return "UNKONWN";
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密方法
|
||||
*
|
||||
* @param encrypted 加密后的字符串
|
||||
* @param key appid对应的密钥secret
|
||||
* @return 解密后的字符串
|
||||
* @author ZFB
|
||||
*/
|
||||
public static String decrypt(String encrypted, String key) {
|
||||
try {
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), KEY_ALGORITHM);
|
||||
String initVector = key.substring(0, 16);
|
||||
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
|
||||
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
|
||||
byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
|
||||
return new String(original);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return "UNKONWN";
|
||||
}
|
||||
|
||||
public static String encryptPkcs5(String text, String key ) {
|
||||
try {
|
||||
Key secretKey = new SecretKeySpec(key.getBytes(), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
byte[] encryptedBytes = cipher.doFinal(text.getBytes());
|
||||
return Base64.encodeBase64String(encryptedBytes);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return "UNKONWN";
|
||||
}
|
||||
|
||||
public static String decryptPkcs5(String encryptedText, String key) {
|
||||
try {
|
||||
Key secretKey = new SecretKeySpec(key.getBytes(), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey);
|
||||
byte[] decryptedBytes = cipher.doFinal(Base64.decodeBase64(encryptedText));
|
||||
return new String(decryptedBytes);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return "UNKONWN";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,716 @@
|
||||
package cn.axzo.riven.third.common;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* restHttp 请求工具类
|
||||
*
|
||||
* @author tanjie@axzo.cn
|
||||
* @date 2021/05/25 17:36
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Setter
|
||||
@Getter
|
||||
public class RestTemplateUtils {
|
||||
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
/**
|
||||
* 初始化简单restTemplate
|
||||
* 未使用线程池
|
||||
* @param httpConnectTimeout
|
||||
* @param httpReadTimeout
|
||||
* @return
|
||||
*/
|
||||
public RestTemplateUtils(int httpConnectTimeout, int httpReadTimeout) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
//SimpleClientHttpRequestFactory底层使用的是URLConnection,如果不设置超时时间,异常情况会导致一致卡主。
|
||||
// 获取RestTemplate使用的ClientHttpRequestFactory
|
||||
SimpleClientHttpRequestFactory clientHttpRequestFactory = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
|
||||
// 设置连接超时时间(单位:毫秒)
|
||||
clientHttpRequestFactory.setConnectTimeout(httpConnectTimeout);
|
||||
// 设置读取超时时间(单位:毫秒)
|
||||
clientHttpRequestFactory.setReadTimeout(httpReadTimeout);
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
// ----------------------------------GET-------------------------------------------------------
|
||||
|
||||
/**
|
||||
* GET请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param responseType 返回对象类型
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> get(String url, Class<T> responseType) throws RestClientException {
|
||||
return restTemplate.getForEntity(url, responseType);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> get(String url, Class<T> responseType, Object... uriVariables)
|
||||
throws RestClientException {
|
||||
return restTemplate.getForEntity(url, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> get(String url, Class<T> responseType, Map<String, ?> uriVariables)
|
||||
throws RestClientException {
|
||||
return restTemplate.getForEntity(url, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的GET请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> get(String url, Map<String, String> headers, Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return get(url, httpHeaders, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的GET请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> get(String url, HttpHeaders headers, Class<T> responseType,
|
||||
Object... uriVariables)
|
||||
throws RestClientException {
|
||||
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
|
||||
return exchange(url, HttpMethod.GET, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的GET请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> get(String url, Map<String, String> headers, Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return get(url, httpHeaders, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的GET请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> get(String url, HttpHeaders headers, Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
|
||||
return exchange(url, HttpMethod.GET, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
// ----------------------------------POST-------------------------------------------------------
|
||||
|
||||
/**
|
||||
* POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param responseType 返回对象类型
|
||||
* @return
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, Class<T> responseType) throws RestClientException {
|
||||
return restTemplate.postForEntity(url, HttpEntity.EMPTY, responseType);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param responseType 返回对象类型
|
||||
* @return
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(URI url, Class<T> responseType) throws RestClientException {
|
||||
return restTemplate.postForEntity(url, HttpEntity.EMPTY, responseType);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType)
|
||||
throws RestClientException {
|
||||
return restTemplate.postForEntity(url, requestBody, responseType);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType,
|
||||
Object... uriVariables)
|
||||
throws RestClientException {
|
||||
return restTemplate.postForEntity(url, requestBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
return restTemplate.postForEntity(url, requestBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, Map<String, String> headers, Object requestBody,
|
||||
Class<T> responseType, Object... uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return post(url, httpHeaders, requestBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, HttpHeaders headers, Object requestBody,
|
||||
Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody, headers);
|
||||
return post(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, Map<String, String> headers, Object requestBody,
|
||||
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return post(url, httpHeaders, requestBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, HttpHeaders headers, Object requestBody,
|
||||
Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody, headers);
|
||||
return post(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义请求头和请求体的POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestEntity 请求头和请求体封装对象
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, HttpEntity<?> requestEntity, Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义请求头和请求体的POST请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestEntity 请求头和请求体封装对象
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> post(String url, HttpEntity<?> requestEntity, Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
// ----------------------------------PUT-------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, Class<T> responseType, Object... uriVariables)
|
||||
throws RestClientException {
|
||||
return put(url, HttpEntity.EMPTY, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, Object requestBody, Class<T> responseType,
|
||||
Object... uriVariables)
|
||||
throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody);
|
||||
return put(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, Object requestBody, Class<T> responseType,
|
||||
Map<String, ?> uriVariables)
|
||||
throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody);
|
||||
return put(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, Map<String, String> headers, Object requestBody,
|
||||
Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return put(url, httpHeaders, requestBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, HttpHeaders headers, Object requestBody,
|
||||
Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody, headers);
|
||||
return put(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, Map<String, String> headers, Object requestBody,
|
||||
Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return put(url, httpHeaders, requestBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, HttpHeaders headers, Object requestBody,
|
||||
Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody, headers);
|
||||
return put(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义请求头和请求体的PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestEntity 请求头和请求体封装对象
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, HttpEntity<?> requestEntity, Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
return restTemplate.exchange(url, HttpMethod.PUT, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义请求头和请求体的PUT请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestEntity 请求头和请求体封装对象
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> put(String url, HttpEntity<?> requestEntity, Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
return restTemplate.exchange(url, HttpMethod.PUT, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
// ----------------------------------DELETE-------------------------------------------------------
|
||||
|
||||
/**
|
||||
* DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, Class<T> responseType, Object... uriVariables)
|
||||
throws RestClientException {
|
||||
return delete(url, HttpEntity.EMPTY, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, Class<T> responseType,
|
||||
Map<String, ?> uriVariables)
|
||||
throws RestClientException {
|
||||
return delete(url, HttpEntity.EMPTY, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, Object requestBody, Class<T> responseType,
|
||||
Object... uriVariables)
|
||||
throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody);
|
||||
return delete(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, Object requestBody, Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody);
|
||||
return delete(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, Map<String, String> headers,
|
||||
Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return delete(url, httpHeaders, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, HttpHeaders headers, Class<T> responseType,
|
||||
Object... uriVariables)
|
||||
throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(headers);
|
||||
return delete(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, Map<String, String> headers,
|
||||
Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return delete(url, httpHeaders, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, HttpHeaders headers, Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(headers);
|
||||
return delete(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, Map<String, String> headers, Object requestBody,
|
||||
Class<T> responseType, Object... uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return delete(url, httpHeaders, requestBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, HttpHeaders headers, Object requestBody,
|
||||
Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody, headers);
|
||||
return delete(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, Map<String, String> headers, Object requestBody,
|
||||
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setAll(headers);
|
||||
return delete(url, httpHeaders, requestBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带请求头的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头参数
|
||||
* @param requestBody 请求参数体
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, HttpHeaders headers, Object requestBody,
|
||||
Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestBody, headers);
|
||||
return delete(url, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义请求头和请求体的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestEntity 请求头和请求体封装对象
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, HttpEntity<?> requestEntity,
|
||||
Class<T> responseType,
|
||||
Object... uriVariables) throws RestClientException {
|
||||
return restTemplate.exchange(url, HttpMethod.DELETE, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义请求头和请求体的DELETE请求调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param requestEntity 请求头和请求体封装对象
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> delete(String url, HttpEntity<?> requestEntity,
|
||||
Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException {
|
||||
return restTemplate.exchange(url, HttpMethod.DELETE, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
// ----------------------------------通用方法-------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 通用调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param method 请求方法类型
|
||||
* @param requestEntity 请求头和请求体封装对象
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,按顺序依次对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
Class<T> responseType, Object... uriVariables) throws RestClientException {
|
||||
return restTemplate.exchange(url, method, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用调用方式
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param method 请求方法类型
|
||||
* @param requestEntity 请求头和请求体封装对象
|
||||
* @param responseType 返回对象类型
|
||||
* @param uriVariables URL中的变量,与Map中的key对应
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
|
||||
return restTemplate.exchange(url, method, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.axzo.riven.third.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 15:56
|
||||
*/
|
||||
@Getter
|
||||
public enum SyncTypeEnum {
|
||||
|
||||
|
||||
/**
|
||||
* 不同步
|
||||
*/
|
||||
SYNC_NULL("0"),
|
||||
/**
|
||||
* 同步普通员工
|
||||
*/
|
||||
SYNC_NORMAL("1"),
|
||||
//其他角色后续追加
|
||||
// SYNC_ADMIN("2"),
|
||||
// SYNC_ALL("3"),
|
||||
;
|
||||
private String code;
|
||||
private static final Map<String, SyncTypeEnum> MAPPING = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (SyncTypeEnum type : SyncTypeEnum.values()) {
|
||||
MAPPING.put(type.getCode(), type);
|
||||
}
|
||||
}
|
||||
|
||||
SyncTypeEnum(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public static SyncTypeEnum apply(String code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
return MAPPING.get(code);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.axzo.riven.third.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 15:58
|
||||
*/
|
||||
@Getter
|
||||
public enum ThirdCodeEnum {
|
||||
|
||||
/**
|
||||
* 泰州
|
||||
*/
|
||||
TAI_ZHOU("taizhou"),
|
||||
|
||||
//其他角色后续追加
|
||||
// SYNC_ADMIN("2"),
|
||||
// SYNC_ALL("3"),
|
||||
;
|
||||
private String code;
|
||||
private static final Map<String, ThirdCodeEnum> MAPPING = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (ThirdCodeEnum type : ThirdCodeEnum.values()) {
|
||||
MAPPING.put(type.getCode(), type);
|
||||
}
|
||||
}
|
||||
|
||||
ThirdCodeEnum(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public static ThirdCodeEnum apply(String code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
return MAPPING.get(code);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.axzo.riven.third.dao;
|
||||
|
||||
import cn.axzo.riven.third.dao.mapper.ThirdPersonMapper;
|
||||
import cn.axzo.riven.third.dao.mapper.ThirdProjectMapper;
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import cn.axzo.riven.third.entity.ThirdProject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 18:08
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ThirdPersonDao extends ServiceImpl<ThirdPersonMapper, ThirdPerson> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package cn.axzo.riven.third.dao;
|
||||
|
||||
import cn.axzo.riven.third.dao.mapper.ThirdProjectMapper;
|
||||
import cn.axzo.riven.third.entity.ThirdProject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 16:40
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ThirdProjectDao extends ServiceImpl<ThirdProjectMapper, ThirdProject> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package cn.axzo.riven.third.dao;
|
||||
|
||||
import cn.axzo.riven.third.dao.mapper.ThirdProjectPersonMapper;
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 15:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ThirdProjectPersonDao extends ServiceImpl<ThirdProjectPersonMapper, ThirdProjectPerson>{
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package cn.axzo.riven.third.dao.mapper;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/24 16:36
|
||||
*/
|
||||
public interface ThirdPersonMapper extends BaseMapper<ThirdPerson> {
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package cn.axzo.riven.third.dao.mapper;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdProject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/24 16:36
|
||||
*/
|
||||
public interface ThirdProjectMapper extends BaseMapper<ThirdProject> {
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package cn.axzo.riven.third.dao.mapper;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/24 16:37
|
||||
*/
|
||||
public interface ThirdProjectPersonMapper extends BaseMapper<ThirdProjectPerson> {
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package cn.axzo.riven.third.entity;
|
||||
|
||||
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("third_person")
|
||||
public class ThirdPerson extends BaseEntity<ThirdPerson> {
|
||||
|
||||
/**
|
||||
* 三方名称code
|
||||
*/
|
||||
private String thirdCode;
|
||||
|
||||
|
||||
/**
|
||||
* 三方人员唯一ID
|
||||
*/
|
||||
private String thirdUniquePersonId;
|
||||
/**
|
||||
* 三方人员姓名
|
||||
*/
|
||||
private String thirdPersonName;
|
||||
/**
|
||||
* 三方人员手机号
|
||||
*/
|
||||
private String thirdPersonPhone;
|
||||
|
||||
/**
|
||||
* 三方人员身份证照片
|
||||
*/
|
||||
private String thirdPersonPhoto;
|
||||
|
||||
/**
|
||||
* 身份证签发单位
|
||||
*/
|
||||
private String thirdAuthority;
|
||||
|
||||
|
||||
/**
|
||||
* 三方身份证号
|
||||
*/
|
||||
private String thirdIdNumber;
|
||||
|
||||
/**
|
||||
* 三方人脸照片
|
||||
*/
|
||||
private String thirdPersonFaceUrl;
|
||||
|
||||
/**
|
||||
* 三方性别
|
||||
*/
|
||||
private String thirdSex;
|
||||
|
||||
/**
|
||||
* 安心筑人员ID,安心筑唯一识别码
|
||||
*/
|
||||
private Long personId;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package cn.axzo.riven.third.entity;
|
||||
|
||||
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("third_project")
|
||||
public class ThirdProject extends BaseEntity<ThirdProject> {
|
||||
|
||||
/**
|
||||
* 三方名称code
|
||||
*/
|
||||
private String thirdCode;
|
||||
|
||||
/**
|
||||
* 三方项目编号
|
||||
*/
|
||||
private String thirdProjectId;
|
||||
|
||||
/**
|
||||
* 三方项目名称
|
||||
*/
|
||||
private String thirdProjectName;
|
||||
|
||||
/**
|
||||
* 同步策略,0不创建人员,1创建普通员工,2创建管理员,3创建普通员工+管理员)
|
||||
*/
|
||||
private String syncType;
|
||||
|
||||
/**
|
||||
* 三方单位统一社会信用代码
|
||||
*/
|
||||
private String uniformSocialCreditCode;
|
||||
|
||||
|
||||
/**
|
||||
* 三方建设单位名称
|
||||
*/
|
||||
private String thirdProjectConstructionUnit;
|
||||
|
||||
/**
|
||||
* 三方扩展域
|
||||
* 每个三方对应扩展域不同
|
||||
*/
|
||||
private String thirdProjectExt;
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package cn.axzo.riven.third.entity;
|
||||
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("third_project_person")
|
||||
public class ThirdProjectPerson extends BaseEntity<ThirdProjectPerson>{
|
||||
|
||||
/**
|
||||
* 三方名称code
|
||||
*/
|
||||
private String thirdCode;
|
||||
|
||||
/**
|
||||
* '三方项目编号'
|
||||
*/
|
||||
private String thirdProjectId;
|
||||
|
||||
|
||||
/**
|
||||
* 三方人员唯一ID
|
||||
*/
|
||||
private String thirdUniquePersonId;
|
||||
|
||||
/**
|
||||
* 三方人员工号ID
|
||||
*/
|
||||
private String thirdWorkerId;
|
||||
/**
|
||||
* 三方工人类型
|
||||
*/
|
||||
private String thirdWorkType;
|
||||
|
||||
/**
|
||||
* 三方所属班组
|
||||
*/
|
||||
private String thirdTeamId;
|
||||
|
||||
/**
|
||||
* 三方所属班组名称
|
||||
*/
|
||||
private String thirdTeamName;
|
||||
|
||||
/**
|
||||
* 三方班组ID
|
||||
*/
|
||||
private String thirdWorkId;
|
||||
|
||||
/**
|
||||
* 三方部门ID
|
||||
*/
|
||||
private String thirdDepartmentId;
|
||||
|
||||
/**
|
||||
* 三方岗位名称
|
||||
*/
|
||||
private String thirdPostName;
|
||||
|
||||
/**
|
||||
* 三方ext,扩展域等等,工种信息等等
|
||||
*/
|
||||
private String thirdExt;
|
||||
|
||||
}
|
||||
@ -0,0 +1,114 @@
|
||||
package cn.axzo.riven.third.job;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
import cn.axzo.riven.third.service.ThirdPersonService;
|
||||
import cn.axzo.riven.third.service.ThirdProjectPersonService;
|
||||
import cn.axzo.riven.third.service.ThirdProjectService;
|
||||
import cn.axzo.riven.third.taizhou.entity.TaiZhouProject;
|
||||
import cn.axzo.riven.third.taizhou.service.TaiZhouService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.IJobHandler;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 14:12
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TaiZhouProjectPersonJob extends IJobHandler {
|
||||
|
||||
|
||||
@Autowired
|
||||
ThirdProjectPersonService thirdProjectPersonService;
|
||||
|
||||
@Autowired
|
||||
ThirdProjectService thirdProjectService;
|
||||
|
||||
@Autowired
|
||||
ThirdPersonService thirdPersonService;
|
||||
|
||||
@Autowired
|
||||
TaiZhouService taiZhouService;
|
||||
|
||||
@Autowired
|
||||
private ThirdCreateUserJob thirdCreateUserJob;
|
||||
|
||||
@XxlJob("taiZhouProjectPersonJob")
|
||||
@Override
|
||||
public ReturnT<String> execute(String s) throws Exception {
|
||||
|
||||
log.info("taiZhouProjectPersonSyncJob start");
|
||||
|
||||
//获取泰州所有的项目信息
|
||||
List<TaiZhouProject> taiZhouProjectList = taiZhouService.queryThirdProjectForTaiZhou();
|
||||
|
||||
if (CollectionUtils.isEmpty(taiZhouProjectList)) {
|
||||
log.info("DB中泰州项目为空,同步结束");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
log.info("taiZhouProjectPersonSyncJob--项目list:{}", JSON.toJSONString(taiZhouProjectList));
|
||||
|
||||
|
||||
log.info("taiZhouProjectPersonSyncJob 同步项目用工信息--开始");
|
||||
taiZhouProjectList.forEach(x -> {
|
||||
log.info("taiZhouProjectPersonSyncJob 同步项目用工信息--项目ID:{} 远程获取开始", x.getThirdProjectId());
|
||||
//基于项目维度进行获取项目下的员工信息
|
||||
List<ThirdProjectPerson> thirdProjectPersonList = taiZhouService.remoteQueryProjectPerson(x);
|
||||
//更新入库
|
||||
if (!CollectionUtils.isEmpty(thirdProjectPersonList)) {
|
||||
log.info("taiZhouProjectPersonSyncJob 同步项目用工信息--项目ID:{},size:{}", x.getThirdProjectId(), thirdProjectPersonList.size());
|
||||
thirdProjectPersonList.forEach(thirdProjectPerson -> {
|
||||
thirdProjectPersonService.addOrUpdateThirdProjectPerson(thirdProjectPerson);
|
||||
});
|
||||
} else {
|
||||
log.info("taiZhouProjectPersonSyncJob 同步项目用工信息--项目ID:{},size:0", x.getThirdProjectId());
|
||||
}
|
||||
});
|
||||
log.info("taiZhouProjectPersonSyncJob 同步项目用工信息--结束");
|
||||
|
||||
log.info("泰州job同步项目人员信息--开始");
|
||||
|
||||
//根据项目信息获取调用泰州的项目人员接口
|
||||
taiZhouProjectList.forEach(x -> {
|
||||
|
||||
log.info("taiZhouProjectPersonSyncJob 同步项目人员信息--项目ID:{} 开始", x.getThirdProjectId());
|
||||
|
||||
List<ThirdPerson> thirdPersonList = taiZhouService.remoteQueryPerson(x);
|
||||
|
||||
//更新入库
|
||||
if (!CollectionUtils.isEmpty(thirdPersonList)) {
|
||||
log.info("taiZhouProjectPersonSyncJob 同步项目人员信息--项目ID:{},size:{}", x.getThirdProjectId(), thirdPersonList.size());
|
||||
thirdPersonList.forEach(thirdPerson -> {
|
||||
taiZhouService.addOrUpdateThirdPerson(thirdPerson, x);
|
||||
});
|
||||
} else {
|
||||
log.info("taiZhouProjectPersonSyncJob 同步项目人员信息--项目ID:{},size:0", x.getThirdProjectId());
|
||||
}
|
||||
});
|
||||
log.info("泰州job同步项目用工信息--结束");
|
||||
|
||||
log.info("泰州job修复人员手机号--开始");
|
||||
|
||||
taiZhouProjectList.forEach(x -> {
|
||||
taiZhouService.syncPhone(x);
|
||||
});
|
||||
log.info("泰州job修复人员手机号--结束");
|
||||
|
||||
|
||||
ReturnT<String> returnT = thirdCreateUserJob.execute(null);
|
||||
|
||||
log.info("taiZhouProjectPersonSyncJob end");
|
||||
|
||||
return returnT;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package cn.axzo.riven.third.job;
|
||||
|
||||
import cn.axzo.riven.third.taizhou.entity.TaiZhouProject;
|
||||
import cn.axzo.riven.third.taizhou.service.TaiZhouService;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.IJobHandler;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/28 11:12
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TaiZhouProjectSyncJob extends IJobHandler {
|
||||
|
||||
@Autowired
|
||||
private TaiZhouService taiZhouService;
|
||||
|
||||
@XxlJob("taiZhouProjectSyncJob")
|
||||
@Override
|
||||
public ReturnT<String> execute(String s) throws Exception {
|
||||
|
||||
log.info("taiZhouProjectSyncJob 开始");
|
||||
//获取泰州所有的项目信息
|
||||
List<TaiZhouProject> taiZhouProjectList = taiZhouService.queryThirdProjectForTaiZhou();
|
||||
|
||||
if (CollectionUtils.isEmpty(taiZhouProjectList)) {
|
||||
log.info("DB中泰州项目为空,同步结束");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
taiZhouProjectList.forEach(x->{
|
||||
log.info("泰州项目id:{} 开始同步数据",x.getThirdProjectId());
|
||||
taiZhouService.updateProjectIdForRemote(x);
|
||||
});
|
||||
|
||||
log.info("taiZhouProjectSyncJob 结束");
|
||||
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package cn.axzo.riven.third.job;
|
||||
|
||||
import cn.axzo.riven.third.common.enums.ThirdCodeEnum;
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import cn.axzo.riven.third.service.ThirdCommonService;
|
||||
import cn.axzo.riven.third.service.ThirdPersonService;
|
||||
import cn.axzo.riven.third.service.ThirdProjectPersonService;
|
||||
import cn.axzo.riven.third.service.ThirdProjectService;
|
||||
import cn.axzo.riven.third.taizhou.service.TaiZhouService;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.IJobHandler;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 14:12
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ThirdCreateUserJob extends IJobHandler {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ThirdProjectPersonService thirdProjectPersonService;
|
||||
|
||||
@Autowired
|
||||
private ThirdProjectService thirdProjectService;
|
||||
|
||||
@Autowired
|
||||
private ThirdPersonService thirdPersonService;
|
||||
|
||||
@Autowired
|
||||
private TaiZhouService taiZhouService;
|
||||
|
||||
@Autowired
|
||||
private ThirdCommonService thirdCommonService;
|
||||
|
||||
@XxlJob("thirdCreateUserJob")
|
||||
@Override
|
||||
public ReturnT<String> execute(String s) throws Exception {
|
||||
|
||||
log.info("thirdCreateUserJob start");
|
||||
|
||||
List<ThirdPerson> thirdPersonList = new ArrayList<>();
|
||||
|
||||
for (ThirdCodeEnum thirdCodeEnum : ThirdCodeEnum.values()) {
|
||||
if (ThirdCodeEnum.TAI_ZHOU == thirdCodeEnum) {
|
||||
//查询未同步同步安心筑账号的泰州人员集合
|
||||
List<ThirdPerson> taizhouList = taiZhouService.queryNeedCreateUserThirdPerson();
|
||||
|
||||
thirdPersonList.addAll(taizhouList);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("thirdCreateUserJob 需要同步数据size:{}", thirdPersonList.size());
|
||||
|
||||
if (CollectionUtils.isEmpty(thirdPersonList)) {
|
||||
log.info("无符合条件的用户,同步结束");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
thirdPersonList.forEach(x -> {
|
||||
String phone = x.getThirdPersonPhone();
|
||||
if (Objects.isNull(phone) || phone.contains("*")) {
|
||||
log.info("手机号不合法,不能进行创建用户校验,{}", phone);
|
||||
return;
|
||||
}
|
||||
|
||||
thirdCommonService.createAxzoPersonAndUpdateThirdPerson(x);
|
||||
});
|
||||
|
||||
log.info("thirdCreateUserJob end");
|
||||
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package cn.axzo.riven.third.service;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/27 10:47
|
||||
*/
|
||||
public interface ThirdCommonService {
|
||||
|
||||
|
||||
void createAxzoPersonAndUpdateThirdPerson(ThirdPerson thirdPerson);
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.axzo.riven.third.service;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import cn.axzo.riven.third.entity.ThirdProject;
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 18:04
|
||||
*/
|
||||
public interface ThirdPersonService {
|
||||
|
||||
|
||||
/**
|
||||
* 更新手机号
|
||||
* @param thirdPerson
|
||||
*/
|
||||
public void updateThirdPersonPhone(ThirdPerson thirdPerson);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.axzo.riven.third.service;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 14:27
|
||||
*/
|
||||
public interface ThirdProjectPersonService {
|
||||
|
||||
public void addOrUpdateThirdProjectPerson(ThirdProjectPerson thirdProjectPerson);
|
||||
|
||||
public ThirdProjectPerson queryThirdProjectPerson(String thirdCode,String thirdProjectId,String thirdUniquePersonId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.axzo.riven.third.service;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdProject;
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 16:44
|
||||
*/
|
||||
public interface ThirdProjectService {
|
||||
|
||||
public List<ThirdProject> queryThirdProjectByThirdCode(String thirdCode);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package cn.axzo.riven.third.service.impl;
|
||||
|
||||
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
||||
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.basic.WorkerProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.request.QueryPersonProfileByIdOrPhoneDto;
|
||||
import cn.axzo.basics.profiles.dto.response.v2.PersonUpdateVO;
|
||||
import cn.axzo.riven.third.dao.ThirdPersonDao;
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import cn.axzo.riven.third.service.ThirdCommonService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/27 10:47
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ThirdCommonServiceImpl implements ThirdCommonService {
|
||||
|
||||
@Autowired
|
||||
private UserProfileServiceApi userProfileServiceApi;
|
||||
|
||||
@Autowired
|
||||
ThirdPersonDao thirdPersonDao;
|
||||
|
||||
@Override
|
||||
public void createAxzoPersonAndUpdateThirdPerson(ThirdPerson thirdPerson) {
|
||||
|
||||
try {
|
||||
//接口支持幂等
|
||||
CommonResponse<WorkerProfileDto> response = userProfileServiceApi.createWorkerByPhone(thirdPerson.getThirdPersonPhone());
|
||||
if (!Objects.isNull(response.getData())) {
|
||||
PersonProfileDto dto = response.getData().getPersonProfile();
|
||||
thirdPerson.setPersonId(dto.getId());
|
||||
|
||||
//先更新安心筑表中的姓名,在更新三方表的记录,顺序不能变
|
||||
if(dto.getRealName().contains("工友")||dto.getRealName().contains("工人")){
|
||||
updateAxzoRealName(thirdPerson);
|
||||
}
|
||||
updateAxzoId(thirdPerson);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("泰州创建用户:{}异常", thirdPerson.getThirdPersonPhone(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateAxzoRealName(ThirdPerson thirdPerson) throws Exception {
|
||||
|
||||
PersonUpdateVO vo = new PersonUpdateVO();
|
||||
vo.setPersonId(thirdPerson.getPersonId());
|
||||
vo.setRealName(thirdPerson.getThirdPersonName());
|
||||
CommonResponse<Object> commonResponse = userProfileServiceApi.updatePersonDetail(vo);
|
||||
if(!(commonResponse.getCode() == HttpStatus.SC_OK)){
|
||||
throw new Exception("更新姓名异常"+thirdPerson.getPersonId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateAxzoId(ThirdPerson thirdPerson) {
|
||||
|
||||
thirdPersonDao.lambdaUpdate()
|
||||
.eq(ThirdPerson::getThirdCode, thirdPerson.getThirdCode())
|
||||
.eq(ThirdPerson::getThirdUniquePersonId, thirdPerson.getThirdUniquePersonId())
|
||||
.set(ThirdPerson::getPersonId, thirdPerson.getPersonId())
|
||||
.update();
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package cn.axzo.riven.third.service.impl;
|
||||
|
||||
import cn.axzo.riven.third.dao.ThirdPersonDao;
|
||||
import cn.axzo.riven.third.dao.ThirdProjectPersonDao;
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import cn.axzo.riven.third.entity.ThirdProject;
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
import cn.axzo.riven.third.service.ThirdPersonService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 18:05
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ThirdPersonServiceImpl implements ThirdPersonService {
|
||||
|
||||
@Autowired
|
||||
ThirdPersonDao thirdPersonDao;
|
||||
|
||||
|
||||
@Override
|
||||
public void updateThirdPersonPhone(ThirdPerson thirdPerson) {
|
||||
|
||||
thirdPersonDao.lambdaUpdate()
|
||||
.eq(ThirdPerson::getThirdCode, thirdPerson.getThirdCode())
|
||||
.eq(ThirdPerson::getThirdUniquePersonId, thirdPerson.getThirdUniquePersonId())
|
||||
.set(ThirdPerson::getThirdPersonPhone, thirdPerson.getThirdPersonPhone())
|
||||
.update();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package cn.axzo.riven.third.service.impl;
|
||||
|
||||
import cn.axzo.riven.third.dao.ThirdProjectPersonDao;
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
import cn.axzo.riven.third.service.ThirdProjectPersonService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 15:12
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ThirdProjectPersonServiceImpl implements ThirdProjectPersonService {
|
||||
|
||||
@Autowired
|
||||
private ThirdProjectPersonDao thirdProjectPersonDao;
|
||||
|
||||
@Override
|
||||
public void addOrUpdateThirdProjectPerson(ThirdProjectPerson thirdProjectPerson) {
|
||||
|
||||
ThirdProjectPerson db = thirdProjectPersonDao.lambdaQuery()
|
||||
.eq(ThirdProjectPerson::getThirdCode, thirdProjectPerson.getThirdCode())
|
||||
.eq(ThirdProjectPerson::getThirdProjectId, thirdProjectPerson.getThirdProjectId())
|
||||
.eq(ThirdProjectPerson::getThirdUniquePersonId, thirdProjectPerson.getThirdUniquePersonId())
|
||||
.one();
|
||||
|
||||
log.info("thirdProjectPerson:{}",JSON.toJSON(thirdProjectPerson));
|
||||
//如果数据库为空,则插入
|
||||
if (Objects.isNull(db)) {
|
||||
thirdProjectPersonDao.save(thirdProjectPerson);
|
||||
}
|
||||
//反之则更新
|
||||
else {
|
||||
thirdProjectPersonDao.lambdaUpdate()
|
||||
.eq(ThirdProjectPerson::getThirdCode, thirdProjectPerson.getThirdCode())
|
||||
.eq(ThirdProjectPerson::getThirdProjectId, thirdProjectPerson.getThirdProjectId())
|
||||
.eq(ThirdProjectPerson::getThirdUniquePersonId, thirdProjectPerson.getThirdUniquePersonId())
|
||||
.set(!Objects.isNull(thirdProjectPerson.getThirdWorkType()),ThirdProjectPerson::getThirdWorkType, thirdProjectPerson.getThirdWorkType())
|
||||
.set(!Objects.isNull(thirdProjectPerson.getThirdTeamId()),ThirdProjectPerson::getThirdTeamId, thirdProjectPerson.getThirdTeamId())
|
||||
.set(!Objects.isNull(thirdProjectPerson.getThirdTeamName()),ThirdProjectPerson::getThirdTeamName, thirdProjectPerson.getThirdTeamName())
|
||||
.set(!Objects.isNull(thirdProjectPerson.getThirdWorkId()),ThirdProjectPerson::getThirdWorkId, thirdProjectPerson.getThirdWorkId())
|
||||
.set(!Objects.isNull(thirdProjectPerson.getThirdDepartmentId()),ThirdProjectPerson::getThirdDepartmentId, thirdProjectPerson.getThirdDepartmentId())
|
||||
.set(!Objects.isNull(thirdProjectPerson.getThirdPostName()),ThirdProjectPerson::getThirdPostName, thirdProjectPerson.getThirdPostName())
|
||||
.set(!Objects.isNull(thirdProjectPerson.getThirdExt()),ThirdProjectPerson::getThirdExt, thirdProjectPerson.getThirdExt())
|
||||
.update();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThirdProjectPerson queryThirdProjectPerson(String thirdCode, String thirdProjectId, String thirdUniquePersonId) {
|
||||
|
||||
return thirdProjectPersonDao.lambdaQuery()
|
||||
.eq(ThirdProjectPerson::getThirdCode, thirdCode)
|
||||
.eq(ThirdProjectPerson::getThirdProjectId, thirdProjectId)
|
||||
.eq(ThirdProjectPerson::getThirdUniquePersonId, thirdUniquePersonId)
|
||||
.one();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.axzo.riven.third.service.impl;
|
||||
|
||||
import cn.axzo.riven.third.dao.ThirdProjectDao;
|
||||
import cn.axzo.riven.third.entity.ThirdProject;
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
import cn.axzo.riven.third.service.ThirdProjectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 16:45
|
||||
*/
|
||||
@Service
|
||||
public class ThirdProjectServiceImpl implements ThirdProjectService {
|
||||
|
||||
@Autowired
|
||||
ThirdProjectDao thirdProjectDao;
|
||||
|
||||
@Override
|
||||
public List<ThirdProject> queryThirdProjectByThirdCode(String thirdCode) {
|
||||
return thirdProjectDao.lambdaQuery().eq(ThirdProject::getThirdCode,thirdCode).list();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.axzo.riven.third.taizhou.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author yangchen@axzo.cn
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
||||
@Getter
|
||||
@Setter
|
||||
public class TaiZhouConfig {
|
||||
@Value("${taizhou.baseUrl}")
|
||||
private String baseUrl;
|
||||
@Value("${taizhou.appKey}")
|
||||
private String key;
|
||||
@Value("${taizhou.appSecret}")
|
||||
private String secret;
|
||||
@Value("${taizhou.redisTokenName}")
|
||||
private String redisTokenName;
|
||||
|
||||
@Value("${taizhou.httpConnectTimeout}")
|
||||
private int httpConnectTimeout = 3000;
|
||||
|
||||
@Value("${taizhou.httpReadTimeout}")
|
||||
private int httpReadTimeout = 10000;
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package cn.axzo.riven.third.taizhou.constant;
|
||||
|
||||
/**
|
||||
* @author yangchen@axzo.cn
|
||||
*/
|
||||
public class TaiZhouRedisKeyConstant {
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package cn.axzo.riven.third.taizhou.constant.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author yangchen@axzo.cn
|
||||
*/
|
||||
@Getter
|
||||
public enum TaiZhouApiEnum {
|
||||
/**
|
||||
* 获取token
|
||||
*/
|
||||
GET_TOKEN("/api/Kqxx/GetToken"),
|
||||
/**
|
||||
* 项目基础信息
|
||||
*/
|
||||
Get_PROJECT("/api/Kqxx/GetProject"),
|
||||
/**
|
||||
* 人员基本信息
|
||||
*/
|
||||
GB_WORKER("/api/Kqxx/GetWorkers"),
|
||||
/**
|
||||
* 项目用工信息(增量)
|
||||
*/
|
||||
GET_WORKER_HMC_INC("/api/Kqxx/GetWorkerHmc_Inc"),
|
||||
/**
|
||||
* 项目用工信息
|
||||
*/
|
||||
GB_PRJ_WORKER("/api/Kqxx/GetWorkerHmc"),
|
||||
/**
|
||||
* 上传考勤
|
||||
*/
|
||||
GB_KQXX("/api/Kqxx/UploadKqxx"),
|
||||
|
||||
/**
|
||||
* 获取手机号接口
|
||||
*/
|
||||
Get_WOEKER_PHONE_NUMBER("/api/Kqxx/GetWorkerPhoneNumber"),
|
||||
|
||||
/**
|
||||
* 获取考勤有效性
|
||||
*/
|
||||
GET_KQXX("/api/Kqxx/GetKqxx");
|
||||
private final String path;
|
||||
|
||||
|
||||
|
||||
TaiZhouApiEnum(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.axzo.riven.third.taizhou.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 泰州工种信息
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/24 16:29
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TaiZhouProfession {
|
||||
|
||||
/**
|
||||
* 工种类别
|
||||
*/
|
||||
private String tpType;
|
||||
|
||||
/**
|
||||
* 工种名称
|
||||
*/
|
||||
private String tpCodeName;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.axzo.riven.third.taizhou.entity;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdProject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/26 14:59
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TaiZhouProject extends ThirdProject implements Serializable {
|
||||
|
||||
private TaiZhouThirdProjectExt taiZhouThirdProjectExt;
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.axzo.riven.third.taizhou.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 泰州项目工人关系扩展域
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/24 16:32
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TaiZhouProjectPersonExt implements Serializable {
|
||||
|
||||
private List<TaiZhouProfession> professionList;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.axzo.riven.third.taizhou.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 泰州项目扩展域
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TaiZhouThirdProjectExt implements Serializable {
|
||||
|
||||
/**
|
||||
* 考勤供应商登记编号
|
||||
*/
|
||||
private String bagsBH;
|
||||
|
||||
/**
|
||||
* 项目数据指纹
|
||||
*/
|
||||
private String dataNumber;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc;
|
||||
|
||||
|
||||
import cn.axzo.riven.third.common.AesUtil;
|
||||
import cn.axzo.riven.third.common.RestTemplateUtils;
|
||||
import cn.axzo.riven.third.taizhou.config.TaiZhouConfig;
|
||||
import cn.axzo.riven.third.taizhou.constant.enums.TaiZhouApiEnum;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TaiZhouRes;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TaiZhouTokenRes;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* @author yangchen@axzo.cn
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TaiZhouClient {
|
||||
@Autowired
|
||||
private TaiZhouConfig taiZhouConfig;
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
public String getToken() {
|
||||
String token = redisTemplate.opsForValue().get(taiZhouConfig.getRedisTokenName());
|
||||
if (StringUtils.hasText(token)) {
|
||||
return token;
|
||||
}
|
||||
String url = taiZhouConfig.getBaseUrl() + TaiZhouApiEnum.GET_TOKEN.getPath() + "?Secret=" + taiZhouConfig.getSecret();
|
||||
|
||||
RestTemplateUtils restTemplateUtils = new RestTemplateUtils(taiZhouConfig.getHttpConnectTimeout(), taiZhouConfig.getHttpReadTimeout());
|
||||
|
||||
ResponseEntity<String> responseEntity = restTemplateUtils.post(url, String.class);
|
||||
if (responseEntity.getStatusCode() != HttpStatus.OK) {
|
||||
log.info("获取泰州token异常:{}", responseEntity.getStatusCode());
|
||||
return null;
|
||||
}
|
||||
|
||||
TaiZhouRes<TaiZhouTokenRes> taiZhouTokenResTaiZhouRes = parseResult(responseEntity, TaiZhouTokenRes.class);
|
||||
//token默认43200秒(12小时),建议提前1小时重新获取
|
||||
redisTemplate.opsForValue().set(taiZhouConfig.getRedisTokenName(), taiZhouTokenResTaiZhouRes.getResultData().getToken(), taiZhouTokenResTaiZhouRes.getResultData().getExpireTime() - 60 * 60, TimeUnit.SECONDS);
|
||||
return taiZhouTokenResTaiZhouRes.getResultData().getToken();
|
||||
}
|
||||
|
||||
public ResponseEntity<String> post(String apiPath, Object paramReq, String requestBody) {
|
||||
|
||||
// 加密
|
||||
String paramJson = AesUtil.encryptPkcs5(JSON.toJSONString(paramReq), taiZhouConfig.getKey());
|
||||
String api = taiZhouConfig.getBaseUrl() + apiPath;
|
||||
// api全路径
|
||||
String apiFullUrl = api + "?Secret=" + taiZhouConfig.getSecret() + "¶mJson=" + paramJson;
|
||||
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
String token = getToken();
|
||||
headers.put("token", token);
|
||||
log.info("请求泰州住建局地址url: {},token: {}", apiFullUrl, token);
|
||||
ResponseEntity<String> responseEntity;
|
||||
RestTemplateUtils restTemplateUtils = new RestTemplateUtils(taiZhouConfig.getHttpConnectTimeout(), taiZhouConfig.getHttpReadTimeout());
|
||||
if (StringUtils.hasText(requestBody)) {
|
||||
String body = AesUtil.encryptPkcs5(requestBody, taiZhouConfig.getKey());
|
||||
log.info("请求泰州住建局body:{}", body);
|
||||
responseEntity = restTemplateUtils.post(apiFullUrl, headers, body, String.class);
|
||||
} else {
|
||||
responseEntity = restTemplateUtils.post(apiFullUrl, headers, String.class);
|
||||
}
|
||||
|
||||
log.info("请求泰州住建局返回结果:httpCode={}, body={}", responseEntity.getStatusCode(), responseEntity.getBody());
|
||||
if (responseEntity.getStatusCode() != HttpStatus.OK) {
|
||||
log.error("泰州住建局接口异常:{},{} {} {} {}", api, "httpCode=", responseEntity.getStatusCode(), "body=", responseEntity.getBody());
|
||||
return null;
|
||||
}
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
public <T> TaiZhouRes<T> parseResult(ResponseEntity<String> responseEntity, Class<T> clazz) {
|
||||
// 解密
|
||||
String resStr = AesUtil.decryptPkcs5(responseEntity.getBody(), taiZhouConfig.getKey());
|
||||
return JSONObject.parseObject(JSONUtil.toJsonStr(resStr), new TypeReference<TaiZhouRes<T>>(clazz) {
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,145 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc;
|
||||
|
||||
import cn.axzo.riven.third.taizhou.constant.enums.TaiZhouApiEnum;
|
||||
import cn.axzo.riven.third.taizhou.rpc.req.TaiZhouParamReq;
|
||||
import cn.axzo.riven.third.taizhou.rpc.req.TaiZhouPhoneReq;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/24 17:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TaiZhouRpc {
|
||||
|
||||
@Autowired
|
||||
private TaiZhouClient client;
|
||||
|
||||
private final static String EMPTY_JSON_STR = "{}";
|
||||
|
||||
|
||||
/**
|
||||
* 泰州-项目用工信息接口
|
||||
* 通过项目信息获取项目下的所有人员
|
||||
*
|
||||
* @param paramReq
|
||||
* @return
|
||||
*/
|
||||
public List<TaiZhouPrjWorkerRes> GetWorkerHmc(TaiZhouParamReq paramReq) {
|
||||
List<TaiZhouPrjWorkerRes> resList = new ArrayList<>();
|
||||
try {
|
||||
ResponseEntity<String> response = client.post(TaiZhouApiEnum.GB_PRJ_WORKER.getPath(), paramReq, EMPTY_JSON_STR);
|
||||
TaiZhouRes<String> taiZhouRes = client.parseResult(response, String.class);
|
||||
if (!taiZhouRes.getResultSuccess()) {
|
||||
log.info("taizhou: GetWorkerHmc failed, res={}", JSON.toJSONString(taiZhouRes));
|
||||
return resList;
|
||||
}
|
||||
List<TaiZhouPrjWorkerRes> list = JSON.parseObject(taiZhouRes.getResultData(), new TypeReference<List<TaiZhouPrjWorkerRes>>() {
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
resList = list;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("泰州获取调用项目人员接口GetWorkerHmc异常",e);
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 调用泰州平台查询:人员基本信息(GB_Worker)
|
||||
*
|
||||
* @author wangqing
|
||||
* @create 2024/5/27 17:50
|
||||
*/
|
||||
public List<TaiZhouWorkerRes> gBWorker(TaiZhouParamReq paramReq) {
|
||||
List<TaiZhouWorkerRes> resList = new ArrayList<>();
|
||||
try {
|
||||
|
||||
ResponseEntity<String> response = client.post(TaiZhouApiEnum.GB_WORKER.getPath(), paramReq, EMPTY_JSON_STR);
|
||||
TaiZhouRes<String> taiZhouRes = client.parseResult(response, String.class);
|
||||
log.info("taizhou: GB_Worker res={}", JSON.toJSONString(taiZhouRes));
|
||||
if (!taiZhouRes.getResultSuccess()) {
|
||||
log.warn("taizhou: GB_Worker failed, res={}", JSON.toJSONString(taiZhouRes));
|
||||
return resList;
|
||||
}
|
||||
List<TaiZhouWorkerRes> list = JSON.parseObject(taiZhouRes.getResultData(), new TypeReference<List<TaiZhouWorkerRes>>() {
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
resList = list;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("taizhou RPC error",e);
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 调用泰州平台查询:人员基本信息(GB_Worker)
|
||||
*
|
||||
* @author wangqing
|
||||
* @create 2024/5/27 17:50
|
||||
*/
|
||||
public List<TaiZhouPhoneRes> getWorkerPhoneNumber(TaiZhouPhoneReq phoneReq) {
|
||||
List<TaiZhouPhoneRes> resList = new ArrayList<>();
|
||||
try {
|
||||
|
||||
ResponseEntity<String> response = client.post(TaiZhouApiEnum.Get_WOEKER_PHONE_NUMBER.getPath(), phoneReq, EMPTY_JSON_STR);
|
||||
TaiZhouRes<String> taiZhouRes = client.parseResult(response, String.class);
|
||||
log.info("taizhou: getWorkerPhoneNumber res={}", JSON.toJSONString(taiZhouRes));
|
||||
if (!taiZhouRes.getResultSuccess()) {
|
||||
log.warn("taizhou: getWorkerPhoneNumber failed, res={}", JSON.toJSONString(taiZhouRes));
|
||||
return resList;
|
||||
}
|
||||
List<TaiZhouPhoneRes> list = JSON.parseObject(taiZhouRes.getResultData(), new TypeReference<List<TaiZhouPhoneRes>>() {
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
resList = list;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("taizhou RPC error",e);
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 调用泰州平台查询:项目基础信息(GB_ProjectInfo)
|
||||
*
|
||||
* @author wangqing
|
||||
* @create 2024/5/27 17:50
|
||||
*/
|
||||
public List<TazZhouProjectRes> GetProject(TaiZhouParamReq paramReq) {
|
||||
List<TazZhouProjectRes> resList = new ArrayList<>();
|
||||
try {
|
||||
ResponseEntity<String> response = client.post(TaiZhouApiEnum.Get_PROJECT.getPath(), paramReq, EMPTY_JSON_STR);
|
||||
TaiZhouRes<String> taiZhouRes = client.parseResult(response, String.class);
|
||||
log.info("taizhou: GetProject res={}", JSON.toJSONString(taiZhouRes));
|
||||
if (!taiZhouRes.getResultSuccess()) {
|
||||
log.warn("taizhou: GetProject failed, res={}", JSON.toJSONString(taiZhouRes));
|
||||
return resList;
|
||||
}
|
||||
List<TazZhouProjectRes> list = JSON.parseObject(taiZhouRes.getResultData(), new TypeReference<List<TazZhouProjectRes>>() {
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
resList = list;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("taizhou RPC error",e);
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.req;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yangchen@axzo.cn
|
||||
*/
|
||||
@Data
|
||||
public class TaiZhouParamReq {
|
||||
/**
|
||||
* 项目指纹
|
||||
*/
|
||||
// @JSONField(name = "DATANUMBER")
|
||||
private String dataNumber;
|
||||
/**
|
||||
* 供应商登记号
|
||||
*/
|
||||
// @JSONField(name = "bagsBH")
|
||||
private String bagsBH;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/26 10:28
|
||||
*/
|
||||
@Data
|
||||
public class TaiZhouPhoneReq {
|
||||
|
||||
/**
|
||||
* 工人唯一编码
|
||||
*/
|
||||
private String workerId;
|
||||
|
||||
/**
|
||||
* 项目标识(数据指纹)
|
||||
*/
|
||||
private String projectNo;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.req;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author wangqing
|
||||
* @create 2024/5/27 17:56
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class TaiZhouWorkerHmcReq extends TaiZhouParamReq {
|
||||
/**
|
||||
* 人员状态(0在场,1离场,空所有)
|
||||
*/
|
||||
private String ryzt;
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.res;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/26 10:30
|
||||
*/
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
public class TaiZhouPhoneRes {
|
||||
|
||||
/**
|
||||
* 工人唯一编码
|
||||
*/
|
||||
private String workerId;
|
||||
|
||||
/**
|
||||
* 工人联系电话(AES加密)
|
||||
*/
|
||||
private String phoneNumber;
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.res;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 项目用工信息返回类
|
||||
*
|
||||
* @author wangqing
|
||||
* @create 2024/5/27 18:06
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TaiZhouPrjWorkerRes {
|
||||
|
||||
/**
|
||||
* 人员唯一编码
|
||||
*/
|
||||
@JSONField(name = "WorkerID")
|
||||
private String workerId;
|
||||
|
||||
/**
|
||||
* 证件号码(前4****后4)
|
||||
*/
|
||||
@JSONField(name = "Zjhm")
|
||||
private String zjhm;
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
@JSONField(name = "PrjNumber")
|
||||
private String prjNumber;
|
||||
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
*/
|
||||
@JSONField(name = "Qyzzjgdm")
|
||||
private String qyzzjgdm;
|
||||
|
||||
/**
|
||||
* 班组名称
|
||||
*/
|
||||
@JSONField(name = "Bzmc")
|
||||
private String bzmc;
|
||||
|
||||
/**
|
||||
* 人员类型(管理人员、普通工人)
|
||||
*/
|
||||
@JSONField(name = "WorkerType")
|
||||
private String workerType;
|
||||
|
||||
/**
|
||||
* 管理人员岗位类别
|
||||
*/
|
||||
@JSONField(name = "Gwlb")
|
||||
private String gwlb;
|
||||
|
||||
/**
|
||||
* 工种类别
|
||||
*/
|
||||
@JSONField(name = "TpType")
|
||||
private String tpType;
|
||||
|
||||
/**
|
||||
* 工种名称
|
||||
*/
|
||||
@JSONField(name = "TpCodeName")
|
||||
private String tpCodeName;
|
||||
|
||||
/**
|
||||
* 计划用工开始日期(只到日期,没有具体时间)
|
||||
*/
|
||||
@JSONField(name = "BeginDate")
|
||||
private Date beginDate;
|
||||
|
||||
/**
|
||||
* 计划用工结束日期(只到日期,没有具体时间)
|
||||
*/
|
||||
@JSONField(name = "EndDate")
|
||||
private Date endDate;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
@JSONField(name = "GH")
|
||||
private String gH;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.res;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yangchen@axzo.cn
|
||||
*/
|
||||
@Data
|
||||
public class TaiZhouRes<T> {
|
||||
@JsonProperty("ResultSuccess")
|
||||
private Boolean resultSuccess;
|
||||
@JsonProperty("ResultMessage")
|
||||
private String resultMessage;
|
||||
@JsonProperty("ResultData")
|
||||
private T resultData;
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.res;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yangchen@axzo.cn
|
||||
*/
|
||||
@Data
|
||||
public class TaiZhouTokenRes {
|
||||
private String token;
|
||||
/**
|
||||
* 过期时间,单位秒
|
||||
*/
|
||||
private Integer expireTime;
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.res;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 泰州人员基本信息返回类
|
||||
*
|
||||
* @author wangqing
|
||||
* @create 2024/5/27 18:26
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TaiZhouWorkerRes {
|
||||
|
||||
/**
|
||||
* 人员唯一编码
|
||||
*/
|
||||
@JSONField(name = "WorkerID")
|
||||
private String workerId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@JSONField(name = "WorkerName")
|
||||
private String workerName;
|
||||
|
||||
/**
|
||||
* 证件号码(前4****后4)
|
||||
*/
|
||||
@JSONField(name = "Zjhm")
|
||||
private String zjhm;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@JSONField(name = "Xb")
|
||||
private String xb;
|
||||
|
||||
/**
|
||||
* 住址
|
||||
*/
|
||||
@JSONField(name = "Zz")
|
||||
private String zz;
|
||||
|
||||
/**
|
||||
* 民族
|
||||
*/
|
||||
@JSONField(name = "Mz")
|
||||
private String mz;
|
||||
|
||||
/**
|
||||
* 身份证发证机关
|
||||
*/
|
||||
@JSONField(name = "SfzFzjg")
|
||||
private String sfzFzjg;
|
||||
|
||||
/**
|
||||
* 户籍所在省份
|
||||
*/
|
||||
@JSONField(name = "Province")
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 户籍所在城市
|
||||
*/
|
||||
@JSONField(name = "City")
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 户籍所在地区
|
||||
*/
|
||||
@JSONField(name = "County")
|
||||
private String county;
|
||||
|
||||
/**
|
||||
* 联系电话(前4****后4)
|
||||
*/
|
||||
@JSONField(name = "Lxdh")
|
||||
private String lxdh;
|
||||
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package cn.axzo.riven.third.taizhou.rpc.res;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/28 13:43
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TazZhouProjectRes {
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
@JSONField(name = "PrjNumber")
|
||||
private String prjNumber;
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@JSONField(name = "PrjName")
|
||||
private String prjName;
|
||||
/**
|
||||
* 项目所属区县
|
||||
*/
|
||||
@JSONField(name = "County")
|
||||
private String county;
|
||||
|
||||
/**
|
||||
* 项目属地(所属区县下的乡镇)
|
||||
*/
|
||||
@JSONField(name = "Ssdq")
|
||||
private String ssdq;
|
||||
|
||||
/**
|
||||
* 项目地址
|
||||
*/
|
||||
@JSONField(name = "PrjAdress")
|
||||
private String prjAdress;
|
||||
|
||||
/**
|
||||
* 建筑面积(平方米)float
|
||||
*/
|
||||
@JSONField(name = "Jzmj")
|
||||
private String jzmj;
|
||||
|
||||
/**
|
||||
* 工程总价(万元) Numeric(14,4)
|
||||
*/
|
||||
@JSONField(name = "Gczj")
|
||||
private String gczj;
|
||||
|
||||
/**
|
||||
* 建设单位
|
||||
*/
|
||||
@JSONField(name = "Jsdw")
|
||||
private String jsdw;
|
||||
|
||||
/**
|
||||
* 建设单位统一社会信用代码
|
||||
*/
|
||||
@JSONField(name = "JsdwZzjgdm")
|
||||
private String jsdwZzjgdm;
|
||||
|
||||
/**
|
||||
* 建设单位联系人
|
||||
*/
|
||||
@JSONField(name = "Jsdwlxr")
|
||||
private String jsdwlxr;
|
||||
|
||||
/**
|
||||
* 建设单位联系电话(前4****后4)
|
||||
*/
|
||||
@JSONField(name = "Jsdwlxrdh")
|
||||
private String jsdwlxrdh;
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.axzo.riven.third.taizhou.service;
|
||||
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import cn.axzo.riven.third.entity.ThirdProjectPerson;
|
||||
import cn.axzo.riven.third.taizhou.entity.TaiZhouProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 16:05
|
||||
*/
|
||||
public interface TaiZhouService {
|
||||
|
||||
|
||||
public void updateProjectIdForRemote(TaiZhouProject taiZhouProject) ;
|
||||
|
||||
public List<TaiZhouProject> queryThirdProjectForTaiZhou();
|
||||
|
||||
|
||||
public List<ThirdProjectPerson> remoteQueryProjectPerson(TaiZhouProject taiZhouProject);
|
||||
|
||||
|
||||
public List<ThirdPerson> remoteQueryPerson(TaiZhouProject taiZhouProject);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 同步手机号
|
||||
*/
|
||||
void syncPhone(TaiZhouProject taiZhouProject);
|
||||
|
||||
|
||||
public void addOrUpdateThirdPerson(ThirdPerson thirdPerson,TaiZhouProject taiZhouProject);
|
||||
|
||||
|
||||
/**
|
||||
* 查询需要创建用户的泰州用户信息
|
||||
* @return
|
||||
*/
|
||||
public List<ThirdPerson> queryNeedCreateUserThirdPerson();
|
||||
|
||||
}
|
||||
@ -0,0 +1,362 @@
|
||||
package cn.axzo.riven.third.taizhou.service.impl;
|
||||
|
||||
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
||||
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.basic.WorkerProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.request.QueryPersonProfileByIdOrPhoneDto;
|
||||
import cn.axzo.riven.third.common.AesUtil;
|
||||
import cn.axzo.riven.third.common.enums.SyncTypeEnum;
|
||||
import cn.axzo.riven.third.common.enums.ThirdCodeEnum;
|
||||
import cn.axzo.riven.third.dao.ThirdPersonDao;
|
||||
import cn.axzo.riven.third.dao.ThirdProjectDao;
|
||||
import cn.axzo.riven.third.dao.ThirdProjectPersonDao;
|
||||
import cn.axzo.riven.third.entity.*;
|
||||
import cn.axzo.riven.third.service.ThirdPersonService;
|
||||
import cn.axzo.riven.third.service.ThirdProjectService;
|
||||
import cn.axzo.riven.third.taizhou.config.TaiZhouConfig;
|
||||
import cn.axzo.riven.third.taizhou.entity.TaiZhouProfession;
|
||||
import cn.axzo.riven.third.taizhou.entity.TaiZhouProject;
|
||||
import cn.axzo.riven.third.taizhou.entity.TaiZhouProjectPersonExt;
|
||||
import cn.axzo.riven.third.taizhou.entity.TaiZhouThirdProjectExt;
|
||||
import cn.axzo.riven.third.taizhou.rpc.TaiZhouRpc;
|
||||
import cn.axzo.riven.third.taizhou.rpc.req.TaiZhouParamReq;
|
||||
import cn.axzo.riven.third.taizhou.rpc.req.TaiZhouPhoneReq;
|
||||
import cn.axzo.riven.third.taizhou.rpc.req.TaiZhouWorkerHmcReq;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TaiZhouPhoneRes;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TaiZhouPrjWorkerRes;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TaiZhouWorkerRes;
|
||||
import cn.axzo.riven.third.taizhou.rpc.res.TazZhouProjectRes;
|
||||
import cn.axzo.riven.third.taizhou.service.TaiZhouService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 16:10
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TaiZhouServiceImpl implements TaiZhouService {
|
||||
|
||||
@Autowired
|
||||
TaiZhouRpc rpc;
|
||||
|
||||
@Autowired
|
||||
ThirdPersonDao thirdPersonDao;
|
||||
|
||||
@Autowired
|
||||
private TaiZhouConfig taiZhouConfig;
|
||||
|
||||
@Autowired
|
||||
ThirdProjectService thirdProjectService;
|
||||
|
||||
@Autowired
|
||||
ThirdPersonService thirdPersonService;
|
||||
|
||||
@Autowired
|
||||
ThirdProjectPersonDao thirdProjectPersonDao;
|
||||
|
||||
@Autowired
|
||||
ThirdProjectDao thirdProjectDao;
|
||||
|
||||
@Override
|
||||
public void updateProjectIdForRemote(TaiZhouProject taiZhouProject) {
|
||||
|
||||
if (Objects.isNull(taiZhouProject.getTaiZhouThirdProjectExt())) {
|
||||
log.info("泰州项目扩展域为空,跳过处理");
|
||||
return;
|
||||
}
|
||||
//查询泰州项目人员接口
|
||||
TaiZhouParamReq req = new TaiZhouParamReq();
|
||||
req.setBagsBH(taiZhouProject.getTaiZhouThirdProjectExt().getBagsBH());
|
||||
req.setDataNumber(taiZhouProject.getTaiZhouThirdProjectExt().getDataNumber());
|
||||
List<TazZhouProjectRes> resList = rpc.GetProject(req);
|
||||
|
||||
if (!CollectionUtils.isEmpty(resList)) {
|
||||
|
||||
String originProjectId = taiZhouProject.getThirdProjectId();
|
||||
//如果项目ID不一致,则更新
|
||||
if (!originProjectId.equals(resList.get(0).getPrjNumber())) {
|
||||
|
||||
log.info("泰州项目id:{},不一致,进行更新ID和名称", taiZhouProject.getThirdProjectId());
|
||||
|
||||
taiZhouProject.setThirdProjectId(resList.get(0).getPrjNumber());
|
||||
taiZhouProject.setThirdProjectName(resList.get(0).getPrjName());
|
||||
|
||||
//更新数据
|
||||
thirdProjectDao.lambdaUpdate()
|
||||
.eq(ThirdProject::getThirdProjectId, originProjectId)
|
||||
.eq(ThirdProject::getThirdCode, taiZhouProject.getThirdCode())
|
||||
.set(ThirdProject::getThirdProjectId, taiZhouProject.getThirdProjectId())
|
||||
.set(!Objects.isNull(taiZhouProject.getThirdProjectName()), ThirdProject::getThirdProjectName, taiZhouProject.getThirdProjectName())
|
||||
.update();
|
||||
} else {
|
||||
log.info("泰州项目id:{},一致,不进行任何处理", taiZhouProject.getThirdProjectId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaiZhouProject> queryThirdProjectForTaiZhou() {
|
||||
|
||||
List<TaiZhouProject> taiZhouProjectList = new ArrayList<>(16);
|
||||
//获取泰州所有的项目信息
|
||||
List<ThirdProject> projectList = thirdProjectService.queryThirdProjectByThirdCode(ThirdCodeEnum.TAI_ZHOU.getCode());
|
||||
if (CollectionUtils.isEmpty(projectList)) {
|
||||
return taiZhouProjectList;
|
||||
}
|
||||
|
||||
//将扩展域解析出来
|
||||
return projectList.stream().map(x -> {
|
||||
TaiZhouProject taiZhouProject = new TaiZhouProject();
|
||||
BeanUtils.copyProperties(x, taiZhouProject);
|
||||
try {
|
||||
String json = x.getThirdProjectExt();
|
||||
TaiZhouThirdProjectExt ext = JSON.parseObject(json, TaiZhouThirdProjectExt.class);
|
||||
taiZhouProject.setTaiZhouThirdProjectExt(ext);
|
||||
} catch (Exception e) {
|
||||
log.error("获取ThirdProject的扩展域转化异常", e);
|
||||
}
|
||||
return taiZhouProject;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThirdProjectPerson> remoteQueryProjectPerson(TaiZhouProject taiZhouProject) {
|
||||
|
||||
List<ThirdProjectPerson> projectPersonList = new ArrayList<>();
|
||||
TaiZhouThirdProjectExt ext = taiZhouProject.getTaiZhouThirdProjectExt();
|
||||
if (Objects.isNull(ext)) {
|
||||
return projectPersonList;
|
||||
}
|
||||
|
||||
//查询泰州项目人员接口
|
||||
TaiZhouWorkerHmcReq req = new TaiZhouWorkerHmcReq();
|
||||
req.setBagsBH(ext.getBagsBH());
|
||||
req.setDataNumber(ext.getDataNumber());
|
||||
req.setRyzt("");
|
||||
List<TaiZhouPrjWorkerRes> resList = rpc.GetWorkerHmc(req);
|
||||
|
||||
|
||||
if (CollectionUtils.isEmpty(resList)) {
|
||||
return projectPersonList;
|
||||
}
|
||||
//转化对象
|
||||
return resList.stream().map(x -> {
|
||||
ThirdProjectPerson projectPerson = new ThirdProjectPerson();
|
||||
projectPerson.setThirdCode(ThirdCodeEnum.TAI_ZHOU.getCode());
|
||||
//泰州人员唯一ID和项目ID应该是的加密字段,和泰州确认不进行解密
|
||||
projectPerson.setThirdUniquePersonId(x.getWorkerId());
|
||||
projectPerson.setThirdProjectId(x.getPrjNumber());
|
||||
projectPerson.setThirdWorkType(x.getWorkerType());
|
||||
projectPerson.setThirdTeamId("");
|
||||
projectPerson.setThirdTeamName(x.getBzmc());
|
||||
projectPerson.setThirdWorkId("");
|
||||
projectPerson.setThirdWorkerId(x.getGH());
|
||||
projectPerson.setThirdDepartmentId("");
|
||||
projectPerson.setThirdPostName("");
|
||||
projectPerson.setCreateAt(new Date());
|
||||
//填充扩展域
|
||||
projectPerson.setThirdExt(buildThirdExt(x));
|
||||
return projectPerson;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ThirdPerson> remoteQueryPerson(TaiZhouProject taiZhouProject) {
|
||||
|
||||
List<ThirdPerson> personList = new ArrayList<>();
|
||||
|
||||
TaiZhouThirdProjectExt ext = taiZhouProject.getTaiZhouThirdProjectExt();
|
||||
if (Objects.isNull(ext)) {
|
||||
return personList;
|
||||
}
|
||||
|
||||
TaiZhouParamReq req = new TaiZhouParamReq();
|
||||
req.setBagsBH(ext.getBagsBH());
|
||||
req.setDataNumber(ext.getDataNumber());
|
||||
List<TaiZhouWorkerRes> resList = rpc.gBWorker(req);
|
||||
if (CollectionUtils.isEmpty(resList)) {
|
||||
return personList;
|
||||
}
|
||||
|
||||
resList.forEach(x -> {
|
||||
|
||||
ThirdPerson person = new ThirdPerson();
|
||||
person.setThirdCode(ThirdCodeEnum.TAI_ZHOU.getCode());
|
||||
person.setThirdUniquePersonId(x.getWorkerId());
|
||||
person.setThirdPersonName(x.getWorkerName());
|
||||
person.setThirdPersonPhone(x.getLxdh());
|
||||
person.setThirdPersonPhoto("");
|
||||
person.setThirdAuthority(x.getSfzFzjg());
|
||||
person.setThirdIdNumber(x.getZjhm());
|
||||
person.setThirdPersonFaceUrl("");
|
||||
person.setThirdSex(x.getXb());
|
||||
person.setCreateAt(new Date());
|
||||
person.setPersonId(0L);
|
||||
person.setCreateAt(new Date());
|
||||
personList.add(person);
|
||||
});
|
||||
|
||||
return personList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建项目工人的扩展域,目前只有工种信息
|
||||
*
|
||||
* @param res
|
||||
* @return
|
||||
*/
|
||||
private String buildThirdExt(TaiZhouPrjWorkerRes res) {
|
||||
TaiZhouProjectPersonExt projectPersonExt = new TaiZhouProjectPersonExt();
|
||||
TaiZhouProfession profession = new TaiZhouProfession();
|
||||
profession.setTpType(res.getTpType());
|
||||
profession.setTpCodeName(res.getTpCodeName());
|
||||
projectPersonExt.setProfessionList(new ArrayList<>());
|
||||
projectPersonExt.getProfessionList().add(profession);
|
||||
return JSON.toJSONString(projectPersonExt);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void syncPhone(TaiZhouProject taiZhouProject) {
|
||||
|
||||
//数据入库时就转化单条转化了手机号,此处只是补充,暂时不考虑分页查询。
|
||||
List<ThirdPerson> list = thirdPersonDao.lambdaQuery()
|
||||
.eq(ThirdPerson::getThirdCode, taiZhouProject.getThirdCode())
|
||||
.eq(ThirdPerson::getPersonId, 0L)
|
||||
.like(ThirdPerson::getThirdPersonPhone, "*")
|
||||
.list();
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
list.forEach(x -> {
|
||||
if (convertPhone(x, taiZhouProject)) {
|
||||
thirdPersonDao.lambdaUpdate()
|
||||
.eq(ThirdPerson::getThirdCode, x.getThirdCode())
|
||||
.eq(ThirdPerson::getThirdUniquePersonId, x.getThirdUniquePersonId())
|
||||
.set(ThirdPerson::getThirdPersonPhone, x.getThirdPersonPhone())
|
||||
.update();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOrUpdateThirdPerson(ThirdPerson thirdPerson, TaiZhouProject taiZhouProject) {
|
||||
ThirdPerson db = thirdPersonDao.lambdaQuery()
|
||||
.eq(ThirdPerson::getThirdCode, thirdPerson.getThirdCode())
|
||||
.eq(ThirdPerson::getThirdUniquePersonId, thirdPerson.getThirdUniquePersonId())
|
||||
.one();
|
||||
|
||||
//如果数据库为空,则插入
|
||||
if (Objects.isNull(db)) {
|
||||
|
||||
//转化手机号
|
||||
convertPhone(thirdPerson, taiZhouProject);
|
||||
|
||||
thirdPersonDao.save(thirdPerson);
|
||||
}
|
||||
//反之则更新
|
||||
else {
|
||||
//如果没有绑定安心筑账号,就继续更新
|
||||
if (db.getPersonId() == 0L) {
|
||||
thirdPersonDao.lambdaUpdate()
|
||||
.eq(ThirdPerson::getThirdCode, thirdPerson.getThirdCode())
|
||||
.eq(ThirdPerson::getThirdUniquePersonId, thirdPerson.getThirdUniquePersonId())
|
||||
.set(!Objects.isNull(thirdPerson.getThirdPersonName()), ThirdPerson::getThirdPersonName, thirdPerson.getThirdPersonName())
|
||||
//手机号不进行更新,只插入,此处是13******715,不进行更新,后续job会进行更新为明文
|
||||
// .set(ThirdPerson::getThirdPersonPhone, thirdPerson.getThirdPersonPhone())
|
||||
.set(!Objects.isNull(thirdPerson.getThirdPersonPhoto()), ThirdPerson::getThirdPersonPhoto, thirdPerson.getThirdPersonPhoto())
|
||||
.set(!Objects.isNull(thirdPerson.getThirdAuthority()), ThirdPerson::getThirdAuthority, thirdPerson.getThirdAuthority())
|
||||
.set(!Objects.isNull(thirdPerson.getThirdIdNumber()), ThirdPerson::getThirdIdNumber, thirdPerson.getThirdIdNumber())
|
||||
.set(!Objects.isNull(thirdPerson.getThirdPersonFaceUrl()), ThirdPerson::getThirdPersonFaceUrl, thirdPerson.getThirdPersonFaceUrl())
|
||||
.set(!Objects.isNull(thirdPerson.getThirdSex()), ThirdPerson::getThirdSex, thirdPerson.getThirdSex())
|
||||
.set(!Objects.isNull(thirdPerson.getPersonId()), ThirdPerson::getPersonId, thirdPerson.getPersonId())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private boolean convertPhone(ThirdPerson thirdPerson, TaiZhouProject taiZhouProject) {
|
||||
|
||||
TaiZhouPhoneReq req = new TaiZhouPhoneReq();
|
||||
|
||||
req.setWorkerId(thirdPerson.getThirdUniquePersonId());
|
||||
req.setProjectNo(taiZhouProject.getTaiZhouThirdProjectExt().getDataNumber());
|
||||
|
||||
List<TaiZhouPhoneRes> resList = rpc.getWorkerPhoneNumber(req);
|
||||
if (CollectionUtils.isEmpty(resList)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
String phone = URLDecoder.decode(resList.get(0).getPhoneNumber(), "UTF-8");
|
||||
phone = AesUtil.decryptPkcs5(phone, taiZhouConfig.getKey());
|
||||
thirdPerson.setThirdPersonPhone(phone);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("解析手机号为明文异常:", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThirdPerson> queryNeedCreateUserThirdPerson() {
|
||||
|
||||
//查询手机号符合条件的三方人员
|
||||
List<ThirdPerson> thirdPersonList = thirdPersonDao.lambdaQuery()
|
||||
.eq(ThirdPerson::getThirdCode, ThirdCodeEnum.TAI_ZHOU.getCode())
|
||||
.eq(ThirdPerson::getPersonId, 0L)
|
||||
.notLike(ThirdPerson::getThirdPersonPhone, "*")
|
||||
.list();
|
||||
|
||||
List<TaiZhouProject> taiZhouProjectList = queryThirdProjectForTaiZhou();
|
||||
Map<String, SyncTypeEnum> typeEnumMap = new HashMap<>();
|
||||
taiZhouProjectList.forEach(x -> {
|
||||
typeEnumMap.put(x.getThirdProjectId(), SyncTypeEnum.apply(x.getSyncType()));
|
||||
});
|
||||
|
||||
//过滤,只需要普通员工
|
||||
return thirdPersonList.stream().filter(x -> {
|
||||
List<ThirdProjectPerson> thirdProjectPersonList = thirdProjectPersonDao.lambdaQuery()
|
||||
.eq(ThirdProjectPerson::getThirdCode, x.getThirdCode())
|
||||
.eq(ThirdProjectPerson::getThirdUniquePersonId, x.getThirdUniquePersonId())
|
||||
.like(ThirdProjectPerson::getThirdWorkType, "普通工人")
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(thirdProjectPersonList)) {
|
||||
return false;
|
||||
} else {
|
||||
//该人员存在普通员工角色,则追加创建用户
|
||||
for (ThirdProjectPerson thirdProjectPerson : thirdProjectPersonList) {
|
||||
SyncTypeEnum syncTypeEnum = typeEnumMap.get(thirdProjectPerson.getThirdProjectId());
|
||||
if (SyncTypeEnum.SYNC_NORMAL == syncTypeEnum) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user