From b1748f1ae4100292642cf5b8f2a007e08e2a05ca Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Mon, 2 Sep 2024 16:40:55 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml index 2c378f0..4598ce0 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml @@ -38,4 +38,5 @@ sgzb: job: settlementJobDay: 1 settlementJobCron: "0 0 1 1 * ?" + zlptUrl: http://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications From dc5136bee4b71867af2ea23912405e614fe17a13 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Mon, 2 Sep 2024 16:49:36 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=8E=A8=E9=80=81=E8=A3=85=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/sgzb/common/core/utils/RsaUtil.java | 135 ++++++++++++++++++ .../base/controller/MaMachineController.java | 10 ++ .../sgzb/base/service/MaMachineService.java | 3 + .../service/impl/MaMachineServiceImpl.java | 66 ++++++++- .../main/resources/bootstrap-sgzb_nw_dev.yml | 1 + .../resources/bootstrap-sgzb_nw_local.yml | 1 + 6 files changed, 212 insertions(+), 4 deletions(-) create mode 100644 sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/RsaUtil.java diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/RsaUtil.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/RsaUtil.java new file mode 100644 index 0000000..3369a85 --- /dev/null +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/RsaUtil.java @@ -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); + } + +} + diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaMachineController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaMachineController.java index d43eae9..8665e7c 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaMachineController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaMachineController.java @@ -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 maMachineList) + { + logger.info("MaMachineController pushNotifications 装备推送入口===="); + return maMachineService.pushNotifications(maMachineList); + } + } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/MaMachineService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/MaMachineService.java index d48f15b..c8b9af3 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/MaMachineService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/MaMachineService.java @@ -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 maMachineList); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java index 9d718f2..770b74a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java @@ -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,53 @@ public class MaMachineServiceImpl implements MaMachineService { } return ma; } + + @Override + public AjaxResult pushNotifications(List 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 map = new HashMap(); + map.put("body", encrypt); + 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.success("请求成功!"); + } + 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 ("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 { + + } + + } } diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml index 6916ce5..80c5b27 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml @@ -38,4 +38,5 @@ sgzb: job: settlementJobDay: 1 settlementJobCron: "0 0 1 1 * ?" + zlptUrl: http://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml index d0474fe..91bbb66 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml @@ -38,4 +38,5 @@ sgzb: job: settlementJobDay: 1 settlementJobCron: "0 0 1 1 * ?" + zlptUrl: http://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications From 2a4a29826f7aa877f0bbba657977d1c7da05e078 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Mon, 2 Sep 2024 17:03:28 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/bootstrap-sgzb_nw_local.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml index 91bbb66..4598ce0 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml @@ -16,11 +16,11 @@ spring: discovery: # 服务注册地址 server-addr: 127.0.0.1:8848 - namespace: sgzb_cloud_dev_nw + namespace: sgzb_nwjj config: # 配置中心地址 server-addr: 127.0.0.1:8848 - namespace: sgzb_cloud_dev_nw + namespace: sgzb_nwjj # 配置文件格式 file-extension: yml # 共享配置 From 1b764077114451973c8c1ed3802e1adc7e915bf9 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 3 Sep 2024 09:15:46 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E6=99=BA=E6=85=A7=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgzb-common/sgzb-common-security/pom.xml | 22 +++++++++ .../security/utils/GetTokenByAppKey.java | 49 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 sgzb-common/sgzb-common-security/src/main/java/com/bonus/sgzb/common/security/utils/GetTokenByAppKey.java diff --git a/sgzb-common/sgzb-common-security/pom.xml b/sgzb-common/sgzb-common-security/pom.xml index e531c52..5e07dc3 100644 --- a/sgzb-common/sgzb-common-security/pom.xml +++ b/sgzb-common/sgzb-common-security/pom.xml @@ -34,6 +34,28 @@ sgzb-common-redis + + cn.hutool + hutool-all + 4.6.16 + + + com.alibaba.fastjson2 + fastjson2 + 2.0.43 + + + + + + + + + + + + + diff --git a/sgzb-common/sgzb-common-security/src/main/java/com/bonus/sgzb/common/security/utils/GetTokenByAppKey.java b/sgzb-common/sgzb-common-security/src/main/java/com/bonus/sgzb/common/security/utils/GetTokenByAppKey.java new file mode 100644 index 0000000..88117ce --- /dev/null +++ b/sgzb-common/sgzb-common-security/src/main/java/com/bonus/sgzb/common/security/utils/GetTokenByAppKey.java @@ -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 token = getToken(); + System.err.println(token); + } + + /** + * 获取Token + * @return Token + * appKey、aesKey联系智慧工程系统提供 + */ + private static String getToken() { + String appKey = "abc123"; + String aesKey = "abcdefghijklmnop"; + Map signatureMap = new HashMap(); + signatureMap.put("appKey", appKey); + signatureMap.put("timestamp", String.valueOf(System.currentTimeMillis())); + Iterator 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(); + } +} \ No newline at end of file From 5d4c26e516b5692ed23deefae10e295c796047d3 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 3 Sep 2024 16:47:09 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E6=99=BA=E6=85=A7=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/MaMachineIntelligentVO.java | 70 ++++++++++++ .../sgzb/common/core/utils/HttpHelper.java | 21 +++- .../security/utils/GetTokenByAppKey.java | 14 +-- .../sgzb/app/controller/TmTaskController.java | 8 ++ .../com/bonus/sgzb/app/domain/TmTask.java | 6 + .../bonus/sgzb/app/mapper/TmTaskMapper.java | 2 + .../bonus/sgzb/app/service/TmTaskService.java | 3 + .../app/service/impl/TmTaskServiceImpl.java | 107 +++++++++++++++++- .../main/resources/bootstrap-sgzb_nw_dev.yml | 4 +- .../resources/bootstrap-sgzb_nw_local.yml | 3 + .../resources/mapper/app/TmTaskMapper.xml | 11 ++ 11 files changed, 235 insertions(+), 14 deletions(-) create mode 100644 sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineIntelligentVO.java diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineIntelligentVO.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineIntelligentVO.java new file mode 100644 index 0000000..2969eeb --- /dev/null +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineIntelligentVO.java @@ -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; +} diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java index 33014a8..a1184bd 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java @@ -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 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 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; diff --git a/sgzb-common/sgzb-common-security/src/main/java/com/bonus/sgzb/common/security/utils/GetTokenByAppKey.java b/sgzb-common/sgzb-common-security/src/main/java/com/bonus/sgzb/common/security/utils/GetTokenByAppKey.java index 88117ce..e3aaaea 100644 --- a/sgzb-common/sgzb-common-security/src/main/java/com/bonus/sgzb/common/security/utils/GetTokenByAppKey.java +++ b/sgzb-common/sgzb-common-security/src/main/java/com/bonus/sgzb/common/security/utils/GetTokenByAppKey.java @@ -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 signatureMap = new HashMap(); signatureMap.put("appKey", appKey); signatureMap.put("timestamp", String.valueOf(System.currentTimeMillis())); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/controller/TmTaskController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/controller/TmTaskController.java index 3119667..927cf5e 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/controller/TmTaskController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/controller/TmTaskController.java @@ -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 tmTasks) + { + logger.info("MaMachineController pushToIntelligentProject 装备推送入口===="); + return tmTaskService.pushToIntelligentProject(tmTasks); + } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java index 1701377..8935b54 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java @@ -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; } \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java index 3876e50..68cc2ed 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java @@ -112,6 +112,8 @@ public interface TmTaskMapper { List getLeaseOutListByUser(TmTask task); + List getLeaseOutDetails(TmTask task); + List getLeaseDetailByParentId(TmTask record); List getMaTypeDetails(LeaseApplyDetails leaseApplyDetails); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/TmTaskService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/TmTaskService.java index 319400f..d8243cd 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/TmTaskService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/TmTaskService.java @@ -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 tmTasks); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java index a37eae3..4e9c283 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java @@ -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 tmTasks) { + log.info("MaMachineServiceImpl pushNotifications 开始处理设备到智慧工程的推送逻辑==={}",tmTasks); + List 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 bodyMap = new HashMap<>(); + bodyMap.put("body", content); + String body = JSONObject.toJSONString(bodyMap); + Map 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 tmTasks, List intelVOList) { + for (TmTask task : tmTasks) { + List 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 { + + } + + } } \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml index 80c5b27..5a3d167 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml @@ -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 diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml index 4598ce0..30f32bd 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml @@ -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 diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml index 8daffb9..44a6cb9 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml @@ -1174,4 +1174,15 @@ AND task_type = #{taskType} ORDER BY create_time DESC LIMIT 1 + + From 088fdd2ed19b6693a44563cf54f97fd5b6fa05f4 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 3 Sep 2024 18:00:27 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E6=99=BA=E6=85=A7=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java | 6 +++--- .../src/main/resources/bootstrap-sgzb_nw_dev.yml | 3 ++- .../src/main/resources/bootstrap-sgzb_nw_local.yml | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java index 4e9c283..c632b38 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java @@ -44,13 +44,13 @@ import java.util.stream.Collectors; @Slf4j public class TmTaskServiceImpl implements TmTaskService { - @Value("zgzb.intelligentUrl") + @Value("${sgzb.intelligentUrl}") private String intelligentUrl; - @Value("zgzb.intelligentAppKey") + @Value("${sgzb.intelligentAppKey}") private String intelligentAppKey; - @Value("zgzb.intelligentAesKey") + @Value("${sgzb.intelligentAesKey}") private String intelligentAesKey; @Resource diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml index 5a3d167..e8a73e2 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_dev.yml @@ -39,6 +39,7 @@ 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 - intelligentUrl: http://www.zhgkxt.com/api/clientapi/public/externalApi + diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml index 30f32bd..dc72f69 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_nw_local.yml @@ -39,7 +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 - intelligentUrl: http://www.zhgkxt.com/api/clientapi/public/externalApi + From 8e02043b066dfb9688cb13c1eb15264047efb7c9 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 3 Sep 2024 19:08:32 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E6=99=BA=E6=85=A7=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/MaMachineIntelligentVO.java | 5 ++- .../sgzb/common/core/utils/DateUtils.java | 5 +++ .../sgzb/common/core/utils/StringUtils.java | 33 ++++++++++++++++++- .../com/bonus/sgzb/app/domain/TmTask.java | 3 ++ .../app/service/impl/TmTaskServiceImpl.java | 2 +- .../resources/mapper/app/TmTaskMapper.xml | 3 +- 6 files changed, 47 insertions(+), 4 deletions(-) diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineIntelligentVO.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineIntelligentVO.java index 2969eeb..85436c9 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineIntelligentVO.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineIntelligentVO.java @@ -21,7 +21,7 @@ public class MaMachineIntelligentVO extends BaseEntity { private String remarks; @ApiModelProperty(value = "工器具编码") - private String deviceCode; + private String deviceCode; //like CSG-A101-2024061900001 @ApiModelProperty(value = "规格型号") private String specificationType; @@ -41,6 +41,9 @@ public class MaMachineIntelligentVO extends BaseEntity { @ApiModelProperty(value = "所属单位") private String affiliatedUnitName; + @ApiModelProperty(value = "企业机构代码(统一社会信用代码)") + private String socialCreditCode; //公司信息必填 + @ApiModelProperty(value = "默认1:智慧工程系统 2:第三方数据") private Integer source; diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateUtils.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateUtils.java index ae010c3..372b96b 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateUtils.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateUtils.java @@ -108,6 +108,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils return DateFormatUtils.format(now, "yyyyMMdd"); } + public static final String getDateTimeString(Date date) + { + return DateFormatUtils.format(date, "yyyyMMdd"); + } + /** * 日期型字符串转化为日期 格式 */ diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/StringUtils.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/StringUtils.java index e20515f..7491ffc 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/StringUtils.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/StringUtils.java @@ -1,11 +1,13 @@ package com.bonus.sgzb.common.core.utils; +import java.security.SecureRandom; import java.util.Collection; +import java.util.Date; import java.util.List; import java.util.Map; - import com.bonus.sgzb.common.core.constant.Constants; import com.bonus.sgzb.common.core.text.StrFormatter; +import lombok.extern.slf4j.Slf4j; import org.springframework.util.AntPathMatcher; /** @@ -13,6 +15,7 @@ import org.springframework.util.AntPathMatcher; * * @author ruoyi */ +@Slf4j public class StringUtils extends org.apache.commons.lang3.StringUtils { /** 空字符串 */ @@ -21,6 +24,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** 下划线 */ private static final char SEPARATOR = '_'; + private static SecureRandom random = null; + /** * 获取参数不为空值 * @@ -551,4 +556,30 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } return sb.toString(); } + +// public static String getDeviceCode() { +// String randomNum = null; +// try { +// random = SecureRandom.getInstance("SHA1PRNG"); +// randomNum = String.format("%02d", random.nextInt(100)); +// } catch (NoSuchAlgorithmException e) { +// log.error("生成随机数失败,", e); +// } +// String deviceCode = "CSG-A101-" + DateUtils.dateTime() + randomNum; //like CSG-A101-2024061900001, need save it +// return deviceCode; +// } + + public static String getDeviceCode(Date date, String maId) { + int number = Integer.parseInt(maId); + if (number > 50000) { + number = number % 50000; + } + String numberStr = String.format("%05d", number); + String deviceCode = "CSG-A101-" + DateUtils.getDateTimeString(date) + numberStr; //like CSG-A101-2024061900001 + return deviceCode; + } + +// public static void main(String[] args) { +// System.out.println(getDeviceCode(new Date(), "500322")); +// } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java index 8935b54..d53cadb 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java @@ -278,4 +278,7 @@ public class TmTask implements Serializable { private String outFacCode; @ApiModelProperty(value = "本次检验日期") private Date thisCheckTime; + @ApiModelProperty(value = "工器具编码") + private String deviceCode; //like CSG-A101-2024061900001 + } \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java index c632b38..a9b5db9 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java @@ -1414,7 +1414,7 @@ public class TmTaskServiceImpl implements TmTaskService { intelVO.setSpecificationType(""); intelVO.setValidityDate(new Date()); //每个设备不同点的设置 - intelVO.setDeviceCode(subTask.getMaCode()); + intelVO.setDeviceCode(StringUtils.getDeviceCode(subTask.getCreateTime(), subTask.getMaId())); intelVO.setFactoryDate(subTask.getOutFacTime()); intelVO.setMachineryCode(subTask.getMaId()); intelVO.setTrialDate(subTask.getThisCheckTime()); diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml index 44a6cb9..d2f4f0d 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml @@ -1180,7 +1180,8 @@ mam.ma_code as maCode, mam.out_fac_time as outFacTime, mam.out_fac_code as outFacCode, - mam.this_check_time as thisCheckTime + mam.this_check_time as thisCheckTime, + mam.create_time as createTime from lease_out_details lod left join ma_machine mam on mam.ma_id = lod.ma_id where parent_id = #{id} From 245306c2e1e8ffcb18a54945294b8e50ade01294 Mon Sep 17 00:00:00 2001 From: 15856 <15856818120@163.com> Date: Wed, 4 Sep 2024 09:20:41 +0800 Subject: [PATCH 08/13] =?UTF-8?q?http=E8=AF=B7=E6=B1=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/common/core/utils/HttpHelper.java | 7 +++--- .../service/impl/MaMachineServiceImpl.java | 22 +++++-------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java index a1184bd..d19db4c 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java @@ -17,6 +17,7 @@ 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; @@ -26,11 +27,11 @@ public class HttpHelper { System.out.println("JSONBody-=========:" + JSONBody); CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(url); - httpPost.addHeader("Content-Type", "application/json"); - httpPost.setEntity(new StringEntity(JSONBody)); + 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, "UTF-8"); + String responseContent = EntityUtils.toString(entity, StandardCharsets.UTF_8); response.close(); httpClient.close(); return responseContent; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java index 770b74a..66239ae 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java @@ -187,22 +187,21 @@ public class MaMachineServiceImpl implements MaMachineService { 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); + //encrypt = RsaUtil.encryptByPublicKey(content, Constants.publicKey); Map map = new HashMap(); - map.put("body", encrypt); + map.put("body", content); String body = JSONObject.toJSONString(map); String data = HttpHelper.sendHttpPost(zlptUrl, body); log.info("dataString-=========:" + data); //对返回的结果进行处理 - resultDataHandler(data); + // resultDataHandler(data); } catch (Exception e) { // throw new RuntimeException(e); - return AjaxResult.success("请求成功!"); + return AjaxResult.error("推送失败!"); } return AjaxResult.success("请求成功!"); } @@ -211,22 +210,13 @@ public class MaMachineServiceImpl implements MaMachineService { 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); log.info("dataArrayString-=========:" + dataArrayString); - JSONArray dataArray = JSONArray.parseArray(dataArrayString); - if (dataArray != null && dataArray.size() > 0) { - - - }else { - - } - } else { - + throw new Exception("推送失败!"); } - } } From ccf30659f4f367a83e5a38c5d6208db5bb99981a Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 4 Sep 2024 09:37:11 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bonus/sgzb/common/core/utils/HttpHelper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java index d19db4c..f05f5a4 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java @@ -41,16 +41,16 @@ public class HttpHelper { System.out.println("JSONBody-=========:" + JSONBody); CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(url); - httpPost.addHeader("Content-Type", "application/json"); + httpPost.addHeader("Content-Type", "application/json; charset=UTF-8"); if (!CollectionUtils.isEmpty(headerMap)) { for (Map.Entry entry : headerMap.entrySet()) { httpPost.addHeader(entry.getKey(), entry.getValue()); } } - httpPost.setEntity(new StringEntity(JSONBody)); + httpPost.setEntity(new StringEntity(JSONBody,StandardCharsets.UTF_8)); CloseableHttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); - String responseContent = EntityUtils.toString(entity, "UTF-8"); + String responseContent = EntityUtils.toString(entity, StandardCharsets.UTF_8); response.close(); httpClient.close(); return responseContent; From 495a07edde3de9dfbc2d040c09030ac4e866bf75 Mon Sep 17 00:00:00 2001 From: 15856 <15856818120@163.com> Date: Wed, 4 Sep 2024 09:39:38 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/controller/MaTypeController.java | 8 +++++++ .../bonus/sgzb/base/domain/MaKeeperUser.java | 22 +++++++++++++++++++ .../bonus/sgzb/base/mapper/MaTypeMapper.java | 7 ++++++ .../bonus/sgzb/base/service/ITypeService.java | 6 +++++ .../base/service/impl/MaTypeServiceImpl.java | 14 +++++++----- .../mapper/base/MaMachineTypeMapper.xml | 12 +++++++++- 6 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/MaKeeperUser.java diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java index cb0a8b0..fdf93fb 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java @@ -1,6 +1,7 @@ package com.bonus.sgzb.base.controller; import com.bonus.sgzb.base.api.domain.MaType; +import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.domain.vo.TreeSelect; import com.bonus.sgzb.base.mapper.MaTypeMapper; import com.bonus.sgzb.base.service.ITypeService; @@ -42,6 +43,13 @@ public class MaTypeController extends BaseController { return AjaxResult.success(maTypeList); } + @ApiOperation(value = "查询全部库管员信息") + @GetMapping("/getMaTypeKeeper") + public AjaxResult getMaTypeKeeper(){ + List maTypeList = iTypeService.getMaTypeKeeper(); + return AjaxResult.success(maTypeList); + } + /** * 工机具类型下拉树 * @return 结果 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/MaKeeperUser.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/MaKeeperUser.java new file mode 100644 index 0000000..d2efda2 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/MaKeeperUser.java @@ -0,0 +1,22 @@ +package com.bonus.sgzb.base.domain; + +import lombok.Data; + +@Data +public class MaKeeperUser { + + /** + * 用户id + */ + private Long userId; + + /** + * 用户名称 + */ + private String userName; + + /** + * 用户昵称 + */ + private String nickName; +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java index dda795a..2a9e94b 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java @@ -2,6 +2,7 @@ package com.bonus.sgzb.base.mapper; import com.bonus.sgzb.base.api.domain.MaMachine; import com.bonus.sgzb.base.api.domain.MaType; +import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.domain.MaPropSet; import com.bonus.sgzb.base.domain.MaTypeKeeper; import com.bonus.sgzb.base.domain.MaTypeRepair; @@ -86,4 +87,10 @@ public interface MaTypeMapper { int updateTypeNum(MaMachine maMachine); List selectMaTypeByUserId(Long userId); + + /** + * 查询全部库管员信息 + * @return + */ + List getMaTypeKeeper(); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java index 6eff718..fe643bf 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java @@ -1,6 +1,7 @@ package com.bonus.sgzb.base.service; import com.bonus.sgzb.base.api.domain.MaType; +import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.domain.vo.TreeSelect; import java.util.List; @@ -69,4 +70,9 @@ public interface ITypeService { List getEquipmentType(Long typeId, String typeName); + /** + * 查询全部库管员信息 + * @return + */ + List getMaTypeKeeper(); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index 90c43a9..924bce0 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -1,10 +1,7 @@ package com.bonus.sgzb.base.service.impl; import com.bonus.sgzb.base.api.domain.MaType; -import com.bonus.sgzb.base.domain.MaPropSet; -import com.bonus.sgzb.base.domain.MaTypeFile; -import com.bonus.sgzb.base.domain.MaTypeKeeper; -import com.bonus.sgzb.base.domain.MaTypeRepair; +import com.bonus.sgzb.base.domain.*; import com.bonus.sgzb.base.domain.vo.TreeSelect; import com.bonus.sgzb.base.mapper.MaTypeFileMapper; import com.bonus.sgzb.base.mapper.MaTypeMapper; @@ -344,7 +341,14 @@ public class MaTypeServiceImpl implements ITypeService { return list; } - + /** + * 查询全部库管员信息 + * @return + */ + @Override + public List getMaTypeKeeper() { + return maTypeMapper.getMaTypeKeeper(); + } /** * @Author dingjie * @Date 2023/12/14 diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml index e5516f9..4a6dd59 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml @@ -422,5 +422,15 @@ update ma_type set num = IFNULL( num, 0 ) + 1 where type_id = #{typeId} - + \ No newline at end of file From e64ea2f2ca4013986ef9772395c9a5fe3e1a805d Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 4 Sep 2024 17:25:57 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E6=8E=A8=E9=80=81=E4=B8=9A=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/sgzb/system/api/domain/SysDept.java | 36 ++++++-- .../sgzb/common/core/utils/StringUtils.java | 84 ++++++++++++++----- .../app/service/impl/TmTaskServiceImpl.java | 10 ++- .../resources/bootstrap-sgzb_cloud_dev.yml | 6 +- .../resources/bootstrap-sgzb_cloud_local.yml | 6 +- .../main/resources/bootstrap-sgzb_cq_dev.yml | 6 +- .../resources/bootstrap-sgzb_cq_local.yml | 6 +- .../resources/mapper/app/TmTaskMapper.xml | 21 +++-- 8 files changed, 132 insertions(+), 43 deletions(-) diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java index fea5c0c..d35793e 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java @@ -1,16 +1,16 @@ package com.bonus.sgzb.system.api.domain; -import java.util.ArrayList; -import java.util.List; +import com.bonus.sgzb.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; - -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.bonus.sgzb.common.core.web.domain.BaseEntity; +import java.util.ArrayList; +import java.util.List; /** * 部门表 sys_dept @@ -75,6 +75,12 @@ public class SysDept extends BaseEntity /** 所属组织id */ private Long companyId; + /** 企业机构代码(统一社会信用代码) */ + private String socialCreditCode; + + /** 企业归属代码 CSG-南方电网下属企业 SE-社会及大集体企业 */ + private String enterpriseOwnershipCode; + @Override public String getRemark() { return remark; @@ -93,6 +99,22 @@ public class SysDept extends BaseEntity this.companyId = companyId; } + public String getSocialCreditCode() { + return socialCreditCode; + } + + public void setSocialCreditCode(String socialCreditCode) { + this.socialCreditCode = socialCreditCode; + } + + public String getEnterpriseOwnershipCode() { + return enterpriseOwnershipCode; + } + + public void setEnterpriseOwnershipCode(String enterpriseOwnershipCode) { + this.enterpriseOwnershipCode = enterpriseOwnershipCode; + } + public Long getDeptId() { return deptId; diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/StringUtils.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/StringUtils.java index 7491ffc..4189ae2 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/StringUtils.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/StringUtils.java @@ -1,10 +1,7 @@ package com.bonus.sgzb.common.core.utils; -import java.security.SecureRandom; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; + import com.bonus.sgzb.common.core.constant.Constants; import com.bonus.sgzb.common.core.text.StrFormatter; import lombok.extern.slf4j.Slf4j; @@ -24,7 +21,58 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** 下划线 */ private static final char SEPARATOR = '_'; - private static SecureRandom random = null; + private static final Map CAT_MAP; + + static { + CAT_MAP = new HashMap<>(); + CAT_MAP.put("线路施工类", "A"); + CAT_MAP.put("变电施工类", "B"); + CAT_MAP.put("特种及其他设备", "C"); + CAT_MAP.put("检修试验", "D"); + CAT_MAP.put("创新装备", "E"); + } + + /** + 1 抱杆 01人字抱杆、02平臂抱杆、03悬浮抱杆、04.... + 2 放线及滑车 01牵张设备、02滑车、03.... + 3 收紧设备 01电动紧线机、02液压紧线机、03... + 4 线路动力设备 01机动绞磨、02压接机、03飞车及间隔棒运输机、04.... + 5 配件及仪器仪表 01锚固、02绳索、03连接器、04全站仪RPK、05附件、06.... + + 1 一次安装设备 01滤油机、02 SF6回收装置、03排油泵、04真空泵、05.... + 2 变电运输设备 01二次屏柜搬运设备、02液压移动小车、03轨道小车、04 GIS运输小坦克、05.. + + 1 直升机及无人机 01、多旋翼无人机、02固定翼无人机、03巡线直升机、04... + 2 带电清洗设备 01线路水冲洗、02变电水冲洗、03... + 3 起重设备 01汽车起重机、02履带式起重机、03随车起重机、04... + 4 土建设备 01履带式推土机、02液压式挖掘机、03混凝土泵车、05旋挖钻机、06... + 5 运输设备 01厢式货车、02平板货车、03灌式运输车、04履带运输车、05... + 6 高空作业设备 01曲臂升降车、02高处作业平台车、03剪叉式升降平台、04... + + 1 一次试验设备 01试验变压器、02高压直流发生器、03绕组直流电阻、04变比测试仪、05... + 2 二次试验设备 01万用表、02电流表、03微安表、04... + 3 油化试验设备 01微水测试仪、02介损测试仪、03... + + 1 线路创新装备 01索道自动上下料装置、02遥控索道牵引机、03塔材组片专用装备、04... + 2 变电创新装备 01自动安装机械、02新型模具和加固装置、03 GIS/HGIS设备整体就位装备、04.. + 3 其他新装备 01砌筑作业机器人、02高处作业平台车、03电缆敷设智能化控制装备、04... + + map.put("抱杆_人字抱杆","101"); + map.put("抱杆_平臂抱杆","102"); + map.put("抱杆_悬浮抱杆","103"); + map.put("放线及滑车_牵张设备","201"); + map.put("放线及滑车_滑车","202"); + map.put("收紧设备_电动紧线机","301"); + map.put("收紧设备_液压紧线机","302"); + map.put("线路动力设备_机动绞磨","401"); + map.put("线路动力设备_压接机","402"); + map.put("线路动力设备_飞车及间隔棒运输机","403"); + map.put("配件及仪器仪表_锚固","501"); + map.put("配件及仪器仪表_绳索","502"); + map.put("配件及仪器仪表_连接器","503"); + map.put("配件及仪器仪表_全站仪RPK","504"); + map.put("配件及仪器仪表_附件","505"); + */ /** * 获取参数不为空值 @@ -557,29 +605,19 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils return sb.toString(); } -// public static String getDeviceCode() { -// String randomNum = null; -// try { -// random = SecureRandom.getInstance("SHA1PRNG"); -// randomNum = String.format("%02d", random.nextInt(100)); -// } catch (NoSuchAlgorithmException e) { -// log.error("生成随机数失败,", e); -// } -// String deviceCode = "CSG-A101-" + DateUtils.dateTime() + randomNum; //like CSG-A101-2024061900001, need save it -// return deviceCode; -// } - - public static String getDeviceCode(Date date, String maId) { + /** 生成工器具编码: 类似CSG-A101-2024061900001 */ + public static String getDeviceCode(String ownerCode, String categoryName, String typeId, Date date, String maId) { int number = Integer.parseInt(maId); - if (number > 50000) { - number = number % 50000; + if (number > 30000) { + number = number % 30000; } String numberStr = String.format("%05d", number); - String deviceCode = "CSG-A101-" + DateUtils.getDateTimeString(date) + numberStr; //like CSG-A101-2024061900001 + String deviceCode = ownerCode + "-" + CAT_MAP.get(categoryName) + typeId + "-" + DateUtils.getDateTimeString(date) + numberStr; return deviceCode; } // public static void main(String[] args) { -// System.out.println(getDeviceCode(new Date(), "500322")); +// System.out.println(getDeviceCode("CSG", "线路施工类", "102", new Date(), "500322")); // } + } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java index a9b5db9..ff45684 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java @@ -22,6 +22,7 @@ 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 com.bonus.sgzb.system.api.model.LoginUser; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -1387,17 +1388,21 @@ public class TmTaskServiceImpl implements TmTaskService { log.info("dataString-=========:" + data); resultDataHandler(data); } catch (Exception e) { - return AjaxResult.success("请求成功!"); + return AjaxResult.error("请求失败!{}", e.getMessage()); } + //TODO 更改pushStatus + return AjaxResult.success("请求成功!"); } return AjaxResult.success("请求成功!"); } private void makeIntelligentVOList(List tmTasks, List intelVOList) { + LoginUser loginUser = SecurityUtils.getLoginUser(); for (TmTask task : tmTasks) { List subTasks = tmTaskMapper.getLeaseOutDetails(task); for (TmTask subTask : subTasks) { MaMachineIntelligentVO intelVO = new MaMachineIntelligentVO(); + intelVO.setSocialCreditCode(loginUser.getSysUser().getDept().getSocialCreditCode()); intelVO.setAffiliatedUnitName(task.getUnitName()); intelVO.setBelongUnitId(String.valueOf(task.getUnitId())); intelVO.setCategoryCode(task.getTypeId()); @@ -1414,7 +1419,8 @@ public class TmTaskServiceImpl implements TmTaskService { intelVO.setSpecificationType(""); intelVO.setValidityDate(new Date()); //每个设备不同点的设置 - intelVO.setDeviceCode(StringUtils.getDeviceCode(subTask.getCreateTime(), subTask.getMaId())); + String ownerCode = loginUser.getSysUser().getDept().getEnterpriseOwnershipCode(); + intelVO.setDeviceCode(StringUtils.getDeviceCode(ownerCode, subTask.getTypeName(), subTask.getTypeId(), subTask.getCreateTime(), subTask.getMaId())); intelVO.setFactoryDate(subTask.getOutFacTime()); intelVO.setMachineryCode(subTask.getMaId()); intelVO.setTrialDate(subTask.getThisCheckTime()); diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cloud_dev.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cloud_dev.yml index 70297e7..d27b307 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cloud_dev.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cloud_dev.yml @@ -32,4 +32,8 @@ sgzb: site: cq job: settlementJobDay: 21 - settlementJobCron: "0 0 1 21 * ?" \ No newline at end of file + settlementJobCron: "0 0 1 21 * ?" + zlptUrl: + intelligentUrl: + intelligentAppKey: + intelligentAesKey: \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cloud_local.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cloud_local.yml index f3326a0..fdef011 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cloud_local.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cloud_local.yml @@ -32,4 +32,8 @@ sgzb: site: cq job: settlementJobDay: 21 - settlementJobCron: "0 0 1 21 * ?" \ No newline at end of file + settlementJobCron: "0 0 1 21 * ?" + zlptUrl: + intelligentUrl: + intelligentAppKey: + intelligentAesKey: \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cq_dev.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cq_dev.yml index d1d05df..f9d7633 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cq_dev.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cq_dev.yml @@ -32,4 +32,8 @@ sgzb: site: cq job: settlementJobDay: 21 - settlementJobCron: "0 0 1 21 * ?" \ No newline at end of file + settlementJobCron: "0 0 1 21 * ?" + zlptUrl: + intelligentUrl: + intelligentAppKey: + intelligentAesKey: \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cq_local.yml b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cq_local.yml index dc5cd6f..a830327 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cq_local.yml +++ b/sgzb-modules/sgzb-material/src/main/resources/bootstrap-sgzb_cq_local.yml @@ -32,4 +32,8 @@ sgzb: site: cq job: settlementJobDay: 21 - settlementJobCron: "0 0 1 21 * ?" \ No newline at end of file + settlementJobCron: "0 0 1 21 * ?" + zlptUrl: + intelligentUrl: + intelligentAppKey: + intelligentAesKey: \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml index d2f4f0d..e442ce3 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml @@ -1176,14 +1176,21 @@ From 9af5335a714bee3f409eef51817d5d9443fa2c01 Mon Sep 17 00:00:00 2001 From: 15856 <15856818120@163.com> Date: Thu, 5 Sep 2024 16:24:36 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/sgzb/base/controller/MaTypeController.java | 7 +------ .../sgzb/base/controller/MaTypeKeeperController.java | 10 ++++++++++ .../bonus/sgzb/base/mapper/MaTypeKeeperMapper.java | 7 +++++++ .../java/com/bonus/sgzb/base/mapper/MaTypeMapper.java | 6 +----- .../bonus/sgzb/base/service/IMaTypeKeeperService.java | 7 +++++++ .../com/bonus/sgzb/base/service/ITypeService.java | 6 +----- .../base/service/impl/MaTypeKeeperServiceImpl.java | 10 ++++++++++ .../sgzb/base/service/impl/MaTypeServiceImpl.java | 8 -------- .../resources/mapper/base/MaMachineTypeMapper.xml | 11 ----------- .../main/resources/mapper/base/MaTypeKeeperMapper.xml | 11 +++++++++++ 10 files changed, 48 insertions(+), 35 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java index fdf93fb..da1119f 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java @@ -43,12 +43,7 @@ public class MaTypeController extends BaseController { return AjaxResult.success(maTypeList); } - @ApiOperation(value = "查询全部库管员信息") - @GetMapping("/getMaTypeKeeper") - public AjaxResult getMaTypeKeeper(){ - List maTypeList = iTypeService.getMaTypeKeeper(); - return AjaxResult.success(maTypeList); - } + /** * 工机具类型下拉树 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeKeeperController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeKeeperController.java index df5aa0f..b840e09 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeKeeperController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeKeeperController.java @@ -1,15 +1,19 @@ package com.bonus.sgzb.base.controller; +import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.service.IMaTypeKeeperService; import com.bonus.sgzb.common.core.web.controller.BaseController; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.core.web.page.TableDataInfo; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * 库管员配置ma_type_keeper(MaTypeKeeper)表控制层 * @@ -52,5 +56,11 @@ public class MaTypeKeeperController extends BaseController { return getDataTable(maTypeKeeperService.getListByMaType(userId, typeName)); } + @ApiOperation(value = "查询全部库管员信息") + @GetMapping("/getMaTypeKeeper") + public AjaxResult getMaTypeKeeper(){ + List maTypeList = maTypeKeeperService.getMaTypeKeeper(); + return AjaxResult.success(maTypeList); + } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeKeeperMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeKeeperMapper.java index a88eb24..16f6923 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeKeeperMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeKeeperMapper.java @@ -1,5 +1,6 @@ package com.bonus.sgzb.base.mapper; +import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.vo.DeptUser; import com.bonus.sgzb.base.vo.MaTypeKeeperVO; import org.apache.ibatis.annotations.Mapper; @@ -29,5 +30,11 @@ public interface MaTypeKeeperMapper { * @return */ List selectListByUserId(Long userId, String typeName); + + /** + * 查询全部库管员信息 + * @return + */ + List getMaTypeKeeper(); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java index 2a9e94b..4cd5aed 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java @@ -88,9 +88,5 @@ public interface MaTypeMapper { List selectMaTypeByUserId(Long userId); - /** - * 查询全部库管员信息 - * @return - */ - List getMaTypeKeeper(); + } \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/IMaTypeKeeperService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/IMaTypeKeeperService.java index a6d6dea..46e769e 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/IMaTypeKeeperService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/IMaTypeKeeperService.java @@ -1,5 +1,6 @@ package com.bonus.sgzb.base.service; +import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.vo.DeptUser; import com.bonus.sgzb.base.vo.MaTypeKeeperVO; @@ -27,5 +28,11 @@ public interface IMaTypeKeeperService { * @return */ List getListByMaType(Long userId, String typeName); + + /** + * 查询全部库管员信息 + * @return + */ + List getMaTypeKeeper(); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java index fe643bf..c1cbb7d 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java @@ -70,9 +70,5 @@ public interface ITypeService { List getEquipmentType(Long typeId, String typeName); - /** - * 查询全部库管员信息 - * @return - */ - List getMaTypeKeeper(); + } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeKeeperServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeKeeperServiceImpl.java index b40828c..3797f00 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeKeeperServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeKeeperServiceImpl.java @@ -1,5 +1,6 @@ package com.bonus.sgzb.base.service.impl; +import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.mapper.MaTypeKeeperMapper; import com.bonus.sgzb.base.service.IMaTypeKeeperService; import com.bonus.sgzb.base.vo.DeptUser; @@ -43,5 +44,14 @@ public class MaTypeKeeperServiceImpl implements IMaTypeKeeperService { return maTypeKeeperMapper.selectListByUserId(userId, typeName); } + + /** + * 查询全部库管员信息 + * @return + */ + @Override + public List getMaTypeKeeper() { + return maTypeKeeperMapper.getMaTypeKeeper(); + } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index 924bce0..45142d0 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -341,14 +341,6 @@ public class MaTypeServiceImpl implements ITypeService { return list; } - /** - * 查询全部库管员信息 - * @return - */ - @Override - public List getMaTypeKeeper() { - return maTypeMapper.getMaTypeKeeper(); - } /** * @Author dingjie * @Date 2023/12/14 diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml index 4a6dd59..70f5220 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml @@ -422,15 +422,4 @@ update ma_type set num = IFNULL( num, 0 ) + 1 where type_id = #{typeId} - \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaTypeKeeperMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaTypeKeeperMapper.xml index 57973bc..3a1ea30 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaTypeKeeperMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaTypeKeeperMapper.xml @@ -26,4 +26,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join sys_user su on mtk.user_id = su.user_id + \ No newline at end of file From ad6c3e64ea78c6ff2c38e9c79e8b234212be88d5 Mon Sep 17 00:00:00 2001 From: 15856 <15856818120@163.com> Date: Fri, 6 Sep 2024 11:34:46 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E6=8E=A5=E6=94=B6=E4=BB=8E=E7=A7=9F?= =?UTF-8?q?=E8=B5=81=E6=8E=A8=E9=80=81=E8=BF=87=E6=9D=A5=E7=9A=84=E8=A3=85?= =?UTF-8?q?=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/controller/MaReceiveController.java | 14 +++++--------- .../sgzb/base/domain/DataReceiveDetail.java | 2 ++ .../sgzb/base/mapper/MaReceiveMapper.java | 3 ++- .../sgzb/base/service/MaReceiveService.java | 2 +- .../service/impl/MaReceiveServiceImpl.java | 19 +++++++++++++++++-- .../resources/mapper/base/MaReceiveMapper.xml | 10 +++++----- 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaReceiveController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaReceiveController.java index 791bf62..000ec39 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaReceiveController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaReceiveController.java @@ -9,6 +9,7 @@ import com.bonus.sgzb.common.core.web.controller.BaseController; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.core.web.page.TableDataInfo; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -32,20 +33,15 @@ public class MaReceiveController extends BaseController { */ @ApiOperation(value = "获取推送数据") @PostMapping("/dataReceive") - public AjaxResult getProjectInfoAll(@RequestBody List dataReceiveDetails) { - if (CollUtil.isEmpty(dataReceiveDetails)) { + public AjaxResult getProjectInfoAll(@RequestBody String maMachineRequest) { + if (StringUtils.isEmpty(maMachineRequest)) { return AjaxResult.error("推送数据为空"); } - DataReceiveInfo dataReceiveInfo = new DataReceiveInfo(); - dataReceiveInfo.setPushNum(dataReceiveDetails.size()); - int id = maReceiveService.saveDataReceiveInfo(dataReceiveInfo); + + int id = maReceiveService.saveDataReceiveInfo(maMachineRequest); if (id == 0) { return AjaxResult.error("推送数据失败"); } - for (DataReceiveDetail dataReceiveDetail : dataReceiveDetails) { - dataReceiveDetail.setReceiveId(id); - maReceiveService.saveDataReceiveDetails(dataReceiveDetail); - } return AjaxResult.success("数据推送成功"); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/DataReceiveDetail.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/DataReceiveDetail.java index 8c4ccde..f209d30 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/DataReceiveDetail.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/DataReceiveDetail.java @@ -85,4 +85,6 @@ public class DataReceiveDetail { @ApiModelProperty(value = "数据来源(0新购 1盘点 2数据推送)") private Integer souceBy; + @ApiModelProperty(value = "接收人") + private String userIds; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaReceiveMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaReceiveMapper.java index d574a3c..769f583 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaReceiveMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaReceiveMapper.java @@ -3,6 +3,7 @@ package com.bonus.sgzb.base.mapper; import com.bonus.sgzb.base.domain.DataReceiveDetail; import com.bonus.sgzb.base.domain.DataReceiveInfo; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -24,5 +25,5 @@ public interface MaReceiveMapper { List getDateReceiveMachine(DataReceiveDetail dataReceiveDetail); - int updateInfoStatus(Integer id); + int updateInfoStatus(@Param("id") Integer id); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/MaReceiveService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/MaReceiveService.java index 087cf15..427acd2 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/MaReceiveService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/MaReceiveService.java @@ -10,7 +10,7 @@ import java.util.List; * @Date:2024/7/24 - 13:20 */ public interface MaReceiveService { - int saveDataReceiveInfo(DataReceiveInfo dataReceiveInfo); + int saveDataReceiveInfo(String maMachineRequest); int saveDataReceiveDetails(DataReceiveDetail dataReceiveDetail); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaReceiveServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaReceiveServiceImpl.java index ce37e77..3bb9806 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaReceiveServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaReceiveServiceImpl.java @@ -1,5 +1,7 @@ package com.bonus.sgzb.base.service.impl; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.bonus.sgzb.base.api.domain.MaMachine; import com.bonus.sgzb.base.domain.DataReceiveDetail; import com.bonus.sgzb.base.domain.DataReceiveInfo; @@ -7,6 +9,7 @@ import com.bonus.sgzb.base.mapper.MaMachineMapper; import com.bonus.sgzb.base.mapper.MaReceiveMapper; import com.bonus.sgzb.base.mapper.MaTypeMapper; import com.bonus.sgzb.base.service.MaReceiveService; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,6 +21,7 @@ import java.util.List; * @Author:liang.chao * @Date:2024/7/24 - 13:20 */ +@Slf4j @Service public class MaReceiveServiceImpl implements MaReceiveService { @@ -32,9 +36,20 @@ public class MaReceiveServiceImpl implements MaReceiveService { @Override @Transactional - public int saveDataReceiveInfo(DataReceiveInfo dataReceiveInfo) { + public int saveDataReceiveInfo(String maMachineRequest) { + log.info("推送数据{}", maMachineRequest); + JSONObject object = JSONObject.parseObject(maMachineRequest); + maMachineRequest = object.getString("body"); + JSONArray dataArray = JSONArray.parseArray(maMachineRequest); + List dataReceiveDetails = dataArray.toJavaList(DataReceiveDetail.class); + DataReceiveInfo dataReceiveInfo = new DataReceiveInfo(); + dataReceiveInfo.setPushNum(dataReceiveDetails.size()); maReceiveMapper.saveDataReceiveInfo(dataReceiveInfo); if (dataReceiveInfo.getId() != null) { + for (DataReceiveDetail dataReceiveDetail : dataReceiveDetails) { + dataReceiveDetail.setReceiveId(dataReceiveInfo.getId()); + saveDataReceiveDetails(dataReceiveDetail); + } return dataReceiveInfo.getId(); } else { return 0; @@ -71,12 +86,12 @@ public class MaReceiveServiceImpl implements MaReceiveService { } @Override + @Transactional(rollbackFor = Exception.class) public int saveMachine(DataReceiveInfo dataReceiveInfo) { for (DataReceiveDetail dataReceiveDetail : dataReceiveInfo.getDataReceiveDetailList()) { MaMachine maMachine = new MaMachine(); maMachine.setMaCode(dataReceiveDetail.getMaCode()); maMachine.setTypeId(dataReceiveDetail.getTypeId()); - maMachine.setMaCode(dataReceiveDetail.getMaCode()); maMachine.setMaStatus("15"); maMachine.setCreateTime(new Date()); maMachine.setSouceBy(2); diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaReceiveMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaReceiveMapper.xml index ee9cc92..791331c 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaReceiveMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaReceiveMapper.xml @@ -9,20 +9,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" values(#{pushNum},now()) - insert into data_receive_detail(receive_id,check_code,check_unit,check_date,is_new,ma_code,ma_user_name,next_check_date,out_factory_time,rent_price,rent_time,supplier,type_id,unit_id) - values(#{receiveId},#{checkCode},#{checkUnit},#{checkDate},#{isNew},#{maCode},#{maUserName},#{nextCheckDate},#{outFactoryTime},#{rentPrice},#{rentTime},#{supplier},#{typeId},#{unitId}) + insert into data_receive_detail(receive_id,check_code,check_unit,check_date,is_new,ma_id,ma_user_name,next_check_date,out_factory_time,rent_price,rent_time,supplier,type_id,unit_id) + values(#{receiveId},#{checkCode},#{checkUnit},#{checkDate},#{isNew},#{maId},#{maUserName},#{nextCheckDate},#{outFactoryTime},#{rentPrice},#{rentTime},#{supplier},#{typeId},#{unitId}) UPDATE data_receive_detail SET STATUS = 1, ma_id = #{maId} - where receive_id = #{receiveId} and type_id = #{typeId} - AND ma_code = #{maCode} + where id = #{id} + UPDATE data_receive_info SET receive_status = 1 - where id = #{receiveId} + where id = #{id}