wuzeyu
2024-05-31 89d7bf273815013c3e4bd518b77dfd35a749d592
田间灌溉项目管理  优化代码 修改轮罐组绑定的灌溉单元接口
1个文件已修改
28 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java
@@ -85,6 +85,7 @@
    /**
     * 逻辑删除灌溉单元
     *
     * @param
     * @return
     */
@@ -119,6 +120,7 @@
    /**
     * 批量删除
     *
     * @param groupIds
     * @return
     */
@@ -147,6 +149,7 @@
    /**
     * 修改灌溉单元
     *
     * @param po
     * @param bindingResult
     * @return
@@ -204,6 +207,7 @@
    /**
     * 分页查询
     *
     * @param vo
     * @return
     */
@@ -275,6 +279,7 @@
    /**
     *  轮灌组移除灌溉单元
     *
     * @param
     * @return
     */
@@ -352,7 +357,6 @@
    }
    /**
     * 修改轮灌组绑定的灌溉单元
     *
@@ -379,32 +383,32 @@
        Long groupId = Long.parseLong(po.get("groupId").toString());
        Long operator = Long.parseLong(po.get("operator").toString());
        List<Long> newUnitIds = (List<Long>) po.get("unitIds");
        List<Long> oldUnitIds = irrigateGroupSv.getGroupBindUnits(groupId);
        IrGroupUnit irGroupUnit = new IrGroupUnit();
        irGroupUnit.setGroupId(groupId);
        irGroupUnit.setOperator(operator);
        try {
            for (int j = 0; j < oldUnitIds.size(); j++) {
                Long oldUnitId = oldUnitIds.get(j);
                IrGroupUnit irGroupUnit1 = new IrGroupUnit();
                irGroupUnit1.setGroupId(groupId);
                irGroupUnit1.setUnitId(oldUnitId);
                irGroupUnit1.setOperator(operator);
                Integer rec = Optional.ofNullable(irrigateGroupSv.deleteGroupUnit(irGroupUnit1)).orElse(0);
                if (!newUnitIds.toString().contains(oldUnitId.toString())) {
                    irGroupUnit.setUnitId(oldUnitId);
                    Integer rec = Optional.ofNullable(irrigateGroupSv.deleteGroupUnit(irGroupUnit)).orElse(0);
                if (rec == 0) {
                    return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage());
                    }
                }
            }
            for (int i = 0; i < newUnitIds.size(); i++) {
                Long newUnitId = newUnitIds.get(i);
                IrGroupUnit irGroupUnit2 = new IrGroupUnit();
                irGroupUnit2.setGroupId(groupId);
                irGroupUnit2.setUnitId(newUnitId);
                irGroupUnit2.setOperator(operator);
                Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(irGroupUnit2)).orElse(0);
                if (!oldUnitIds.toString().contains(newUnitId.toString())) {
                    irGroupUnit.setUnitId(newUnitId);
                    Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(irGroupUnit)).orElse(0);
                if (rec == 0) {
                    return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage());
                }
            }
            }
        } catch (Exception e) {
            log.error("修改轮灌组绑定的灌溉单元异常", e);
            return BaseResponseUtils.buildException(e.getMessage());