Commit 85dfea34 by liuyang

2024-07-17 业务账期维护重复添加校验优化

parent 06610fdf
......@@ -97,13 +97,6 @@ public class ServiceHGCW001 extends ServiceBase {
hgcw001.setAccountPeriodDateStart(DateUtils.formatShort(hgcw001.getAccountPeriodDateStart()));
hgcw001.setAccountPeriodDateEnd(DateUtils.formatShort(hgcw001.getAccountPeriodDateEnd()));
if (hgcw001.getId() == null || hgcw001.getId() == 0) {
Map paramMap = new HashMap<>();
paramMap.put(HGCW001.FIELD_COMPANY_CODE,hgcw001.getCompanyCode());
paramMap.put(HGCW001.FIELD_ACCOUNT_PERIOD,hgcw001.getAccountPeriod());
HGCW001 cw001 =HGCWTools.HgCw001.getByCondition(paramMap); //获取当月业务账期
if (cw001 != null) {
throw new PlatException(String.format("公司[%s]会计期[%s]已存在,保存失败!",hgcw001.getCompanyCode(),hgcw001.getAccountPeriod()));
}
this.add(hgcw001);
} else {
this.modify(hgcw001);
......
package com.baosight.hggp.hg.cw.tools;
import cn.hutool.core.util.StrUtil;
import com.baosight.hggp.common.AccountPeriodStatusEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.cb.domain.HGCB001;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.cw.domain.*;
import com.baosight.hggp.hg.cw.vo.UserVO;
......@@ -69,7 +69,9 @@ public class HGCWTools {
* @param paramMap
* @return
*/
public static HGCW001 getByCondition(Map paramMap){
public static HGCW001 getByCondition(Map<String,String> paramMap){
AssertUtils.isEmpty(paramMap.get(HGCB001.FIELD_COMPANY_CODE), "公司不能为空!");
AssertUtils.isEmpty(paramMap.get(HGCB001.FIELD_ACCOUNT_PERIOD), "会计期不能为空!");
List<HGCW001> results = DaoBase.getInstance().query(HGCW001.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
......@@ -228,6 +230,18 @@ public class HGCWTools {
}
}
/**
* 检查数据是否重复
* @param hgcw001
*/
public static void checkSaveData(HGCW001 hgcw001){
Map<String,String> paramMap = new HashMap<>();
paramMap.put(HGCW001.FIELD_COMPANY_CODE,hgcw001.getCompanyCode());
paramMap.put(HGCW001.FIELD_ACCOUNT_PERIOD,hgcw001.getAccountPeriod());
HGCW001 cw001 = getByCondition(paramMap); //重复校验
AssertUtils.isNotNull(cw001, String.format("[%s]会计期[%s]已存在,无法重复添加,保存失败!",hgcw001.getCompanyName(),hgcw001.getAccountPeriod()));
}
public static List<HGCW001> queryNoAuth(Map paramMap){
List<HGCW001> list = DaoBase.getInstance().query(HGCW001.QUERY_NO_AUTH, paramMap);
return list;
......
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