获取openId接口

This commit is contained in:
小魔仙~
2024-12-26 19:05:03 +08:00
parent efd0fa1e44
commit 8ea671775e
25 changed files with 728 additions and 20 deletions

View File

@ -30,6 +30,7 @@ import java.util.List;
public class BaseController { public class BaseController {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource @Resource
private RedisCache redisCache; private RedisCache redisCache;

View File

@ -1,5 +1,6 @@
package com.fastbee.common.utils; package com.fastbee.common.utils;
import com.fastbee.common.core.page.TableDataInfo;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.fastbee.common.core.page.PageDomain; import com.fastbee.common.core.page.PageDomain;
import com.fastbee.common.core.page.TableSupport; import com.fastbee.common.core.page.TableSupport;
@ -22,7 +23,8 @@ public class PageUtils extends PageHelper
Integer pageSize = pageDomain.getPageSize(); Integer pageSize = pageDomain.getPageSize();
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
Boolean reasonable = pageDomain.getReasonable(); Boolean reasonable = pageDomain.getReasonable();
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable); PageHelper.startPage(pageNum, pageSize, orderBy)
.setReasonable(reasonable);
} }
/** /**

View File

@ -1,3 +1,9 @@
-----BEGIN PUBLIC KEY----- -----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----- -----END PUBLIC KEY-----

View File

@ -62,6 +62,5 @@ public class wxPayConfig {
} }
return fileContent.toString(); return fileContent.toString();
} }
// 这里可以添加其他与微信支付相关的配置方法 // 这里可以添加其他与微信支付相关的配置方法
} }

View File

@ -51,7 +51,10 @@ public class DeviceReportInfoController extends BaseController
public TableDataInfo list(DeviceReportInfo deviceReportInfo) public TableDataInfo list(DeviceReportInfo deviceReportInfo)
{ {
startPage(); startPage();
List<DeviceReportInfo> list = deviceReportInfoService.selectDeviceReportInfoList(deviceReportInfo); List<DeviceReportInfo> list = deviceReportInfoService.selectDeviceReportInfoList(deviceReportInfo);
//查询设备在线状态 //查询设备在线状态
list.forEach(d->{ list.forEach(d->{
if(d.getType()==1){ if(d.getType()==1){
@ -67,6 +70,7 @@ public class DeviceReportInfoController extends BaseController
} }
}); });
return getDataTable(list); return getDataTable(list);
} }
//统计是设备相关信息 //统计是设备相关信息

View File

@ -52,6 +52,22 @@ import static com.fastbee.rechargecard.service.impl.UserWechatPayServiceImpl.api
@RestController @RestController
@RequestMapping("/pay") @RequestMapping("/pay")
public class WeChatPayController extends BaseController { 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 @Autowired
private INgUserRechargeRecordsService ngUserRechargeRecordsService; private INgUserRechargeRecordsService ngUserRechargeRecordsService;
@ -62,6 +78,36 @@ public class WeChatPayController extends BaseController {
@Autowired @Autowired
private IUserWechatPayService userWechatPayService; private IUserWechatPayService userWechatPayService;
/**
* 获取openId
* @param code
* @return
*/
@ApiOperation("获取openId")
@PostMapping("/getOpenId")
public Map<String,Object> BuildOrder(@RequestBody String code)
{
Map<String ,Object> result=userWechatPayService.GetOpenId(code);
Map<String,Object> 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 登录结果 * @return 登录结果
@ -140,14 +186,23 @@ public class WeChatPayController extends BaseController {
* responseBody 应答报文主体 * responseBody 应答报文主体
* publicKey 微信支付公钥PEM 格式,去掉头尾并解码为二进制) * 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); boolean isVerified = verifySignature(wechatpaySignature, wechatpayTimestamp, wechatpayNonce, json, publicKey);
if (isVerified) { if (isVerified) {
System.out.println("签名验证成功"); System.out.println("签名验证成功");
} else { } else {
System.out.println("签名验证失败"); System.out.println("签名验证失败");
return error("签名验证失败"); responseBody.put("code", "FAIL");
responseBody.put("message", "签名验证失败");
// 返回500状态码以及符合要求的应答报文
return new ResponseEntity<>(responseBody, HttpStatus.INTERNAL_SERVER_ERROR);
//return error("签名验证失败");
}*/ }*/
//使用apiv3key解密 //使用apiv3key解密
String decryptData=""; String decryptData="";
try{ try{
@ -212,7 +267,4 @@ public class WeChatPayController extends BaseController {
//return error("修改数据库失败"); //return error("修改数据库失败");
} }
} }

View File

@ -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<NgIrrigationArea> list = ngIrrigationAreaService.selectNgIrrigationAreaList(ngIrrigationArea);
return getDataTable(list);
}
/**
* 导出灌区列表
*/
@ApiOperation("导出灌区列表")
@PreAuthorize("@ss.hasPermi('rechargecard:area:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, NgIrrigationArea ngIrrigationArea)
{
List<NgIrrigationArea> list = ngIrrigationAreaService.selectNgIrrigationAreaList(ngIrrigationArea);
ExcelUtil<NgIrrigationArea> util = new ExcelUtil<NgIrrigationArea>(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));
}
}

View File

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

View File

@ -200,6 +200,11 @@ public class Device extends BaseEntity
@ApiModelProperty("设备型号") @ApiModelProperty("设备型号")
private String deviceModel; private String deviceModel;
/** 测站号 */
/*@Excel(name = "测站号")
@ApiModelProperty("测站号")
private String stationNumber;*/
/** /**
* 关联组态,来源产品 * 关联组态,来源产品
*/ */

View File

@ -45,6 +45,8 @@ public class DeviceAllShortOutput
/** wifi信号强度信号极好4格[-55— 0]信号好3格[-70— -55]信号一般2格[-85— -70]信号差1格[-100— -85] */ /** wifi信号强度信号极好4格[-55— 0]信号好3格[-70— -55]信号一般2格[-85— -70]信号差1格[-100— -85] */
private Integer rssi; private Integer rssi;
/** 测站号*/
private String stationNumber;
/** 激活时间 */ /** 激活时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")

View File

@ -17,6 +17,11 @@ public class DeviceMqttVO {
*/ */
private String serialNumber; private String serialNumber;
/**
* 测站号
*/
private String stationNumber;
/** /**
* 产品id * 产品id
*/ */

View File

@ -20,6 +20,9 @@ public class ProductAuthenticateModel implements Serializable {
/** 产品ID */ /** 产品ID */
private Long productId; private Long productId;
/** 测站号 */
private String stationNumber;
/** 产品名称 */ /** 产品名称 */
private String productName; private String productName;

View File

@ -23,6 +23,9 @@ public class ThingsModelValuesOutput
private int isShadow; private int isShadow;
//测站号
private String stationNumber;
/** 设备ID **/ /** 设备ID **/
private String serialNumber; private String serialNumber;

View File

@ -97,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="tel" column="tel" /> <result property="tel" column="tel" />
<result property="caretaker" column="caretaker" /> <result property="caretaker" column="caretaker" />
<result property="managementUnit" column="management_unit" /> <result property="managementUnit" column="management_unit" />
<result property="managementUnit" column="management_unit" />
</resultMap> </resultMap>
<resultMap type="com.fastbee.iot.model.UserAndTenant" id="UserAndTenantResult"> <resultMap type="com.fastbee.iot.model.UserAndTenant" id="UserAndTenantResult">
@ -1015,7 +1016,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tenant_name=#{tenantName}, tenant_name=#{tenantName},
longitude=#{longitude}, longitude=#{longitude},
latitude=#{latitude}, latitude=#{latitude},
img_url=#{imgUrl} img_url=#{imgUrl},
where serial_number = #{serialNumber} where serial_number = #{serialNumber}
</update> </update>

View File

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

View File

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

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords; import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
/** /**
* 水泵设备使用记录Mapper接口 * 水泵设备使用记录Mapper接口
@ -23,6 +24,14 @@ public interface NgWaterPumpUsageRecordsMapper extends BaseMapper<NgWaterPumpUsa
*/ */
public NgWaterPumpUsageRecords selectNgWaterPumpUsageRecordsById(Long id); public NgWaterPumpUsageRecords selectNgWaterPumpUsageRecordsById(Long id);
/**
* 查询水泵设备最细实时数据
* @param deviceNumber 水泵设备编码
* @return 水泵设备使用记录
*/
@Select("SELECT * FROM ng_water_pump_usage_records WHERE" +
" device_number=#{deviceNumber} ORDER BY pump_start_time DESC LIMIT 1")
public NgWaterPumpUsageRecords selectNgWaterPumpUsageDeviceNumber(String deviceNumber);
/** /**
* 查询水泵设备使用记录列表 * 查询水泵设备使用记录列表
* *

View File

@ -0,0 +1,61 @@
package com.fastbee.rechargecard.service;
import java.util.List;
import com.fastbee.rechargecard.domain.NgIrrigationArea;
/**
* 灌区Service接口
*
* @author kerwincui
* @date 2024-12-26
*/
public interface INgIrrigationAreaService
{
/**
* 查询灌区
*
* @param id 灌区主键
* @return 灌区
*/
public NgIrrigationArea selectNgIrrigationAreaById(Long id);
/**
* 查询灌区列表
*
* @param ngIrrigationArea 灌区
* @return 灌区集合
*/
public List<NgIrrigationArea> 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);
}

View File

@ -1,5 +1,6 @@
package com.fastbee.rechargecard.service; package com.fastbee.rechargecard.service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords; import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords;
@ -18,7 +19,12 @@ public interface INgWaterPumpUsageRecordsService
* @return 水泵设备使用记录 * @return 水泵设备使用记录
*/ */
public NgWaterPumpUsageRecords selectNgWaterPumpUsageRecordsById(Long id); public NgWaterPumpUsageRecords selectNgWaterPumpUsageRecordsById(Long id);
/**
* 查询水泵设备最细实时数据
* @param deviceNumber 水泵设备编码
* @return 水泵设备使用记录
*/
public HashMap<String,Object> selectNgWaterPumpUsageDeviceNumber(String deviceNumber);
/** /**
* 查询水泵设备使用记录列表 * 查询水泵设备使用记录列表
* *

View File

@ -16,4 +16,12 @@ public interface IUserWechatPayService {
* @return * @return
*/ */
public Map<String,String> CreateOrder(WeChatRecharge recharge) throws Exception; public Map<String,String> CreateOrder(WeChatRecharge recharge) throws Exception;
/**
* 获取openId
* @param code
* @return
*/
public Map<String,Object> GetOpenId(String code);
} }

View File

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

View File

@ -1,6 +1,14 @@
package com.fastbee.rechargecard.service.impl; package com.fastbee.rechargecard.service.impl;
import java.util.HashMap;
import java.util.List; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper; import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper;
@ -19,6 +27,8 @@ public class NgWaterPumpUsageRecordsServiceImpl implements INgWaterPumpUsageReco
@Autowired @Autowired
private NgWaterPumpUsageRecordsMapper ngWaterPumpUsageRecordsMapper; private NgWaterPumpUsageRecordsMapper ngWaterPumpUsageRecordsMapper;
@Autowired
private DeviceMapper deviceMapper;
/** /**
* 查询水泵设备使用记录 * 查询水泵设备使用记录
* *
@ -31,6 +41,43 @@ public class NgWaterPumpUsageRecordsServiceImpl implements INgWaterPumpUsageReco
return ngWaterPumpUsageRecordsMapper.selectNgWaterPumpUsageRecordsById(id); return ngWaterPumpUsageRecordsMapper.selectNgWaterPumpUsageRecordsById(id);
} }
/**
* 查询水泵设备最细实时数据
* @param deviceNumber 水泵设备编码
* @return 水泵设备使用记录
*/
@Override
public HashMap<String,Object> selectNgWaterPumpUsageDeviceNumber(String deviceNumber)
{
NgWaterPumpUsageRecords result = ngWaterPumpUsageRecordsMapper.selectNgWaterPumpUsageDeviceNumber(deviceNumber);
NgWaterPumpUsageRecords ngWaterPumpUsageRecords = new NgWaterPumpUsageRecords();
System.err.println(result);
HashMap<String,Object> map = new HashMap<String,Object>();
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;
}
}
/** /**
* 查询水泵设备使用记录列表 * 查询水泵设备使用记录列表
* *

View File

@ -9,37 +9,47 @@ import com.fastbee.rechargecard.service.IUserConsumptionDetailsService;
import com.fastbee.rechargecard.service.IUserRechargeCardsService; import com.fastbee.rechargecard.service.IUserRechargeCardsService;
import com.fastbee.rechargecard.service.IUserWechatPayService; import com.fastbee.rechargecard.service.IUserWechatPayService;
import org.apache.http.client.methods.CloseableHttpResponse; 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.client.methods.HttpPost;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.io.IOException; import java.io.IOException;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.Signature; import java.security.Signature;
import java.util.Base64; import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@Service @Service
public class UserWechatPayServiceImpl implements IUserWechatPayService { public class UserWechatPayServiceImpl implements IUserWechatPayService {
/** 商户号 */ /** 商户号 */
public static String mchId = "1531795301"; //public static String mchId = "1531795301";
public static String mchId = "1503198881";
/** 商户API私钥文件路径 */ /** 商户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证书序列号 */ /** 商户API证书序列号 */
public static String serial_no = "3075B63EF52666EDC3EAFC5D4FB35C02CE123A9C"; //public static String serial_no = "3075B63EF52666EDC3EAFC5D4FB35C02CE123A9C";
public static String serial_no = "7A55F5763A002C749F1AB10E1D52DE6688DCDDC0";
/** 商户APIV3密钥 */ /** 商户APIV3密钥 */
public static String apiV3Key = "e85a203e8ca146102f5cd7ecff912580"; //public static String apiV3Key = "e85a203e8ca146102f5cd7ecff912580";
public static String apiV3Key = "damogangguanqunongcunyunshuizhex";
//微信小程序appid //微信小程序appid
public static String appId="wx308612d2a8423311"; 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 @Override
/** /**
* 创建订单获取prepay_id和paySign * 创建订单获取prepay_id和paySign
@ -192,4 +202,39 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
sign.update(message); sign.update(message);
return Base64.getEncoder().encodeToString(sign.sign()); return Base64.getEncoder().encodeToString(sign.sign());
} }
/**
* 获取openId
* @param code
* @return
*/
@Override
public Map<String, Object> 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<String, String> 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<String, Object> responseMap = JSONUtil.toBean(responseString, Map.class);
//打印出返回前端的所有参数
// 获取键的集合
Set<String> 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);
}
}
} }

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fastbee.rechargecard.mapper.NgIrrigationAreaMapper">
<resultMap type="NgIrrigationArea" id="NgIrrigationAreaResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="merchantId" column="merchant_id" />
<result property="serialNo" column="serial_no" />
<result property="apiv3Key" column="apiv3_key" />
<result property="publicKey" column="public_key" />
<result property="privateKey" column="private_key" />
</resultMap>
<sql id="selectNgIrrigationAreaVo">
select id, name, merchant_id, serial_no, apiv3_key, public_key, private_key from ng_Irrigation_area
</sql>
<select id="selectNgIrrigationAreaList" parameterType="NgIrrigationArea" resultMap="NgIrrigationAreaResult">
<include refid="selectNgIrrigationAreaVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="merchantId != null and merchantId != ''"> and merchant_id = #{merchantId}</if>
<if test="serialNo != null and serialNo != ''"> and serial_no = #{serialNo}</if>
<if test="apiv3Key != null and apiv3Key != ''"> and apiv3_key = #{apiv3Key}</if>
<if test="publicKey != null and publicKey != ''"> and public_key = #{publicKey}</if>
<if test="privateKey != null and privateKey != ''"> and private_key = #{privateKey}</if>
</where>
</select>
<select id="selectNgIrrigationAreaById" parameterType="Long" resultMap="NgIrrigationAreaResult">
<include refid="selectNgIrrigationAreaVo"/>
where id = #{id}
</select>
<insert id="insertNgIrrigationArea" parameterType="NgIrrigationArea" useGeneratedKeys="true" keyProperty="id">
insert into ng_Irrigation_area
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="merchantId != null">merchant_id,</if>
<if test="serialNo != null">serial_no,</if>
<if test="apiv3Key != null">apiv3_key,</if>
<if test="publicKey != null">public_key,</if>
<if test="privateKey != null">private_key,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="merchantId != null">#{merchantId},</if>
<if test="serialNo != null">#{serialNo},</if>
<if test="apiv3Key != null">#{apiv3Key},</if>
<if test="publicKey != null">#{publicKey},</if>
<if test="privateKey != null">#{privateKey},</if>
</trim>
</insert>
<update id="updateNgIrrigationArea" parameterType="NgIrrigationArea">
update ng_Irrigation_area
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="merchantId != null">merchant_id = #{merchantId},</if>
<if test="serialNo != null">serial_no = #{serialNo},</if>
<if test="apiv3Key != null">apiv3_key = #{apiv3Key},</if>
<if test="publicKey != null">public_key = #{publicKey},</if>
<if test="privateKey != null">private_key = #{privateKey},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteNgIrrigationAreaById" parameterType="Long">
delete from ng_Irrigation_area where id = #{id}
</delete>
<delete id="deleteNgIrrigationAreaByIds" parameterType="String">
delete from ng_Irrigation_area where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -259,8 +259,13 @@ public class SysDeptServiceImpl implements ISysDeptService
} }
//设置祖级别列表 //设置祖级别列表
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
//设置项目id //设置项目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); parseAdministrativeDivisionInfo(dept);
dept.setCreateTime(DateUtils.getNowDate()); dept.setCreateTime(DateUtils.getNowDate());