| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoPr.PrControllerMapper; |
| | | import com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = prControllerMapper.getControllers(params); |
| | | |
| | | |
| | | ArrayList<Object> list = new ArrayList<>(); |
| | | List<VoController> controllers = prControllerMapper.getControllers(params); |
| | | for (int i = 0; i < controllers.size(); i++) { |
| | | VoController controller = controllers.get(i); |
| | | String rtuAddr = controller.getRtuAddr(); |
| | | list.add(rtuAddr); |
| | | } |
| | | String url = "http://localhost:8080/accMw/com/send"; |
| | | HttpEntity<?> httpEntity = new HttpEntity<>(list); |
| | | ResponseEntity<String> entity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); |
| | | JSONObject data = JSONObject.parseObject(entity.getBody()).getJSONObject("data"); |
| | | data.getString("rtuAddr"); |
| | | return rsVo; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public Integer addController(PrController po) { |
| | | prControllerMapper.insert(po); |
| | | int rows = prControllerMapper.insert(po); |
| | | if(rows == 0) { |
| | | return 0; |
| | | } |
| | | PrIntakeController addPrIntakeController = new PrIntakeController(); |
| | | addPrIntakeController.setIntakeid(po.getIntakeId()); |
| | | addPrIntakeController.setControllerid(po.getId()); |
| | |
| | | addPrIntakeController.setOperator(po.getOperator()); |
| | | addPrIntakeController.setOperatedt(po.getOperateDt()); |
| | | addPrIntakeController.setRemarks("绑定"); |
| | | prIntakeControllerMapper.insert(addPrIntakeController); |
| | | return 1; |
| | | int rec = prIntakeControllerMapper.insert(addPrIntakeController); |
| | | if(rec == 0) { |
| | | return 0; |
| | | } |
| | | return 1 ; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | return array; |
| | | } |
| | | |
| | | /** |
| | | * 根据控制器编号物理删除控制 |
| | | *2024-6-7 |
| | | * @param controllerId |
| | | * @return |
| | | */ |
| | | public Integer deleteControllerByIdTwo(Long controllerId) { |
| | | return prControllerMapper.deleteByPrimaryKey(controllerId); |
| | | } |
| | | |
| | | /** |
| | | * 根据主键查询控制器列表 |
| | | *2024-6-7 |
| | | * @param controllerId |
| | | * @return |
| | | */ |
| | | public PrController getByControllerId(Long controllerId) { |
| | | return prControllerMapper.selectByPrimaryKey(controllerId); |
| | | } |
| | | } |