智慧工程
This commit is contained in:
parent
1b76407711
commit
5d4c26e516
|
|
@ -0,0 +1,70 @@
|
|||
package com.bonus.sgzb.base.api.domain;
|
||||
|
||||
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value="com.bonus.sgzb.base.api.domain.MaMachineIntelligentVO")
|
||||
@Data
|
||||
public class MaMachineIntelligentVO extends BaseEntity {
|
||||
@ApiModelProperty(value = "数据有效标识 0:有效 1:无效")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "作废原因,数据作废时必填")
|
||||
private String delReason;
|
||||
|
||||
@ApiModelProperty(value = "备注信息")
|
||||
private String remarks;
|
||||
|
||||
@ApiModelProperty(value = "工器具编码")
|
||||
private String deviceCode;
|
||||
|
||||
@ApiModelProperty(value = "规格型号")
|
||||
private String specificationType;
|
||||
|
||||
@ApiModelProperty(value = "生产厂家")
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期")
|
||||
private Date factoryDate;
|
||||
|
||||
@ApiModelProperty(value = "检验证编号")
|
||||
private String inspectionCertificateNumber;
|
||||
|
||||
@ApiModelProperty(value = "检验单位")
|
||||
private String inspectorUnitName;
|
||||
|
||||
@ApiModelProperty(value = "所属单位")
|
||||
private String affiliatedUnitName;
|
||||
|
||||
@ApiModelProperty(value = "默认1:智慧工程系统 2:第三方数据")
|
||||
private Integer source;
|
||||
|
||||
@ApiModelProperty(value = "试验日期")
|
||||
private Date trialDate;
|
||||
|
||||
@ApiModelProperty(value = "有效截止日期")
|
||||
private Date validityDate;
|
||||
|
||||
@ApiModelProperty(value = "使用所属单位ID")
|
||||
private String belongUnitId;
|
||||
|
||||
@ApiModelProperty(value = "门类编码")
|
||||
private String categoryCode;
|
||||
|
||||
@ApiModelProperty(value = "分类编码")
|
||||
private String classifyCode;
|
||||
|
||||
@ApiModelProperty(value = "机具编码")
|
||||
private String machineryCode;
|
||||
|
||||
@ApiModelProperty(value = "操作方式 0:默认新增 1:修改以前推送的数据")
|
||||
private Integer operateType;
|
||||
|
||||
@ApiModelProperty(value = "存在图片时必填")
|
||||
private String multipartFiles;
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ 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;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
|
|
@ -22,7 +23,6 @@ import java.util.Map;
|
|||
public class HttpHelper {
|
||||
|
||||
public static String sendHttpPost(String url, String JSONBody) throws Exception {
|
||||
|
||||
System.out.println("JSONBody-=========:" + JSONBody);
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
|
|
@ -36,6 +36,25 @@ public class HttpHelper {
|
|||
return responseContent;
|
||||
}
|
||||
|
||||
public static String sendHttpPost(String url, Map<String,String> headerMap, String JSONBody) throws Exception {
|
||||
System.out.println("JSONBody-=========:" + JSONBody);
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
httpPost.addHeader("Content-Type", "application/json");
|
||||
if (!CollectionUtils.isEmpty(headerMap)) {
|
||||
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
|
||||
httpPost.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
public static String doPost(String urlString,String param) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
|
||||
public class GetTokenByAppKey {
|
||||
public static void main(String[] args) {
|
||||
String token = getToken();
|
||||
System.err.println(token);
|
||||
}
|
||||
// public static void main(String[] args) {
|
||||
// String appKey = "abc123";
|
||||
// String aesKey = "abcdefghijklmnop";
|
||||
// String token = getToken(appKey, aesKey);
|
||||
// System.err.println(token);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取Token
|
||||
* @return Token
|
||||
* appKey、aesKey联系智慧工程系统提供
|
||||
*/
|
||||
private static String getToken() {
|
||||
String appKey = "abc123";
|
||||
String aesKey = "abcdefghijklmnop";
|
||||
public static String getToken(String appKey, String aesKey) {
|
||||
Map<String, Object> signatureMap = new HashMap<String, Object>();
|
||||
signatureMap.put("appKey", appKey);
|
||||
signatureMap.put("timestamp", String.valueOf(System.currentTimeMillis()));
|
||||
|
|
|
|||
|
|
@ -604,5 +604,13 @@ public class TmTaskController extends BaseController {
|
|||
return getDataTable(leaseAuditList);
|
||||
}
|
||||
|
||||
@Log(title = "把设备推送到智慧工程", businessType = BusinessType.QUERY)
|
||||
@ApiOperation(value = "把设备推送到智慧工程")
|
||||
@PostMapping("/pushToIntelligentProject")
|
||||
public AjaxResult pushToIntelligentProject(@RequestBody List<TmTask> tmTasks)
|
||||
{
|
||||
logger.info("MaMachineController pushToIntelligentProject 装备推送入口====");
|
||||
return tmTaskService.pushToIntelligentProject(tmTasks);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,4 +272,10 @@ public class TmTask implements Serializable {
|
|||
private Integer souceByRefuse;
|
||||
private int souceBy;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期")
|
||||
private Date outFacTime;
|
||||
@ApiModelProperty(value = "出厂编号")
|
||||
private String outFacCode;
|
||||
@ApiModelProperty(value = "本次检验日期")
|
||||
private Date thisCheckTime;
|
||||
}
|
||||
|
|
@ -112,6 +112,8 @@ public interface TmTaskMapper {
|
|||
|
||||
List<TmTask> getLeaseOutListByUser(TmTask task);
|
||||
|
||||
List<TmTask> getLeaseOutDetails(TmTask task);
|
||||
|
||||
List<TmTask> getLeaseDetailByParentId(TmTask record);
|
||||
|
||||
List<TmTask> getMaTypeDetails(LeaseApplyDetails leaseApplyDetails);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.sgzb.app.service;
|
|||
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.TmTask;
|
||||
import com.bonus.sgzb.base.api.domain.MaMachine;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -110,4 +111,6 @@ public interface TmTaskService{
|
|||
* @return
|
||||
*/
|
||||
String selectTaskNumByMonths(@Param("date") Date nowDate, @Param("taskType") Integer taskType);
|
||||
|
||||
AjaxResult pushToIntelligentProject(List<TmTask> tmTasks);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.sgzb.app.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.TmTask;
|
||||
|
|
@ -8,19 +10,23 @@ import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
|||
import com.bonus.sgzb.app.mapper.LeaseApplyInfoMapper;
|
||||
import com.bonus.sgzb.app.mapper.TmTaskMapper;
|
||||
import com.bonus.sgzb.app.service.*;
|
||||
import com.bonus.sgzb.base.api.domain.BmFlowRecord;
|
||||
import com.bonus.sgzb.base.api.domain.BmFlowRelation;
|
||||
import com.bonus.sgzb.base.api.domain.MachinePart;
|
||||
import com.bonus.sgzb.base.api.domain.*;
|
||||
import com.bonus.sgzb.common.core.constant.Constants;
|
||||
import com.bonus.sgzb.common.core.domain.R;
|
||||
import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||
import com.bonus.sgzb.common.core.utils.HttpHelper;
|
||||
import com.bonus.sgzb.common.core.utils.RsaUtil;
|
||||
import com.bonus.sgzb.common.core.utils.StringUtils;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.common.security.utils.GetTokenByAppKey;
|
||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||
import com.bonus.sgzb.material.exception.ExceptionDict;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
|
@ -38,6 +44,15 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
public class TmTaskServiceImpl implements TmTaskService {
|
||||
|
||||
@Value("zgzb.intelligentUrl")
|
||||
private String intelligentUrl;
|
||||
|
||||
@Value("zgzb.intelligentAppKey")
|
||||
private String intelligentAppKey;
|
||||
|
||||
@Value("zgzb.intelligentAesKey")
|
||||
private String intelligentAesKey;
|
||||
|
||||
@Resource
|
||||
private TmTaskMapper tmTaskMapper;
|
||||
|
||||
|
|
@ -545,7 +560,6 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
return tmTaskMapper.selectTaskNumByMonths(nowDate, taskType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取领料申请列表
|
||||
*/
|
||||
|
|
@ -1349,4 +1363,87 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
public LeaseApplyInfo getListSomeol(LeaseApplyInfo info) {
|
||||
return tmTaskMapper.getListSomeol(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult pushToIntelligentProject(List<TmTask> tmTasks) {
|
||||
log.info("MaMachineServiceImpl pushNotifications 开始处理设备到智慧工程的推送逻辑==={}",tmTasks);
|
||||
List<MaMachineIntelligentVO> intelVOList = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(tmTasks)){
|
||||
throw new ServiceException(String.format(ExceptionDict.PARAM_IS_NULL_ERROR_MSG,"maMachineList"), ExceptionDict.PARAM_IS_NULL_ERROR);
|
||||
} else {
|
||||
makeIntelligentVOList(tmTasks, intelVOList);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(intelVOList)) {
|
||||
try {
|
||||
String content = JSONObject.toJSONString(intelVOList);
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
bodyMap.put("body", content);
|
||||
String body = JSONObject.toJSONString(bodyMap);
|
||||
Map<String, String> headerMap = new HashMap<>();
|
||||
headerMap.put("appKey", intelligentAppKey);
|
||||
String token = GetTokenByAppKey.getToken(intelligentAppKey, intelligentAesKey);
|
||||
headerMap.put("token", token);
|
||||
String data = HttpHelper.sendHttpPost(intelligentUrl+"/acceptExternalMechanical", headerMap, body);
|
||||
log.info("dataString-=========:" + data);
|
||||
resultDataHandler(data);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.success("请求成功!");
|
||||
}
|
||||
}
|
||||
return AjaxResult.success("请求成功!");
|
||||
}
|
||||
|
||||
private void makeIntelligentVOList(List<TmTask> tmTasks, List<MaMachineIntelligentVO> intelVOList) {
|
||||
for (TmTask task : tmTasks) {
|
||||
List<TmTask> subTasks = tmTaskMapper.getLeaseOutDetails(task);
|
||||
for (TmTask subTask : subTasks) {
|
||||
MaMachineIntelligentVO intelVO = new MaMachineIntelligentVO();
|
||||
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.setOperateType(1); //0:默认新增 1:修改以前推送的数据
|
||||
intelVO.setRemarks("");
|
||||
intelVO.setSource(2); //1:智慧工程系统 2:第三方数据
|
||||
intelVO.setStatus("15".equals(task.getMaStatus()) ? 0 : 1); //0:有效 1:无效
|
||||
intelVO.setSpecificationType("");
|
||||
intelVO.setValidityDate(new Date());
|
||||
//每个设备不同点的设置
|
||||
intelVO.setDeviceCode(subTask.getMaCode());
|
||||
intelVO.setFactoryDate(subTask.getOutFacTime());
|
||||
intelVO.setMachineryCode(subTask.getMaId());
|
||||
intelVO.setTrialDate(subTask.getThisCheckTime());
|
||||
//组成list
|
||||
intelVOList.add(intelVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -39,4 +39,6 @@ sgzb:
|
|||
settlementJobDay: 1
|
||||
settlementJobCron: "0 0 1 1 * ?"
|
||||
zlptUrl: http://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications
|
||||
|
||||
intelligentAppKey: abc123
|
||||
intelligentAesKey: abcdefghijklmnop
|
||||
intelligentUrl: http://www.zhgkxt.com/api/clientapi/public/externalApi
|
||||
|
|
|
|||
|
|
@ -39,4 +39,7 @@ sgzb:
|
|||
settlementJobDay: 1
|
||||
settlementJobCron: "0 0 1 1 * ?"
|
||||
zlptUrl: http://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications
|
||||
intelligentAppKey: abc123
|
||||
intelligentAesKey: abcdefghijklmnop
|
||||
intelligentUrl: http://www.zhgkxt.com/api/clientapi/public/externalApi
|
||||
|
||||
|
|
|
|||
|
|
@ -1174,4 +1174,15 @@
|
|||
AND task_type = #{taskType}
|
||||
ORDER BY create_time DESC LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="getLeaseOutDetails" resultType="com.bonus.sgzb.app.domain.TmTask">
|
||||
select mam.ma_id as maId,
|
||||
mam.ma_code as maCode,
|
||||
mam.out_fac_time as outFacTime,
|
||||
mam.out_fac_code as outFacCode,
|
||||
mam.this_check_time as thisCheckTime
|
||||
from lease_out_details lod
|
||||
left join ma_machine mam on mam.ma_id = lod.ma_id
|
||||
where parent_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue