Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaUser; |
| | | import com.dy.pipIrrGlobal.voBa.VoRoleSimple; |
| | | import com.dy.pipIrrGlobal.voBa.VoSimpleUser; |
| | | import com.dy.pipIrrGlobal.voBa.VoUserInfo; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | |
| | | */ |
| | | List<VoSimpleUser> getSimpleUsers(); |
| | | |
| | | /** |
| | | * 获取巡检员列表 |
| | | * @param inspector |
| | | * @return |
| | | */ |
| | | List<VoRoleSimple> getInspectors(@Param("inspector") String inspector); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrGroupClient; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupSimple; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | |
| | | int updateByPrimaryKeySelective(IrGroupClient record); |
| | | |
| | | int updateByPrimaryKey(IrGroupClient record); |
| | | |
| | | /** |
| | | * 根据农户编号获取轮灌组列表 |
| | | * @param clientId |
| | | * @return |
| | | */ |
| | | List<VoGroupSimple> getGroupsByClientId(Long clientId); |
| | | |
| | | |
| | | } |
| | |
| | | * 向通信中间件发送rtu远程升级任务 |
| | | * @param restTemplate SpringBoot的RestTemplate |
| | | * @param toMwUrl 到通信中间件的web请求Url |
| | | * @param param 请求参数 |
| | | * @param body 请求数据 |
| | | * @return |
| | | */ |
| | | protected BaseResponse sendRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object param) { |
| | | protected BaseResponse sendPostRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object body) { |
| | | String url = UriComponentsBuilder.fromUriString(toMwUrl) |
| | | .build() |
| | | .toUriString(); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpEntity<?> httpEntity ; |
| | | if(param != null){ |
| | | httpEntity = new HttpEntity<>(param, headers); |
| | | }else{ |
| | | httpEntity = new HttpEntity<>(headers); |
| | | } |
| | | HttpEntity<?> httpEntity = new HttpEntity<>(body, headers); |
| | | ResponseEntity<BaseResponse> response = null; |
| | | try { |
| | | // 通过Post方式调用接口 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 向通信中间件发送rtu远程升级任务 |
| | | * @param restTemplate SpringBoot的RestTemplate |
| | | * @param toMwUrl 到通信中间件的web请求Url |
| | | * @return |
| | | */ |
| | | protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl) { |
| | | String url = UriComponentsBuilder.fromUriString(toMwUrl) |
| | | .build() |
| | | .toUriString(); |
| | | |
| | | //UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) |
| | | // .queryParam("test", test); |
| | | UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ; |
| | | |
| | | ResponseEntity<BaseResponse> response = null; |
| | | try { |
| | | // 通过Get方式调用接口 |
| | | response = restTemplate.exchange(builder.toUriString(), |
| | | HttpMethod.GET, |
| | | new HttpEntity<>(new HttpHeaders()), |
| | | BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("后端系统出错,中间件调用异常"); |
| | | } |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("后端系统出错,中间件调用异常"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建外部命令(发给控制器) |
| | | * @param code 命令code |
| | | * @return |
New file |
| | |
| | | package com.dy.pipIrrGlobal.voBa; |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.dy.common.po.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-11-29 15:02 |
| | | * @LastEditTime 2024-11-29 15:02 |
| | | * @Description 角色简单视图对象,获取巡检员使用 |
| | | */ |
| | | |
| | | @Data |
| | | @JsonPropertyOrder({"inspectorId", "inspector"}) |
| | | public class VoRoleSimple implements BaseEntity { |
| | | public static final long serialVersionUID = 202411291506001L; |
| | | |
| | | /** |
| | | * 巡检员ID |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | private Long inspectorId; |
| | | |
| | | /** |
| | | * 巡检员姓名 |
| | | */ |
| | | private String inspector; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.voIr; |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.dy.common.po.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-11-28 17:11 |
| | | * @LastEditTime 2024-11-28 17:11 |
| | | * @Description 轮灌组简单视图对象 |
| | | */ |
| | | |
| | | @Data |
| | | @JsonPropertyOrder({"groupId", "groupCode"}) |
| | | public class VoGroupSimple implements BaseEntity { |
| | | public static final long serialVersionUID = 202411281712001L; |
| | | |
| | | /** |
| | | * 轮灌组ID |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | private Long groupId; |
| | | |
| | | /** |
| | | * 轮灌组编码 |
| | | */ |
| | | private String groupCode; |
| | | } |
| | |
| | | */ |
| | | @Schema(description = "升级是否结束" ) |
| | | @ExcelProperty("升级结束") |
| | | @ColumnWidth(10) |
| | | @ColumnWidth(14) |
| | | @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER) |
| | | public String isOverStr; |
| | | |
| | |
| | | WHERE disabled = 0 AND deleted = 0 |
| | | </select> |
| | | |
| | | <!--获取巡检员列表--> |
| | | <select id="getInspectors" resultType="com.dy.pipIrrGlobal.voBa.VoRoleSimple"> |
| | | SELECT |
| | | us.id AS inspectorId, |
| | | us.name AS inspector |
| | | FROM ba_user us |
| | | INNER JOIN ba_user_role ur ON ur.userId = us.id |
| | | INNER JOIN ba_role rol ON rol.id = ur.roleId |
| | | <where> |
| | | AND us.disabled = 0 |
| | | AND us.deleted = 0 |
| | | AND rol.`name` = '巡检员' |
| | | <if test = "inspector != null and inspector !=''"> |
| | | AND us.name LIKE CONCAT('%',#{inspector},'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |
| | |
| | | operate_time = #{operateTime,jdbcType=TIMESTAMP} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <!--根据农户编号获取轮灌组列表--> |
| | | <select id="getGroupsByClientId" resultType="com.dy.pipIrrGlobal.voIr.VoGroupSimple"> |
| | | SELECT |
| | | grp.id AS groupId, |
| | | grp.group_code AS groupCode |
| | | FROM ir_group_client gc |
| | | INNER JOIN ir_irrigate_group grp ON grp.id = gc.group_id |
| | | WHERE grp.deleted = 0 AND client_id = #{clientId} |
| | | ORDER BY grp.group_code |
| | | </select> |
| | | </mapper> |
| | |
| | | * 接收web系统发来强制结束升级任务 |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "ugForceOver", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @GetMapping(path = "ugForceOver") |
| | | public BaseResponse<String> ugForceOver() { |
| | | log.info("收到停止RTU升级任务命令") ; |
| | | try{ |
New file |
| | |
| | | package com.dy.pipIrrApp.config; |
| | | |
| | | import com.dy.common.multiDataSource.DataSourceContext; |
| | | import jakarta.servlet.*; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-11-29 14:24 |
| | | * @LastEditTime 2024-11-29 14:24 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | public class DataSourceFilter implements Filter { |
| | | |
| | | @Override |
| | | public void init(FilterConfig filterConfig) throws ServletException { |
| | | } |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException { |
| | | HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; |
| | | String wxDataSourceName = httpRequest.getHeader("tag"); |
| | | if (wxDataSourceName != null && wxDataSourceName.trim().length() > 0) { |
| | | log.info("APP开发,设置数据源名称为:" + wxDataSourceName); |
| | | //把组织单位标签作为数据源名称 |
| | | DataSourceContext.set(wxDataSourceName); |
| | | } else { |
| | | log.info("用户未选择数据源"); |
| | | } |
| | | filterChain.doFilter(servletRequest, servletResponse); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrApp.config; |
| | | |
| | | import jakarta.servlet.Filter; |
| | | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-11-29 14:29 |
| | | * @LastEditTime 2024-11-29 14:29 |
| | | * @Description |
| | | */ |
| | | |
| | | @Configuration |
| | | public class DataSourceFilterConfiguration { |
| | | @Bean |
| | | public FilterRegistrationBean<? extends Filter> DataSourceFilter() { |
| | | FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>(); |
| | | filterRegistrationBean.setFilter(new DataSourceFilter()); |
| | | filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则 |
| | | filterRegistrationBean.setName("DataSourceFilter");//设置过滤器名称 |
| | | filterRegistrationBean.setOrder(1);//执行次序 |
| | | |
| | | return filterRegistrationBean; |
| | | } |
| | | } |
| | |
| | | import com.dy.pipIrrGlobal.pojoOp.OpeApproveResult; |
| | | import com.dy.pipIrrGlobal.pojoOp.OpeProcessingResult; |
| | | import com.dy.pipIrrGlobal.pojoOp.OpeWorkOrder; |
| | | import com.dy.pipIrrGlobal.voBa.VoRoleSimple; |
| | | import com.dy.pipIrrGlobal.voOp.VoProcessingResult; |
| | | import com.dy.pipIrrGlobal.voOp.VoTaskType; |
| | | import com.dy.pipIrrGlobal.voOp.VoWorkOrder; |
| | |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取巡检员列表 |
| | | * @param inspector |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getInspectors") |
| | | @SsoAop() |
| | | public BaseResponse<List<VoRoleSimple>> getInspectors(@RequestParam("inspector") String inspector) { |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(workOrderSv.getInspectors(inspector)); |
| | | } catch (Exception e) { |
| | | log.error("获取任务类型异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrApp.workOrder.qo.QoWorkOrder; |
| | | import com.dy.pipIrrGlobal.daoBa.BaUserMapper; |
| | | import com.dy.pipIrrGlobal.daoOp.OpeApproveResultMapper; |
| | | import com.dy.pipIrrGlobal.daoOp.OpeProcessingResultMapper; |
| | | import com.dy.pipIrrGlobal.daoOp.OpeTaskTypeMapper; |
| | |
| | | import com.dy.pipIrrGlobal.pojoOp.OpeApproveResult; |
| | | import com.dy.pipIrrGlobal.pojoOp.OpeProcessingResult; |
| | | import com.dy.pipIrrGlobal.pojoOp.OpeWorkOrder; |
| | | import com.dy.pipIrrGlobal.voBa.VoRoleSimple; |
| | | import com.dy.pipIrrGlobal.voOp.VoProcessingResult; |
| | | import com.dy.pipIrrGlobal.voOp.VoTaskType; |
| | | import com.dy.pipIrrGlobal.voOp.VoWorkOrder; |
| | |
| | | |
| | | @Autowired |
| | | private OpeTaskTypeMapper opeTaskTypeMapper; |
| | | |
| | | @Autowired |
| | | private BaUserMapper baUserMapper; |
| | | |
| | | /** |
| | | * 添加工单记录 |
| | |
| | | public List<VoTaskType> getTaskTypes() { |
| | | return opeTaskTypeMapper.getTaskTypes(); |
| | | } |
| | | |
| | | /** |
| | | * 获取巡检员列表 |
| | | * @param inspector |
| | | * @return |
| | | */ |
| | | public List<VoRoleSimple> getInspectors(String inspector) { |
| | | return baUserMapper.getInspectors(inspector); |
| | | } |
| | | } |
| | |
| | | import com.dy.common.webUtil.ResultCodeMsg; |
| | | import com.dy.pipIrrGlobal.pojoUg.UgRtuTask; |
| | | import com.dy.pipIrrGlobal.voUg.VoUgResult; |
| | | import com.dy.pipIrrGlobal.voUg.VoUgRtuResult; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.media.Content; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | |
| | | setExcelRespProp(response, "升级结果列表"); |
| | | List<VoUgResult> rsList = this.sv.selectAll(vo); |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head(VoUgRtuResult.class) |
| | | .head(VoUgResult.class) |
| | | .excelType(ExcelTypeEnum.XLSX) |
| | | .sheet("升级结果列表") |
| | | .doWrite(rsList); |
New file |
| | |
| | | package com.dy.pipIrrIrrigate.irrigatePlan; |
| | | |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupSimple; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-11-28 17:20 |
| | | * @LastEditTime 2024-11-28 17:20 |
| | | * @Description 灌溉计划控制类 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path = "irrigatePlan") |
| | | @RequiredArgsConstructor |
| | | public class IrrigatePlanCtrl { |
| | | private final IrrigatePlanSv irrigatePlanSv; |
| | | |
| | | /** |
| | | * 根据农户编号获取轮灌组列表 |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getGroups") |
| | | @SsoAop() |
| | | public BaseResponse<List<VoGroupSimple>> getGroups(@RequestParam("clientId") Long clientId) { |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(irrigatePlanSv.getGroups(clientId)); |
| | | } catch (Exception e) { |
| | | log.error("获取任务类型异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrIrrigate.irrigatePlan; |
| | | |
| | | import com.dy.pipIrrGlobal.daoIr.IrGroupClientMapper; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupSimple; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-11-28 17:20 |
| | | * @LastEditTime 2024-11-28 17:20 |
| | | * @Description 灌溉计划服务类 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class IrrigatePlanSv { |
| | | @Autowired |
| | | private IrGroupClientMapper irGroupClientMapper; |
| | | |
| | | /** |
| | | * 根据农户编号获取轮灌组列表 |
| | | * @param clientId |
| | | * @return |
| | | */ |
| | | public List<VoGroupSimple> getGroups(Long clientId) { |
| | | return irGroupClientMapper.getGroupsByClientId(clientId); |
| | | } |
| | | } |
| | |
| | | Command com = this.createInnerCommand(CodeLocal.onLinePart); |
| | | com.setParam(rtuAddrs) ; |
| | | String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ; |
| | | BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, com) ; |
| | | BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ; |
| | | if(res != null){ |
| | | if(res.isSuccess()){ |
| | | Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ; |
| | |
| | | //向通信中间件发关命令,查询部分RTU在线情况 |
| | | Command com = this.createInnerCommand(CodeLocal.onLineAll); |
| | | String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ; |
| | | BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, com) ; |
| | | BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ; |
| | | if(res != null){ |
| | | if(res.isSuccess()){ |
| | | Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ; |
| | |
| | | vo.callbackWebUrl = ugCallbackUrl_rm ; |
| | | |
| | | String rqUrl = this.get2MwRequestUrl(this.env, ContextUgTaskSend) ; |
| | | BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, vo) ; |
| | | BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, vo) ; |
| | | if(res != null){ |
| | | if(res.isSuccess()){ |
| | | this.sv.setUpgradeTaskExecuted(id); |
| | |
| | | if(msg == null){ |
| | | msg = res.getMsg() ; |
| | | } |
| | | log.error("通信中间件执行下发升级任务失败" + msg) ; |
| | | return BaseResponseUtils.buildErrorMsg("通信中间件执行失败" + msg) ; |
| | | log.error("通信中间件执行下发升级任务失败," + msg) ; |
| | | return BaseResponseUtils.buildErrorMsg("通信中间件执行失败," + msg) ; |
| | | } |
| | | }else{ |
| | | log.error("通信中间件返回结果为null") ; |
| | |
| | | @SsoAop() |
| | | public BaseResponse<String> forceOver() { |
| | | String rqUrl = this.get2MwRequestUrl(this.env, ContextUgForceOver) ; |
| | | BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, null) ; |
| | | BaseResponse res = sendGetRequest2Mw(restTemplate, rqUrl) ; |
| | | if(res != null){ |
| | | if(res.isSuccess()){ |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | String msg = res.getContent()==null?null:(String)res.getContent() ; |
| | | if(msg == null){ |
| | | msg = res.getMsg() ; |
| | | } |
| | | return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, msg, msg) ; |
| | | }else{ |
| | | String msg = res.getContent()==null?null:(String)res.getContent() ; |
| | | if(msg == null){ |