接收从租赁推送过来的装备

This commit is contained in:
15856 2024-10-08 09:27:49 +08:00
parent 7705e3245a
commit 7cbaa24e7b
2 changed files with 43 additions and 21 deletions

View File

@ -41,7 +41,7 @@ public class HttpHelper {
System.out.println("JSONBody-=========:" + JSONBody);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json; charset=UTF-8");
httpPost.addHeader("Content-Type", "multipart/form-data; charset=UTF-8");
if (!CollectionUtils.isEmpty(headerMap)) {
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.addHeader(entry.getKey(), entry.getValue());

View File

@ -1383,16 +1383,19 @@ public class TmTaskServiceImpl implements TmTaskService {
try {
String content = JSONObject.toJSONString(intelVOList);
Map<String, String> bodyMap = new HashMap<>();
bodyMap.put("body", content);
//如果以后文件就添加进去
bodyMap.put("files", "");
bodyMap.put("params", content);
String body = JSONObject.toJSONString(bodyMap);
Map<String, String> headerMap = new HashMap<>();
headerMap.put("appKey", intelligentAppKey);
String token = GetTokenByAppKey.getToken(intelligentAppKey, intelligentAesKey);
headerMap.put("appKey", /*intelligentAppKey*/"abc123");
String token = GetTokenByAppKey.getToken(/*intelligentAppKey*/"abc123", /*intelligentAesKey*/"abcdefghijklmnop");
headerMap.put("token", token);
String data = HttpHelper.sendHttpPost(intelligentUrl+"/acceptExternalMechanical", headerMap, body);
String data = HttpHelper.sendHttpPost(/*intelligentUrl+*/"https://sit.zhgkxt.com/api/clientapi/public/externalApi/acceptExternalMechanical", headerMap, body);
log.info("dataString-=========:" + data);
resultDataHandler(data);
} catch (Exception e) {
log.error("请求失败!{}", e);
return AjaxResult.error("请求失败!{}", e.getMessage());
}
log.info("推送成功!修改状态");
@ -1407,37 +1410,56 @@ public class TmTaskServiceImpl implements TmTaskService {
return AjaxResult.success("请求成功!");
}
public static void main(String[] args) {
List<TmTask> tmTasks = new ArrayList<>();
TmTask tmTask= new TmTask();
tmTask.setId("622");
tmTask.setCreateTime(new Date());
tmTask.setLeasePerson("李思思");
tmTask.setAgreementCode("XY20240830-0001");
tmTask.setManageType("0");
tmTask.setPartNum(5);
tmTask.setProName("核打击保密单位");
tmTasks.add(tmTask);
TmTaskServiceImpl tm = new TmTaskServiceImpl();
tm.pushToIntelligentProject( tmTasks);
}
private void makeIntelligentVOList(List<TmTask> tmTasks, List<MaMachineIntelligentVO> intelVOList) {
LoginUser loginUser = SecurityUtils.getLoginUser();
for (TmTask task : tmTasks) {
List<TmTask> subTasks = tmTaskMapper.getLeaseOutDetails(task);
for (TmTask subTask : subTasks) {
// List<TmTask> subTasks = tmTaskMapper.getLeaseOutDetails(task);
// for (TmTask subTask : subTasks) {
MaMachineIntelligentVO intelVO = new MaMachineIntelligentVO();
intelVO.setSocialCreditCode(loginUser.getSysUser().getDept().getSocialCreditCode());
intelVO.setSocialCreditCode(/*loginUser.getSysUser().getDept().getSocialCreditCode()*/"9134010039449847XC");
intelVO.setAffiliatedUnitName(task.getUnitName());
intelVO.setBelongUnitId(String.valueOf(task.getUnitId()));
intelVO.setCategoryCode(task.getTypeId());
intelVO.setClassifyCode(task.getTypeId());
intelVO.setDelReason("");
intelVO.setInspectorUnitName("");
intelVO.setInspectionCertificateNumber("");
intelVO.setManufacturer("");
intelVO.setMultipartFiles("");
intelVO.setDelReason("不是报废");
intelVO.setInspectorUnitName("123");
intelVO.setInspectionCertificateNumber("123");
intelVO.setManufacturer("123");
intelVO.setMultipartFiles("123");
intelVO.setOperateType(1); //0:默认新增 1:修改以前推送的数据
intelVO.setRemarks("");
intelVO.setRemarks("123");
intelVO.setSource(2); //1:智慧工程系统 2:第三方数据
intelVO.setStatus("15".equals(task.getMaStatus()) ? 0 : 1); //0:有效 1:无效
intelVO.setSpecificationType("");
intelVO.setSpecificationType("123");
intelVO.setValidityDate(new Date());
//每个设备不同点的设置
String ownerCode = loginUser.getSysUser().getDept().getEnterpriseOwnershipCode();
intelVO.setDeviceCode(StringUtils.getDeviceCode(ownerCode, subTask.getTypeName(), subTask.getTypeId(), subTask.getCreateTime(), subTask.getMaId()));
intelVO.setFactoryDate(subTask.getOutFacTime());
// String ownerCode = loginUser.getSysUser().getDept().getEnterpriseOwnershipCode();
//intelVO.setDeviceCode(StringUtils.getDeviceCode(ownerCode, subTask.getTypeName(), subTask.getTypeId(), subTask.getCreateTime(), subTask.getMaId()));
intelVO.setDeviceCode("CSG-A101-2024061950001");
/* intelVO.setFactoryDate(subTask.getOutFacTime());
intelVO.setMachineryCode(subTask.getMaId());
intelVO.setTrialDate(subTask.getThisCheckTime());
intelVO.setTrialDate(subTask.getThisCheckTime());*/
intelVO.setFactoryDate(new Date());
intelVO.setMachineryCode("123");
intelVO.setTrialDate(new Date());
//组成list
intelVOList.add(intelVO);
}
// }
}
}
@ -1445,7 +1467,7 @@ public class TmTaskServiceImpl implements TmTaskService {
JSONObject object = JSONObject.parseObject(data);
System.err.println(data);
String code = object.getString("code");
if ("200".equals(code)) {
if ("0".equals(code)) {
String dataResultString = object.getString("data");
// 数据解密
String dataArrayString = RsaUtil.decryptByPrivateKey(dataResultString, Constants.publicKey);