|  |  | 
 |  |  | import com.alibaba.fastjson2.JSON; | 
 |  |  | import com.alibaba.fastjson2.JSONArray; | 
 |  |  | import com.alibaba.fastjson2.JSONObject; | 
 |  |  | 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.config.DingTalk; | 
 |  |  | import com.dy.pipIrrGlobal.daoPr.PrDivideMapper; | 
 |  |  | import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper; | 
 |  |  | import com.dy.pipIrrGlobal.pojoPr.PrIntake; | 
 |  |  | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.apache.dubbo.common.utils.PojoUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.core.env.Environment; | 
 |  |  | import org.springframework.http.HttpEntity; | 
 |  |  | import org.springframework.http.HttpHeaders; | 
 |  |  | import org.springframework.http.HttpMethod; | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RestTemplate restTemplate; | 
 |  |  |  | 
 |  |  |     protected static String mwUrlSendCom = "http://127.0.0.1:8070/rtuMw/com/send" ; | 
 |  |  |     protected String comSendUrl; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * pro_mw:属性 | 
 |  |  |      * tag从控制器中获取 | 
 |  |  |      * key_mw:url的key | 
 |  |  |      */ | 
 |  |  |     private Environment env = null; | 
 |  |  |     private String pro_mw = "mw"; | 
 |  |  |     private String key_mw = "comSendUrl"; | 
 |  |  |     @Autowired | 
 |  |  |     public IntakeSv(Environment env) { | 
 |  |  |         this.env = env; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private DingTalk dingTalk; | 
 |  |  |  | 
 |  |  |     public String sendMessage(String message) { | 
 |  |  |         try { | 
 |  |  |             dingTalk.sendMessage(message); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             return "发送失败"; | 
 |  |  |         } | 
 |  |  |         return "发送成功"; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 添加取水口 | 
 |  |  | 
 |  |  |     public Long getSupperByVillageId(long vaId) { | 
 |  |  |         return prIntakeMapper.getSupperByVillageId(vaId); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存修改实体 | 
 |  |  | 
 |  |  |         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); | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     protected BaseResponse sendCom2Mw(Command com){ | 
 |  |  |         String url = UriComponentsBuilder.fromUriString(mwUrlSendCom) | 
 |  |  |         String url = UriComponentsBuilder.fromUriString(comSendUrl) | 
 |  |  |                 .build() | 
 |  |  |                 .toUriString(); | 
 |  |  |         HttpHeaders headers = new HttpHeaders(); | 
 |  |  | 
 |  |  |         return response.getBody(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 得到所有取水口名称 | 
 |  |  |      * 取水口名称换取水口ID,验证是否重复名称使用 | 
 |  |  |      * @param intakeName | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public List<String> getIntakeName() { | 
 |  |  |         return prIntakeMapper.getIntakeName(); | 
 |  |  |     public List<Long> getIntakeIdsByName(String intakeName) { | 
 |  |  |         return prIntakeMapper.getIntakeIdsByName(intakeName); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * @param intakeName | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public List<Long> getIntakeIdByName1(String intakeName) { | 
 |  |  |         return prIntakeMapper.getIntakeIdByName1(intakeName); | 
 |  |  |     public List<Long> getIntakeIdByNameExcludeId(Long id, String intakeName) { | 
 |  |  |         return prIntakeMapper.getIntakeIdByNameExcludeId(id, intakeName); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } |