pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIntakeOperateMapper.java
@@ -39,6 +39,14 @@ int updateByCommandId(@Param("commandId") Long commandId, @Param("commandResult") Byte commandResult, @Param("failureFactors") String failureFactors); /** * 根据主键修改命令ID * @param commandId * @param id * @return */ int updateCommandId(@Param("commandId") Long commandId, @Param("id") Long id); /** * 根据计划ID获取待终止的取水口ID(已发布开发命令,无论是否成功) * @param planId * @return pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeControllerMapper.java
@@ -59,4 +59,11 @@ * @return */ int updateByIntakeSelective(PrIntakeController record); /** * 根据取水口ID获取取水口名称 * @param intakeId * @return */ String getIntakeNameById(@Param("intakeId") Long intakeId); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoTermActiveCard.java
New file @@ -0,0 +1,36 @@ package com.dy.pipIrrGlobal.voSe; import com.alibaba.fastjson2.annotation.JSONField; import com.alibaba.fastjson2.writer.ObjectWriterImplToString; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import lombok.Data; import java.util.Date; /** * @author ZhuBaoMin * @date 2025-06-04 11:45 * @LastEditTime 2025-06-04 11:45 * @Description 充值机开卡返回视图对象 */ @Data @JsonPropertyOrder({"projectNo", "cardNum", "balance", "waterPrice", "time", "orderNo"}) public class VoTermActiveCard { public static final long serialVersionUID = 202506041146001L; private Integer projectNo; @JSONField(serializeUsing= ObjectWriterImplToString.class) private Long cardNum; private Float balance; private Double waterPrice; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date time; private String orderNo; } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoTermRecharge.java
@@ -12,11 +12,11 @@ * @author ZhuBaoMin * @date 2025-05-08 15:59 * @LastEditTime 2025-05-08 15:59 * @Description * @Description 充值机充值返回视图对象 */ @Data @JsonPropertyOrder({"projectNo", "cardNum", "balance", "waterPrice", "time", "orderNo"}) @JsonPropertyOrder({"projectNo", "cardNum", "orderNo"}) public class VoTermRecharge { public static final long serialVersionUID = 202505081559001L; @@ -24,13 +24,6 @@ @JSONField(serializeUsing= ObjectWriterImplToString.class) private Long cardNum; private Float balance; private Double waterPrice; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date time; private String orderNo; } pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -85,7 +85,7 @@ pipIrr: global: dev: false #是否开发阶段,true或false dev: true #是否开发阶段,true或false dsName: ym #开发阶段,设置临时的数据库名称 nginx: root: D:/apps/pipIrr/nginx-1.27.0 pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIntakeOperateMapper.xml
@@ -156,6 +156,13 @@ where command_id = #{commandId} </update> <!--根据主键修改命令ID--> <update id="updateCommandId"> update ir_intake_operate set command_id = #{commandId} where id = #{id} </update> <!--根据计划ID获取待终止的取水口ID(已发布开发命令,无论是否成功)--> <select id="getToTerminateIntakeIds" resultType="java.lang.Long"> SELECT pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
@@ -434,7 +434,7 @@ FROM ir_irrigate_schedule sche INNER JOIN ir_plan_schedule ps ON schedule_id = sche.id WHERE ps.plan_id = #{planId} LIMIT 1 <!-- LIMIT 1--> ) AS has_intersection </select> pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeControllerMapper.xml
@@ -210,4 +210,9 @@ </set> where intakeId = #{intakeid,jdbcType=BIGINT} </update> <!--根据取水口ID获取取水口名称--> <select id="getIntakeNameById" resultType="java.lang.String"> SELECT name AS intakeName FROM pr_intake WHERE id = #{intakeId} </select> </mapper> pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java
@@ -3,14 +3,15 @@ import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.pipIrrGlobal.voSe.VoTermActiveCard; import com.dy.pipIrrGlobal.voSe.VoTermRecharge; import com.dy.pipIrrTerminal.card.dto.ActiveCard; import io.swagger.v3.oas.annotations.tags.Tag; import com.dy.pipIrrTerminal.card.dto.DtoRecharge; import com.dy.pipIrrTerminal.card.dto.DtoReissue; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -34,10 +35,15 @@ public class CardCtrl { private final CardSv cardSv; @PostMapping(path = "activeTermCard", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) /** * 开卡(含充值) * @param po * @param bindingResult * @return */ @PostMapping(path = "termActiveCard", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<VoTermRecharge> activeTermCard(@RequestBody @Valid ActiveCard po, BindingResult bindingResult) { public BaseResponse<VoTermActiveCard> termActiveCard(@RequestBody @Valid ActiveCard po, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } @@ -49,4 +55,46 @@ return BaseResponseUtils.buildSuccess(map_result.get("content")) ; } /** * 充值 * @param po * @param bindingResult * @return */ @PostMapping(path = "termRecharge", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<VoTermRecharge> termRecharge(@RequestBody @Valid DtoRecharge po, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } Map map_result = cardSv.addRecharge(po); if(map_result.get("success").equals(false)) { return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); } return BaseResponseUtils.buildSuccess(map_result.get("content")) ; } /** * 补卡 * @param po * @param bindingResult * @return */ @PostMapping(path = "termReissue", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<VoTermRecharge> termReissue(@RequestBody @Valid DtoReissue po, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } Map map_result = cardSv.reissue(po); if(map_result.get("success").equals(false)) { return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); } return BaseResponseUtils.buildSuccess(map_result.get("content")) ; } } pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardSv.java
@@ -1,22 +1,28 @@ package com.dy.pipIrrTerminal.card; import com.dy.common.webUtil.BaseResponse; import com.dy.pipIrrGlobal.daoPr.PrWaterPriceMapper; import com.dy.pipIrrGlobal.daoSe.SeCardOperateMapper; import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper; import com.dy.pipIrrGlobal.daoSe.SeClientMapper; import com.dy.pipIrrGlobal.daoSe.SeRechargeHistoryMapper; import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; import com.dy.pipIrrGlobal.pojoSe.SeClientCard; import com.dy.pipIrrGlobal.pojoSe.SeRechargeHistory; import com.dy.pipIrrGlobal.voSe.VoTermActiveCard; import com.dy.pipIrrGlobal.voSe.VoTermRecharge; import com.dy.pipIrrTerminal.card.dto.ActiveCard; import com.dy.pipIrrTerminal.card.dto.CardSimple; import com.dy.pipIrrTerminal.card.dto.DtoRecharge; import com.dy.pipIrrTerminal.card.dto.DtoReissue; import com.dy.pipIrrTerminal.card.enums.CardStateENUM; import com.dy.pipIrrTerminal.card.enums.LastOperateENUM; import com.dy.pipIrrTerminal.card.enums.OperateTypeENUM; import com.dy.pipIrrTerminal.card.enums.RechargeTypeENUM; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -44,6 +50,9 @@ @Autowired private PrWaterPriceMapper prWaterPriceMapper; @Autowired private SeRechargeHistoryMapper seRechargeHistoryMapper; @Value("${project.projectNo}") private Integer projectNo; @@ -66,6 +75,70 @@ } return false; } /** * 根据水卡编号判断该卡是否可以充值 * @param po * @return true:可以充值 */ public Map canRecharge(DtoRecharge po) { Map map = new HashMap<>(); map.put("success", false); map.put("content", null); String stateName = Optional.ofNullable(seClientCardMapper.getCardStateByCardNum(po.getCardNum())).orElse(""); // 单独充值时卡片必须为正常 if((po.getRechargeType() == RechargeTypeENUM.RECHARGE.getCode()) && !stateName.equals("正常")) { map.put("msg", stateName + ", " + "水卡状态不支持当前操作"); return map; } map.put("success", true); return map; } /** * 根据水卡编号判断该卡是否可以补卡 * @param po * @return true:可以补卡 */ public Map canReissue(DtoReissue po) { Map map = new HashMap<>(); map.put("success", false); map.put("content", null); Long cardNum = po.getCardNum(); Integer lostCount = seClientCardMapper.getLostCount(cardNum); Integer replacedCount = seClientCardMapper.getReplacedCount(cardNum); if(lostCount == 0 || replacedCount > 0) { map.put("msg", "水卡未挂失或已补卡,不能补卡"); return map; } Float reissueAmount = po.getReissueAmount(); if (reissueAmount != null && reissueAmount > 0) { Double tradeAmount = seCardOperateMapper.getTradeAmountByCardNo(cardNum); if (tradeAmount != null && tradeAmount > 0) { map.put("msg", "原卡挂失时已退款,补卡时不能补费用"); return map; } } Map map_card = Optional.ofNullable(seClientCardMapper.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if (map_card == null || map_card.size() <= 0) { map.put("msg", "卡号错误,该卡不存在"); return map; } CardSimple card = new CardSimple(); card.setCardId(Long.parseLong(map_card.get("cardId").toString())); card.setClientId(Long.parseLong(map_card.get("clientId").toString())); card.setProtocol(map_card.get("protocol").toString()); map.put("success", true); map.put("content", card); return map; } /** @@ -124,7 +197,6 @@ } return dtf.format(dateTime) + sb.toString(); } public Map addCardAndOperate(ActiveCard po, Long cardNum, String orderNo) { Map map = new HashMap<>(); @@ -188,11 +260,20 @@ return map; } /** * 开卡附加充值 * @param po * @param cardNum * @return */ public Map plusRecharge(ActiveCard po, Long cardNum) { Map map = new HashMap<>(); map.put("success", false); map.put("content", null); /** * 添加水卡操作记录 */ DtoRecharge dtoRecharge = new DtoRecharge(); dtoRecharge.setCardNum(cardNum); dtoRecharge.setAmount(po.getAmount()); @@ -202,17 +283,21 @@ dtoRecharge.setMoney(0f); dtoRecharge.setGift(0f); dtoRecharge.setPrice(0f); //BaseResponse<Boolean> job = cardOperateSv.addRecharge(dtoRecharge); BaseResponse<Boolean> job = null; if (!job.getCode().equals("0001")) { Map map_plusRecharge = addRecharge(dtoRecharge); if (!map_plusRecharge.get("success").equals(true)) { map.put("msg", "开卡失败-充值异常"); return map; } map.put("success", true); return map; } /** * 激活或补卡 * @param po * @return */ @Transactional(rollbackFor = Exception.class) public Map activeOrReissueTermCard(ActiveCard po) { Map map = new HashMap<>(); map.put("success", false); @@ -250,12 +335,100 @@ Float balance = Optional.ofNullable(seClientCardMapper.getMoneyByCardNum(cardNum)).orElse(0f); Double waterPrice = prWaterPriceMapper.getPrice(); VoTermActiveCard voTermActiveCard = new VoTermActiveCard(); voTermActiveCard.setProjectNo(projectNo); voTermActiveCard.setCardNum(cardNum); voTermActiveCard.setBalance(balance); voTermActiveCard.setWaterPrice(waterPrice); voTermActiveCard.setTime(new Date()); voTermActiveCard.setOrderNo(orderNo); map.put("success", true); map.put("msg", "操作成功"); map.put("content", voTermActiveCard); return map; } /** * 充值 * @param po * @return */ @Transactional(rollbackFor = Exception.class) public Map addRecharge(DtoRecharge po) { Map map = new HashMap<>(); map.put("success", false); map.put("content", null); Map map_canRecharge = canRecharge(po); if(map_canRecharge.get("success").equals(false)) { map.put("msg", map_canRecharge.get("msg").toString()); return map; } /** * 依据水卡编号获取水卡表主键及农户编号 */ Map map_cardAndClient = seClientCardMapper.getCardIdAndClientNum(po.getCardNum()); if (map_cardAndClient == null || map_cardAndClient.size() <= 0) { map.put("msg", "卡号错误,该卡不存在"); return map; } Long cardId = Long.parseLong(map_cardAndClient.get("cardId").toString()); Long clientId = Long.parseLong(map_cardAndClient.get("clientId").toString()); String orderNo = generateOrderNo(); /** * 添加水卡充值操作记录 */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setMoney(po.getMoney()); seCardOperate.setTradeAmount(po.getAmount()); seCardOperate.setGift(po.getGift()); seCardOperate.setOperateType(OperateTypeENUM.RECHARGE.getCode()); seCardOperate.setPaymentId(po.getPaymentId()); seCardOperate.setPrice(po.getPrice()); seCardOperate.setRemarks(po.getRemarks()); seCardOperate.setOperator(po.getOperator()); seCardOperate.setOperateDt(new Date()); seCardOperate.setOrderNo(orderNo); seCardOperate.setOperateValid((byte) 1); seCardOperateMapper.insert(seCardOperate); Long rec = Optional.ofNullable(seCardOperate.getId()).orElse(0L); if (rec == 0) { map.put("msg", "充值失败-充值记录写入异常"); return map; } /** * 添加充值历史记录 */ SeRechargeHistory seRechargeHistory = new SeRechargeHistory(); seRechargeHistory.setCardid(cardId); seRechargeHistory.setClientid(clientId); seRechargeHistory.setMoney(po.getMoney()); seRechargeHistory.setAmount(po.getAmount()); seRechargeHistory.setGift(po.getGift()); Float afterRecharge = po.getMoney() + po.getAmount() + po.getGift(); seRechargeHistory.setAfterrecharge(afterRecharge); seRechargeHistory.setPaymentid(po.getPaymentId()); seRechargeHistory.setPrice(po.getPrice()); seRechargeHistory.setRemarks(po.getRemarks()); seRechargeHistory.setOperator(po.getOperator()); seRechargeHistory.setOperatedt(new Date()); seRechargeHistory.setOperateValid((byte) 1); seRechargeHistoryMapper.insert(seRechargeHistory); Long rec_seRechargeHistory = Optional.ofNullable(seRechargeHistory.getId()).orElse(0L); if (rec_seRechargeHistory == 0) { map.put("msg", "充值失败-充值历史记录写入异常"); return map; } VoTermRecharge voTermRecharge = new VoTermRecharge(); voTermRecharge.setProjectNo(projectNo); voTermRecharge.setCardNum(cardNum); voTermRecharge.setBalance(balance); voTermRecharge.setWaterPrice(waterPrice); voTermRecharge.setTime(new Date()); voTermRecharge.setCardNum(po.getCardNum()); voTermRecharge.setOrderNo(orderNo); map.put("success", true); @@ -264,4 +437,47 @@ return map; } /** * 补卡 * @param po * @return */ @Transactional(rollbackFor = Exception.class) public Map reissue(DtoReissue po) { Map map = new HashMap<>(); map.put("success", false); map.put("content", null); Map map_canReissue = canReissue(po); if(map_canReissue.get("success").equals(false)) { map.put("msg", map_canReissue.get("msg").toString()); return map; } CardSimple card = (CardSimple) map_canReissue.get("content"); Long cardId = card.getCardId(); Long clientId = card.getClientId(); String protocol = card.getProtocol(); /** * 添加开卡记录,退还金额冲到新卡中 */ ActiveCard activeCard = new ActiveCard(); activeCard.setProtocol(protocol); activeCard.setCardAddr(po.getCardAddr()); activeCard.setClientId(clientId); activeCard.setOriginalCardId(cardId); activeCard.setCardCost(po.getCardCost()); activeCard.setAmount(po.getReissueAmount()); activeCard.setPaymentId(po.getPaymentId()); activeCard.setRemarks(po.getRemarks()); activeCard.setOperator(po.getOperator()); Map map_newCard = activeOrReissueTermCard(activeCard); VoTermActiveCard voTermActiveCard = (VoTermActiveCard) map_newCard.get("content"); map.put("success", true); map.put("msg", "操作成功"); map.put("content", voTermActiveCard); return map; } } pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/dto/ActiveCard.java
@@ -66,4 +66,5 @@ */ @NotNull(message = "操作人不能为空") private Long operator; } pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/dto/CardSimple.java
New file @@ -0,0 +1,30 @@ package com.dy.pipIrrTerminal.card.dto; import lombok.Data; /** * @author ZhuBaoMin * @date 2025-06-04 16:26 * @LastEditTime 2025-06-04 16:26 * @Description 水卡简单信息 */ @Data public class CardSimple { public static final long serialVersionUID = 202506041628001L; /** * 水卡ID */ private Long cardId; /** * 农户ID */ private Long clientId; /** * 协议名称 */ private String protocol; } pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/dto/DtoRecharge.java
@@ -70,4 +70,10 @@ */ @Positive(message = "操作人编号必须为大于0的整数") private Long operator; /** * 充值类型:1-开卡同步充值,2-充值 */ @NotNull(message = "充值类型不能为空") private Byte rechargeType; } pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/dto/DtoReissue.java
New file @@ -0,0 +1,60 @@ package com.dy.pipIrrTerminal.card.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.*; /** * @author ZhuBaoMin * @date 2025-06-04 14:42 * @LastEditTime 2025-06-04 14:42 * @Description 补卡传入对象 */ @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor public class DtoReissue { public static final long serialVersionUID = 202506041446001L; /** * 水卡地址 */ @NotBlank(message = "水卡地址不能为空") private String cardAddr; /** * 水卡编号 */ @NotNull(message = "水卡编号不能为空") private Long cardNum; /** * 卡片费用 */ private Integer cardCost; /** * 退还金额 */ private Float reissueAmount; /** * 支付方式 */ @NotNull(message = "支付方式不能为空") private Long paymentId; /** * 备注信息 */ private String remarks; /** * 操作人编号 */ @NotNull(message = "操作人不能为空") private Long operator; } pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/enums/RechargeTypeENUM.java
New file @@ -0,0 +1,21 @@ package com.dy.pipIrrTerminal.card.enums; import lombok.AllArgsConstructor; import lombok.Getter; /** * @author ZhuBaoMin * @date 2025-05-09 20:12 * @LastEditTime 2025-05-09 20:12 * @Description */ @Getter @AllArgsConstructor public enum RechargeTypeENUM { PLUS((byte)1, "开卡同步充值"), RECHARGE((byte)2, "充值"); private final Byte code; private final String message; } pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
@@ -22,6 +22,7 @@ import com.dy.pipIrrGlobal.command.ComSupport; import com.dy.pipIrrGlobal.command.dto.Param; import com.dy.pipIrrGlobal.daoIr.IrIntakeOperateMapper; import com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper; import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper; import com.dy.pipIrrGlobal.daoPr.PrIntakeVcMapper; import com.dy.pipIrrGlobal.daoPr.PrWaterPriceMapper; @@ -40,6 +41,8 @@ import com.dy.pipIrrWechat.command.dto.AutomaticClose; import com.dy.pipIrrWechat.command.dto.ValveClose; import com.dy.pipIrrWechat.command.dto.ValveOpen; import com.dy.pipIrrWechat.irrigatePlan.IrrigatePlanSv; import com.dy.pipIrrWechat.irrigation.IrrigationSv; import com.dy.pipIrrWechat.result.WechatResultCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -72,6 +75,8 @@ private final RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper; //private final PrCommonIntakesMapper prCommonIntakesMapper; private final IrIntakeOperateMapper irIntakeOperateMapper; private final IrrigationSv irrigationSv; private final PrIntakeControllerMapper prIntakeControllerMapper; @Value("${mw.rtuCallbackUrl_wx}") private String rtuCallbackUrl_wx; @@ -85,7 +90,7 @@ private String pro_mw = "mw"; private String key_mw = "comSendUrl"; @Autowired public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper,RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, RmIrrigateProfileMapper rmIrrigateProfileMapper, Environment env, IrIntakeOperateMapper irIntakeOperateMapper) { public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper,RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, RmIrrigateProfileMapper rmIrrigateProfileMapper, Environment env, IrIntakeOperateMapper irIntakeOperateMapper, IrrigationSv irrigationSv, PrIntakeControllerMapper prIntakeControllerMapper) { this.rmCommandHistoryMapper = rmCommandHistoryMapper; this.rmOpenCloseValveLastMapper = rmOpenCloseValveLastMapper; //this.prCommonIntakesMapper = prCommonIntakesMapper; @@ -97,6 +102,8 @@ this.rmIrrigateProfileMapper = rmIrrigateProfileMapper; this.env = env; this.irIntakeOperateMapper = irIntakeOperateMapper; this.irrigationSv = irrigationSv; this.prIntakeControllerMapper = prIntakeControllerMapper; } /** * 虚拟卡ID换虚拟卡对象 @@ -127,6 +134,7 @@ com.type = "innerCommand"; comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw); JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com)); String aa = response.toJSONString(); JSONArray jsonArray = new JSONArray(); if(response != null && response.getString("code").equals("0001")) { @@ -268,8 +276,10 @@ Long operator = automaticClose.getOperator(); Byte openType = automaticClose.getOpenType(); Long comId = new IDLongGenerator().generate(); String intakeName = Optional.ofNullable(prIntakeControllerMapper.getIntakeNameById(intakeId)).orElse(""); // 如果是轮灌 Long operateId = null; if(openType != null && openType == 1) { IrIntakeOperate irIntakeOperate = new IrIntakeOperate(); irIntakeOperate.setPlanId(planId); @@ -279,8 +289,8 @@ irIntakeOperate.setStartTime(startTime); irIntakeOperate.setDuration(duration); Long id = addIntakeOperate(irIntakeOperate); if(id == null) { operateId = addIntakeOperate(irIntakeOperate); if(operateId == null) { Map map = new HashMap<>(); map.put("success", false); map.put("msg", "添加取水口操作记录失败"); @@ -307,7 +317,7 @@ Map map = new HashMap<>(); map.put("success", false); map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeId + ")"); map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeName + ")"); map.put("content", null); return map; } @@ -320,14 +330,14 @@ Map map = new HashMap<>(); map.put("success", false); map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeId + ")"); map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeName + ")"); map.put("content", null); return map; } String vcNum = vc.getVcNum().toString(); Double moneyRemain = vc.getMoney(); if(moneyRemain < 100) { irIntakeOperateMapper.updateByCommandId(comId, (byte)2, "虚拟卡余额不足,请充值" + "(" + intakeId + ")"); irIntakeOperateMapper.updateByCommandId(comId, (byte)2, "虚拟卡余额不足,请充值" + "(" + intakeName + ")"); Map map = new HashMap<>(); map.put("success", false); map.put("msg", "虚拟卡余额不足,请充值"); @@ -338,6 +348,7 @@ // 获取水价 Double waterPrice = getPrice(); if(waterPrice == null) { irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.NO_WATER_PRICE.getMessage() + "(" + intakeName + ")"); Map map = new HashMap<>(); map.put("success", false); map.put("msg", WechatResultCode.NO_WATER_PRICE.getMessage()); @@ -348,7 +359,7 @@ // 取水口ID换阀控器地址及通讯协议 JSONObject job_rtu = getRtu(intakeId, null); if(job_rtu == null) { irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.RTU_NOT_EXIST.getMessage() + "(" + intakeId + ")"); irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.RTU_NOT_EXIST.getMessage() + "(" + intakeName + ")"); Map map = new HashMap<>(); map.put("success", false); @@ -364,11 +375,22 @@ // 生成订单号 String orderNo = generateOrderNo(); if(orderNo == null) { irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.NO_ORDER_NUMBER.getMessage() + "(" + intakeId + ")"); irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.NO_ORDER_NUMBER.getMessage() + "(" + intakeName + ")"); Map map = new HashMap<>(); map.put("success", false); map.put("msg", WechatResultCode.NO_ORDER_NUMBER.getMessage()); map.put("content", null); return map; } // 判断阀控器是否已经开阀 Boolean isOpen = irrigationSv.getOpenCloseStatus(rtuAddr); if(isOpen) { irIntakeOperateMapper.updateByCommandId(comId, (byte)2, intakeName + " 阀门为打开状态"); Map map = new HashMap<>(); map.put("success", false); map.put("msg", intakeName + " 阀门为打开状态"); map.put("content", null); return map; } @@ -419,8 +441,12 @@ BaseResponse<Boolean> result = dealWithCommandResult(myParam); // 如果命令执行失败,则再次执行命令 if(!result.isSuccess()) { myParam.setComId(new IDLongGenerator().generate()); Long newComId = new IDLongGenerator().generate(); myParam.setComId(newComId); result = dealWithCommandResult(myParam); // 根据operateId修改取水口操作记录中的commandId irIntakeOperateMapper.updateCommandId(newComId, operateId); } Map map = new HashMap<>(); pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java
@@ -285,6 +285,13 @@ for (VoIrrigateSchedule schedule : schedules) { Long groupId = schedule.getGroupId(); List<Long> intakeIds = getIntakeIdsByGroupId(groupId); if(intakeIds == null || intakeIds.size() <= 0) { Map map = new HashMap<>(); map.put("success", false); map.put("msg", "当前轮灌组内没有有效的取水口"); map.put("content", null); return map; } for (Long intakeId : intakeIds) { if (schedule.getDuration() > 0) { // 今发布灌溉时长大于0的 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigation/IrrigationSv.java
@@ -191,7 +191,8 @@ return false; } if(response.getJSONObject("content").getJSONObject("attachment").get("valveOpenTrueCloseFalse").equals("true")) { // if(response.getJSONObject("content").getJSONObject("attachment").get("valveOpenTrueCloseFalse").equals("true")) { if(response.getJSONObject("content").getJSONObject("attachment").getBoolean("valveOpenTrueCloseFalse")) { return true; } else {