仓储推送到租赁平台
This commit is contained in:
parent
9b4d6ab400
commit
3c54729c87
|
|
@ -6,12 +6,10 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import com.bonus.sgzb.auth.form.*;
|
import com.bonus.sgzb.auth.form.*;
|
||||||
import com.bonus.sgzb.auth.service.NwRegisterService;
|
import com.bonus.sgzb.auth.service.NwRegisterService;
|
||||||
import com.bonus.sgzb.auth.service.NwUserLoginService;
|
import com.bonus.sgzb.auth.service.NwUserLoginService;
|
||||||
import com.bonus.sgzb.auth.utils.RsaUtil;
|
|
||||||
import com.bonus.sgzb.common.core.constant.CacheConstants;
|
import com.bonus.sgzb.common.core.constant.CacheConstants;
|
||||||
import com.bonus.sgzb.common.core.constant.Constants;
|
|
||||||
import com.bonus.sgzb.common.core.exception.ServiceException;
|
import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||||
import com.bonus.sgzb.common.core.utils.GlobalConstants;
|
import com.bonus.sgzb.common.core.utils.GlobalConstants;
|
||||||
import com.bonus.sgzb.common.core.constant.Constants;
|
import com.bonus.sgzb.common.core.utils.RsaUtil;
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.common.redis.service.RedisService;
|
import com.bonus.sgzb.common.redis.service.RedisService;
|
||||||
import com.bonus.sgzb.system.api.RemoteUserService;
|
import com.bonus.sgzb.system.api.RemoteUserService;
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,10 @@
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.bonus.sgzb.common.core.exception;
|
||||||
|
|
||||||
|
public class ExceptionDict {
|
||||||
|
|
||||||
|
// 参数不合法
|
||||||
|
public static final Integer PARAM_VALUE_IS_ERROR = 50000;
|
||||||
|
public static final String PARAM_VALUE_IS_ERROR_MSG = "参数不合法";
|
||||||
|
|
||||||
|
// 参数为空异常提示code,msg
|
||||||
|
public static final Integer PARAM_IS_NULL_ERROR = 50001;
|
||||||
|
public static final String PARAM_IS_NULL_ERROR_MSG = "参数%s不能为空";
|
||||||
|
|
||||||
|
// 参数为空异常提示code,msg
|
||||||
|
public static final Integer NEW_AGREEMENT_SETTLEMENT_ERROR = 50002;
|
||||||
|
public static final String NEW_AGREEMENT_SETTLEMENT_ERROR_MSG = "新增协议结算记录失败";
|
||||||
|
|
||||||
|
public static final Integer SETTLEMENT_REVIEW_ERROR = 50003;
|
||||||
|
public static final String SETTLEMENT_REVIEW_ERROR_MSG = "结算审核失败";
|
||||||
|
|
||||||
|
public static final Integer NEW_SETTLEMENT_NUMBER_ERROR = 50004;
|
||||||
|
public static final String NEW_SETTLEMENT_NUMBER_ERROR_MSG = "新增结算单号失败";
|
||||||
|
|
||||||
|
public static final Integer TASK_ID_IS_EMPTY = 50005;
|
||||||
|
public static final String TASK_ID_IS_EMPTY_MSG = "任务taskId为空!!";
|
||||||
|
|
||||||
|
public static final Integer BINDING_USER_IS_EMPTY = 50006;
|
||||||
|
public static final String BINDING_USER_IS_EMPTY_MSG = "绑定用户为空!!";
|
||||||
|
|
||||||
|
public static final Integer TASK_IS_EMPTY = 50007;
|
||||||
|
public static final String TASK_IS_EMPTY_MSG = "获取预报废任务为空";
|
||||||
|
|
||||||
|
public static final Integer TASK_DETAILS_IS_EMPTY = 50008;
|
||||||
|
public static final String TASK_DETAILS_IS_EMPTY_MSG = "获取报废任务详细为空";
|
||||||
|
|
||||||
|
public static final Integer ERROR_OCCURRED_DURING_SCRAP_TASK_REVIEW = 50009;
|
||||||
|
public static final String ERROR_OCCURRED_DURING_SCRAP_TASK_REVIEW_MSG = "报废任务审核失败!";
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
System.out.println(String.format(ExceptionDict.PARAM_IS_NULL_ERROR_MSG,"name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.bonus.sgzb.common.core.utils;
|
||||||
|
|
||||||
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
|
public class HttpHelper {
|
||||||
|
|
||||||
|
public static String sendHttpPost(String url, String JSONBody) throws Exception {
|
||||||
|
|
||||||
|
System.err.println("JSONBody-=========:" + JSONBody);
|
||||||
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
HttpPost httpPost = new HttpPost(url);
|
||||||
|
httpPost.addHeader("Content-Type", "application/json");
|
||||||
|
httpPost.setEntity(new StringEntity(JSONBody));
|
||||||
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||||
|
HttpEntity entity = response.getEntity();
|
||||||
|
String responseContent = EntityUtils.toString(entity, "UTF-8");
|
||||||
|
response.close();
|
||||||
|
httpClient.close();
|
||||||
|
return responseContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.bonus.sgzb.auth.utils;
|
package com.bonus.sgzb.common.core.utils;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
|
|
@ -117,4 +117,16 @@ public class MaMachineController extends BaseController {
|
||||||
{
|
{
|
||||||
return success(maMachineService.selectMaMachineByMaId(maId));
|
return success(maMachineService.selectMaMachineByMaId(maId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把设备推送到租赁平台
|
||||||
|
*/
|
||||||
|
@Log(title = "把设备推送到租赁平台", businessType = BusinessType.QUERY)
|
||||||
|
@ApiOperation(value = "把设备推送到租赁平台")
|
||||||
|
@PostMapping("/pushNotifications")
|
||||||
|
public AjaxResult pushNotifications(@RequestBody List<MaMachine> maMachineList)
|
||||||
|
{
|
||||||
|
logger.info("MaMachineController pushNotifications 装备推送入口====");
|
||||||
|
return maMachineService.pushNotifications(maMachineList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bonus.sgzb.base.service;
|
package com.bonus.sgzb.base.service;
|
||||||
|
|
||||||
import com.bonus.sgzb.base.api.domain.MaMachine;
|
import com.bonus.sgzb.base.api.domain.MaMachine;
|
||||||
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -22,4 +23,6 @@ public interface MaMachineService {
|
||||||
public MaMachine selectMaMachineByMaId(Long maId);
|
public MaMachine selectMaMachineByMaId(Long maId);
|
||||||
|
|
||||||
MaMachine getMachineByQrCode(MaMachine maMachine);
|
MaMachine getMachineByQrCode(MaMachine maMachine);
|
||||||
|
|
||||||
|
AjaxResult pushNotifications(List<MaMachine> maMachineList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,37 @@
|
||||||
package com.bonus.sgzb.base.service.impl;
|
package com.bonus.sgzb.base.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
|
||||||
import com.bonus.sgzb.base.api.domain.MaMachine;
|
import com.bonus.sgzb.base.api.domain.MaMachine;
|
||||||
import com.bonus.sgzb.base.api.domain.MaType;
|
import com.bonus.sgzb.base.api.domain.MaType;
|
||||||
import com.bonus.sgzb.base.api.domain.MaLabelBind;
|
import com.bonus.sgzb.base.api.domain.MaLabelBind;
|
||||||
import com.bonus.sgzb.base.api.domain.SltAgreementApply;
|
import com.bonus.sgzb.base.api.domain.SltAgreementApply;
|
||||||
import com.bonus.sgzb.base.domain.BmProjectLot;
|
|
||||||
import com.bonus.sgzb.base.domain.MaPropSet;
|
import com.bonus.sgzb.base.domain.MaPropSet;
|
||||||
import com.bonus.sgzb.base.mapper.MaLabelBindMapper;
|
import com.bonus.sgzb.base.mapper.MaLabelBindMapper;
|
||||||
import com.bonus.sgzb.base.mapper.MaMachineMapper;
|
import com.bonus.sgzb.base.mapper.MaMachineMapper;
|
||||||
import com.bonus.sgzb.base.mapper.MaPropInfoMapper;
|
import com.bonus.sgzb.base.mapper.MaPropInfoMapper;
|
||||||
import com.bonus.sgzb.base.mapper.MaTypeMapper;
|
import com.bonus.sgzb.base.mapper.MaTypeMapper;
|
||||||
import com.bonus.sgzb.base.service.MaMachineService;
|
import com.bonus.sgzb.base.service.MaMachineService;
|
||||||
|
import com.bonus.sgzb.common.core.constant.Constants;
|
||||||
|
import com.bonus.sgzb.common.core.exception.ExceptionDict;
|
||||||
import com.bonus.sgzb.common.core.exception.ServiceException;
|
import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||||
|
import com.bonus.sgzb.common.core.utils.HttpHelper;
|
||||||
|
import com.bonus.sgzb.common.core.utils.RsaUtil;
|
||||||
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class MaMachineServiceImpl implements MaMachineService {
|
public class MaMachineServiceImpl implements MaMachineService {
|
||||||
|
|
||||||
|
|
@ -35,6 +47,8 @@ public class MaMachineServiceImpl implements MaMachineService {
|
||||||
@Resource
|
@Resource
|
||||||
private MaPropInfoMapper maPropInfoMapper;
|
private MaPropInfoMapper maPropInfoMapper;
|
||||||
|
|
||||||
|
@Value("${zlptUrl}")
|
||||||
|
private String zlptUrl;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MaMachine> getMaMachine(MaMachine maMachine) {
|
public List<MaMachine> getMaMachine(MaMachine maMachine) {
|
||||||
|
|
@ -152,4 +166,53 @@ public class MaMachineServiceImpl implements MaMachineService {
|
||||||
}
|
}
|
||||||
return ma;
|
return ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult pushNotifications(List<MaMachine> maMachineList) {
|
||||||
|
log.info("MaMachineServiceImpl pushNotifications 开始处理设备推送逻辑==={}",maMachineList);
|
||||||
|
if (maMachineList.isEmpty()){
|
||||||
|
throw new ServiceException(String.format(ExceptionDict.PARAM_IS_NULL_ERROR_MSG,"maMachineList"), ExceptionDict.PARAM_IS_NULL_ERROR);
|
||||||
|
}
|
||||||
|
//遍历推送,防止数据量过大
|
||||||
|
String content = JSONObject.toJSONString(maMachineList);
|
||||||
|
String encrypt;
|
||||||
|
try {
|
||||||
|
encrypt = RsaUtil.encryptByPublicKey(content, Constants.publicKey);
|
||||||
|
/* Map<String, String> map = new HashMap<String, String>();
|
||||||
|
map.put("body", encrypt);
|
||||||
|
String body = JSONObject.toJSONString(map);*/
|
||||||
|
String data = HttpHelper.sendHttpPost(zlptUrl, encrypt);
|
||||||
|
System.err.println("dataString-=========:" + data);
|
||||||
|
//对返回的结果进行处理
|
||||||
|
resultDataHandler(data);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
return AjaxResult.success("请求成功!");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resultDataHandler(String data) throws Exception {
|
||||||
|
JSONObject object = JSONObject.parseObject(data);
|
||||||
|
System.err.println(data);
|
||||||
|
String code = object.getString("code");
|
||||||
|
if ("200".equals(code)) {
|
||||||
|
String dataResultString = object.getString("data");
|
||||||
|
// 数据解密
|
||||||
|
String dataArrayString = RsaUtil.decryptByPrivateKey(dataResultString, Constants.publicKey);
|
||||||
|
log.info("dataArrayString-=========:" + dataArrayString);
|
||||||
|
JSONArray dataArray = JSONArray.parseArray(dataArrayString);
|
||||||
|
if (dataArray != null && dataArray.size() > 0) {
|
||||||
|
|
||||||
|
}else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,13 @@ import com.bonus.sgzb.common.core.enums.ReviewStatusEnum;
|
||||||
import com.bonus.sgzb.common.core.enums.ScrapSourceEnum;
|
import com.bonus.sgzb.common.core.enums.ScrapSourceEnum;
|
||||||
import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
|
import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
|
||||||
import com.bonus.sgzb.common.core.enums.TaskTypeEnum;
|
import com.bonus.sgzb.common.core.enums.TaskTypeEnum;
|
||||||
|
import com.bonus.sgzb.common.core.exception.ExceptionDict;
|
||||||
import com.bonus.sgzb.common.core.exception.ServiceException;
|
import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||||
import com.bonus.sgzb.common.core.utils.StringHelper;
|
import com.bonus.sgzb.common.core.utils.StringHelper;
|
||||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.sgzb.material.domain.*;
|
import com.bonus.sgzb.material.domain.*;
|
||||||
import com.bonus.sgzb.material.exception.ExceptionDict;
|
|
||||||
import com.bonus.sgzb.material.mapper.*;
|
import com.bonus.sgzb.material.mapper.*;
|
||||||
import com.bonus.sgzb.material.service.IScrapApplyDetailsService;
|
import com.bonus.sgzb.material.service.IScrapApplyDetailsService;
|
||||||
import com.bonus.sgzb.material.vo.ForecastWasteExcel;
|
import com.bonus.sgzb.material.vo.ForecastWasteExcel;
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,21 @@
|
||||||
package com.bonus.sgzb.material.service.impl;
|
package com.bonus.sgzb.material.service.impl;
|
||||||
|
|
||||||
import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
|
|
||||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.material.domain.AgreementInfo;
|
|
||||||
import com.bonus.sgzb.material.domain.BmNoticeInfo;
|
import com.bonus.sgzb.material.domain.BmNoticeInfo;
|
||||||
import com.bonus.sgzb.material.domain.TmTask;
|
|
||||||
import com.bonus.sgzb.material.domain.ToDoBean;
|
import com.bonus.sgzb.material.domain.ToDoBean;
|
||||||
|
|
||||||
import com.bonus.sgzb.material.exception.ExceptionDict;
|
import com.bonus.sgzb.material.exception.ExceptionDict;
|
||||||
import com.bonus.sgzb.material.mapper.AgreementInfoMapper;
|
|
||||||
import com.bonus.sgzb.material.mapper.PurchaseCheckDetailsMapper;
|
|
||||||
import com.bonus.sgzb.material.mapper.PurchaseCheckInfoMapper;
|
import com.bonus.sgzb.material.mapper.PurchaseCheckInfoMapper;
|
||||||
import com.bonus.sgzb.material.mapper.ToDoMapper;
|
import com.bonus.sgzb.material.mapper.ToDoMapper;
|
||||||
import com.bonus.sgzb.material.service.AgreementInfoService;
|
|
||||||
import com.bonus.sgzb.material.service.ToDoService;
|
import com.bonus.sgzb.material.service.ToDoService;
|
||||||
import com.bonus.sgzb.material.vo.GlobalContants;
|
|
||||||
import com.bonus.sgzb.material.vo.NoticeInfoVO;
|
import com.bonus.sgzb.material.vo.NoticeInfoVO;
|
||||||
import com.bonus.sgzb.system.api.RemoteUserService;
|
import com.bonus.sgzb.system.api.RemoteUserService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import com.bonus.sgzb.common.core.exception.ServiceException;
|
import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue