2024-09-07 18:48:41 +08:00
|
|
|
|
package com.zhgd.xmgl.util;
|
|
|
|
|
|
|
2024-09-12 18:01:53 +08:00
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
2024-09-07 18:48:41 +08:00
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.entity.Company;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.entity.DictionaryItem;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.service.IDictionaryItemService;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.cost.entity.CostContract;
|
2024-09-18 18:28:12 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.cost.entity.CostContractDetail;
|
2024-09-07 18:48:41 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.cost.entity.CostContractPay;
|
2024-10-22 20:23:35 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.cost.entity.CostPayPlan;
|
2024-09-18 18:28:12 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.cost.service.ICostContractDetailService;
|
2024-09-07 18:48:41 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.cost.service.ICostContractPayService;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.cost.service.ICostContractService;
|
2024-10-22 20:23:35 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.cost.service.ICostPayPlanService;
|
2024-09-07 18:48:41 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.jz.dto.PlanTargetDto;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.project.entity.ProjectSupplier;
|
2024-09-11 21:50:50 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.project.entity.dto.ProgressPanoramaNodePlanDto;
|
2024-09-07 18:48:41 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.project.service.IProjectSupplierService;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
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.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
2024-12-05 16:25:57 +08:00
|
|
|
|
import java.math.BigDecimal;
|
2024-09-07 18:48:41 +08:00
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
|
import java.security.MessageDigest;
|
|
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
@Component
|
|
|
|
|
|
public class JiuzhuDateUtil {
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${jiuzhu.address}")
|
|
|
|
|
|
private final String ADDRESS = "http://218.95.151.122:18000";
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IProjectService projectService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IProjectSupplierService projectSupplierService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ICostContractService costContractService;
|
|
|
|
|
|
|
2024-09-18 18:28:12 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private ICostContractDetailService costContractDetailService;
|
|
|
|
|
|
|
2024-09-07 18:48:41 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private ICostContractPayService costContractPayService;
|
|
|
|
|
|
|
2024-10-22 20:23:35 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private ICostPayPlanService costPayPlanService;
|
|
|
|
|
|
|
2024-09-07 18:48:41 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private ICompanyService companyService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IDictionaryItemService dictionaryItemService;
|
|
|
|
|
|
|
|
|
|
|
|
public void getSubCompanyData() {
|
|
|
|
|
|
String url = "/api/cube/restful/interface/getModeDataPageList/xmxx";
|
|
|
|
|
|
String systemid = "xmxx";
|
|
|
|
|
|
String d_password = "E3BA750749804E65B0A93833635F8ED2";
|
|
|
|
|
|
JSONObject mainTable = new JSONObject();
|
|
|
|
|
|
String result = doAction(url, systemid, d_password, mainTable);
|
|
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
2024-10-24 19:07:01 +08:00
|
|
|
|
List<String> projects = projectService.list(Wrappers.<Project>lambdaQuery())
|
2024-09-07 18:48:41 +08:00
|
|
|
|
.stream().map(p -> p.getProjectId().toString()).collect(Collectors.toList());
|
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
|
|
|
|
JSONArray jsonArray = obj.getJSONArray("result");
|
|
|
|
|
|
List<Project> projectList = new ArrayList<>();
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
|
JSONObject projectObj = jsonArray.getJSONObject(i).getJSONObject("mainTable");
|
|
|
|
|
|
Project project = new Project();
|
|
|
|
|
|
String uuid = UUID.randomUUID().toString().replace("-", "").toUpperCase();
|
|
|
|
|
|
project.setProjectId(Long.valueOf(projectObj.getInteger("id")));
|
|
|
|
|
|
if (!projects.contains(project.getProjectId().toString())) {
|
|
|
|
|
|
project.setProjectSn(uuid);
|
|
|
|
|
|
}
|
|
|
|
|
|
project.setProjectName(projectObj.getString("xmmc"));
|
|
|
|
|
|
project.setProjectAddress(projectObj.getString("xmdz"));
|
|
|
|
|
|
project.setLongitude(projectObj.getString("xmdz"));
|
|
|
|
|
|
project.setLatitude(projectObj.getString("wdzb"));
|
|
|
|
|
|
project.setProjectNumber(projectObj.getString("xmbh"));
|
|
|
|
|
|
project.setProjectType(projectObj.getString("gclb"));
|
|
|
|
|
|
project.setEngineeringPurpose(projectObj.getInteger("gcyt"));
|
|
|
|
|
|
project.setStructureType(projectObj.getInteger( "jglx"));
|
|
|
|
|
|
project.setProjectAcreage(projectObj.getString("xmmj"));
|
|
|
|
|
|
project.setStartWorkDate(projectObj.getString("kgrq"));
|
|
|
|
|
|
project.setConstructionStage(projectObj.getInteger("sgjd"));
|
|
|
|
|
|
project.setSaleAcreage(projectObj.getString("ksmj"));
|
|
|
|
|
|
project.setHouseholds(projectObj.getInteger("hs"));
|
|
|
|
|
|
project.setBuildingNum(projectObj.getInteger("lds"));
|
2024-10-30 15:41:27 +08:00
|
|
|
|
project.setMajorProjectType(projectObj.getString("sfszdgc").equals("是") ? 1 : 0);
|
2024-09-07 18:48:41 +08:00
|
|
|
|
Company sdw = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getExternalId, projectObj.getString("sdw"))
|
|
|
|
|
|
.eq(Company::getCompanyType, 3));
|
|
|
|
|
|
project.setCompanySn(sdw == null ? "" : sdw.getCompanySn());
|
|
|
|
|
|
String xmlx = projectObj.getString("xmlx");
|
|
|
|
|
|
DictionaryItem projectLx = dictionaryItemService.getOne(Wrappers.<DictionaryItem>lambdaQuery()
|
|
|
|
|
|
.eq(DictionaryItem::getName, xmlx)
|
|
|
|
|
|
.eq(DictionaryItem::getDictionaryEncoding, "project_lx"));
|
2024-10-30 15:41:27 +08:00
|
|
|
|
project.setProjectLx(projectLx == null ? null : projectLx.getData());
|
2024-09-10 17:39:54 +08:00
|
|
|
|
project.setNature(projectObj.getString("xmlxxm").equals("0") ? 1 : 2);
|
2024-09-07 18:48:41 +08:00
|
|
|
|
projectList.add(project);
|
|
|
|
|
|
}
|
|
|
|
|
|
projectService.saveOrUpdateBatch(projectList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getProjectSupplier() {
|
|
|
|
|
|
String url = "/api/cube/restful/interface/getModeDataPageList/gyszcxxlb";
|
|
|
|
|
|
String systemid = "gyszcxxlb";
|
|
|
|
|
|
String d_password = "D548C325B35C41CCA08D819D80151822";
|
|
|
|
|
|
JSONObject mainTable = new JSONObject();
|
|
|
|
|
|
mainTable.put("spzt", 2);
|
|
|
|
|
|
String result = doAction(url, systemid, d_password, mainTable);
|
|
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
|
|
|
|
JSONArray jsonArray = obj.getJSONArray("result");
|
|
|
|
|
|
List<ProjectSupplier> projectSupplierList = new ArrayList<>();
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
|
JSONObject projectObj = jsonArray.getJSONObject(i).getJSONObject("mainTable");
|
|
|
|
|
|
ProjectSupplier projectSupplier = JSONObject.parseObject(JSON.toJSONString(projectObj), ProjectSupplier.class);
|
|
|
|
|
|
projectSupplierList.add(projectSupplier);
|
|
|
|
|
|
}
|
|
|
|
|
|
projectSupplierService.saveOrUpdateBatch(projectSupplierList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getContract() {
|
2024-09-12 18:01:53 +08:00
|
|
|
|
String url = "/api/cube/restful/interface/getModeDataPageList/CGHTTZ";
|
2024-09-18 18:28:12 +08:00
|
|
|
|
String systemid = "CGHTTZ";
|
|
|
|
|
|
String d_password = "D377DAB261E34627B74ECF14EF093D08";
|
2024-09-07 18:48:41 +08:00
|
|
|
|
JSONObject mainTable = new JSONObject();
|
|
|
|
|
|
String result = doAction(url, systemid, d_password, mainTable);
|
|
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
2024-10-22 20:23:35 +08:00
|
|
|
|
List<Project> projects = projectService.list();
|
2024-09-07 18:48:41 +08:00
|
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
|
|
|
|
JSONArray jsonArray = obj.getJSONArray("result");
|
|
|
|
|
|
List<CostContract> contractList = new ArrayList<>();
|
2024-09-18 18:28:12 +08:00
|
|
|
|
List<CostContractDetail> contractDetails = new ArrayList<>();
|
2024-09-07 18:48:41 +08:00
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
|
JSONObject projectObj = jsonArray.getJSONObject(i).getJSONObject("mainTable");
|
|
|
|
|
|
CostContract costContract = JSONObject.parseObject(JSON.toJSONString(projectObj), CostContract.class);
|
2024-09-18 18:28:12 +08:00
|
|
|
|
// JSONArray detailArray = jsonArray.getJSONObject(i).getJSONArray("detail1");
|
|
|
|
|
|
// StringBuilder gys = new StringBuilder();
|
|
|
|
|
|
// for (int j = 0; j < detailArray.size(); j++) {
|
|
|
|
|
|
// String gysbm = detailArray.getJSONObject(j).getString("gysbm");
|
|
|
|
|
|
// if (StringUtils.isNotBlank(gysbm)) {
|
|
|
|
|
|
// gys.append(gysbm);
|
|
|
|
|
|
// gys.append(",");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// System.out.println(detailArray);
|
|
|
|
|
|
// costContract.setGysbm(gys.toString());
|
2024-12-17 16:21:44 +08:00
|
|
|
|
JSONArray shareArray = jsonArray.getJSONObject(i).getJSONArray("detail5");
|
|
|
|
|
|
for (int j = 0; j < shareArray.size(); j++) {
|
|
|
|
|
|
CostContractDetail costContractDetail = new CostContractDetail();
|
|
|
|
|
|
costContractDetail.setContractId(costContract.getId());
|
|
|
|
|
|
String hygh = shareArray.getJSONObject(j).getString("hygh");
|
|
|
|
|
|
costContractDetail.setContractPlanId(StringUtils.isNotBlank(hygh) ? Long.valueOf(hygh) : null);
|
|
|
|
|
|
costContractDetail.setAmount(shareArray.getJSONObject(j).getString("htgjjehs"));
|
|
|
|
|
|
String kmlkd = shareArray.getJSONObject(j).getString("kmlkd");
|
|
|
|
|
|
costContractDetail.setSubjectId(StringUtils.isNotBlank(kmlkd) ? Long.valueOf(kmlkd) : null);
|
|
|
|
|
|
costContractDetail.setProjectId(Integer.valueOf(shareArray.getJSONObject(j).getString("xmid")));
|
|
|
|
|
|
List<Project> projectList = projects.stream().filter(p ->
|
|
|
|
|
|
p.getProjectId().toString().equals(costContractDetail.getProjectId().toString())).collect(Collectors.toList());
|
|
|
|
|
|
costContractDetail.setProjectSn(projectList.size() > 0 ? projectList.get(0).getProjectSn() : "");
|
|
|
|
|
|
contractDetails.add(costContractDetail);
|
|
|
|
|
|
}
|
2024-09-07 18:48:41 +08:00
|
|
|
|
contractList.add(costContract);
|
|
|
|
|
|
}
|
|
|
|
|
|
costContractService.saveOrUpdateBatch(contractList);
|
2024-12-17 16:21:44 +08:00
|
|
|
|
costContractDetailService.remove(null);
|
|
|
|
|
|
costContractDetailService.saveBatch(contractDetails);
|
2024-09-07 18:48:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getContractPay() {
|
2024-10-22 20:23:35 +08:00
|
|
|
|
String url = "/api/cube/restful/interface/getModeDataPageList/FKTZ";
|
|
|
|
|
|
String systemid = "FKTZ";
|
|
|
|
|
|
String d_password = "A59348E9E6C840918623EE23DEFE74B4";
|
2024-09-07 18:48:41 +08:00
|
|
|
|
JSONObject mainTable = new JSONObject();
|
|
|
|
|
|
String result = doAction(url, systemid, d_password, mainTable);
|
|
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
|
|
|
|
JSONArray jsonArray = obj.getJSONArray("result");
|
|
|
|
|
|
List<CostContractPay> contractPayList = new ArrayList<>();
|
2024-12-17 16:21:44 +08:00
|
|
|
|
List<Project> projects = projectService.list();
|
2024-09-07 18:48:41 +08:00
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
|
JSONObject projectObj = jsonArray.getJSONObject(i).getJSONObject("mainTable");
|
|
|
|
|
|
CostContractPay costContractPay = JSONObject.parseObject(JSON.toJSONString(projectObj), CostContractPay.class);
|
2024-12-05 16:25:57 +08:00
|
|
|
|
JSONArray detailArray = jsonArray.getJSONObject(i).getJSONArray("detail6");
|
|
|
|
|
|
BigDecimal jshjTotal = new BigDecimal(0);
|
|
|
|
|
|
for (Object o : detailArray) {
|
|
|
|
|
|
JSONObject detail6Obj = JSONObject.parseObject(JSON.toJSONString(o));
|
|
|
|
|
|
String jshj = detail6Obj.getString("jshj");
|
|
|
|
|
|
if (StringUtils.isNotBlank(jshj)) {
|
2024-12-05 17:29:26 +08:00
|
|
|
|
jshjTotal = jshjTotal.add(new BigDecimal(jshj));
|
2024-12-05 16:25:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
costContractPay.setJshj(jshjTotal.toString());
|
2024-12-17 16:21:44 +08:00
|
|
|
|
List<Project> projectList = projects.stream().filter(p ->
|
|
|
|
|
|
p.getProjectId().toString().equals(costContractPay.getSxm())).collect(Collectors.toList());
|
|
|
|
|
|
costContractPay.setProjectSn(projectList.size() > 0 ? projectList.get(0).getProjectSn() : "");
|
2024-09-07 18:48:41 +08:00
|
|
|
|
contractPayList.add(costContractPay);
|
|
|
|
|
|
}
|
|
|
|
|
|
costContractPayService.saveOrUpdateBatch(contractPayList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-22 20:23:35 +08:00
|
|
|
|
public void getPayPlan() {
|
|
|
|
|
|
String url = "/api/cube/restful/interface/getModeDataPageList/FKJH";
|
|
|
|
|
|
String systemid = "FKJH";
|
|
|
|
|
|
String d_password = "B5FF1C9D6FF64401852987834FDAA635";
|
|
|
|
|
|
JSONObject mainTable = new JSONObject();
|
|
|
|
|
|
String result = doAction(url, systemid, d_password, mainTable);
|
|
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
|
|
|
|
JSONArray jsonArray = obj.getJSONArray("result");
|
|
|
|
|
|
List<CostPayPlan> payPlanList = new ArrayList<>();
|
2024-12-17 16:21:44 +08:00
|
|
|
|
List<Project> projects = projectService.list();
|
2024-10-22 20:23:35 +08:00
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
|
JSONObject projectObj = jsonArray.getJSONObject(i).getJSONObject("mainTable");
|
|
|
|
|
|
CostPayPlan costPayPlan = JSONObject.parseObject(JSON.toJSONString(projectObj), CostPayPlan.class);
|
2024-12-17 16:21:44 +08:00
|
|
|
|
List<Project> projectList = projects.stream().filter(p ->
|
|
|
|
|
|
p.getProjectId().toString().equals(costPayPlan.getSxm())).collect(Collectors.toList());
|
|
|
|
|
|
costPayPlan.setProjectSn(projectList.size() > 0 ? projectList.get(0).getProjectSn() : "");
|
2024-10-22 20:23:35 +08:00
|
|
|
|
payPlanList.add(costPayPlan);
|
|
|
|
|
|
}
|
|
|
|
|
|
costPayPlanService.saveOrUpdateBatch(payPlanList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-07 18:48:41 +08:00
|
|
|
|
public List<PlanTargetDto> getProjectTarget() {
|
|
|
|
|
|
String url = "/api/cube/restful/interface/getModeDataPageList/MBGL";
|
|
|
|
|
|
String systemid = "MBGL";
|
|
|
|
|
|
String d_password = "EC54DFE0A5F34B5DB18E2B7D8C9252F7";
|
|
|
|
|
|
JSONObject mainTable = new JSONObject();
|
|
|
|
|
|
String result = doAction(url, systemid, d_password, mainTable);
|
|
|
|
|
|
List<PlanTargetDto> planTargetDtoList = new ArrayList<>();
|
|
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
|
|
|
|
JSONArray jsonArray = obj.getJSONArray("result");
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
|
JSONObject projectObj = jsonArray.getJSONObject(i).getJSONObject("mainTable");
|
|
|
|
|
|
PlanTargetDto planTargetDto = JSONObject.parseObject(JSON.toJSONString(projectObj), PlanTargetDto.class);
|
|
|
|
|
|
planTargetDtoList.add(planTargetDto);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return planTargetDtoList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-11 21:50:50 +08:00
|
|
|
|
public List<PlanTargetDto> sendPlan(List<ProgressPanoramaNodePlanDto> progressPanoramaNodePlan) {
|
|
|
|
|
|
String url = "/api/cube/restful/interface/saveOrUpdateModeData/JHTS";
|
|
|
|
|
|
String systemid = "jhrwts";
|
|
|
|
|
|
String d_password = "FD8363502986471684F8443F0BE8A502";
|
|
|
|
|
|
JSONArray mainTable = convert(progressPanoramaNodePlan);
|
|
|
|
|
|
String result = doAction1(url, systemid, d_password, mainTable);
|
2024-09-11 11:33:24 +08:00
|
|
|
|
List<PlanTargetDto> planTargetDtoList = new ArrayList<>();
|
|
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
|
|
|
|
System.out.println("推送任务结果======" + obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
return planTargetDtoList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-11 21:50:50 +08:00
|
|
|
|
public void delPlan(List<String> ids) {
|
|
|
|
|
|
String url = "/api/cube/restful/interface/deleteModeDataByPK/JHSC";
|
|
|
|
|
|
String systemid = "JHSC";
|
|
|
|
|
|
String d_password = "A58B63C23E684FA0A6120895156AF87E";
|
|
|
|
|
|
JSONArray mainTable = convert1(ids);
|
|
|
|
|
|
for (int i = 0; i < mainTable.size(); i++) {
|
|
|
|
|
|
String result = doAction(url, systemid, d_password, mainTable.getJSONObject(i));
|
|
|
|
|
|
System.out.println("删除任务结果======" + result);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private JSONArray convert(List<ProgressPanoramaNodePlanDto> progressPanoramaNodePlans) {
|
|
|
|
|
|
JSONArray array = new JSONArray();
|
2024-09-12 18:01:53 +08:00
|
|
|
|
List<Company> list = companyService.list(Wrappers.<Company>lambdaQuery());
|
2024-09-11 21:50:50 +08:00
|
|
|
|
for (ProgressPanoramaNodePlanDto progressPanoramaNodePlan : progressPanoramaNodePlans) {
|
|
|
|
|
|
JSONObject main = new JSONObject();
|
|
|
|
|
|
main.put("rwid", progressPanoramaNodePlan.getId());
|
|
|
|
|
|
main.put("rwlx", progressPanoramaNodePlan.getLevelName().equals("主项任务") ? 0 : 1);
|
|
|
|
|
|
main.put("rwlb", progressPanoramaNodePlan.getType());
|
|
|
|
|
|
main.put("sfwgjjd", progressPanoramaNodePlan.getKeyNode() ? 1 : 0);
|
|
|
|
|
|
main.put("sfwlcb", progressPanoramaNodePlan.getMilepostNode() ? 1 : 0);
|
|
|
|
|
|
main.put("jhksrq", progressPanoramaNodePlan.getPlanStartDate());
|
|
|
|
|
|
main.put("jhjsrq", progressPanoramaNodePlan.getPlanFinishDate());
|
|
|
|
|
|
main.put("zzr", progressPanoramaNodePlan.getChargerId());
|
|
|
|
|
|
main.put("zzbm", progressPanoramaNodePlan.getChargerDeptId());
|
|
|
|
|
|
main.put("lcb", progressPanoramaNodePlan.getMilepostName());
|
|
|
|
|
|
main.put("jdxcg", progressPanoramaNodePlan.getResultName());
|
|
|
|
|
|
main.put("bh", progressPanoramaNodePlan.getNodeCode());
|
|
|
|
|
|
main.put("gq", progressPanoramaNodePlan.getDuration());
|
|
|
|
|
|
main.put("xzr", progressPanoramaNodePlan.getAssistId());
|
|
|
|
|
|
main.put("ndjhmc", progressPanoramaNodePlan.getNodeName());
|
|
|
|
|
|
main.put("sfjdxcg", progressPanoramaNodePlan.getResultNode() ? 1 : 0);
|
|
|
|
|
|
main.put("ndjhlx ", 1);
|
|
|
|
|
|
main.put("zt", progressPanoramaNodePlan.getApprovalStatue());
|
|
|
|
|
|
main.put("xmid", progressPanoramaNodePlan.getProjectId());
|
2024-09-12 18:01:53 +08:00
|
|
|
|
List<Company> companyList = list.stream().filter(l -> l.getCompanyType() == 4 && l.getCompanySn().equals(progressPanoramaNodePlan.getChargerDeptId())).collect(Collectors.toList());
|
|
|
|
|
|
if (companyList.size() > 0) {
|
|
|
|
|
|
List<Company> companyStream = list.stream().filter(l -> l.getCompanyId().toString().equals(companyList.get(0).getParentId().toString())).collect(Collectors.toList());
|
|
|
|
|
|
main.put("zzdw", companyStream.get(0).getCompanySn());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-05 17:29:26 +08:00
|
|
|
|
if (StringUtils.isNotBlank(progressPanoramaNodePlan.getPlanStartDate())) {
|
|
|
|
|
|
main.put("nd", DateUtil.year(DateUtil.parseDate(progressPanoramaNodePlan.getPlanStartDate())));
|
|
|
|
|
|
}
|
2024-09-11 21:50:50 +08:00
|
|
|
|
// main.put("rwid", "123");
|
|
|
|
|
|
// main.put("rwlx", "");
|
|
|
|
|
|
// main.put("rwlb", "");
|
|
|
|
|
|
// main.put("sfwgjjd", "");
|
|
|
|
|
|
// main.put("sfwlcb", "");
|
|
|
|
|
|
// main.put("jhksrq", "");
|
|
|
|
|
|
// main.put("jhjsrq", "");
|
|
|
|
|
|
// main.put("zzr", "");
|
|
|
|
|
|
// main.put("zzbm", "");
|
|
|
|
|
|
// main.put("lcb", "");
|
|
|
|
|
|
// main.put("jdxcg", "");
|
|
|
|
|
|
// main.put("bh", "");
|
|
|
|
|
|
// main.put("gq", "");
|
|
|
|
|
|
// main.put("xzr", "");
|
|
|
|
|
|
// main.put("ndjhmc", "");
|
|
|
|
|
|
array.add(main);
|
|
|
|
|
|
}
|
|
|
|
|
|
return array;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private JSONArray convert1(List<String> ids) {
|
|
|
|
|
|
JSONArray array = new JSONArray();
|
|
|
|
|
|
for (String id : ids) {
|
|
|
|
|
|
JSONObject main = new JSONObject();
|
|
|
|
|
|
main.put("rwid", id);
|
|
|
|
|
|
array.add(main);
|
|
|
|
|
|
}
|
|
|
|
|
|
return array;
|
2024-09-11 11:33:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-07 18:48:41 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*restful接口调用案例
|
|
|
|
|
|
*以getModeDataPageList为例
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String doAction(String url, String systemid, String d_password, JSONObject mainTable){
|
|
|
|
|
|
|
|
|
|
|
|
CloseableHttpResponse response;// 响应类,
|
|
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
|
|
|
|
|
|
|
|
//restful接口url
|
|
|
|
|
|
HttpPost httpPost = new HttpPost(ADDRESS + url);
|
|
|
|
|
|
|
|
|
|
|
|
//当前日期
|
|
|
|
|
|
String currentDate = getCurrentDate();
|
|
|
|
|
|
//当前时间
|
|
|
|
|
|
String currentTime = getCurrentTime();
|
|
|
|
|
|
//获取时间戳
|
|
|
|
|
|
String currentTimeTamp = getTimestamp();
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
Map paramDatajson = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//header
|
|
|
|
|
|
Map header = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
//系统标识
|
|
|
|
|
|
// String systemid = "xmxx";
|
|
|
|
|
|
//密码
|
|
|
|
|
|
// String d_password = "E3BA750749804E65B0A93833635F8ED2";
|
|
|
|
|
|
//封装header里的参数
|
|
|
|
|
|
header.put("systemid",systemid);
|
|
|
|
|
|
header.put("currentDateTime",currentTimeTamp);
|
|
|
|
|
|
String md5Source = systemid+d_password+currentTimeTamp;
|
|
|
|
|
|
String md5OfStr = getMD5Str(md5Source).toLowerCase();
|
|
|
|
|
|
//Md5是:系统标识+密码+时间戳 并且md5加密的结果
|
|
|
|
|
|
header.put("Md5",md5OfStr);
|
|
|
|
|
|
paramDatajson.put("header",header);
|
|
|
|
|
|
|
|
|
|
|
|
//封装pageinfo
|
|
|
|
|
|
JSONObject pageInfo = new JSONObject();
|
|
|
|
|
|
pageInfo.put("pageNo", 1);
|
|
|
|
|
|
pageInfo.put("pageSize", 1000);
|
|
|
|
|
|
paramDatajson.put("pageInfo",pageInfo);
|
|
|
|
|
|
|
|
|
|
|
|
//封装mainTable参数
|
|
|
|
|
|
// JSONObject mainTable = new JSONObject();
|
|
|
|
|
|
// mainTable.put("id", "1");
|
|
|
|
|
|
paramDatajson.put("mainTable",mainTable);
|
|
|
|
|
|
|
|
|
|
|
|
//封装operationinfo参数
|
|
|
|
|
|
JSONObject operationinfo = new JSONObject();
|
2024-09-11 21:50:50 +08:00
|
|
|
|
operationinfo.put("operator", "1");
|
2024-09-07 18:48:41 +08:00
|
|
|
|
paramDatajson.put("operationinfo",operationinfo);
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("===请求参数datajson==="+paramDatajson);
|
|
|
|
|
|
params.put("datajson",paramDatajson);
|
|
|
|
|
|
//装填参数
|
|
|
|
|
|
List nvps = new ArrayList();
|
|
|
|
|
|
if(params!=null){
|
|
|
|
|
|
for (Object entry : params.entrySet()) {
|
|
|
|
|
|
Map.Entry<String, Object> en = (Map.Entry) entry;
|
|
|
|
|
|
nvps.add(new BasicNameValuePair(en.getKey(), JSONObject.toJSONString(en.getValue())));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
try{
|
|
|
|
|
|
httpPost.addHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
|
|
|
|
|
|
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
|
|
|
|
|
|
response = httpClient.execute(httpPost);
|
|
|
|
|
|
if (response != null && response.getEntity() != null) {
|
|
|
|
|
|
//返回信息
|
|
|
|
|
|
String resulString = EntityUtils.toString(response.getEntity());
|
|
|
|
|
|
|
|
|
|
|
|
//todo这里处理返回信息
|
2024-09-11 21:50:50 +08:00
|
|
|
|
|
|
|
|
|
|
System.out.println("成功"+ resulString);
|
|
|
|
|
|
return resulString;
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
System.out.println("获取数据失败,请查看日志"+currentDate+" "+currentTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
System.out.println("请求失败"+currentDate+" "+currentTime+"====errormsg:"+e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String doAction1(String url, String systemid, String d_password, JSONArray mainTable){
|
|
|
|
|
|
|
|
|
|
|
|
CloseableHttpResponse response;// 响应类,
|
|
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
|
|
|
|
|
|
|
|
//restful接口url
|
|
|
|
|
|
HttpPost httpPost = new HttpPost(ADDRESS + url);
|
|
|
|
|
|
|
|
|
|
|
|
//当前日期
|
|
|
|
|
|
String currentDate = getCurrentDate();
|
|
|
|
|
|
//当前时间
|
|
|
|
|
|
String currentTime = getCurrentTime();
|
|
|
|
|
|
//获取时间戳
|
|
|
|
|
|
String currentTimeTamp = getTimestamp();
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
Map paramDatajson = new HashMap<>();
|
|
|
|
|
|
JSONObject dataobj = new JSONObject();
|
|
|
|
|
|
JSONArray data = new JSONArray();
|
|
|
|
|
|
|
|
|
|
|
|
//header
|
|
|
|
|
|
Map header = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
//系统标识
|
|
|
|
|
|
// String systemid = "xmxx";
|
|
|
|
|
|
//密码
|
|
|
|
|
|
// String d_password = "E3BA750749804E65B0A93833635F8ED2";
|
|
|
|
|
|
//封装header里的参数
|
|
|
|
|
|
header.put("systemid",systemid);
|
|
|
|
|
|
header.put("currentDateTime",currentTimeTamp);
|
|
|
|
|
|
String md5Source = systemid+d_password+currentTimeTamp;
|
|
|
|
|
|
String md5OfStr = getMD5Str(md5Source).toLowerCase();
|
|
|
|
|
|
//Md5是:系统标识+密码+时间戳 并且md5加密的结果
|
|
|
|
|
|
header.put("Md5",md5OfStr);
|
|
|
|
|
|
dataobj.put("header",header);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//封装operationinfo参数
|
|
|
|
|
|
JSONObject operationinfo = new JSONObject();
|
|
|
|
|
|
operationinfo.put("operator", "1");
|
|
|
|
|
|
for (int i = 0; i < mainTable.size(); i++) {
|
|
|
|
|
|
Map paramDatajson1 = new HashMap<>();
|
|
|
|
|
|
paramDatajson1.put("operationinfo",operationinfo);
|
|
|
|
|
|
paramDatajson1.put("mainTable",mainTable.getJSONObject(i));
|
|
|
|
|
|
data.add(paramDatajson1);
|
|
|
|
|
|
}
|
|
|
|
|
|
System.out.println("===请求参数datajson==="+paramDatajson);
|
|
|
|
|
|
dataobj.put("data", data);
|
|
|
|
|
|
params.put("datajson",dataobj);
|
|
|
|
|
|
//装填参数
|
|
|
|
|
|
List nvps = new ArrayList();
|
|
|
|
|
|
if(params!=null){
|
|
|
|
|
|
for (Object entry : params.entrySet()) {
|
|
|
|
|
|
Map.Entry<String, Object> en = (Map.Entry) entry;
|
|
|
|
|
|
nvps.add(new BasicNameValuePair(en.getKey(), JSONObject.toJSONString(en.getValue())));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
try{
|
|
|
|
|
|
httpPost.addHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
|
|
|
|
|
|
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
|
|
|
|
|
|
response = httpClient.execute(httpPost);
|
|
|
|
|
|
if (response != null && response.getEntity() != null) {
|
|
|
|
|
|
//返回信息
|
|
|
|
|
|
String resulString = EntityUtils.toString(response.getEntity());
|
|
|
|
|
|
|
|
|
|
|
|
//todo这里处理返回信息
|
2024-09-07 18:48:41 +08:00
|
|
|
|
|
|
|
|
|
|
System.out.println("成功"+ resulString);
|
|
|
|
|
|
return resulString;
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
System.out.println("获取数据失败,请查看日志"+currentDate+" "+currentTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
System.out.println("请求失败"+currentDate+" "+currentTime+"====errormsg:"+e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getMD5Str(String plainText){
|
|
|
|
|
|
//定义一个字节数组
|
|
|
|
|
|
byte[] secretBytes = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 生成一个MD5加密计算摘要
|
|
|
|
|
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
|
|
|
//对字符串进行加密
|
|
|
|
|
|
md.update(plainText.getBytes());
|
|
|
|
|
|
//获得加密后的数据
|
|
|
|
|
|
secretBytes = md.digest();
|
|
|
|
|
|
} catch (NoSuchAlgorithmException e) {
|
|
|
|
|
|
throw new RuntimeException("没有md5这个算法!");
|
|
|
|
|
|
}
|
|
|
|
|
|
//将加密后的数据转换为16进制数字
|
|
|
|
|
|
String md5code = new BigInteger(1, secretBytes).toString(16);
|
|
|
|
|
|
// 如果生成数字未满32位,需要前面补0
|
|
|
|
|
|
// 不能把变量放到循环条件,值改变之后会导致条件变化。如果生成30位 只能生成31位md5
|
|
|
|
|
|
int tempIndex = 32 - md5code.length();
|
|
|
|
|
|
for (int i = 0; i < tempIndex; i++) {
|
|
|
|
|
|
md5code = "0" + md5code;
|
|
|
|
|
|
}
|
|
|
|
|
|
return md5code;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String getCurrentTime() {
|
|
|
|
|
|
Date newdate = new Date();
|
|
|
|
|
|
long datetime = newdate.getTime();
|
|
|
|
|
|
Timestamp timestamp = new Timestamp(datetime);
|
|
|
|
|
|
String currenttime = (timestamp.toString()).substring(11, 13) + ":" + (timestamp.toString()).substring(14, 16) + ":"
|
|
|
|
|
|
+ (timestamp.toString()).substring(17, 19);
|
|
|
|
|
|
return currenttime;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String getCurrentDate() {
|
|
|
|
|
|
Date newdate = new Date();
|
|
|
|
|
|
long datetime = newdate.getTime();
|
|
|
|
|
|
Timestamp timestamp = new Timestamp(datetime);
|
|
|
|
|
|
String currentdate = (timestamp.toString()).substring(0, 4) + "-" + (timestamp.toString()).substring(5, 7) + "-"
|
|
|
|
|
|
+ (timestamp.toString()).substring(8, 10);
|
|
|
|
|
|
return currentdate;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取当前日期时间。 YYYY-MM-DD HH:MM:SS
|
|
|
|
|
|
* @return 当前日期时间
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String getCurDateTime() {
|
|
|
|
|
|
Date newdate = new Date();
|
|
|
|
|
|
long datetime = newdate.getTime();
|
|
|
|
|
|
Timestamp timestamp = new Timestamp(datetime);
|
|
|
|
|
|
return (timestamp.toString()).substring(0, 19);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取时间戳 格式如:19990101235959
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String getTimestamp(){
|
|
|
|
|
|
return getCurDateTime().replace("-", "").replace(":", "").replace(" ", "");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int getIntValue(String v, int def) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
return Integer.parseInt(v);
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
return def;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String null2String(Object s) {
|
|
|
|
|
|
return s == null ? "" : s.toString();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|