Explorar o código

optimize owner committee

java110 %!s(int64=3) %!d(string=hai) anos
pai
achega
a817aeed58

+ 102 - 104
java110-db/src/main/resources/mapper/user/OwnerCommitteeContractV1ServiceDaoImplMapper.xml

@@ -5,129 +5,127 @@
 <mapper namespace="ownerCommitteeContractV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存紧急联系人信息 add by wuxw 2018-07-03 -->
     <insert id="saveOwnerCommitteeContractInfo" parameterType="Map">
         insert into owner_committee_contract(
-rel_name,address,contract_id,name,link,remark,oc_id,community_id
-) values (
-#{relName},#{address},#{contractId},#{name},#{link},#{remark},#{ocId},#{communityId}
-)
+        rel_name,address,contract_id,name,link,remark,oc_id,community_id
+        ) values (
+        #{relName},#{address},#{contractId},#{name},#{link},#{remark},#{ocId},#{communityId}
+        )
     </insert>
 
 
-
     <!-- 查询紧急联系人信息 add by wuxw 2018-07-03 -->
     <select id="getOwnerCommitteeContractInfo" parameterType="Map" resultType="Map">
-        select  t.rel_name,t.rel_name relName,t.address,t.contract_id,t.contract_id contractId,t.name,t.link,t.remark,t.status_cd,t.status_cd statusCd,t.oc_id,t.oc_id ocId,t.community_id,t.community_id communityId 
-from owner_committee_contract t 
-where 1 =1 
-<if test="relName !=null and relName != ''">
-   and t.rel_name= #{relName}
-</if> 
-<if test="address !=null and address != ''">
-   and t.address= #{address}
-</if> 
-<if test="contractId !=null and contractId != ''">
-   and t.contract_id= #{contractId}
-</if> 
-<if test="name !=null and name != ''">
-   and t.name= #{name}
-</if> 
-<if test="link !=null and link != ''">
-   and t.link= #{link}
-</if> 
-<if test="remark !=null and remark != ''">
-   and t.remark= #{remark}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="ocId !=null and ocId != ''">
-   and t.oc_id= #{ocId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.rel_name,t.rel_name relName,t.address,t.contract_id,t.contract_id
+        contractId,t.name,t.link,t.remark,t.status_cd,t.status_cd statusCd,t.oc_id,t.oc_id
+        ocId,t.community_id,t.community_id communityId
+        from owner_committee_contract t
+        where 1 =1
+        <if test="relName !=null and relName != ''">
+            and t.rel_name= #{relName}
+        </if>
+        <if test="address !=null and address != ''">
+            and t.address= #{address}
+        </if>
+        <if test="contractId !=null and contractId != ''">
+            and t.contract_id= #{contractId}
+        </if>
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="link !=null and link != ''">
+            and t.link= #{link}
+        </if>
+        <if test="remark !=null and remark != ''">
+            and t.remark= #{remark}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="ocId !=null and ocId != ''">
+            and t.oc_id= #{ocId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改紧急联系人信息 add by wuxw 2018-07-03 -->
     <update id="updateOwnerCommitteeContractInfo" parameterType="Map">
-        update  owner_committee_contract t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="relName !=null and relName != ''">
-, t.rel_name= #{relName}
-</if> 
-<if test="address !=null and address != ''">
-, t.address= #{address}
-</if> 
-<if test="name !=null and name != ''">
-, t.name= #{name}
-</if> 
-<if test="link !=null and link != ''">
-, t.link= #{link}
-</if> 
-<if test="remark !=null and remark != ''">
-, t.remark= #{remark}
-</if> 
-<if test="ocId !=null and ocId != ''">
-, t.oc_id= #{ocId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
- where 1=1 <if test="contractId !=null and contractId != ''">
-and t.contract_id= #{contractId}
-</if> 
+        update owner_committee_contract t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="relName !=null and relName != ''">
+            , t.rel_name= #{relName}
+        </if>
+        <if test="address !=null and address != ''">
+            , t.address= #{address}
+        </if>
+        <if test="name !=null and name != ''">
+            , t.name= #{name}
+        </if>
+        <if test="link !=null and link != ''">
+            , t.link= #{link}
+        </if>
+        <if test="remark !=null and remark != ''">
+            , t.remark= #{remark}
+        </if>
+
+        <if test="communityId !=null and communityId != ''">
+            , t.community_id= #{communityId}
+        </if>
+        where 1=1
+        <if test="contractId !=null and contractId != ''">
+            and t.contract_id= #{contractId}
+        </if>
+        <if test="ocId !=null and ocId != ''">
+            and t.oc_id= #{ocId}
+        </if>
 
     </update>
 
     <!-- 查询紧急联系人数量 add by wuxw 2018-07-03 -->
-     <select id="queryOwnerCommitteeContractsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from owner_committee_contract t 
-where 1 =1 
-<if test="relName !=null and relName != ''">
-   and t.rel_name= #{relName}
-</if> 
-<if test="address !=null and address != ''">
-   and t.address= #{address}
-</if> 
-<if test="contractId !=null and contractId != ''">
-   and t.contract_id= #{contractId}
-</if> 
-<if test="name !=null and name != ''">
-   and t.name= #{name}
-</if> 
-<if test="link !=null and link != ''">
-   and t.link= #{link}
-</if> 
-<if test="remark !=null and remark != ''">
-   and t.remark= #{remark}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="ocId !=null and ocId != ''">
-   and t.oc_id= #{ocId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
+    <select id="queryOwnerCommitteeContractsCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from owner_committee_contract t
+        where 1 =1
+        <if test="relName !=null and relName != ''">
+            and t.rel_name= #{relName}
+        </if>
+        <if test="address !=null and address != ''">
+            and t.address= #{address}
+        </if>
+        <if test="contractId !=null and contractId != ''">
+            and t.contract_id= #{contractId}
+        </if>
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="link !=null and link != ''">
+            and t.link= #{link}
+        </if>
+        <if test="remark !=null and remark != ''">
+            and t.remark= #{remark}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="ocId !=null and ocId != ''">
+            and t.oc_id= #{ocId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 0 - 79
service-user/src/main/java/com/java110/user/cmd/ownerCommittee/SaveOwnerCommitteeContractCmd.java

@@ -1,79 +0,0 @@
-/*
- * Copyright 2017-2020 吴学文 and java110 team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.java110.user.cmd.ownerCommittee;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.core.annotation.Java110Cmd;
-import com.java110.core.annotation.Java110Transactional;
-import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.Cmd;
-import com.java110.core.event.cmd.CmdEvent;
-import com.java110.core.factory.GenerateCodeFactory;
-import com.java110.intf.user.IOwnerCommitteeContractV1InnerServiceSMO;
-import com.java110.po.ownerCommitteeContract.OwnerCommitteeContractPo;
-import com.java110.utils.exception.CmdException;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.vo.ResultVo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * 类表述:保存
- * 服务编码:ownerCommitteeContract.saveOwnerCommitteeContract
- * 请求路劲:/app/ownerCommitteeContract.SaveOwnerCommitteeContract
- * add by 吴学文 at 2023-03-06 12:01:17 mail: 928255095@qq.com
- * open source address: https://gitee.com/wuxw7/MicroCommunity
- * 官网:http://www.homecommunity.cn
- * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
- * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
- */
-@Java110Cmd(serviceCode = "ownerCommittee.saveOwnerCommitteeContract")
-public class SaveOwnerCommitteeContractCmd extends Cmd {
-
-    private static Logger logger = LoggerFactory.getLogger(SaveOwnerCommitteeContractCmd.class);
-
-    public static final String CODE_PREFIX_ID = "10";
-
-    @Autowired
-    private IOwnerCommitteeContractV1InnerServiceSMO ownerCommitteeContractV1InnerServiceSMOImpl;
-
-    @Override
-    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
-        Assert.hasKeyAndValue(reqJson, "ocId", "请求报文中未包含ocId");
-Assert.hasKeyAndValue(reqJson, "name", "请求报文中未包含name");
-Assert.hasKeyAndValue(reqJson, "relName", "请求报文中未包含relName");
-Assert.hasKeyAndValue(reqJson, "link", "请求报文中未包含link");
-        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含小区信息");
-
-    }
-
-    @Override
-    @Java110Transactional
-    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
-
-       OwnerCommitteeContractPo ownerCommitteeContractPo = BeanConvertUtil.covertBean(reqJson, OwnerCommitteeContractPo.class);
-        ownerCommitteeContractPo.setContractId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
-        int flag = ownerCommitteeContractV1InnerServiceSMOImpl.saveOwnerCommitteeContract(ownerCommitteeContractPo);
-
-        if (flag < 1) {
-            throw new CmdException("保存数据失败");
-        }
-
-        cmdDataFlowContext.setResponseEntity(ResultVo.success());
-    }
-}

+ 27 - 3
service-user/src/main/java/com/java110/user/cmd/ownerCommittee/UpdateOwnerCommitteeCmd.java

@@ -15,6 +15,7 @@
  */
 package com.java110.user.cmd.ownerCommittee;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.annotation.Java110Transactional;
@@ -22,8 +23,10 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.intf.user.IOwnerCommitteeContractV1InnerServiceSMO;
 import com.java110.intf.user.IOwnerCommitteeV1InnerServiceSMO;
 import com.java110.po.ownerCommittee.OwnerCommitteePo;
+import com.java110.po.ownerCommitteeContract.OwnerCommitteeContractPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -46,16 +49,19 @@ import org.slf4j.LoggerFactory;
 @Java110Cmd(serviceCode = "ownerCommittee.updateOwnerCommittee")
 public class UpdateOwnerCommitteeCmd extends Cmd {
 
-  private static Logger logger = LoggerFactory.getLogger(UpdateOwnerCommitteeCmd.class);
+    private static Logger logger = LoggerFactory.getLogger(UpdateOwnerCommitteeCmd.class);
 
 
     @Autowired
     private IOwnerCommitteeV1InnerServiceSMO ownerCommitteeV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IOwnerCommitteeContractV1InnerServiceSMO ownerCommitteeContractV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "ocId", "ocId不能为空");
-Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
+        Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
 
     }
 
@@ -63,13 +69,31 @@ Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-       OwnerCommitteePo ownerCommitteePo = BeanConvertUtil.covertBean(reqJson, OwnerCommitteePo.class);
+        OwnerCommitteePo ownerCommitteePo = BeanConvertUtil.covertBean(reqJson, OwnerCommitteePo.class);
         int flag = ownerCommitteeV1InnerServiceSMOImpl.updateOwnerCommittee(ownerCommitteePo);
 
         if (flag < 1) {
             throw new CmdException("更新数据失败");
         }
 
+        JSONArray contracts = reqJson.getJSONArray("contracts");
+
+        if (contracts == null || contracts.size() < 1) {
+            return;
+        }
+        OwnerCommitteeContractPo ownerCommitteeContractPo = null;
+
+        ownerCommitteeContractPo = new OwnerCommitteeContractPo();
+        ownerCommitteeContractPo.setOcId(ownerCommitteePo.getOcId());
+        ownerCommitteeContractV1InnerServiceSMOImpl.deleteOwnerCommitteeContract(ownerCommitteeContractPo);
+
+        for (int contractIndex = 0; contractIndex < contracts.size(); contractIndex++) {
+            ownerCommitteeContractPo = BeanConvertUtil.covertBean(contracts.getJSONObject(contractIndex), OwnerCommitteeContractPo.class);
+            ownerCommitteeContractPo.setContractId(GenerateCodeFactory.getGeneratorId("11"));
+            ownerCommitteeContractPo.setOcId(ownerCommitteePo.getOcId());
+            ownerCommitteeContractV1InnerServiceSMOImpl.saveOwnerCommitteeContract(ownerCommitteeContractPo);
+        }
+
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }

+ 0 - 74
service-user/src/main/java/com/java110/user/cmd/ownerCommittee/UpdateOwnerCommitteeContractCmd.java

@@ -1,74 +0,0 @@
-/*
- * Copyright 2017-2020 吴学文 and java110 team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.java110.user.cmd.ownerCommittee;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.core.annotation.Java110Cmd;
-import com.java110.core.annotation.Java110Transactional;
-import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.Cmd;
-import com.java110.core.event.cmd.CmdEvent;
-import com.java110.intf.user.IOwnerCommitteeContractV1InnerServiceSMO;
-import com.java110.po.ownerCommitteeContract.OwnerCommitteeContractPo;
-import com.java110.utils.exception.CmdException;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.vo.ResultVo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * 类表述:更新
- * 服务编码:ownerCommitteeContract.updateOwnerCommitteeContract
- * 请求路劲:/app/ownerCommitteeContract.UpdateOwnerCommitteeContract
- * add by 吴学文 at 2023-03-06 12:01:17 mail: 928255095@qq.com
- * open source address: https://gitee.com/wuxw7/MicroCommunity
- * 官网:http://www.homecommunity.cn
- * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
- * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
- */
-@Java110Cmd(serviceCode = "ownerCommittee.updateOwnerCommitteeContract")
-public class UpdateOwnerCommitteeContractCmd extends Cmd {
-
-    private static Logger logger = LoggerFactory.getLogger(UpdateOwnerCommitteeContractCmd.class);
-
-
-    @Autowired
-    private IOwnerCommitteeContractV1InnerServiceSMO ownerCommitteeContractV1InnerServiceSMOImpl;
-
-    @Override
-    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
-        Assert.hasKeyAndValue(reqJson, "contractId", "contractId不能为空");
-        Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
-
-    }
-
-    @Override
-    @Java110Transactional
-    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
-
-        OwnerCommitteeContractPo ownerCommitteeContractPo = BeanConvertUtil.covertBean(reqJson, OwnerCommitteeContractPo.class);
-        int flag = ownerCommitteeContractV1InnerServiceSMOImpl.updateOwnerCommitteeContract(ownerCommitteeContractPo);
-
-        if (flag < 1) {
-            throw new CmdException("更新数据失败");
-        }
-
-        cmdDataFlowContext.setResponseEntity(ResultVo.success());
-    }
-}