From 8ea671775e48f2b4fb975181dda270a5bc0375b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=AD=94=E4=BB=99=7E?= <13068499+willowhh@user.noreply.gitee.com> Date: Thu, 26 Dec 2024 19:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96openId=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/controller/BaseController.java | 1 + .../com/fastbee/common/utils/PageUtils.java | 4 +- .../common/utils/pay/wechat_public_key.pem | 8 +- .../fastbee/common/utils/pay/wxPayConfig.java | 1 - .../DeviceReportInfoController.java | 4 + .../controller/pay/WeChatPayController.java | 62 +++++++++- .../NgIrrigationAreaController.java | 110 ++++++++++++++++++ .../HanZhenWaterRecordsController.java | 41 +++++++ .../java/com/fastbee/iot/domain/Device.java | 5 + .../iot/model/DeviceAllShortOutput.java | 2 + .../com/fastbee/iot/model/DeviceMqttVO.java | 5 + .../iot/model/ProductAuthenticateModel.java | 3 + .../ThingsModels/ThingsModelValuesOutput.java | 3 + .../resources/mapper/iot/DeviceMapper.xml | 3 +- .../rechargecard/domain/NgIrrigationArea.java | 58 +++++++++ .../mapper/NgIrrigationAreaMapper.java | 61 ++++++++++ .../mapper/NgWaterPumpUsageRecordsMapper.java | 9 ++ .../service/INgIrrigationAreaService.java | 61 ++++++++++ .../INgWaterPumpUsageRecordsService.java | 8 +- .../service/IUserWechatPayService.java | 8 ++ .../impl/NgIrrigationAreaServiceImpl.java | 93 +++++++++++++++ .../NgWaterPumpUsageRecordsServiceImpl.java | 47 ++++++++ .../impl/UserWechatPayServiceImpl.java | 63 ++++++++-- .../rechargecard/NgIrrigationAreaMapper.xml | 81 +++++++++++++ .../service/impl/SysDeptServiceImpl.java | 7 +- 25 files changed, 728 insertions(+), 20 deletions(-) create mode 100644 fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/NgIrrigationAreaController.java create mode 100644 fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/hanZhen/HanZhenWaterRecordsController.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/NgIrrigationArea.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/NgIrrigationAreaMapper.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/INgIrrigationAreaService.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/NgIrrigationAreaServiceImpl.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/resources/mapper/rechargecard/NgIrrigationAreaMapper.xml diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/controller/BaseController.java b/fastbee-common/src/main/java/com/fastbee/common/core/controller/BaseController.java index 32cf4e1..a33d010 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/controller/BaseController.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/controller/BaseController.java @@ -30,6 +30,7 @@ import java.util.List; public class BaseController { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Resource private RedisCache redisCache; diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/PageUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/PageUtils.java index 8de87f8..18727b9 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/PageUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/PageUtils.java @@ -1,5 +1,6 @@ package com.fastbee.common.utils; +import com.fastbee.common.core.page.TableDataInfo; import com.github.pagehelper.PageHelper; import com.fastbee.common.core.page.PageDomain; import com.fastbee.common.core.page.TableSupport; @@ -22,7 +23,8 @@ public class PageUtils extends PageHelper Integer pageSize = pageDomain.getPageSize(); String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); Boolean reasonable = pageDomain.getReasonable(); - PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable); + PageHelper.startPage(pageNum, pageSize, orderBy) + .setReasonable(reasonable); } /** diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem b/fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem index 5b5f421..0e39665 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem @@ -1,3 +1,9 @@ -----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4zej1cqugGQtVSY2Ah8RMCKcr2UpZ8Npo+5Ja9xpFPYkWHaF1Gjrn3d5kcwAFuHHcfdc3yxDYx6+9grvJnCA2zQzWjzVRa3BJ5LTMj6yqvhEmtvjO9D1xbFTA2m3kyjxlaIar/RYHZSslT4VmjIatW9KJCDKkwpM6x/RIWL8wwfFwgz2q3Zcrff1y72nB8p8P12ndH7GSLoY6d2Tv0OB2+We2Kyy2+QzfGXOmLp7UK/pFQjJjzhSf9jxaWJXYKIBxpGlddbRZj9PqvFPTiep8rvfKGNZF9Q6QaMYTpTp/uKQ3YvpDlyeQlYe4rRFauH3mOE6j56QlYQWivknDX9VrwIDAQAB +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3cwXyRjQVNjj2hXje0w+ +6ylZ58Fk5owAvF53D0IBrleshtKZOrspxc+qw6Wi2nTJzAmH4xVpmORTdxKw7LF7 +GwdHoldlfpggvDP6y4S7YM3yNUqpX44ogfGXuNszt1ffbIpazqsyYcxoPpIacOmO +KdapylnU4S/wyca3NVv4Gw+1Yn6blXdNcAoXhCVHqLhJ7tFilgQTAmifp3W0XXWW +aLJdrK/mhxMXdnCjF8xPU4lPSUrOHTHbJGsddPIg79R87iZm1Xj+ctgR57sox+LG +sojZTnGsBVANHkakSMG3ezYxoUBA1eoo7sHxDSd1UHOEzJJD0e7jolQP3+18z9iJ +FQIDAQAB -----END PUBLIC KEY----- \ No newline at end of file diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/pay/wxPayConfig.java b/fastbee-common/src/main/java/com/fastbee/common/utils/pay/wxPayConfig.java index 4a31e34..68c1704 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/pay/wxPayConfig.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/pay/wxPayConfig.java @@ -62,6 +62,5 @@ public class wxPayConfig { } return fileContent.toString(); } - // 这里可以添加其他与微信支付相关的配置方法 } \ No newline at end of file diff --git a/fastbee-open-api/src/main/java/com/fastbee/data/controller/DeviceReportInfoController.java b/fastbee-open-api/src/main/java/com/fastbee/data/controller/DeviceReportInfoController.java index 7c8bc25..7ed1b1e 100644 --- a/fastbee-open-api/src/main/java/com/fastbee/data/controller/DeviceReportInfoController.java +++ b/fastbee-open-api/src/main/java/com/fastbee/data/controller/DeviceReportInfoController.java @@ -51,7 +51,10 @@ public class DeviceReportInfoController extends BaseController public TableDataInfo list(DeviceReportInfo deviceReportInfo) { startPage(); + List list = deviceReportInfoService.selectDeviceReportInfoList(deviceReportInfo); + + //查询设备在线状态 list.forEach(d->{ if(d.getType()==1){ @@ -67,6 +70,7 @@ public class DeviceReportInfoController extends BaseController } }); + return getDataTable(list); } //统计是设备相关信息 diff --git a/fastbee-open-api/src/main/java/com/fastbee/data/controller/pay/WeChatPayController.java b/fastbee-open-api/src/main/java/com/fastbee/data/controller/pay/WeChatPayController.java index 16d3c26..5fb3a61 100644 --- a/fastbee-open-api/src/main/java/com/fastbee/data/controller/pay/WeChatPayController.java +++ b/fastbee-open-api/src/main/java/com/fastbee/data/controller/pay/WeChatPayController.java @@ -52,6 +52,22 @@ import static com.fastbee.rechargecard.service.impl.UserWechatPayServiceImpl.api @RestController @RequestMapping("/pay") public class WeChatPayController extends BaseController { + /** 商户号 */ + public static String mchId = "1531795301"; + /** 商户API私钥文件路径 */ + public static String privateKeyPath = "fastbee-common/src/main/java/com/fastbee/common/utils/pay/apiclient_key.pem"; + /** 商户API证书序列号 */ + public static String serial_no = "3075B63EF52666EDC3EAFC5D4FB35C02CE123A9C"; + /** 商户APIV3密钥 */ + public static String apiV3Key = "e85a203e8ca146102f5cd7ecff912580"; + //微信小程序appid + public static String appId="wx308612d2a8423311"; + //请求随机串 + public static String nonce_str=""; + //时间戳 + public static String timeStamp=""; + // 使用HttpClientBuilder创建CloseableHttpClient实例,采用默认配置 + CloseableHttpClient httpClient = HttpClientBuilder.create().build(); @Autowired private INgUserRechargeRecordsService ngUserRechargeRecordsService; @@ -62,6 +78,36 @@ public class WeChatPayController extends BaseController { @Autowired private IUserWechatPayService userWechatPayService; + /** + * 获取openId + * @param code + * @return + */ + @ApiOperation("获取openId") + @PostMapping("/getOpenId") + public Map BuildOrder(@RequestBody String code) + { + Map result=userWechatPayService.GetOpenId(code); + Map returnParams=new HashMap<>(); + if(result.get("openid")==null && result.get("errcode")!=null) + { + if(result.get("errcode").equals(40163)) + { + returnParams.put("code",401); + returnParams.put("message","验证码已经被使用,请重新获取"); + return returnParams; + //return warn("验证码已经被使用,请重新获取"); + }else if(result.get("errcode").equals(40029)) + { + returnParams.put("code",403); + returnParams.put("message","验证码已失效,请重新获取"); + return returnParams; + //return warn("验证码已失效,请重新获取"); + } + } + return success(result.get("openid").toString()); + } + /** * 微信支付生成订单 * @return 登录结果 @@ -140,14 +186,23 @@ public class WeChatPayController extends BaseController { * responseBody 应答报文主体 * publicKey 微信支付公钥(PEM 格式,去掉头尾并解码为二进制) */ - /*String publicKey=wxPayConfig.getPublicKey(publicKeyPath);//读取并预处理后的微信支付公钥 + //String publicKey= wxPayConfig.getPublicKey(publicKeyPath);//读取并预处理后的微信支付公钥 + /*String Authorization= + String publicKey=userWechatPayService.getPublicKeyByCertificat(); boolean isVerified = verifySignature(wechatpaySignature, wechatpayTimestamp, wechatpayNonce, json, publicKey); if (isVerified) { System.out.println("签名验证成功"); } else { System.out.println("签名验证失败"); - return error("签名验证失败"); + responseBody.put("code", "FAIL"); + responseBody.put("message", "签名验证失败"); + + // 返回500状态码以及符合要求的应答报文 + return new ResponseEntity<>(responseBody, HttpStatus.INTERNAL_SERVER_ERROR); + //return error("签名验证失败"); }*/ + + //使用apiv3key解密 String decryptData=""; try{ @@ -212,7 +267,4 @@ public class WeChatPayController extends BaseController { //return error("修改数据库失败"); } - - - } diff --git a/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/NgIrrigationAreaController.java b/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/NgIrrigationAreaController.java new file mode 100644 index 0000000..18322c2 --- /dev/null +++ b/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/NgIrrigationAreaController.java @@ -0,0 +1,110 @@ +package com.fastbee.data.controller.userRecharge; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.fastbee.common.annotation.Log; +import com.fastbee.common.core.controller.BaseController; +import com.fastbee.common.core.domain.AjaxResult; +import com.fastbee.common.enums.BusinessType; +import com.fastbee.rechargecard.domain.NgIrrigationArea; +import com.fastbee.rechargecard.service.INgIrrigationAreaService; +import com.fastbee.common.utils.poi.ExcelUtil; +import com.fastbee.common.core.page.TableDataInfo; + +/** + * 灌区Controller + * + * @author kerwincui + * @date 2024-12-26 + */ +@RestController +@RequestMapping("/rechargecard/area") +@Api(tags = "灌区") +public class NgIrrigationAreaController extends BaseController +{ + @Autowired + private INgIrrigationAreaService ngIrrigationAreaService; + +/** + * 查询灌区列表 + */ +@PreAuthorize("@ss.hasPermi('rechargecard:area:list')") +@GetMapping("/list") +@ApiOperation("查询灌区列表") + public TableDataInfo list(NgIrrigationArea ngIrrigationArea) + { + startPage(); + List list = ngIrrigationAreaService.selectNgIrrigationAreaList(ngIrrigationArea); + return getDataTable(list); + } + + /** + * 导出灌区列表 + */ + @ApiOperation("导出灌区列表") + @PreAuthorize("@ss.hasPermi('rechargecard:area:export')") + @PostMapping("/export") + public void export(HttpServletResponse response, NgIrrigationArea ngIrrigationArea) + { + List list = ngIrrigationAreaService.selectNgIrrigationAreaList(ngIrrigationArea); + ExcelUtil util = new ExcelUtil(NgIrrigationArea.class); + util.exportExcel(response, list, "灌区数据"); + } + + /** + * 获取灌区详细信息 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:area:query')") + @GetMapping(value = "/{id}") + @ApiOperation("获取灌区详细信息") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(ngIrrigationAreaService.selectNgIrrigationAreaById(id)); + } + + /** + * 新增灌区 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:area:add')") + @PostMapping + @ApiOperation("新增灌区") + public AjaxResult add(@RequestBody NgIrrigationArea ngIrrigationArea) + { + return toAjax(ngIrrigationAreaService.insertNgIrrigationArea(ngIrrigationArea)); + } + + /** + * 修改灌区 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:area:edit')") + @PutMapping + @ApiOperation("修改灌区") + public AjaxResult edit(@RequestBody NgIrrigationArea ngIrrigationArea) + { + return toAjax(ngIrrigationAreaService.updateNgIrrigationArea(ngIrrigationArea)); + } + + /** + * 删除灌区 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:area:remove')") + @DeleteMapping("/{ids}") + @ApiOperation("删除灌区") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(ngIrrigationAreaService.deleteNgIrrigationAreaByIds(ids)); + } +} diff --git a/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/hanZhen/HanZhenWaterRecordsController.java b/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/hanZhen/HanZhenWaterRecordsController.java new file mode 100644 index 0000000..9884fc0 --- /dev/null +++ b/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/hanZhen/HanZhenWaterRecordsController.java @@ -0,0 +1,41 @@ +package com.fastbee.data.controller.userRecharge.hanZhen; + +import com.fastbee.common.core.controller.BaseController; +import com.fastbee.common.core.domain.AjaxResult; +import com.fastbee.common.core.domain.AjaxResultPro; +import com.fastbee.common.core.page.TableDataInfo; +import com.fastbee.rechargecard.domain.NgIrrigationArea; +import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper; +import com.fastbee.rechargecard.service.impl.NgWaterPumpUsageRecordsServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.query.Param; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * Controller + *设备瞬时数据 + * @author kerwincui + * @date 2024-12-19 + */ +@RestController +@RequestMapping("/pump/usage") +@Api(tags = "设备瞬时数据") +public class HanZhenWaterRecordsController extends BaseController { + + + @Autowired + private NgWaterPumpUsageRecordsServiceImpl ngWaterPumpUsageRecordsService; + @GetMapping("/realtimeData") + public AjaxResult realtimeData(@Param("deviceNumber") String deviceNumber) { + + ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageDeviceNumber(deviceNumber); + return toAjax(ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageDeviceNumber(deviceNumber)); + } +} diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Device.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Device.java index 272564f..fd937e5 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Device.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Device.java @@ -200,6 +200,11 @@ public class Device extends BaseEntity @ApiModelProperty("设备型号") private String deviceModel; + /** 测站号 */ + /*@Excel(name = "测站号") + @ApiModelProperty("测站号") + private String stationNumber;*/ + /** * 关联组态,来源产品 */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/DeviceAllShortOutput.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/DeviceAllShortOutput.java index d455d9f..0c33012 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/DeviceAllShortOutput.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/DeviceAllShortOutput.java @@ -45,6 +45,8 @@ public class DeviceAllShortOutput /** wifi信号强度(信号极好4格[-55— 0],信号好3格[-70— -55],信号一般2格[-85— -70],信号差1格[-100— -85]) */ private Integer rssi; + /** 测站号*/ + private String stationNumber; /** 激活时间 */ @JsonFormat(pattern = "yyyy-MM-dd") diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/DeviceMqttVO.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/DeviceMqttVO.java index bab8639..1310aaf 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/DeviceMqttVO.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/DeviceMqttVO.java @@ -17,6 +17,11 @@ public class DeviceMqttVO { */ private String serialNumber; + /** + * 测站号 + */ + private String stationNumber; + /** * 产品id */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/ProductAuthenticateModel.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/ProductAuthenticateModel.java index 7f95556..6538390 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/ProductAuthenticateModel.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/ProductAuthenticateModel.java @@ -20,6 +20,9 @@ public class ProductAuthenticateModel implements Serializable { /** 产品ID */ private Long productId; + /** 测站号 */ + private String stationNumber; + /** 产品名称 */ private String productName; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/ThingsModels/ThingsModelValuesOutput.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/ThingsModels/ThingsModelValuesOutput.java index 2b7be20..03d811c 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/ThingsModels/ThingsModelValuesOutput.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/model/ThingsModels/ThingsModelValuesOutput.java @@ -23,6 +23,9 @@ public class ThingsModelValuesOutput private int isShadow; + //测站号 + private String stationNumber; + /** 设备ID **/ private String serialNumber; diff --git a/fastbee-service/fastbee-iot-service/src/main/resources/mapper/iot/DeviceMapper.xml b/fastbee-service/fastbee-iot-service/src/main/resources/mapper/iot/DeviceMapper.xml index 404a85b..00bc857 100644 --- a/fastbee-service/fastbee-iot-service/src/main/resources/mapper/iot/DeviceMapper.xml +++ b/fastbee-service/fastbee-iot-service/src/main/resources/mapper/iot/DeviceMapper.xml @@ -97,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -1015,7 +1016,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" tenant_name=#{tenantName}, longitude=#{longitude}, latitude=#{latitude}, - img_url=#{imgUrl} + img_url=#{imgUrl}, where serial_number = #{serialNumber} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/NgIrrigationArea.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/NgIrrigationArea.java new file mode 100644 index 0000000..a3fa6ec --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/NgIrrigationArea.java @@ -0,0 +1,58 @@ +package com.fastbee.rechargecard.domain; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.fastbee.common.annotation.Excel; +import com.fastbee.common.core.domain.BaseEntity; + +/** + * 灌区对象 ng_Irrigation_area + * + * @author kerwincui + * @date 2024-12-26 + */ +@ApiModel(value = "NgIrrigationArea",description = "灌区 ng_Irrigation_area") +@Data +@EqualsAndHashCode(callSuper = true) +public class NgIrrigationArea extends BaseEntity + { +private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 灌区名称 */ + @Excel(name = "灌区名称") + @ApiModelProperty("灌区名称") + private String name; + + /** 商户号 */ + @Excel(name = "商户号") + @ApiModelProperty("商户号") + private String merchantId; + + /** 商户api证书序列号 */ + @Excel(name = "商户api证书序列号") + @ApiModelProperty("商户api证书序列号") + private String serialNo; + + /** 商户apiv3密钥 */ + @Excel(name = "商户apiv3密钥") + @ApiModelProperty("商户apiv3密钥") + private String apiv3Key; + + /** 微信支付公钥 */ + @Excel(name = "微信支付公钥") + @ApiModelProperty("微信支付公钥") + private String publicKey; + + /** 商户API私钥 */ + @Excel(name = "商户API私钥") + @ApiModelProperty("商户API私钥") + private String privateKey; + +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/NgIrrigationAreaMapper.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/NgIrrigationAreaMapper.java new file mode 100644 index 0000000..07e7505 --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/NgIrrigationAreaMapper.java @@ -0,0 +1,61 @@ +package com.fastbee.rechargecard.mapper; + +import java.util.List; +import com.fastbee.rechargecard.domain.NgIrrigationArea; + +/** + * 灌区Mapper接口 + * + * @author kerwincui + * @date 2024-12-26 + */ +public interface NgIrrigationAreaMapper +{ + /** + * 查询灌区 + * + * @param id 灌区主键 + * @return 灌区 + */ + public NgIrrigationArea selectNgIrrigationAreaById(Long id); + + /** + * 查询灌区列表 + * + * @param ngIrrigationArea 灌区 + * @return 灌区集合 + */ + public List selectNgIrrigationAreaList(NgIrrigationArea ngIrrigationArea); + + /** + * 新增灌区 + * + * @param ngIrrigationArea 灌区 + * @return 结果 + */ + public int insertNgIrrigationArea(NgIrrigationArea ngIrrigationArea); + + /** + * 修改灌区 + * + * @param ngIrrigationArea 灌区 + * @return 结果 + */ + public int updateNgIrrigationArea(NgIrrigationArea ngIrrigationArea); + + /** + * 删除灌区 + * + * @param id 灌区主键 + * @return 结果 + */ + public int deleteNgIrrigationAreaById(Long id); + + /** + * 批量删除灌区 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteNgIrrigationAreaByIds(Long[] ids); +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/NgWaterPumpUsageRecordsMapper.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/NgWaterPumpUsageRecordsMapper.java index 9d75719..6122513 100644 --- a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/NgWaterPumpUsageRecordsMapper.java +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/NgWaterPumpUsageRecordsMapper.java @@ -5,6 +5,7 @@ import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; /** * 水泵设备使用记录Mapper接口 @@ -23,6 +24,14 @@ public interface NgWaterPumpUsageRecordsMapper extends BaseMapper selectNgIrrigationAreaList(NgIrrigationArea ngIrrigationArea); + + /** + * 新增灌区 + * + * @param ngIrrigationArea 灌区 + * @return 结果 + */ + public int insertNgIrrigationArea(NgIrrigationArea ngIrrigationArea); + + /** + * 修改灌区 + * + * @param ngIrrigationArea 灌区 + * @return 结果 + */ + public int updateNgIrrigationArea(NgIrrigationArea ngIrrigationArea); + + /** + * 批量删除灌区 + * + * @param ids 需要删除的灌区主键集合 + * @return 结果 + */ + public int deleteNgIrrigationAreaByIds(Long[] ids); + + /** + * 删除灌区信息 + * + * @param id 灌区主键 + * @return 结果 + */ + public int deleteNgIrrigationAreaById(Long id); +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/INgWaterPumpUsageRecordsService.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/INgWaterPumpUsageRecordsService.java index b9ec2a7..a87d574 100644 --- a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/INgWaterPumpUsageRecordsService.java +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/INgWaterPumpUsageRecordsService.java @@ -1,5 +1,6 @@ package com.fastbee.rechargecard.service; +import java.util.HashMap; import java.util.List; import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords; @@ -18,7 +19,12 @@ public interface INgWaterPumpUsageRecordsService * @return 水泵设备使用记录 */ public NgWaterPumpUsageRecords selectNgWaterPumpUsageRecordsById(Long id); - + /** + * 查询水泵设备最细实时数据 + * @param deviceNumber 水泵设备编码 + * @return 水泵设备使用记录 + */ + public HashMap selectNgWaterPumpUsageDeviceNumber(String deviceNumber); /** * 查询水泵设备使用记录列表 * diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/IUserWechatPayService.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/IUserWechatPayService.java index 70cf8a8..c10e5b7 100644 --- a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/IUserWechatPayService.java +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/IUserWechatPayService.java @@ -16,4 +16,12 @@ public interface IUserWechatPayService { * @return */ public Map CreateOrder(WeChatRecharge recharge) throws Exception; + /** + * 获取openId + * @param code + * @return + */ + public Map GetOpenId(String code); + + } diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/NgIrrigationAreaServiceImpl.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/NgIrrigationAreaServiceImpl.java new file mode 100644 index 0000000..b6fe962 --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/NgIrrigationAreaServiceImpl.java @@ -0,0 +1,93 @@ +package com.fastbee.rechargecard.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.fastbee.rechargecard.mapper.NgIrrigationAreaMapper; +import com.fastbee.rechargecard.domain.NgIrrigationArea; +import com.fastbee.rechargecard.service.INgIrrigationAreaService; + +/** + * 灌区Service业务层处理 + * + * @author kerwincui + * @date 2024-12-26 + */ +@Service +public class NgIrrigationAreaServiceImpl implements INgIrrigationAreaService +{ + @Autowired + private NgIrrigationAreaMapper ngIrrigationAreaMapper; + + /** + * 查询灌区 + * + * @param id 灌区主键 + * @return 灌区 + */ + @Override + public NgIrrigationArea selectNgIrrigationAreaById(Long id) + { + return ngIrrigationAreaMapper.selectNgIrrigationAreaById(id); + } + + /** + * 查询灌区列表 + * + * @param ngIrrigationArea 灌区 + * @return 灌区 + */ + @Override + public List selectNgIrrigationAreaList(NgIrrigationArea ngIrrigationArea) + { + return ngIrrigationAreaMapper.selectNgIrrigationAreaList(ngIrrigationArea); + } + + /** + * 新增灌区 + * + * @param ngIrrigationArea 灌区 + * @return 结果 + */ + @Override + public int insertNgIrrigationArea(NgIrrigationArea ngIrrigationArea) + { + return ngIrrigationAreaMapper.insertNgIrrigationArea(ngIrrigationArea); + } + + /** + * 修改灌区 + * + * @param ngIrrigationArea 灌区 + * @return 结果 + */ + @Override + public int updateNgIrrigationArea(NgIrrigationArea ngIrrigationArea) + { + return ngIrrigationAreaMapper.updateNgIrrigationArea(ngIrrigationArea); + } + + /** + * 批量删除灌区 + * + * @param ids 需要删除的灌区主键 + * @return 结果 + */ + @Override + public int deleteNgIrrigationAreaByIds(Long[] ids) + { + return ngIrrigationAreaMapper.deleteNgIrrigationAreaByIds(ids); + } + + /** + * 删除灌区信息 + * + * @param id 灌区主键 + * @return 结果 + */ + @Override + public int deleteNgIrrigationAreaById(Long id) + { + return ngIrrigationAreaMapper.deleteNgIrrigationAreaById(id); + } +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/NgWaterPumpUsageRecordsServiceImpl.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/NgWaterPumpUsageRecordsServiceImpl.java index 6e5e2f8..4f0d0bf 100644 --- a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/NgWaterPumpUsageRecordsServiceImpl.java +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/NgWaterPumpUsageRecordsServiceImpl.java @@ -1,6 +1,14 @@ package com.fastbee.rechargecard.service.impl; +import java.util.HashMap; import java.util.List; +import java.util.Map; + +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.fastbee.common.utils.json.JsonStrUtil; +import com.fastbee.common.utils.json.JsonUtils; +import com.fastbee.iot.mapper.DeviceMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper; @@ -19,6 +27,8 @@ public class NgWaterPumpUsageRecordsServiceImpl implements INgWaterPumpUsageReco @Autowired private NgWaterPumpUsageRecordsMapper ngWaterPumpUsageRecordsMapper; + @Autowired + private DeviceMapper deviceMapper; /** * 查询水泵设备使用记录 * @@ -31,6 +41,43 @@ public class NgWaterPumpUsageRecordsServiceImpl implements INgWaterPumpUsageReco return ngWaterPumpUsageRecordsMapper.selectNgWaterPumpUsageRecordsById(id); } + /** + * 查询水泵设备最细实时数据 + * @param deviceNumber 水泵设备编码 + * @return 水泵设备使用记录 + */ + @Override + public HashMap selectNgWaterPumpUsageDeviceNumber(String deviceNumber) + { + + NgWaterPumpUsageRecords result = ngWaterPumpUsageRecordsMapper.selectNgWaterPumpUsageDeviceNumber(deviceNumber); + NgWaterPumpUsageRecords ngWaterPumpUsageRecords = new NgWaterPumpUsageRecords(); + System.err.println(result); + HashMap map = new HashMap(); + if (result != null) { + String message= result.getMessageContent(); + JSONObject jsonObject1 = JSONUtil.parseObj(message); + String jsonStr = jsonObject1.getStr("data"); + JSONObject jsonObject2 = JSONUtil.parseObj(jsonStr); + if (jsonObject2.getStr("meterIns")!=null){ + map.put("meterIns",jsonObject2.getStr("meterIns")); + }else { + map.put("meterIns",0); + } + if (jsonObject2.getStr("meterSum")!=null){ + map.put("meterSum",jsonObject2.getStr("meterSum")); + }else { + map.put("meterSum",0); + } + System.err.println(jsonStr); + return map; + } else { + map.put("meterIns",0); + map.put("meterSum",0); + return map; + } + } + /** * 查询水泵设备使用记录列表 * diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/UserWechatPayServiceImpl.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/UserWechatPayServiceImpl.java index 1a98513..349a227 100644 --- a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/UserWechatPayServiceImpl.java +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/UserWechatPayServiceImpl.java @@ -9,37 +9,47 @@ import com.fastbee.rechargecard.service.IUserConsumptionDetailsService; import com.fastbee.rechargecard.service.IUserRechargeCardsService; import com.fastbee.rechargecard.service.IUserWechatPayService; import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; import java.io.IOException; import java.security.PrivateKey; import java.security.Signature; -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; +import java.util.*; + @Service public class UserWechatPayServiceImpl implements IUserWechatPayService { /** 商户号 */ - public static String mchId = "1531795301"; + //public static String mchId = "1531795301"; + public static String mchId = "1503198881"; /** 商户API私钥文件路径 */ - public static String privateKeyPath = "fastbee-common/src/main/java/com/fastbee/common/utils/pay/apiclient_key.pem"; + //public static String privateKeyPath = "fastbee-common/src/main/java/com/fastbee/common/utils/pay/apiclient_key.pem"; + public static String privateKeyPath = "fastbee-common/src/main/java/com/fastbee/common/utils/pay/damogang_apiclient_key.pem"; /** 商户API证书序列号 */ - public static String serial_no = "3075B63EF52666EDC3EAFC5D4FB35C02CE123A9C"; + //public static String serial_no = "3075B63EF52666EDC3EAFC5D4FB35C02CE123A9C"; + public static String serial_no = "7A55F5763A002C749F1AB10E1D52DE6688DCDDC0"; /** 商户APIV3密钥 */ - public static String apiV3Key = "e85a203e8ca146102f5cd7ecff912580"; + //public static String apiV3Key = "e85a203e8ca146102f5cd7ecff912580"; + public static String apiV3Key = "damogangguanqunongcunyunshuizhex"; //微信小程序appid public static String appId="wx308612d2a8423311"; + //微信小程序appSecret + public static String appSecret="7f591f559929a3bf2dbea4e156b08ae9"; //微信支付公钥地址 - public static String publicKeyPath="fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem"; + //public static String publicKeyPath="fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem"; + //public static String publicKeyPath="fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem"; + //支付结果回调地址 + public static String notify_url="https://3e744f6.r3.cpolar.cn/pay/getresult";//https://3e744f6.r3.cpolar.cn @Override /** * 创建订单,获取prepay_id和paySign @@ -192,4 +202,39 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService { sign.update(message); return Base64.getEncoder().encodeToString(sign.sign()); } + + /** + * 获取openId + * @param code + * @return + */ + @Override + public Map GetOpenId(String code) + { + System.out.println(code); + //String url = String.format("https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code", appId, appSecret, code); + //String url="https://api.weixin.qq.com/sns/oauth2/access_token?appid="+appId+"&secret="+appSecret+"&code="+code+"&grant_type=authorization_code"; + String url="https://api.weixin.qq.com/sns/jscode2session?appid="+appId+"&secret="+appSecret+"&js_code="+code+"&grant_type=authorization_code"; + RestTemplate restTemplate = new RestTemplate(); + Map response = restTemplate.getForObject(url, Map.class); + + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpGet httpGet = new HttpGet(url); + try (CloseableHttpResponse response2 = httpClient.execute(httpGet)) { + String responseString = EntityUtils.toString(response2.getEntity()); + Map responseMap = JSONUtil.toBean(responseString, Map.class); + //打印出返回前端的所有参数 + // 获取键的集合 + Set keySet = responseMap.keySet(); + // 遍历键集合 + for (String key : keySet) { + System.out.println(key + ": " + responseMap.get(key)); + } + // 解析responseString以获取openid + return responseMap; // 这里返回的是整个响应字符串,需要自行解析出openid + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } } diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/resources/mapper/rechargecard/NgIrrigationAreaMapper.xml b/fastbee-service/fastbee-rechargecard-service/src/main/resources/mapper/rechargecard/NgIrrigationAreaMapper.xml new file mode 100644 index 0000000..bd8b12a --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/resources/mapper/rechargecard/NgIrrigationAreaMapper.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + select id, name, merchant_id, serial_no, apiv3_key, public_key, private_key from ng_Irrigation_area + + + + + + + + insert into ng_Irrigation_area + + name, + merchant_id, + serial_no, + apiv3_key, + public_key, + private_key, + + + #{name}, + #{merchantId}, + #{serialNo}, + #{apiv3Key}, + #{publicKey}, + #{privateKey}, + + + + + update ng_Irrigation_area + + name = #{name}, + merchant_id = #{merchantId}, + serial_no = #{serialNo}, + apiv3_key = #{apiv3Key}, + public_key = #{publicKey}, + private_key = #{privateKey}, + + where id = #{id} + + + + delete from ng_Irrigation_area where id = #{id} + + + + delete from ng_Irrigation_area where id in + + #{id} + + + \ No newline at end of file diff --git a/fastbee-service/fastbee-system-service/src/main/java/com/fastbee/system/service/impl/SysDeptServiceImpl.java b/fastbee-service/fastbee-system-service/src/main/java/com/fastbee/system/service/impl/SysDeptServiceImpl.java index 6c0d7a7..c4d979c 100644 --- a/fastbee-service/fastbee-system-service/src/main/java/com/fastbee/system/service/impl/SysDeptServiceImpl.java +++ b/fastbee-service/fastbee-system-service/src/main/java/com/fastbee/system/service/impl/SysDeptServiceImpl.java @@ -259,8 +259,13 @@ public class SysDeptServiceImpl implements ISysDeptService } //设置祖级别列表 dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); + //设置项目id - dept.setProjectId(Long.valueOf(ProjectHolder.getProjectInfo().getProjectId())); + String projectIdStr = ProjectHolder.getProjectInfo().getProjectId(); + if (projectIdStr != null && !projectIdStr.isEmpty()) { + dept.setProjectId(Long.valueOf(projectIdStr)); + } + //dept.setProjectId(Long.valueOf(ProjectHolder.getProjectInfo().getProjectId())); //处理机构所管理行政区划信息 parseAdministrativeDivisionInfo(dept); dept.setCreateTime(DateUtils.getNowDate());