|
@@ -1,16 +1,27 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.google.gson.JsonArray;
|
|
|
|
+import com.google.gson.JsonElement;
|
|
|
|
+import com.google.gson.JsonObject;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.vo.*;
|
|
import com.management.platform.entity.vo.*;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.service.*;
|
|
import com.management.platform.service.*;
|
|
import com.management.platform.util.*;
|
|
import com.management.platform.util.*;
|
|
|
|
+import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
@@ -164,6 +175,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
OperationRecordService operationRecordService;
|
|
OperationRecordService operationRecordService;
|
|
@Resource
|
|
@Resource
|
|
ProjectBasecostService projectBasecostService;
|
|
ProjectBasecostService projectBasecostService;
|
|
|
|
+ @Resource
|
|
|
|
+ ThirdPartyInterfaceService thirdPartyInterfaceService;
|
|
|
|
+ @Resource
|
|
|
|
+ ProjectSeparateService projectSeparateService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
@@ -973,11 +988,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
return m;
|
|
return m;
|
|
}
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
|
- String startDate = "2020-12-01";
|
|
|
|
- String endDate = "2021-01-31";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private List<Integer> getBranchDepartment(Integer departmentId, List<Department> departmentList) {
|
|
private List<Integer> getBranchDepartment(Integer departmentId, List<Department> departmentList) {
|
|
List<Integer> list = new ArrayList<>();
|
|
List<Integer> list = new ArrayList<>();
|
|
list.add(departmentId);
|
|
list.add(departmentId);
|
|
@@ -5298,6 +5308,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}else{
|
|
}else{
|
|
divide=new BigDecimal(0);
|
|
divide=new BigDecimal(0);
|
|
}
|
|
}
|
|
|
|
+ if(divide.compareTo(new BigDecimal(1))==1){
|
|
|
|
+ divide=new BigDecimal(1);
|
|
|
|
+ log.error("填报及时率数据异常:==="+user.getName());
|
|
|
|
+ }
|
|
String number = dft.format(divide);
|
|
String number = dft.format(divide);
|
|
timelinessRateVO.setTimelinessRate(String.valueOf(number));
|
|
timelinessRateVO.setTimelinessRate(String.valueOf(number));
|
|
}
|
|
}
|
|
@@ -6333,6 +6347,84 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg synchronizationProject(String dataJson) {
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(dataJson);
|
|
|
|
+ JSONObject header = (JSONObject) jsonObject.get("header");
|
|
|
|
+ String token = String.valueOf(header.get("token"));
|
|
|
|
+ List<Project> projectList = JSON.parseArray(String.valueOf(jsonObject.get("projectArrays")), Project.class);
|
|
|
|
+ List<ProjectSeparate> projectSeparateList = JSON.parseArray(String.valueOf(jsonObject.get("projectSeparateArrays")), ProjectSeparate.class);
|
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
+ List<ThirdPartyInterface> thirdPartyInterfaceList = thirdPartyInterfaceService.list(new QueryWrapper<ThirdPartyInterface>().eq("token", token));
|
|
|
|
+ if(thirdPartyInterfaceList.size()==0){
|
|
|
|
+ msg.setError("token错误");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ ThirdPartyInterface thirdPartyInterface = thirdPartyInterfaceList.get(0);
|
|
|
|
+ if(LocalDateTime.now().isAfter(thirdPartyInterface.getExpireTime())){
|
|
|
|
+ msg.setError("token过期失效");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ List<Project> allProject = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", thirdPartyInterface.getCompanyId()));
|
|
|
|
+ String message="";
|
|
|
|
+ if(projectList!=null &&projectList.size()>0){
|
|
|
|
+ List<Project> changeProjectList=new ArrayList<>();
|
|
|
|
+ for (Project project : projectList) {
|
|
|
|
+ Optional<Project> first = allProject.stream().filter(ap -> ap.getProjectCode().equals(project.getProjectCode())).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ project.setId(first.get().getId());
|
|
|
|
+ changeProjectList.add(project);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(updateBatchById(changeProjectList)){
|
|
|
|
+ message+="成功更新"+changeProjectList.size()+"条项目数据";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(projectSeparateList!=null&&projectSeparateList.size()>0){
|
|
|
|
+ if(projectSeparateService.updateBatchById(projectSeparateList)){
|
|
|
|
+ message+="成功更新"+projectSeparateList.size()+"条项目子表数据";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ msg.data=message;
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ Map params = new HashMap<>();
|
|
|
|
+ Map paramDataJson = new HashMap<>();
|
|
|
|
+ JSONArray projectArrays= new JSONArray();
|
|
|
|
+ Map header=new HashMap();
|
|
|
|
+ header.put("token","123456789");
|
|
|
|
+ paramDataJson.put("header",header);
|
|
|
|
+ JSONObject project=new JSONObject();
|
|
|
|
+ project.put("id",246);
|
|
|
|
+ project.put("projectName",1000);
|
|
|
|
+ projectArrays.add(project);
|
|
|
|
+ paramDataJson.put("projectArrays",projectArrays);
|
|
|
|
+ params.put("dataJson",paramDataJson);
|
|
|
|
+ //装填参数
|
|
|
|
+ List nvps = new ArrayList();
|
|
|
|
+ if(params!=null){
|
|
|
|
+ params.forEach((key, value) -> nvps.add(new BasicNameValuePair((String) key, JSONObject.toJSONString(value))));
|
|
|
|
+ }
|
|
|
|
+ System.out.println(nvps);
|
|
|
|
+ CloseableHttpResponse response;// 响应类
|
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
+ HttpPost httpPost=new HttpPost("http://localhost:10010/project/synchronizationProject");
|
|
|
|
+ httpPost.addHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
|
|
|
+ try {
|
|
|
|
+ httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
|
|
|
|
+ response = httpClient.execute(httpPost);
|
|
|
|
+ if (response != null && response.getEntity() != null) {
|
|
|
|
+ //返回信息
|
|
|
|
+ String resulString = EntityUtils.toString(response.getEntity());
|
|
|
|
+ //todo 这里处理返回信息
|
|
|
|
+ System.out.println("成功"+ resulString);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());
|