Commit a0a5dc3b by liuyang

2024-10-24 验证项目立项客户已使用过的客户不能删除

parent 5b7fd38e
...@@ -8,6 +8,7 @@ import com.baosight.hggp.core.dao.DaoUtils; ...@@ -8,6 +8,7 @@ import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.constant.HGConstant; import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.cw.domain.HGCW002; import com.baosight.hggp.hg.cw.domain.HGCW002;
import com.baosight.hggp.hg.pz.domain.HGPZ002; import com.baosight.hggp.hg.pz.domain.HGPZ002;
import com.baosight.hggp.hg.sc.domain.HGSC001;
import com.baosight.hggp.hg.xs.tools.HGXSTools; import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.util.AssertUtils; import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.CommonMethod; import com.baosight.hggp.util.CommonMethod;
...@@ -205,7 +206,7 @@ public class ServiceHGPZ002 extends ServiceBase { ...@@ -205,7 +206,7 @@ public class ServiceHGPZ002 extends ServiceBase {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<String> custCodes = resultRows.stream().map(row -> row.get(HGPZ002.FIELD_CUST_CODE).toString()).collect(Collectors.toList()); List<String> custCodes = resultRows.stream().map(row -> row.get(HGPZ002.FIELD_CUST_CODE).toString()).collect(Collectors.toList());
List<HGCW002> hgcw002List = queryCustCode(custCodes); List<HGSC001> hgsc001List = queryCustCode(custCodes);
for (Map resultRow : resultRows) { for (Map resultRow : resultRows) {
HGPZ002 hgpz002 = new HGPZ002(); HGPZ002 hgpz002 = new HGPZ002();
hgpz002.fromMap(resultRow); hgpz002.fromMap(resultRow);
...@@ -214,26 +215,28 @@ public class ServiceHGPZ002 extends ServiceBase { ...@@ -214,26 +215,28 @@ public class ServiceHGPZ002 extends ServiceBase {
if (count > 0) { if (count > 0) {
//throw new PlatException(String.format("企业[%s]已关联用户,请先解除用户", hgpz002.getAccountName())); //throw new PlatException(String.format("企业[%s]已关联用户,请先解除用户", hgpz002.getAccountName()));
} }
List<HGCW002> hgcw002s =hgcw002List.stream().filter(hgcw002 -> hgcw002.getPartyA().equals(hgpz002.getCustCode())).collect(Collectors.toList()); List<HGSC001> hgcw002s =hgsc001List.stream().filter(hgsc001 ->
AssertUtils.isNotEmpty(hgcw002s, String.format("客户[%s]已关联业务,请先解除业务", hgpz002.getCustName())); hgsc001.getSubcontractCode().equals(hgpz002.getCustCode())||
hgsc001.getGenralContractCode().equals(hgpz002.getCustCode())
).collect(Collectors.toList());
AssertUtils.isNotEmpty(hgcw002s, String.format("客户[%s]已关联业务,无法删除", hgpz002.getCustName()));
DaoUtils.update(HGPZ002.DELETE, hgpz002); DaoUtils.update(HGPZ002.DELETE, hgpz002);
} }
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!"); inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "修改失败"); LogUtils.setDetailMsg(inInfo, e, "删除失败");
} }
return inInfo; return inInfo;
} }
public List<HGCW002> queryCustCode(List<String> custCodes){ public List<HGSC001> queryCustCode(List<String> custCodes){
List<HGCW002> hgcw002List = DaoBase.getInstance().query(HGCW002.QUERY, List<HGSC001> hgsc001List = DaoBase.getInstance().query(HGSC001.QUERY,
new HashMap<String,Object>(){{ new HashMap<String,Object>(){{
put("partyA", custCodes); put("custCodes", custCodes);
put("partyB", custCodes);
}}); }});
return hgcw002List; return hgsc001List;
} }
} }
...@@ -122,6 +122,10 @@ ...@@ -122,6 +122,10 @@
<isNotEmpty prepend=" AND " property="branchUnit"> <isNotEmpty prepend=" AND " property="branchUnit">
branch_unit = #branchUnit# branch_unit = #branchUnit#
</isNotEmpty> </isNotEmpty>
<isNotEmpty prepend=" AND " property="custCodes">
(subcontract_code in <iterate close=")" open="(" conjunction="," property="custCodes">#custCodes[]#</iterate>
or genral_contract_code in <iterate close=")" open="(" conjunction="," property="custCodes">#custCodes[]#</iterate>)
</isNotEmpty>
</sql> </sql>
<sql id="customCondition"> <sql id="customCondition">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment