Administrator
2024-07-17 16900a8d681aed70bca5b3fea8dc28715dde9712
2024-07-17 朱宝民 重构了获取取水口两个接口
8个文件已修改
104 ■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentCtrl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java
@@ -22,9 +22,6 @@
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        String ds = DataSourceContext.get();
        System.out.println(ds);
        HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
        String wxDataSourceName = httpRequest.getHeader("tag");
        if(wxDataSourceName != null && wxDataSourceName.trim().length() > 0){
@@ -33,7 +30,6 @@
            DataSourceContext.set(wxDataSourceName);
        } else {
            log.info("用户未选择数据源");
            DataSourceContext.set("ym");
        }
        filterChain.doFilter(servletRequest, servletResponse);
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java
@@ -329,12 +329,12 @@
            Data myData = (Data)response_CallBack.getContent();
            // 更新命令日志:执行结果、返回结果时间、结果内容
            rmCommandHistory = new RmCommandHistory();
            rmCommandHistory.setComId(comId);
            rmCommandHistory.setResult((byte)1);
            rmCommandHistory.setResultTime(new Date());
            rmCommandHistory.setResultText((JSONObject)JSON.toJSON(myData));
            rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory);
            //rmCommandHistory = new RmCommandHistory();
            //rmCommandHistory.setComId(comId);
            //rmCommandHistory.setResult((byte)1);
            //rmCommandHistory.setResultTime(new Date());
            //rmCommandHistory.setResultText((JSONObject)JSON.toJSON(myData));
            //rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory);
            return BaseResponseUtils.buildSuccess(myData) ;
        } else {
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java
@@ -113,14 +113,14 @@
    List<Map<String, Object>> getNoBindingIntakes();
    /**
     * 获取取水口数量(在线和不在线)废弃
     * 获取取水口数量(在线和不在线)
     * @param params
     * @return
     */
    Long getOnLineIntakesCount(Map<?, ?> params);
    /**
     * 获取取水口列表(在线和不在线)废弃
     * 获取取水口列表(在线和不在线)
     * @param params
     * @return
     */
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
@@ -5,8 +5,8 @@
            #name: ym
            type: com.alibaba.druid.pool.DruidDataSource
            driverClassName: com.mysql.cj.jdbc.Driver
#            url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://8.140.179.55:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            username: root
            password: dysql,;.abc!@#
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -358,7 +358,7 @@
    WHERE id NOT IN(SELECT intakeId FROM pr_controller) AND deleted = 0
  </select>
  <!--获取取水口数量(在线和不在先) 废弃-->
  <!--获取取水口数量(在线和不在先)-->
  <select id="getOnLineIntakesCount" resultType="java.lang.Long">
    SELECT
        COUNT(*) AS recordCount
@@ -377,12 +377,12 @@
        rtus.isOnLine = #{isOnLine}
      </if>
      <if test="intakeNum != null and intakeNum != ''">
        AND inta.name LIKE CONCAT('%', #{intakeNum}, '%')
        AND inta.name = #{intakeNum}
      </if>
    </where>
  </select>
  <!--获取取水口列表(在线和不在先) 废弃-->
  <!--获取取水口列表(在线和不在先)-->
  <select id="getOnLineIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake">
    SELECT
      con.intakeId,
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java
@@ -30,14 +30,29 @@
    private final IntakeSv intakeSv;
    /**
     * 获取取水口(在线和不在线)
     * 根据取水口编号获取取水口对象
     * @param qo
     * @return
     */
    @GetMapping(path = "one_intake")
    public BaseResponse<QueryResultVo<VoOnLineIntake>> getOneIntake(OnLineIntakesQO qo) {
        try {
            return BaseResponseUtils.buildSuccess(intakeSv.selectOneIntake(qo));
        } catch (Exception e) {
            log.error("查询取水口异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
    /**
     * 获取取水口列表(在线和不在线)
     * @param qo
     * @return
     */
    @GetMapping(path = "all_intakes")
    public BaseResponse<QueryResultVo<VoOnLineIntake>> getAllIntakes(OnLineIntakesQO qo) {
        try {
            return BaseResponseUtils.buildSuccess(intakeSv.selectOnLineIntakes(qo));
            return BaseResponseUtils.buildSuccess(intakeSv.selectAllIntakes(qo));
        } catch (Exception e) {
            log.error("查询取水口异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java
@@ -6,6 +6,7 @@
import com.dy.common.multiDataSource.DataSourceContext;
import com.dy.common.mw.protocol.Command;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import com.dy.pipIrrWechat.intake.qo.OnLineIntakesQO;
@@ -58,10 +59,10 @@
    }
    /**
     * 获取取水口
     * 根据取水口编号获取取水口对象
     * @return
     */
    public VoOnLineIntake selectOnLineIntakes(OnLineIntakesQO qo) {
    public VoOnLineIntake selectOneIntake(OnLineIntakesQO qo) {
        Command com = new Command() ;
        com.id = Command.defaultId;
        com.code = "LCD0001";
@@ -96,6 +97,52 @@
    }
    /**
     * 获取取水口列表(在线和不在线)
     * @return
     */
    public QueryResultVo<List<VoOnLineIntake>> selectAllIntakes(OnLineIntakesQO qo) {
        Command com = new Command() ;
        com.id = Command.defaultId;
        com.code = "LCD0001";
        com.type = "innerCommand";
        comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
        JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com));
        if(response != null && response.getString("code").equals("0001")) {
            JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
            HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
            JSONArray jsonArray = new JSONArray();
            for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("rtuAddr", entry.getKey());
                jsonObject.put("isOnLine", entry.getValue());
                jsonArray.add(jsonObject);
            }
            qo.setOnLineMap(jsonArray.toJSONString());
            // 如果 intakeNum 不为空,则转为小写再写入qo对象
            String intakeNum = qo.getIntakeNum();
            if(intakeNum != null) {
                qo.setIntakeNum(intakeNum.toLowerCase());
            }
            Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
            Long itemTotal = prIntakeMapper.getOnLineIntakesCount(params);
            QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>() ;
            rsVo.pageSize = qo.pageSize ;
            rsVo.pageCurr = qo.pageCurr ;
            rsVo.calculateAndSet(itemTotal, params);
            rsVo.obj = prIntakeMapper.getOnLineIntakes(params);
            return rsVo;
        } else {
            QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>();
            return rsVo;
        }
    }
    /**
     * 根据操作员获取常用取水口
     * @param operator
     * @return
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentCtrl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.multiDataSource.DataSourceContext;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.ResultCodeMsg;
@@ -246,6 +247,7 @@
        job_body.put("mchid", mchid);
        job_body.put("description", description);
        job_body.put("out_trade_no", orderNumber);
        job_body.put("attach", DataSourceContext.get());
        job_body.put("notify_url", notifyUrl);
        //订单金额
@@ -420,6 +422,8 @@
            JSONObject job_resource = JSONObject.parseObject(resource);
            // 解密后取出:商户订单号、微信支付订单号、交易状态、支付完成时间
            String attach = job_resource.getString("attach");
            DataSourceContext.set(attach);
            String out_trade_no = job_resource.getString("out_trade_no");
            String transaction_id = job_resource.getString("transaction_id");
            String trade_state = job_resource.getString("trade_state");