# Conflicts:
#	sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml
This commit is contained in:
sxu 2024-09-04 09:21:40 +08:00
commit 868c9a5a8e
27 changed files with 555 additions and 41 deletions

View File

@ -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;
}

View File

@ -11,22 +11,42 @@ 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;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
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);
httpPost.addHeader("Content-Type", "application/json; charset=UTF-8");
httpPost.setEntity(new StringEntity(JSONBody,StandardCharsets.UTF_8));
CloseableHttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, StandardCharsets.UTF_8);
response.close();
httpClient.close();
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();

View File

@ -0,0 +1,135 @@
package com.bonus.sgzb.common.core.utils;
import javax.crypto.Cipher;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
/**
* @Author ma_sh
* @create 2024/5/25 16:07
*/
public class RsaUtil {
//签名算法名称
private static final String RSA_KEY_ALGORITHM = "RSA";
//RSA密钥长度,默认密钥长度是1024,密钥长度必须是64的倍数在512到65536位之间,不管是RSA还是RSA2长度推荐使用2048
private static final int KEY_SIZE = 2048;
/**
* 公钥加密(用于数据加密)
*
* @param data 加密前的字符串
* @param publicKeyStr base64编码后的公钥
* @return base64编码后的字符串
* @throws Exception
*/
public static String encryptByPublicKey(String data, String publicKeyStr) throws Exception {
//Java原生base64解码
byte[] pubKey = Base64.getDecoder().decode(publicKeyStr);
//创建X509编码密钥规范
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(pubKey);
//返回转换指定算法的KeyFactory对象
KeyFactory keyFactory = KeyFactory.getInstance(RSA_KEY_ALGORITHM);
//根据X509编码密钥规范产生公钥对象
PublicKey publicKey = keyFactory.generatePublic(x509KeySpec);
//根据转换的名称获取密码对象Cipher转换的名称算法/工作模式/填充模式
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
//用公钥初始化此Cipher对象加密模式
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
//对数据加密
byte[] encrypt = cipher.doFinal(data.getBytes());
//返回base64编码后的字符串
return Base64.getEncoder().encodeToString(encrypt);
}
/**
* 私钥解密(用于数据解密)
*
* @param data 解密前的字符串
* @param privateKeyStr 私钥
* @return 解密后的字符串
* @throws Exception
*/
public static String decryptByPrivateKey(String data, String privateKeyStr) throws Exception {
//Java原生base64解码
byte[] priKey = Base64.getDecoder().decode(privateKeyStr);
//创建PKCS8编码密钥规范
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(priKey);
//返回转换指定算法的KeyFactory对象
KeyFactory keyFactory = KeyFactory.getInstance(RSA_KEY_ALGORITHM);
//根据PKCS8编码密钥规范产生私钥对象
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
//根据转换的名称获取密码对象Cipher转换的名称算法/工作模式/填充模式
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
//用私钥初始化此Cipher对象解密模式
cipher.init(Cipher.DECRYPT_MODE, privateKey);
//对数据解密
byte[] decrypt = cipher.doFinal(Base64.getDecoder().decode(data));
//返回字符串
return new String(decrypt);
}
/**
* 私钥加密(用于数据签名)
*
* @param data 加密前的字符串
* @param privateKeyStr base64编码后的私钥
* @return base64编码后后的字符串
* @throws Exception
*/
public static String encryptByPrivateKey(String data, String privateKeyStr) throws Exception {
//Java原生base64解码
byte[] priKey = Base64.getDecoder().decode(privateKeyStr);
//创建PKCS8编码密钥规范
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(priKey);
//返回转换指定算法的KeyFactory对象
KeyFactory keyFactory = KeyFactory.getInstance(RSA_KEY_ALGORITHM);
//根据PKCS8编码密钥规范产生私钥对象
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
//根据转换的名称获取密码对象Cipher转换的名称算法/工作模式/填充模式
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
//用私钥初始化此Cipher对象加密模式
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
//对数据加密
byte[] encrypt = cipher.doFinal(data.getBytes());
//返回base64编码后的字符串
return Base64.getEncoder().encodeToString(encrypt);
}
/**
* 公钥解密(用于数据验签)
*
* @param data 解密前的字符串
* @param publicKeyStr base64编码后的公钥
* @return 解密后的字符串
* @throws Exception
*/
public static String decryptByPublicKey(String data, String publicKeyStr) throws Exception {
//Java原生base64解码
byte[] pubKey = Base64.getDecoder().decode(publicKeyStr);
//创建X509编码密钥规范
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(pubKey);
//返回转换指定算法的KeyFactory对象
KeyFactory keyFactory = KeyFactory.getInstance(RSA_KEY_ALGORITHM);
//根据X509编码密钥规范产生公钥对象
PublicKey publicKey = keyFactory.generatePublic(x509KeySpec);
//根据转换的名称获取密码对象Cipher转换的名称算法/工作模式/填充模式
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
//用公钥初始化此Cipher对象解密模式
cipher.init(Cipher.DECRYPT_MODE, publicKey);
//对数据解密
byte[] decrypt = cipher.doFinal(Base64.getDecoder().decode(data));
//返回字符串
return new String(decrypt);
}
}

View File

@ -34,6 +34,28 @@
<artifactId>sgzb-common-redis</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.6.16</version>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.43</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-configuration-processor</artifactId>-->
<!-- <version>3.1.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>fastjson</artifactId>-->
<!-- <version>2.0.25</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>
</project>

View File

@ -0,0 +1,49 @@
package com.bonus.sgzb.common.security.utils;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;
import com.alibaba.fastjson2.JSONObject;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class GetTokenByAppKey {
// public static void main(String[] args) {
// String appKey = "abc123";
// String aesKey = "abcdefghijklmnop";
// String token = getToken(appKey, aesKey);
// System.err.println(token);
// }
/**
* 获取Token
* @return Token
* appKeyaesKey联系智慧工程系统提供
*/
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()));
Iterator<String> iterator = signatureMap.keySet().iterator();
//Map 转成 JSONObject 字符串
JSONObject jsonObj = new JSONObject(signatureMap);
String jsonStr = jsonObj.toJSONString();
AES aes = new AES(Mode.ECB, Padding.PKCS5Padding, aesKey.getBytes());
byte[] aesByte = aes.encrypt(jsonStr.getBytes(StandardCharsets.UTF_8));
String token = byteToHex(aesByte);
return token;
}
public static String byteToHex(byte[] bytes) {
String strHex = "";
StringBuilder sb = new StringBuilder("");
for (int n = 0; n < bytes.length; n++) {
strHex = Integer.toHexString(bytes[n] & 0xFF);
sb.append((strHex.length() == 1) ? "0" + strHex : strHex); // 每个字节由两个字符表示位数不够高位补0
}
return sb.toString().trim();
}
}

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -190,7 +190,6 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
return AjaxResult.error("已领数量大于预领数量或该机具未在库");
}
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("出库失败");
}
return AjaxResult.success("出库成功");

View File

@ -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("${sgzb.intelligentUrl}")
private String intelligentUrl;
@Value("${sgzb.intelligentAppKey}")
private String intelligentAppKey;
@Value("${sgzb.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 {
}
}
}

View File

@ -125,7 +125,7 @@ public class BmProjectInfoController extends BaseController{
util.exportExcel(response, list, "往来单位");
}
@Log(title = "项目管理导入", businessType = BusinessType.IMPORT)
/* @Log(title = "项目管理导入", businessType = BusinessType.IMPORT)
@RequiresPermissions("system:user:import")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
@ -134,6 +134,5 @@ public class BmProjectInfoController extends BaseController{
List<BmProjectInfo> bmProjectInfoList = util.importExcel(file.getInputStream());
String message = bmProjectInfoService.importBmProjectInfo(bmProjectInfoList, updateSupport);
return success(message);
}
}*/
}

View File

@ -90,7 +90,7 @@ public class BmProjectLotController extends BaseController {
return bmProjectLotService.updateBmProjectLot(bmProjectLot);
}
@Log(title = "项目管理导入", businessType = BusinessType.IMPORT)
/* @Log(title = "项目管理导入", businessType = BusinessType.IMPORT)
@RequiresPermissions("system:user:import")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file) throws Exception
@ -99,6 +99,6 @@ public class BmProjectLotController extends BaseController {
List<BmProjectLotImport> bmProjectLotList = util.importExcel(file.getInputStream());
String message = bmProjectLotService.importBmProjectLot(bmProjectLotList);
return success(message);
}
}*/
}

View File

@ -162,7 +162,7 @@ public class BmUnitInfoController extends BaseController{
ExcelUtil<BmUnitInfo> util = new ExcelUtil<BmUnitInfo>(BmUnitInfo.class);
util.exportExcel(response, list, "往来单位");
}
@ApiOperation(value = "往来单位导入")
/* @ApiOperation(value = "往来单位导入")
@Log(title = "往来单位导入", businessType = BusinessType.IMPORT)
@RequiresPermissions("system:user:import")
@PostMapping("/importData")
@ -173,6 +173,6 @@ public class BmUnitInfoController extends BaseController{
Long userId = SecurityUtils.getLoginUser().getUserid();
String message = bmUnitInfoService.importUser(bmUnitInfoList, updateSupport, userId);
return success(message);
}
}*/
}

View File

@ -117,4 +117,14 @@ public class MaMachineController extends BaseController {
{
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);
}
}

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.base.service;
import com.bonus.sgzb.base.api.domain.MaMachine;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import java.util.List;
@ -22,4 +23,6 @@ public interface MaMachineService {
public MaMachine selectMaMachineByMaId(Long maId);
MaMachine getMachineByQrCode(MaMachine maMachine);
AjaxResult pushNotifications(List<MaMachine> maMachineList);
}

View File

@ -1,5 +1,7 @@
package com.bonus.sgzb.base.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.bonus.sgzb.base.api.domain.MaLabelBind;
import com.bonus.sgzb.base.api.domain.MaMachine;
import com.bonus.sgzb.base.api.domain.MaType;
@ -8,19 +10,26 @@ import com.bonus.sgzb.base.domain.MaPropSet;
import com.bonus.sgzb.base.domain.vo.IotRecordVo;
import com.bonus.sgzb.base.mapper.*;
import com.bonus.sgzb.base.service.MaMachineService;
import com.bonus.sgzb.common.core.constant.Constants;
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.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 javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
@Slf4j
public class MaMachineServiceImpl implements MaMachineService {
@Value("${sgzb.zlptUrl}")
private String zlptUrl;
@Resource
private MaMachineMapper maMachineMapper;
@ -171,4 +180,43 @@ public class MaMachineServiceImpl implements MaMachineService {
}
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", content);
String body = JSONObject.toJSONString(map);
String data = HttpHelper.sendHttpPost(zlptUrl, body);
log.info("dataString-=========:" + data);
//对返回的结果进行处理
// resultDataHandler(data);
} catch (Exception e) {
// throw new RuntimeException(e);
return AjaxResult.error("推送失败!");
}
return AjaxResult.success("请求成功!");
}
private void resultDataHandler(String data) throws Exception {
JSONObject object = JSONObject.parseObject(data);
System.err.println(data);
String code = object.getString("code");
if ("0".equals(code)) {
String dataResultString = object.getString("data");
// 数据解密
String dataArrayString = RsaUtil.decryptByPrivateKey(dataResultString, Constants.publicKey);
log.info("dataArrayString-=========:" + dataArrayString);
} else {
throw new Exception("推送失败!");
}
}
}

View File

@ -66,8 +66,8 @@ public class MaWholeSetController extends BaseController {
* @return
*/
@ApiOperation("查询整套抱杆明细")
@PostMapping("/selectListById")
public TableDataInfo selectListById(@ApiParam(value = "查询信息") @RequestBody MaWholeSetDto dto) {
@GetMapping("/selectListById")
public TableDataInfo selectListById(@ApiParam(value = "查询信息") MaWholeSetDto dto) {
log.info("查询整套抱杆明细:{}", dto);
startPage();
List<MaWholeVo> list = maWholeSetService.selectListById(dto);

View File

@ -1,10 +1,13 @@
package com.bonus.sgzb.material.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 整套抱杆最外层表单vo
* @Author ma_sh
@ -18,16 +21,42 @@ public class MaWholeVo {
/** 主键ID */
@ApiModelProperty(value = "主键ID")
private Integer id;
/** 主键ID */
@ApiModelProperty(value = "设备类型1主体设备 2配套设备")
private Integer ascriptionType;
/** 设备id */
@ApiModelProperty(value = "设备id")
private Integer deviceTypeId;
/** 设备id */
@ApiModelProperty(value = "设备数量")
private Integer deviceNum;
/** 机具名称 */
@ApiModelProperty(value = "机具名称")
private String typeName;
/** 机具名称 */
@ApiModelProperty(value = "配套设备类型")
private String deviceAscription;
/** 机具名称 */
@ApiModelProperty(value = "机具名称")
private String deviceType;
/** 规格型号 */
@ApiModelProperty(value = "规格型号")
private String typeModelName;
/** 配套名称 */
@ApiModelProperty(value = "配套名称")
private String wholeTypeName;
/** 创建人 */
@ApiModelProperty(value = "创建人")
private String nickName;
/** 创建日期 */
@ApiModelProperty(value = "创建日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 套装所需配件数量 */
@ApiModelProperty(value = "套装所需配件数量")
@ApiModelProperty(value = "套装所需配件种类数量")
private Integer totalNum;
}

View File

@ -36,9 +36,9 @@ public class ExceptionDict {
public static final String ERROR_OCCURRED_DURING_SCRAP_TASK_REVIEW_MSG = "报废任务审核失败!";
public static void main(String[] args) {
/* public static void main(String[] args) {
System.out.println(String.format(ExceptionDict.PARAM_IS_NULL_ERROR_MSG,"name"));
}
}*/
}

View File

@ -223,11 +223,8 @@ public class BackApplyServiceImpl implements BackApplyService {
roles = SecurityUtils.getLoginUser().getRoles();
userid = SecurityUtils.getLoginUser().getUserid();
companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
} catch (NullPointerException e) {
e.printStackTrace();
return AjaxResult.error("获取用户信息失败:{}", e);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("获取用户信息失败:{}", e);
}
int num = 0;
if (!StringUtils.isEmpty(bean.getIds())) {
@ -425,6 +422,7 @@ public class BackApplyServiceImpl implements BackApplyService {
/**
* 退料批量审核-审核(web)
*
* @param dto
* @return
*/
@ -437,11 +435,8 @@ public class BackApplyServiceImpl implements BackApplyService {
roles = SecurityUtils.getLoginUser().getRoles();
userid = SecurityUtils.getLoginUser().getUserid();
companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
} catch (NullPointerException e) {
e.printStackTrace();
return AjaxResult.error("获取用户信息失败:{}", e);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("获取用户信息失败:{}", e);
}
if (CollectionUtils.isNotEmpty(dto.getBackApplyList())) {
for (BackApplyListDto backApplyListDto : dto.getBackApplyList()) {

View File

@ -159,7 +159,6 @@ public class MaWholeSetServiceImpl implements MaWholeSetService {
throw new RuntimeException("配套名称已重复,请重新输入");
}*/
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
}
return AjaxResult.success("修改成功", res);

View File

@ -13,6 +13,7 @@ import com.bonus.sgzb.material.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -356,7 +357,7 @@ public class WorkSiteDirectManageImpl implements WorkSiteDirectManageService {
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return res;
}
@ -381,7 +382,7 @@ public class WorkSiteDirectManageImpl implements WorkSiteDirectManageService {
throw new RuntimeException("createBackApplyInfoAndDetails异常");
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return res;
@ -508,7 +509,7 @@ public class WorkSiteDirectManageImpl implements WorkSiteDirectManageService {
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return res;
@ -561,7 +562,7 @@ public class WorkSiteDirectManageImpl implements WorkSiteDirectManageService {
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return res;
}
@ -586,7 +587,7 @@ public class WorkSiteDirectManageImpl implements WorkSiteDirectManageService {
taskId = Integer.valueOf(task.getId());
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return taskId;
@ -599,7 +600,7 @@ public class WorkSiteDirectManageImpl implements WorkSiteDirectManageService {
DirectApplyInfo directApplyInfos = getDirectApplyInfoById(directApplyInfoDetails.getId());
directApplyInfos.setStatus("1");
directApplyInfos.setAuditor(SecurityUtils.getLoginUser().getUsername());
directApplyInfos.setAuditTime(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
directApplyInfos.setAuditTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
res = refuseDirectApplyInfo(directApplyInfos);
} else {
return res;

View File

@ -38,4 +38,8 @@ sgzb:
job:
settlementJobDay: 1
settlementJobCron: "0 0 1 1 * ?"
zlptUrl: http://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications
intelligentUrl: http://www.zhgkxt.com/api/clientapi/public/externalApi
intelligentAppKey: abc123
intelligentAesKey: abcdefghijklmnop

View File

@ -39,4 +39,8 @@ sgzb:
settlementJobDay: 1
settlementJobCron: "0 0 1 1 * ?"
zlptUrl: http://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications
intelligentUrl: http://www.zhgkxt.com/api/clientapi/public/externalApi
intelligentAppKey: abc123
intelligentAesKey: abcdefghijklmnop

View File

@ -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>

View File

@ -41,13 +41,13 @@
<insert id="insert">
<foreach item="item" index="index" collection="wholeList" separator=";">
insert into ma_whole_set (type_id,parent_id,part_num,whole_type_name,create_by,ascription_type,create_time,status,company_id)
values(#{item.typeId},#{item.parentId},#{item.totalNum},#{item.wholeTypeName},#{item.createBy},#{item.ascriptionType}, now(),1,#{item.companyId})
insert into ma_whole_set (type_id,parent_id,part_num,whole_type_name,create_by,ascription_type,create_time,status)
values(#{item.typeId},#{item.parentId},#{item.totalNum},#{item.wholeTypeName},#{item.createBy},#{item.ascriptionType}, now(),1)
</foreach>
</insert>
<delete id="deleteById" parameterType="java.lang.Integer">
<delete id="deleteById">
delete from ma_whole_set
where parent_id = #{id} and whole_type_name = #{wholeTypeName}
where parent_id = #{id}
</delete>
<select id="selectByParentId" resultType="java.lang.Integer">