|
@@ -5,13 +5,18 @@ import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.project.zcustom.domain.addional.LargeAssetDirs;
|
|
|
import com.project.zcustom.domain.addional.LargeLogistics;
|
|
|
+import com.project.zcustom.domain.basics.PlatAppOrg;
|
|
|
import com.project.zcustom.mapper.logistics.PlatLogisticsMapper;
|
|
|
+import com.project.zcustom.service.basics.IPlatAppOrgService;
|
|
|
+import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description 后勤资源监控服务
|
|
@@ -24,6 +29,8 @@ public class LogisticsService {
|
|
|
|
|
|
@Autowired
|
|
|
private PlatLogisticsMapper platLogisticsMapper;
|
|
|
+ @Autowired
|
|
|
+ private IPlatAppOrgService platAppOrgService;
|
|
|
|
|
|
public void getLogisticsData(){
|
|
|
String json = "{\n" +
|
|
@@ -176,38 +183,29 @@ public class LogisticsService {
|
|
|
List<LargeAssetDirs> officeAssetList = new ArrayList<>();
|
|
|
List<LargeAssetDirs> buildingAssetList = new ArrayList<>();
|
|
|
List<LargeAssetDirs> serviceAssetList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 查询所有组织信息
|
|
|
+ List<PlatAppOrg> orgList = platAppOrgService.selectAppCodeList();
|
|
|
+ Map<String, String> orgMap = orgList.stream().collect(Collectors.toMap(PlatAppOrg::getAppCode, PlatAppOrg::getAppName, (v1, v2) -> v1));
|
|
|
+
|
|
|
for (int i = 0; i < dataArray.size(); i++) {
|
|
|
JSONObject dataItem = dataArray.getJSONObject(i);
|
|
|
LargeLogistics largeLogistics = JSON.parseObject(dataItem.toString(), LargeLogistics.class);
|
|
|
-
|
|
|
- JSONArray officeAssetArray = dataItem.getJSONArray("officeAssetDistrs");
|
|
|
- for (int j = 0; j < dataArray.size(); j++) {
|
|
|
- LargeAssetDirs largeAssetDirs = new LargeAssetDirs();
|
|
|
- JSONObject assetItem = officeAssetArray.getJSONObject(j);
|
|
|
- largeAssetDirs.setAppCode(largeLogistics.getOrgId());
|
|
|
- largeAssetDirs.setCategoryName(assetItem.getString("categoryName"));
|
|
|
- largeAssetDirs.setAssetNum(Long.valueOf(assetItem.getString("assetNum")));
|
|
|
- officeAssetList.add(largeAssetDirs);
|
|
|
- }
|
|
|
- JSONArray buildingAssetArray = dataItem.getJSONArray("buildingAssetDistrs");
|
|
|
- for (int j = 0; j < dataArray.size(); j++) {
|
|
|
- LargeAssetDirs largeAssetDirs = new LargeAssetDirs();
|
|
|
- JSONObject assetItem = buildingAssetArray.getJSONObject(j);
|
|
|
- largeAssetDirs.setAppCode(largeLogistics.getOrgId());
|
|
|
- largeAssetDirs.setCategoryName(assetItem.getString("categoryName"));
|
|
|
- largeAssetDirs.setAssetNum(Long.valueOf(assetItem.getString("assetNum")));
|
|
|
- buildingAssetList.add(largeAssetDirs);
|
|
|
- }
|
|
|
- JSONArray serviceAssetArray = dataItem.getJSONArray("serviceAssetDistrs");
|
|
|
- for (int j = 0; j < dataArray.size(); j++) {
|
|
|
- LargeAssetDirs largeAssetDirs = new LargeAssetDirs();
|
|
|
- JSONObject assetItem = serviceAssetArray.getJSONObject(j);
|
|
|
- largeAssetDirs.setAppCode(largeLogistics.getOrgId());
|
|
|
- largeAssetDirs.setCategoryName(assetItem.getString("categoryName"));
|
|
|
- largeAssetDirs.setAssetNum(Long.valueOf(assetItem.getString("assetNum")));
|
|
|
- serviceAssetList.add(largeAssetDirs);
|
|
|
+ // 业务方提供的数据包含一些不需要的部门数据进行过滤
|
|
|
+ if ( !orgMap.containsKey(largeLogistics.getOrgId())){
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
+ // 资产列表数据提取
|
|
|
+ List<LargeAssetDirs> officeList = getAssetList(dataItem, largeLogistics.getOrgId(), "officeAssetDistrs");
|
|
|
+ officeAssetList.addAll(officeList);
|
|
|
+
|
|
|
+ List<LargeAssetDirs> buildingList = getAssetList(dataItem, largeLogistics.getOrgId(),"buildingAssetDistrs");
|
|
|
+ buildingAssetList.addAll(buildingList);
|
|
|
+
|
|
|
+ List<LargeAssetDirs> serviceList = getAssetList(dataItem, largeLogistics.getOrgId(), "serviceAssetDistrs");
|
|
|
+ serviceAssetList.addAll(serviceList);
|
|
|
+
|
|
|
list.add(largeLogistics);
|
|
|
}
|
|
|
platLogisticsMapper.deleteLogistics();
|
|
@@ -219,4 +217,29 @@ public class LogisticsService {
|
|
|
platLogisticsMapper.deleteServiceAssetDirs();
|
|
|
platLogisticsMapper.insertServiceAssetDirs(serviceAssetList);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * officeAssetDistrs 办公资产分布列表
|
|
|
+ * buildingAssetDistrs 楼宇设备分布列表
|
|
|
+ * serviceAssetDistrs 服务设备分布列表
|
|
|
+ * @param dataItem
|
|
|
+ * @param appCode
|
|
|
+ * @param jsonKey
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<LargeAssetDirs> getAssetList(JSONObject dataItem, String appCode, String jsonKey){
|
|
|
+ List<LargeAssetDirs> list = Lists.newArrayList();
|
|
|
+ JSONArray buildingAssetArray = dataItem.getJSONArray(jsonKey);
|
|
|
+ for (int k = 0; k < buildingAssetArray.size(); k++) {
|
|
|
+ LargeAssetDirs largeAssetDirs = new LargeAssetDirs();
|
|
|
+ JSONObject assetItem = buildingAssetArray.getJSONObject(k);
|
|
|
+ largeAssetDirs.setAppCode(appCode);
|
|
|
+ largeAssetDirs.setCategoryName(assetItem.getString("categoryName"));
|
|
|
+ largeAssetDirs.setAssetNum(assetItem.getLong("assetNum"));
|
|
|
+ list.add(largeAssetDirs);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|