From d6bc4983c4b435f09f62d978ad3facfa2c337ad1 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期四, 09 五月 2024 20:02:21 +0800 Subject: [PATCH] 添加修改绑定记录通过取水口接口 修改添加控制器接口 修改取水口流浪控制器绑定接口 修改根据控制器编号获取绑定记录列表 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeControllerMapper.xml | 22 +++++++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerSv.java | 12 +++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java | 15 ++++- pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeControllerMapper.java | 7 ++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/DtoIntakeController.java | 6 +- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java | 89 ++++++++++++++++------------- pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml | 2 7 files changed, 105 insertions(+), 48 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeControllerMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeControllerMapper.java index bf71fdc..09e26e5 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeControllerMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeControllerMapper.java @@ -52,4 +52,11 @@ * @return 鍙栨按鍙d笌鎺у埗鍣ㄧ粦瀹氬垪琛� */ List<Map<String, Object>> getBindsByControllerId(@Param("controllerId") Long controllerId); + + /** + * 淇敼缁戝畾璁板綍閫氳繃鍙栨按鍙� + * @param record + * @return + */ + int updateByIntakeSelective(PrIntakeController record); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml index d9edbe5..1c5ffbd 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml @@ -247,7 +247,7 @@ SELECT COUNT(*) AS recordCount FROM pr_controller WHERE deleted = 0 AND id = ${controllerId} </select> - <!--鏍规嵁鎺у埗鍣ㄧ紪鍙疯幏鍙栧凡缁戝畾璁板綍鏁�--> + <!--鏍规嵁娴佹氮鎺у埗鍣ㄧ紪鍙疯幏鍙栧凡缁戝畾璁板綍鏁�--> <select id="getBindedCount" resultType="java.lang.Integer"> SELECT COUNT(*) AS recordCount FROM pr_controller WHERE rtuAddr = (SELECT rtuAddr FROM pr_controller_tramp WHERE id = ${controllerId}) AND intakeId IS NOT NULL </select> diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeControllerMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeControllerMapper.xml index 9e87a44..96d940c 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeControllerMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeControllerMapper.xml @@ -186,4 +186,26 @@ </if> ORDER BY ic.operateDt DESC </select> + <!--鏍规嵁鍙栨按鍙g紪鍙蜂慨鏀圭粦瀹氳褰曞垪琛�--> + <update id="updateByIntakeSelective"> + update pr_intake_controller + <set> + <if test="controllerid != null"> + controllerId = #{controllerid,jdbcType=BIGINT}, + </if> + <if test="operatetype != null"> + operateType = #{operatetype,jdbcType=TINYINT}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + `operator` = #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + operateDt = #{operatedt,jdbcType=TIMESTAMP}, + </if> + </set> + where intakeId = #{intakeid,jdbcType=BIGINT} + </update> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java index e0d70d1..090d07f 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java @@ -4,6 +4,8 @@ import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.dy.common.mw.protocol.Command; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoPr.PrControllerMapper; import com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper; @@ -11,6 +13,7 @@ import com.dy.pipIrrGlobal.pojoPr.PrController; import com.dy.pipIrrGlobal.pojoPr.PrIntakeController; import com.dy.pipIrrGlobal.voPr.VoController; +import com.dy.pipIrrProject.result.ProjectResultCode; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -80,7 +83,10 @@ * @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()); @@ -88,8 +94,11 @@ 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 ; } /** diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/DtoIntakeController.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/DtoIntakeController.java index 05e545b..c49197c 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/DtoIntakeController.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/DtoIntakeController.java @@ -26,10 +26,10 @@ private Long intakeId; /** - * 鎺у埗鍣↖D + * 锛堟祦娴級鎺у埗鍣↖D */ - @Schema(description = "鎺у埗鍣↖D", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "鎺у埗鍣↖D涓嶈兘涓虹┖") + @Schema(description = "缁戝畾鏃朵负娴佹氮鎺у埗鍣↖D/瑙g粦鏃朵负鎺у埗鍣↖D", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "锛堟祦娴級鎺у埗鍣↖D涓嶈兘涓虹┖") private Long controllerId; /** diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java index fd0aced..252376c 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java @@ -42,7 +42,7 @@ @Slf4j @Tag(name = "鍙栨按鍙�/鎺у埗鍣ㄥ叧鑱旂鐞�", description = "鍙栨按鍙�/鎺у埗鍣ㄥ叧鑱旀搷浣�") @RestController -@RequestMapping(path="intake_controller") +@RequestMapping(path = "intake_controller") @RequiredArgsConstructor public class IntakeControllerCtrl { private final IntakeControllerSv intakeControllerSv; @@ -53,9 +53,10 @@ * 鍙栨按鍙g粦瀹氭帶鍒跺櫒 * 1. 鎺ユ敹鍙栨按鍙D鍙婃祦娴帶鍒跺櫒ID锛屽苟楠岃瘉鍙栨按鍙e拰鎺у埗鍣ㄦ槸鍚﹀瓨鍦� * 2. 鍒ゆ柇璇ユ帶鍒跺櫒鏄惁瀛樺湪鏈В缁戣褰曪紝濡傛灉瀛樺湪鎻愮ず鐢ㄦ埛璇ユ帶鍒跺櫒瀛樺湪鏈В缁戣褰� - * 3. 缁勮鎺у埗鍣ㄥ璞℃彃鍏ユ帶鍒跺櫒琛ㄤ腑 - * 4. 娣诲姞缁戝畾璁板綍 + * 3. 缁勮鎺у埗鍣ㄥ璞℃彃鍏ユ帶鍒跺櫒琛ㄤ腑锛堝強娣诲姞缁戝畾璁板綍锛� + * 4. 淇敼缁戝畾璁板綍璁剧疆澶囨敞 * 5. 鍒犻櫎娴佹氮鎺у埗鍣紙鐗╃悊鍒犻櫎锛� + * * @param po * @param bindingResult * @return @@ -74,26 +75,26 @@ @SsoAop() public BaseResponse<Boolean> bind(@RequestBody @Valid DtoIntakeController po, BindingResult bindingResult) throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - if(bindingResult != null && bindingResult.hasErrors()){ + if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 鎺ユ敹鍙傛暟 Long intakeId = po.getIntakeId(); - Long controllerId = po.getControllerId(); + Long trampControllerId = po.getControllerId(); String remarks = po.getRemarks(); Long operator = po.getOperator(); // 鏍规嵁缂栧彿鍒嗗埆鑾峰彇鍙栨按鍙h褰曟暟銆佹祦娴帶鍒跺櫒淇℃伅锛屽垽鏂彇姘村彛鍙婃帶鍒跺櫒鏄惁瀛樺湪 Integer recIntke = Optional.ofNullable(intakeSv.getRecordCountOfIntake(intakeId)).orElse(0); - PrControllerTramp prControllerTramp = intakeControllerSv.getTrampControllerInfo(controllerId); + PrControllerTramp prControllerTramp = intakeControllerSv.getTrampControllerInfo(trampControllerId); //Map map_TrampController = Optional.ofNullable(intakeControllerSv.getTrampControllerInfo(controllerId)).orElse(new HashMap()); - if(recIntke == 0 || prControllerTramp == null) { + if (recIntke == 0 || prControllerTramp == null) { return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_OR_CONTROLLER_NO_EXIST.getMessage()); } // 鏍规嵁鎺у埗鍣ㄧ紪鍙峰垽鏂鎺у埗鍣ㄦ槸鍚﹀瓨鍦ㄦ湭瑙g粦璁板綍 - Integer recBinded = Optional.ofNullable(controllerSv.getBindedCount(controllerId)).orElse(0); - if(recBinded > 0) { + Integer recBinded = Optional.ofNullable(controllerSv.getBindedCount(trampControllerId)).orElse(0); + if (recBinded > 0) { return BaseResponseUtils.buildFail(ProjectResultCode.CONTROLLER_BINDED.getMessage()); } @@ -103,29 +104,31 @@ prController.setRtuAddr(prControllerTramp.getRtuAddr()); prController.setProtocol(prControllerTramp.getProtocol()); prController.setFindDt(prControllerTramp.getFindDt()); - prController.setAddWays((byte)1); + prController.setAddWays((byte) 1); prController.setOperator(operator); Date operateTime = new Date(); prController.setOperateDt(operateTime); - prController.setDeleted((byte)0); + prController.setDeleted((byte) 0); Integer rec_addController = Optional.ofNullable(controllerSv.addController(prController)).orElse(0); - if(rec_addController == 0) { + if (rec_addController == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage()); } - // 娣诲姞缁戝畾璁板綍 - PrIntakeController prIntakeController = DtoToPojo.INSTANCT.po2vo(po); - prIntakeController.setOperatedt(operateTime); - prIntakeController.setOperatetype((byte)1); - Integer rec = Optional.ofNullable(intakeControllerSv.addRecord(prIntakeController)).orElse(0); - if(rec == 0) { + + // 淇敼缁戝畾璁板綍 + PrIntakeController prIntakeController = new PrIntakeController(); + prIntakeController.setRemarks(remarks); + prIntakeController.setIntakeid(intakeId); + + Integer rec = Optional.ofNullable(intakeControllerSv.updateBindRecord(prIntakeController)).orElse(0); + if (rec == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage()); } // 鏍规嵁娴佹氮鎺у埗鍣ㄧ紪鍙峰垹闄ゆ祦娴帶鍒跺櫒璁板綍 - intakeControllerSv.deleteTrampController(controllerId); + intakeControllerSv.deleteTrampController(trampControllerId); - return BaseResponseUtils.buildSuccess(true) ; + return BaseResponseUtils.buildSuccess(true); } /** @@ -133,6 +136,7 @@ * 1. 鎺ユ敹鍙栨按鍙D鍙婃祦娴帶鍒跺櫒ID锛屽苟楠岃瘉鍙栨按鍙e拰鎺у埗鍣ㄦ槸鍚﹀瓨鍦� * 2. 娣诲姞瑙g粦璁板綍 * 3. 鍒犻櫎鎺у埗鍣ㄥ閿� + * * @param po * @param bindingResult * @return @@ -149,15 +153,15 @@ @PostMapping(path = "unbind", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> unbind(@RequestBody @Valid DtoIntakeController po, BindingResult bindingResult){ - if(bindingResult != null && bindingResult.hasErrors()){ + public BaseResponse<Boolean> unbind(@RequestBody @Valid DtoIntakeController po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 鏍规嵁缂栧彿鍒嗗埆鑾峰彇鍙栨按鍙c�佹帶鍒跺櫒鏈垹闄よ褰曟暟 Integer recIntke = Optional.ofNullable(intakeSv.getRecordCountOfIntake(po.getIntakeId())).orElse(0); Integer recController = Optional.ofNullable(controllerSv.getRecordCountOfController(po.getControllerId())).orElse(0); - if(recIntke == 0 || recController == 0) { + if (recIntke == 0 || recController == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_OR_CONTROLLER_NO_EXIST.getMessage()); } @@ -171,23 +175,24 @@ PrIntakeController prIntakeController = DtoToPojo.INSTANCT.po2vo(po); Date operateTime = new Date(); prIntakeController.setOperatedt(operateTime); - prIntakeController.setOperatetype((byte)2); + prIntakeController.setOperatetype((byte) 2); Integer rec = Optional.ofNullable(intakeControllerSv.addRecord(prIntakeController)).orElse(0); - if(rec == 0) { + if (rec == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage()); } // 鍒犻櫎鎺у埗鍣ㄥ閿� Integer rec_deleteIntakeId = Optional.ofNullable(controllerSv.deleteIntakeId(po.getControllerId())).orElse(0); - if(rec_deleteIntakeId == 0) { + if (rec_deleteIntakeId == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + return BaseResponseUtils.buildSuccess(true); } /** * 鏍规嵁鍙栨按鍙g紪鍙疯幏鍙栫粦瀹氳褰曞垪琛� + * * @param intakeId 鍙栨按鍙g紪鍙� * @return 鍙栨按鍙d笅鎺у埗鍣ㄧ殑缁戝畾銆佽В缁戣褰� */ @@ -202,22 +207,23 @@ }) @GetMapping(path = "intake_binds") @SsoAop() - public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getBindsByIntakeId(Long intakeId){ + public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getBindsByIntakeId(Long intakeId) { try { List<Map<String, Object>> list = Optional.ofNullable(intakeControllerSv.getBindsByIntakeId(intakeId)).orElse(new ArrayList<>()); - if(list.size() <= 0) { + if (list.size() <= 0) { //鏃犵粦瀹氳褰曚篃杩斿洖鎴愬姛 浣嗘暟鎹负绌� return BaseResponseUtils.buildSuccess(list); }//鎴愬姛杩斿洖缁戝畾璁板綍鏁版嵁 return BaseResponseUtils.buildSuccess(list); } catch (Exception e) { - log.error("鏌ヨ鍐滄埛寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + log.error("鏌ヨ寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); } } /** * 鏍规嵁鎺у埗鍣ㄧ紪鍙疯幏鍙栫粦瀹氳褰曞垪琛� + * * @param controllerId 鎺у埗鍣ㄧ紪鍙� * @return 涓庤鎺у埗鍣ㄧ浉鍏崇殑缁戝畾銆佽В缁戣褰� */ @@ -232,16 +238,17 @@ }) @GetMapping(path = "controller_binds") @SsoAop() - public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getBindsByControllerId(Long controllerId){ + public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getBindsByControllerId(Long controllerId) { try { List<Map<String, Object>> list = Optional.ofNullable(intakeControllerSv.getBindsByControllerId(controllerId)).orElse(new ArrayList<>()); - if(list.size() <= 0) { - return BaseResponseUtils.buildFail(ProjectResultCode.CONTROLLER_NO_RECORDS.getMessage()); + if (list.size() <= 0) { + //鏃犵粦瀹氳褰曚篃杩斿洖鎴愬姛 浣嗘暟鎹负绌� + return BaseResponseUtils.buildSuccess(list); } return BaseResponseUtils.buildSuccess(list); } catch (Exception e) { - log.error("鏌ヨ鍐滄埛寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + log.error("鏌ヨ寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); } } @@ -282,13 +289,14 @@ /** * 娣诲姞娴佹氮鎺у埗鍣� + * * @param pct * @return */ @PostMapping("addTrampController") @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> addTrampController(@RequestBody PrControllerTramp pct){ + public BaseResponse<Boolean> addTrampController(@RequestBody PrControllerTramp pct) { pct.setFindDt(new Date()); Integer rows = intakeControllerSv.addTrampController(pct); if (rows == 0) { @@ -299,15 +307,18 @@ /** * 鍒犻櫎娴佹氮鎺у埗鍣� + * * @param id * @return */ @PostMapping("deleteTrampController") @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> deleteTrampController(Long id){ + public BaseResponse<Boolean> deleteTrampController(Long id) { PrControllerTramp controllerInfo = intakeControllerSv.getTrampControllerInfo(id); - if (controllerInfo==null){return BaseResponseUtils.buildFail(ProjectResultCode.NO_EXIST_TRAMP_CONTROLLER.getMessage());} + if (controllerInfo == null) { + return BaseResponseUtils.buildFail(ProjectResultCode.NO_EXIST_TRAMP_CONTROLLER.getMessage()); + } Integer rows = intakeControllerSv.deleteTrampController(id); if (rows == 0) { diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerSv.java index 2af426b..043a59c 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerSv.java @@ -98,13 +98,13 @@ return prControllerTrampMapper.deleteByPrimaryKey(controllerId); } - //澧� + //娴佹氮鎺у埗鍣ㄥ public Integer addTrampController(PrControllerTramp record){ return prControllerTrampMapper.insertSelective(record); } -/*鏌�*/ +/*娴佹氮鎺у埗鍣ㄦ煡*/ public QueryResultVo<List<PrControllerTramp>> getTrampControllers(TrampControllerQueryVo queryVo){ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); @@ -119,4 +119,12 @@ return rsVo; } + /** + * 淇敼缁戝畾璁板綍閫氳繃鍙栨按鍙� + * @param record + * @return + */ + public Integer updateBindRecord(PrIntakeController record){ + return prIntakeControllerMapper.updateByIntakeSelective(record); + } } -- Gitblit v1.8.0