Commit 70248531648e72dd7197cd5f433e3d6e0df2b68d
1 parent
d2195b33
Exists in
dev
中燃-开发-肖顺,发来的代码,要求替换的
Showing
3 changed files
with
29 additions
and
24 deletions
Show diff stats
zr-cloud/zr-api/zr-api-system/src/main/java/com/chinagas/api/otherSystem/Mdm.java
... | ... | @@ -9,7 +9,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; |
9 | 9 | import com.fasterxml.jackson.databind.node.ObjectNode; |
10 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
11 | 11 | import org.springframework.beans.factory.annotation.Value; |
12 | -import org.springframework.cloud.context.config.annotation.RefreshScope; | |
13 | 12 | import org.springframework.http.HttpEntity; |
14 | 13 | import org.springframework.http.HttpHeaders; |
15 | 14 | import org.springframework.http.MediaType; |
... | ... | @@ -98,17 +97,23 @@ public class Mdm { |
98 | 97 | responseEntity = restTemplate.postForEntity(reqUrl,request,String.class); |
99 | 98 | Map<String,Object> body = objectMapper.readValue(responseEntity.getBody(), Map.class); |
100 | 99 | objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); |
101 | - DataRecive<T> dataM = objectMapper.readValue(Base64.decode(body.get("data").toString()),typeReference); | |
102 | - if(DataSyncConstants.RYXX.equals(ifaceCode)){ | |
103 | - instList.addAll(dataM.getCustMasterDataIntfList()); | |
100 | + if (!DataSyncConstants.ZZJG.equals(ifaceCode)){ | |
101 | + DataRecive<T> dataM = objectMapper.readValue(Base64.decode(body.get("data").toString()),typeReference); | |
102 | + if(DataSyncConstants.RYXX.equals(ifaceCode)){ | |
103 | + instList.addAll(dataM.getCustMasterDataIntfList()); | |
104 | + } | |
105 | + if(DataSyncConstants.RYZZGX.equals(ifaceCode)){ | |
106 | + instList.addAll(dataM.getEmpDepRelationships()); | |
107 | + } | |
104 | 108 | } |
105 | 109 | if (DataSyncConstants.ZZJG.equals(ifaceCode)){ |
106 | - instList.addAll(dataM.getDepInfoList()); | |
110 | + String decodedString = new String(Base64.decode(body.get("data").toString()), StandardCharsets.UTF_8); | |
111 | + ObjectMapper objectMapper = new ObjectMapper(); | |
112 | + Map<String, Object> map = objectMapper.readValue(decodedString, Map.class); | |
113 | + List<T> list = (List<T>) map.get("depInfoList"); | |
114 | + instList.addAll(list); | |
115 | +// instList.addAll(dataM.getDepInfoList()); | |
107 | 116 | } |
108 | - if(DataSyncConstants.RYZZGX.equals(ifaceCode)){ | |
109 | - instList.addAll(dataM.getEmpDepRelationships()); | |
110 | - } | |
111 | - | |
112 | 117 | } |
113 | 118 | return instList; |
114 | 119 | } | ... | ... |
zr-cloud/zr-modules/zr-system/src/main/java/com/chinagas/modules/system/controller/DataSyncController.java
1 | 1 | package com.chinagas.modules.system.controller; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSON; | |
3 | 4 | import com.chinagas.api.otherSystem.Mdm; |
4 | 5 | import com.chinagas.api.system.domain.DepInfo; |
5 | 6 | import com.chinagas.api.system.domain.EmpDepRelationship; |
6 | 7 | import com.chinagas.api.system.domain.EmpInfo; |
7 | -import com.chinagas.common.core.constants.Constants; | |
8 | 8 | import com.chinagas.common.core.constants.DataSyncConstants; |
9 | 9 | import com.chinagas.common.core.domain.R; |
10 | 10 | import com.chinagas.common.core.utils.sync.DataRecive; |
11 | -import com.chinagas.common.core.utils.sync.DataSyncUtils; | |
12 | 11 | import com.chinagas.common.core.web.controller.BaseController; |
13 | 12 | import com.chinagas.common.security.annotation.InnerAuth; |
14 | 13 | import com.chinagas.modules.system.service.IDepInfoService; |
... | ... | @@ -21,13 +20,12 @@ import org.springframework.web.bind.annotation.PathVariable; |
21 | 20 | import org.springframework.web.bind.annotation.PostMapping; |
22 | 21 | import org.springframework.web.bind.annotation.RequestMapping; |
23 | 22 | import org.springframework.web.bind.annotation.RestController; |
24 | -import org.springframework.web.client.RestTemplate; | |
25 | 23 | |
26 | -import javax.annotation.Resource; | |
27 | -import java.io.IOException; | |
28 | 24 | import java.text.SimpleDateFormat; |
29 | 25 | import java.util.Calendar; |
30 | 26 | import java.util.List; |
27 | +import java.util.Map; | |
28 | +import java.util.stream.Collectors; | |
31 | 29 | |
32 | 30 | /** |
33 | 31 | * @ClassName DataSyncController |
... | ... | @@ -69,9 +67,13 @@ public class DataSyncController extends BaseController { |
69 | 67 | res = empInfoService.insertEmpInfoBatch(empList); |
70 | 68 | } |
71 | 69 | if(DataSyncConstants.ZZJG.equals(iFaceCode)){ |
72 | - List<DepInfo> depList = mdm.requestOrgData(DataSyncConstants.ZZJG,startTime,endTime, new TypeReference<DataRecive<DepInfo>>() {}); | |
70 | + List<Map> depList = mdm.requestOrgData(DataSyncConstants.ZZJG,startTime,endTime, new TypeReference<DataRecive<Map>>() {}); | |
73 | 71 | System.out.println("depList size: "+depList.size()); |
74 | - res = depInfoService.insertDepInfoBach(depList); | |
72 | + List<DepInfo> depInfoArrayList = depList.stream() | |
73 | + .map(map -> JSON.parseObject(JSON.toJSONString(map),DepInfo.class)) | |
74 | + .collect(Collectors.toList()); | |
75 | + | |
76 | + res = depInfoService.insertDepInfoBach(depInfoArrayList); | |
75 | 77 | } |
76 | 78 | if(DataSyncConstants.RYZZGX.equals(iFaceCode)){ |
77 | 79 | List<EmpDepRelationship> empDepRelationshipList = mdm.requestOrgData(DataSyncConstants.RYZZGX,startTime,endTime, new TypeReference<DataRecive<EmpDepRelationship>>() {}); | ... | ... |
zr-cloud/zr-modules/zr-system/src/main/java/com/chinagas/modules/system/service/impl/DepInfoServiceImpl.java
1 | 1 | package com.chinagas.modules.system.service.impl; |
2 | 2 | |
3 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
3 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
4 | 4 | import com.chinagas.api.system.domain.DepInfo; |
5 | 5 | import com.chinagas.api.system.domain.SysDept; |
6 | 6 | import com.chinagas.common.core.constants.UserConstants; |
7 | 7 | import com.chinagas.common.core.utils.StringUtils; |
8 | -import com.chinagas.common.log.enums.BusinessType; | |
9 | -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
10 | 8 | import com.chinagas.modules.system.mapper.DepInfoMapper; |
11 | -import com.chinagas.modules.system.service.ISysDeptService; | |
12 | 9 | import com.chinagas.modules.system.service.IDepInfoService; |
10 | +import com.chinagas.modules.system.service.ISysDeptService; | |
13 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
14 | 12 | import org.springframework.stereotype.Service; |
15 | -import org.springframework.transaction.annotation.Transactional; | |
16 | 13 | |
17 | 14 | import java.util.ArrayList; |
18 | -import java.util.Date; | |
19 | 15 | import java.util.List; |
20 | 16 | |
21 | 17 | /** |
... | ... | @@ -53,7 +49,7 @@ public class DepInfoServiceImpl extends ServiceImpl<DepInfoMapper, DepInfo> impl |
53 | 49 | // } |
54 | 50 | |
55 | 51 | @Override |
56 | - @Transactional(rollbackFor = Exception.class) | |
52 | +// @Transactional(rollbackFor = Exception.class) | |
57 | 53 | public int insertDepInfoBach(List<DepInfo> depList){ |
58 | 54 | int rows = 0; |
59 | 55 | SysDept sysDept = null; |
... | ... | @@ -66,7 +62,9 @@ public class DepInfoServiceImpl extends ServiceImpl<DepInfoMapper, DepInfo> impl |
66 | 62 | }else { |
67 | 63 | sysDept.setDeptName(""); |
68 | 64 | } |
69 | - sysDept.setParentId(Long.parseLong(depInfo.getCgDeptParent())); | |
65 | + if(StringUtils.isNotEmpty(depInfo.getCgDeptParent())){ | |
66 | + sysDept.setParentId(Long.parseLong(depInfo.getCgDeptParent())); | |
67 | + } | |
70 | 68 | sysDept.setAncestors(getAncestors(depInfo.getDeptId(), depList)); |
71 | 69 | sysDept.setDeptPath(depInfo.getCgDeptPath()); |
72 | 70 | ... | ... |