Commit 053f47a2 by 江和松

Merge remote-tracking branch 'origin/dev' into dev

parents 3ade397b 7aa95d79
...@@ -57,6 +57,8 @@ public class HGCB001 extends DaoEPBase { ...@@ -57,6 +57,8 @@ public class HGCB001 extends DaoEPBase {
public static final String INSERT = "HGCB001.insert"; public static final String INSERT = "HGCB001.insert";
public static final String UPDATE = "HGCB001.update"; public static final String UPDATE = "HGCB001.update";
public static final String DELETE = "HGCB001.delete"; public static final String DELETE = "HGCB001.delete";
public static final String QUERY_NO_AUTH = "HGCB001.queryNoAuth";
private Long id = new Long(0); private Long id = new Long(0);
private String accountCode = " "; /* 企业编码*/ private String accountCode = " "; /* 企业编码*/
......
...@@ -2,22 +2,24 @@ package com.baosight.hggp.hg.cb.service; ...@@ -2,22 +2,24 @@ package com.baosight.hggp.hg.cb.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation; import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum; import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils; import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils; import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cb.domain.HGCB001; import com.baosight.hggp.hg.cb.domain.HGCB001;
import com.baosight.hggp.hg.cb.tools.HGCBTools;
import com.baosight.hggp.hg.cw.domain.HGCW001;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.xs.domain.Company; import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.CommonMethod; import com.baosight.hggp.util.*;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase; import com.baosight.iplat4j.core.service.impl.ServiceBase;
import org.apache.commons.collections.CollectionUtils;
import java.util.Arrays; import java.text.ParseException;
import java.util.List; import java.util.*;
import java.util.Map; import java.util.stream.Collectors;
/** /**
* @author yukang * @author yukang
...@@ -74,17 +76,16 @@ public class ServiceHGCB001 extends ServiceBase { ...@@ -74,17 +76,16 @@ public class ServiceHGCB001 extends ServiceBase {
public EiInfo save(EiInfo inInfo) { public EiInfo save(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<HGCB001> hgcb001List = MapUtils.toDaoEPBase(resultRows,HGCB001.class);
checkSaveData(hgcb001List);
// 写入数据 // 写入数据
for (int i = 0; i < resultRows.size(); i++) { Optional.ofNullable(hgcb001List).orElse(new ArrayList<>()).forEach(hgcb001 -> {
HGCB001 HGCB001 = new HGCB001(); hgcb001.setAccountPeriod(DateUtils.formatShort(hgcb001.getAccountPeriod()));
HGCB001.fromMap(resultRows.get(i)); });
HGCB001.setAccountPeriod(DateUtils.formatShort(HGCB001.getAccountPeriod())); List<HGCB001> addList = Optional.ofNullable(hgcb001List).orElse(new ArrayList<>()).stream().filter(o -> Objects.isNull(o.getId())||o.getId()==0).collect(Collectors.toList());
if (HGCB001.getId() == null || HGCB001.getId() == 0) { add(addList);
this.add(HGCB001); List<HGCB001> updateList = Optional.ofNullable(hgcb001List).orElse(new ArrayList<>()).stream().filter(o -> Objects.nonNull(o.getId())&&o.getId()!=0).collect(Collectors.toList());
} else { modify(updateList);
this.modify(HGCB001);
}
}
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() + "]条数据保存成功!");
...@@ -94,24 +95,53 @@ public class ServiceHGCB001 extends ServiceBase { ...@@ -94,24 +95,53 @@ public class ServiceHGCB001 extends ServiceBase {
return inInfo; return inInfo;
} }
private void checkSaveData(List<HGCB001> hgcb001List){
if(CollectionUtils.isNotEmpty(hgcb001List)) {
List<String> stringList = hgcb001List.stream().map(o -> {
return o.getCompanyCode() + "-" + o.getAccountPeriod();
}).collect(Collectors.toList());
long count = stringList.stream().distinct().count();
AssertUtils.isTrue(stringList.size() != count, "账期重复,请检查数据!");
}
}
/** /**
* 新增操作 * 新增操作
* *
* @param HGCB001 * @param addList
* @return * @return
*/ */
public void add(HGCB001 HGCB001) { public void add(List<HGCB001> addList) {
DaoUtils.insert("HGCB001.insert", HGCB001); Map<String,List<String>> periodMap = Optional.ofNullable(addList).orElse(new ArrayList<>()).stream().collect(
Collectors.groupingBy(HGCB001::getCompanyCode,Collectors.mapping(HGCB001::getAccountPeriod,Collectors.toList())));
Optional.ofNullable(periodMap).orElse(new HashMap<>()).forEach((k,v)->{
Map paramMap = new HashMap();
paramMap.put(HGCB001.FIELD_COMPANY_CODE,k);
paramMap.put("accountPeriods",v);
List dbList = HGCBTools.HgCb001.queryNoAuth(paramMap);
AssertUtils.isNotEmpty(dbList,"账期重复,请检查数据!");
});
DaoUtils.insertBatch(HGCB001.INSERT, addList);
} }
/** /**
* 修改操作 * 修改操作
* *
* @param HGCB001 * @param updateList
* @return * @return
*/ */
public void modify(HGCB001 HGCB001) { public void modify(List<HGCB001> updateList) {
DaoUtils.update("HGCB001.update", HGCB001); Map<String,List<String>> periodMap = Optional.ofNullable(updateList).orElse(new ArrayList<>()).stream().collect(
Collectors.groupingBy(HGCB001::getCompanyCode,Collectors.mapping(HGCB001::getAccountPeriod,Collectors.toList()))); List<Long> notIds = Optional.ofNullable(updateList).orElse(new ArrayList<>()).stream().map(HGCB001::getId).collect(Collectors.toList());
Optional.ofNullable(periodMap).orElse(new HashMap<>()).forEach((k,v)->{
Map paramMap = new HashMap();
paramMap.put(HGCB001.FIELD_COMPANY_CODE,k);
paramMap.put("accountPeriods",v);
paramMap.put("notIds",notIds);
List dbList = HGCBTools.HgCb001.queryNoAuth(paramMap);
AssertUtils.isNotEmpty(dbList,"账期重复,请检查数据!");
});
DaoUtils.updateBatch(HGCB001.UPDATE, updateList);
} }
/** /**
...@@ -175,9 +205,13 @@ public class ServiceHGCB001 extends ServiceBase { ...@@ -175,9 +205,13 @@ public class ServiceHGCB001 extends ServiceBase {
public EiInfo delete(EiInfo inInfo) { public EiInfo delete(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (int i = 0; i < resultRows.size(); i++) { List<HGCB001> hgcb001List = MapUtils.toDaoEPBase(resultRows,HGCB001.class);
DaoUtils.update("HGCB001.delete", resultRows.get(i)); Optional.ofNullable(hgcb001List).orElse(new ArrayList<>()).stream().forEach(o -> {
} AssertUtils.isTrue(o.getAccountPeriodStatus()== CommonConstant.YesNo.NO_0,String.format(
"%s[%s]账期已关账,无法删除!",o.getCompanyName(),o.getAccountPeriod()
));
});
DaoUtils.updateBatch("HGCB001.delete", hgcb001List);
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() + "]条数据删除成功!");
...@@ -196,24 +230,24 @@ public class ServiceHGCB001 extends ServiceBase { ...@@ -196,24 +230,24 @@ public class ServiceHGCB001 extends ServiceBase {
public EiInfo switchRow(EiInfo inInfo) { public EiInfo switchRow(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
HGCB001 HGCB001 = new HGCB001(); HGCB001 hgcb001 = new HGCB001();
HGCB001.fromMap(resultRows.get(0)); hgcb001.fromMap(resultRows.get(0));
Integer accountPeriodStatus = hgcb001.getAccountPeriodStatus();
Integer accountPeriodStatus = HGCB001.getAccountPeriodStatus();
if (accountPeriodStatus == 1) { if (accountPeriodStatus == 1) {
//开账 - 做关账 //开账 - 做关账
HGCB001.setAccountPeriodStatus(0); //当前账期的上个账期是否关账,当前账期对应的业务账是否关账
DaoUtils.update("HGCB001.updateSwitchRow", HGCB001); hgcb001.setAccountPeriodStatus(0);
DaoUtils.update("HGCB001.updateSwitchRow", hgcb001);
} else if (accountPeriodStatus == 0) { } else if (accountPeriodStatus == 0) {
//先找是否已经有开账的记录 //当前账期的下个账期是否开账状态
int switchRowNum = dao.count("HGCB001.getSwitchRowNum", HGCB001); int switchRowNum = dao.count("HGCB001.getSwitchRowNum", hgcb001);
if (switchRowNum > 0) { if (switchRowNum > 0) {
inInfo.setStatus(EiConstant.STATUS_FAILURE); inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!已经有一个会计期为开账状态!"); inInfo.setMsg("操作失败!已经有一个会计期为开账状态!");
return inInfo; return inInfo;
} }
HGCB001.setAccountPeriodStatus(1); hgcb001.setAccountPeriodStatus(1);
DaoUtils.update("HGCB001.updateSwitchRow", HGCB001); DaoUtils.update("HGCB001.updateSwitchRow", hgcb001);
} }
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
...@@ -223,5 +257,43 @@ public class ServiceHGCB001 extends ServiceBase { ...@@ -223,5 +257,43 @@ public class ServiceHGCB001 extends ServiceBase {
} }
return inInfo; return inInfo;
} }
private void checkSwitchDate(HGCB001 hgcb001){
try {
HGCB001 dbhgcb001 = null;
switch (hgcb001.getAccountPeriodStatus()) {
case 0:
Date nextDate = DateUtils.addMonths(DateUtils.parseDate(hgcb001.getAccountPeriod(), DateUtil.DATE12_PATTERN), 1);
String nextDateStr = DateUtil.toDateStr(nextDate,DateUtil.DATE12_PATTERN);
dbhgcb001 = HGCBTools.HgCb001.getNoAuth(new HashMap(){{
put(HGCW001.FIELD_COMPANY_CODE,hgcb001.getCompanyCode());
put(HGCW001.FIELD_ACCOUNT_PERIOD,nextDateStr);
}});
AssertUtils.isTrue(Objects.nonNull(dbhgcb001)&&dbhgcb001.getAccountPeriodStatus()== CommonConstant.YesNo.NO_0,String.format("下个账期为关账状态:%s[%s]账期会计账已经关账!",dbhgcb001.getCompanyName(),dbhgcb001.getAccountPeriod()));
break;
case 1:
Date lastDate = DateUtils.addMonths(DateUtils.parseDate(hgcb001.getAccountPeriod(), DateUtil.DATE12_PATTERN), -1);
String lastDateStr = DateUtil.toDateStr(lastDate,DateUtil.DATE12_PATTERN);
dbhgcb001 = HGCBTools.HgCb001.getNoAuth(new HashMap(){{
put(HGCW001.FIELD_COMPANY_CODE,hgcb001.getCompanyCode());
put(HGCW001.FIELD_ACCOUNT_PERIOD,lastDateStr);
}});
AssertUtils.isNull(Objects.isNull(dbhgcb001),String.format("会计账期缺失:%s[%s]账期会计账不存在!",hgcb001.getCompanyName(),lastDateStr));
AssertUtils.isTrue(dbhgcb001.getAccountPeriodStatus()== CommonConstant.YesNo.YES_1,String.format("上个账期未关账:%s[%s]账期会计账未关账!",dbhgcb001.getCompanyName(),dbhgcb001.getAccountPeriod()));
HGCW001 hgcw001 = HGCWTools.HgCw001.getNoAuth(new HashMap(){{
put(HGCW001.FIELD_COMPANY_CODE,hgcb001.getCompanyCode());
put(HGCW001.FIELD_ACCOUNT_PERIOD,hgcb001.getAccountPeriod());
}});
AssertUtils.isTrue(Objects.nonNull(hgcw001)&&hgcw001.getAccountPeriodStatus()== CommonConstant.YesNo.YES_1,String.format("业务账未关账:%s[%s]账期业务账未关账!",hgcb001.getCompanyName(),hgcb001.getAccountPeriod()));
break;
default:
AssertUtils.isTrue(true,"会计账期状态异常!");
break;
}
} catch (ParseException e) {
AssertUtils.isTrue(true,"会计账期会计期异常!");
e.printStackTrace();
}
}
} }
...@@ -72,6 +72,8 @@ public class ServiceHGCB002 extends ServiceEPBase { ...@@ -72,6 +72,8 @@ public class ServiceHGCB002 extends ServiceEPBase {
} }
HGCBTools.HgCb002.select(params); HGCBTools.HgCb002.select(params);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次数据同步成功!");
}catch (Exception e){ }catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "同步数据失败"); LogUtils.setDetailMsg(inInfo, e, "同步数据失败");
} }
......
...@@ -59,6 +59,8 @@ public class ServiceHGCB003 extends ServiceEPBase { ...@@ -59,6 +59,8 @@ public class ServiceHGCB003 extends ServiceEPBase {
throw new PlatException(String.format("公司[%s]上月会计期[%s]为开账状态,数据同步失败!", hgcw001Last.getCompanyCode(), hgcw001Last.getAccountPeriod())); throw new PlatException(String.format("公司[%s]上月会计期[%s]为开账状态,数据同步失败!", hgcw001Last.getCompanyCode(), hgcw001Last.getAccountPeriod()));
} }
HGCBTools.HgCb003.select(params); HGCBTools.HgCb003.select(params);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次数据同步成功!");
}catch (Exception e){ }catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "同步数据失败"); LogUtils.setDetailMsg(inInfo, e, "同步数据失败");
} }
......
...@@ -93,7 +93,7 @@ public class ServiceHGCB004 extends ServiceEPBase { ...@@ -93,7 +93,7 @@ public class ServiceHGCB004 extends ServiceEPBase {
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次数据同步成功!"); inInfo.setMsg("操作成功!本次数据同步成功!");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "数据同步失败"); LogUtils.setDetailMsg(inInfo, e, "同步数据失败");
} }
return inInfo; return inInfo;
} }
......
...@@ -23,6 +23,59 @@ ...@@ -23,6 +23,59 @@
--> -->
<sqlMap namespace="HGCB001"> <sqlMap namespace="HGCB001">
<sql id="no_auth_condition">
<isNotEmpty prepend=" AND " property="notIds">
ID NOT IN <iterate close=")" open="(" conjunction="," property="notIds">#notIds[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="ids">
ID IN <iterate close=")" open="(" conjunction="," property="ids">#ids[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriods">
ACCOUNT_PERIOD IN <iterate close=")" open="(" conjunction="," property="accountPeriods">#accountPeriods[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyName">
COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountYear">
ACCOUNT_YEAR = #accountYear#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriod">
ACCOUNT_PERIOD = #accountPeriod#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodStatus">
ACCOUNT_PERIOD_STATUS = #accountPeriodStatus#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
</sql>
<sql id="condition"> <sql id="condition">
<include refid="HGXSDataAuth.authCondition"/> <include refid="HGXSDataAuth.authCondition"/>
<isNotEmpty prepend=" AND " property="id"> <isNotEmpty prepend=" AND " property="id">
...@@ -287,4 +340,27 @@ ...@@ -287,4 +340,27 @@
ID = #id# ID = #id#
</update> </update>
<select id="queryNoAuth" parameterClass="java.util.HashMap"
resultClass="com.baosight.hggp.hg.cb.domain.HGCB001">
SELECT
ID as "id",
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
ACCOUNT_YEAR as "accountYear", <!-- 会计年度 -->
ACCOUNT_PERIOD as "accountPeriod", <!-- 会计期 -->
ACCOUNT_PERIOD_STATUS as "accountPeriodStatus", <!-- 会计期状态0:关账1:开账 -->
CREATED_BY as "createdBy", <!-- 记录创建者 -->
CREATED_NAME as "createdName", <!-- 记录创建名称 -->
CREATED_TIME as "createdTime", <!-- 记录创建时间 -->
UPDATED_BY as "updatedBy", <!-- 记录修改者 -->
UPDATED_NAME as "updatedName", <!-- 记录修改名称 -->
UPDATED_TIME as "updatedTime", <!-- 记录修改时间 -->
DEP_CODE as "depCode" <!-- 部门编码 -->
FROM ${hggpSchema}.HGCB001 WHERE 1=1
where 1=1
<include refid="no_auth_condition"/>
</select>
</sqlMap> </sqlMap>
...@@ -46,6 +46,7 @@ import java.util.stream.Collectors; ...@@ -46,6 +46,7 @@ import java.util.stream.Collectors;
*/ */
public class HGCBTools { public class HGCBTools {
public static void setBaseInfo(List<HGCB004> cb004s) { public static void setBaseInfo(List<HGCB004> cb004s) {
for (HGCB004 hgcb004 : cb004s) { for (HGCB004 hgcb004 : cb004s) {
...@@ -74,6 +75,22 @@ public class HGCBTools { ...@@ -74,6 +75,22 @@ public class HGCBTools {
public static class HgCb001 { public static class HgCb001 {
public static List<HGCB001> listByIds(List<Long> ids){
List<HGCB001> hgcb001s = queryNoAuth(new HashMap(){{put("ids",ids);}});
return hgcb001s;
}
public static List<HGCB001> queryNoAuth(Map paramMap){
List<HGCB001> hgcb001s = DaoBase.getInstance().query(HGCB001.QUERY_NO_AUTH, paramMap);
return hgcb001s;
}
public static HGCB001 getNoAuth(Map paramMap){
List<HGCB001> list = queryNoAuth(paramMap);
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
/** /**
* 查询当前公司账期 * 查询当前公司账期
* @param params 业务账期 * @param params 业务账期
...@@ -430,10 +447,10 @@ public class HGCBTools { ...@@ -430,10 +447,10 @@ public class HGCBTools {
* @param queryMap * @param queryMap
* @return * @return
*/ */
public static List<HGCB004> synchData(Map<String,Object> queryMap) { public static List<HGCB004> synchData(Map<String,String> queryMap) {
queryMap.put(HGCB004.FIELD_DATE_TYPE, CommonConstant.DateType.MONTH); queryMap.put(HGCB004.FIELD_DATE_TYPE, CommonConstant.DateType.MONTH);
queryMap.put(HGCB004.FIELD_INVENT_TYPE_DETAIL,InventTypeDetailEnum.RAW.getCode()); queryMap.put(HGCB004.FIELD_INVENT_TYPE_DETAIL,InventTypeDetailEnum.RAW.getCode().toString());
//删除当月同时数据 //删除当月同时数据
DaoBase.getInstance().delete(HGCB004.DELETE_BY_TIME, queryMap); DaoBase.getInstance().delete(HGCB004.DELETE_BY_TIME, queryMap);
// 1、统计收发存 // 1、统计收发存
......
...@@ -63,6 +63,8 @@ public class HGCW001 extends DaoEPBase { ...@@ -63,6 +63,8 @@ public class HGCW001 extends DaoEPBase {
public static final String INSERT = "HGCW001.insert"; public static final String INSERT = "HGCW001.insert";
public static final String UPDATE = "HGCW001.update"; public static final String UPDATE = "HGCW001.update";
public static final String DELETE = "HGCW001.delete"; public static final String DELETE = "HGCW001.delete";
public static final String QUERY_NO_AUTH = "HGCW001.queryNoAuth";
private Long id = new Long(0); private Long id = new Long(0);
private String accountCode = " "; /* 企业编码*/ private String accountCode = " "; /* 企业编码*/
...@@ -70,7 +72,7 @@ public class HGCW001 extends DaoEPBase { ...@@ -70,7 +72,7 @@ public class HGCW001 extends DaoEPBase {
private String companyName = " "; /* 公司名称*/ private String companyName = " "; /* 公司名称*/
private String accountYear = " "; /* 会计年度*/ private String accountYear = " "; /* 会计年度*/
private String accountPeriod = " "; /* 会计期*/ private String accountPeriod = " "; /* 会计期*/
private Integer accountPeriodStatus; /* 会计期状态0:关账1:开账*/ private Integer accountPeriodStatus = 1; /* 会计期状态0:关账1:开账*/
private String accountPeriodDateStart = " "; /* 账期开始日期*/ private String accountPeriodDateStart = " "; /* 账期开始日期*/
private String accountPeriodDateEnd = " "; /* 账期结束日期*/ private String accountPeriodDateEnd = " "; /* 账期结束日期*/
private String createdBy = " "; /* 记录创建者*/ private String createdBy = " "; /* 记录创建者*/
......
package com.baosight.hggp.hg.cw.service; package com.baosight.hggp.hg.cw.service;
import cn.hutool.core.bean.BeanUtil;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation; import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum; import com.baosight.hggp.common.DdynamicEnum;
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.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils; import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cb.domain.HGCB001;
import com.baosight.hggp.hg.cb.tools.HGCBTools;
import com.baosight.hggp.hg.cw.domain.HGCW001; import com.baosight.hggp.hg.cw.domain.HGCW001;
import com.baosight.hggp.hg.cw.domain.HGCW002; import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.sb.domain.HGSB001;
import com.baosight.hggp.hg.sb.tools.HGSBTools; import com.baosight.hggp.hg.sb.tools.HGSBTools;
import com.baosight.hggp.hg.xs.domain.Company; import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.hg.xs.domain.Org; import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.util.CommonMethod; import com.baosight.hggp.util.*;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.contants.ACConstants; import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase; import com.baosight.iplat4j.core.service.impl.ServiceBase;
import java.util.Arrays; import java.text.SimpleDateFormat;
import java.util.HashMap; import java.time.LocalDate;
import java.util.List; import java.util.*;
import java.util.Map;
/** /**
* @author yukang * @author yukang
* @date 2024年05月06日 18:22 * @date 2024年05月06日 18:22
*/ */
public class ServiceHGCW001 extends ServiceBase { public class ServiceHGCW001 extends ServiceBase {
/** /**
* 画面初始化 * 画面初始化
* *
* @param inInfo * @param inInfo
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "业务账期维护",operType = "查询",operDesc = "初始化")
@Override
@OperationLogAnnotation(operModul = "账期维护",operType = "查询",operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) { public EiInfo initLoad(EiInfo inInfo) {
EiInfo outInfo = super.initLoad(inInfo,new HGCW001()); EiInfo outInfo = super.initLoad(inInfo,new HGCW001());
try { try {
...@@ -49,7 +46,7 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -49,7 +46,7 @@ public class ServiceHGCW001 extends ServiceBase {
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCW001().eiMetadata); inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCW001().eiMetadata);
outInfo = super.query(inInfo, HGCW001.QUERY, new HGCW001()); outInfo = super.query(inInfo, HGCW001.QUERY, new HGCW001());
Map<String,Object> qarma = new HashMap<>(); Map<String,Object> qarma = new HashMap<>();
EiInfoUtils.addBlock(outInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class); EiInfoUtils.addBlock(outInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.GROUP_RECORD_BLOCK_ID)); CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.GROUP_RECORD_BLOCK_ID));
//角色公司 //角色公司
List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode(); List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
...@@ -67,17 +64,16 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -67,17 +64,16 @@ public class ServiceHGCW001 extends ServiceBase {
* @param inInfo * @param inInfo
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "账期维护",operType = "查询",operDesc = "查询") @OperationLogAnnotation(operModul = "业务账期维护",operType = "查询",operDesc = "查询")
@Override @Override
public EiInfo query(EiInfo inInfo) { public EiInfo query(EiInfo inInfo) {
List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
if (!roleCompanyCode.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HGCW001.FIELD_COMPANY_CODES,roleCompanyCode);
}
try { try {
List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
if (!roleCompanyCode.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HGCW001.FIELD_COMPANY_CODES,roleCompanyCode);
}
inInfo = super.query(inInfo, HGCW001.QUERY, new HGCW001()); inInfo = super.query(inInfo, HGCW001.QUERY, new HGCW001());
} }catch (Exception e) {
catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
} }
return inInfo; return inInfo;
...@@ -89,24 +85,30 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -89,24 +85,30 @@ public class ServiceHGCW001 extends ServiceBase {
* @param inInfo * @param inInfo
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "账期维护",operType = "保存",operDesc = "保存") @OperationLogAnnotation(operModul = "业务账期维护",operType = "保存",operDesc = "保存")
public EiInfo save(EiInfo inInfo) { public EiInfo save(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据 // 写入数据
for (int i = 0; i < resultRows.size(); i++) { for (Map resultRow : resultRows) {
HGCW001 HGCW001 = new HGCW001(); HGCW001 hgcw001 = new HGCW001();
HGCW001.fromMap(resultRows.get(i)); hgcw001.fromMap(resultRow);
HGCW001.setAccountPeriod(DateUtils.formatShort(HGCW001.getAccountPeriod())); hgcw001.setAccountPeriod(DateUtils.formatShort(hgcw001.getAccountPeriod()));
HGCW001.setAccountPeriodDateStart(DateUtils.formatShort(HGCW001.getAccountPeriodDateStart())); hgcw001.setAccountPeriodDateStart(DateUtils.formatShort(hgcw001.getAccountPeriodDateStart()));
HGCW001.setAccountPeriodDateEnd(DateUtils.formatShort(HGCW001.getAccountPeriodDateEnd())); hgcw001.setAccountPeriodDateEnd(DateUtils.formatShort(hgcw001.getAccountPeriodDateEnd()));
if (HGCW001.getId() == null || HGCW001.getId() == 0) { if (hgcw001.getId() == null || hgcw001.getId() == 0) {
this.add(HGCW001); 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 { } else {
this.modify(HGCW001); this.modify(hgcw001);
} }
} }
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) {
...@@ -118,11 +120,20 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -118,11 +120,20 @@ public class ServiceHGCW001 extends ServiceBase {
/** /**
* 新增操作 * 新增操作
* *
* @param HGCW001 * @param hgcw001
* @return * @return
*/ */
public void add(HGCW001 HGCW001) { public void add(HGCW001 hgcw001) {
DaoUtils.insert("HGCW001.insert", HGCW001); DaoUtils.insert(HGCW001.INSERT, hgcw001);
HGCB001 hgcb001 = new HGCB001();
BeanUtils.copyProperties(hgcw001,hgcb001);
HGCB001 cb001 = HGCBTools.HgCb001.select(new HashMap<String,String>(){{
put(HGCB001.FIELD_ACCOUNT_PERIOD,hgcw001.getAccountPeriod());
put(HGCB001.FIELD_COMPANY_CODE,hgcw001.getCompanyCode());
}});
if (cb001 == null) {
DaoUtils.insert(HGCB001.INSERT, hgcb001); //同步添加会计期维护
}
} }
/** /**
...@@ -141,18 +152,27 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -141,18 +152,27 @@ public class ServiceHGCW001 extends ServiceBase {
* @param inInfo * @param inInfo
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "账期维护",operType = "新增",operDesc = "新增") @OperationLogAnnotation(operModul = "业务账期维护",operType = "新增",operDesc = "新增")
@Override @Override
public EiInfo insert(EiInfo inInfo) { public EiInfo insert(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 数据写入 // 数据写入
for (int i = 0; i < resultRows.size(); i++) { for (Map resultRow : resultRows) {
HGCW001 HGCW001 = new HGCW001(); HGCW001 hgcw001 = new HGCW001();
HGCW001.fromMap(resultRows.get(i)); hgcw001.fromMap(resultRow);
DaoUtils.insert("HGCW001.insert", HGCW001); Map paramMap = new HashMap<>();
paramMap.put(HGCW001.FIELD_COMPANY_CODE,hgcw001.getCompanyCode());
paramMap.put(HGCW001.FIELD_ACCOUNT_PERIOD,hgcw001.getAccountPeriod());
HGCW001 hgcw0011 =HGCWTools.HgCw001.getByCondition(paramMap); //获取当月业务账期
if (hgcw0011 == null) {
throw new PlatException(String.format("公司[%s]会计期[%s]已存在",hgcw001.getCompanyCode(),hgcw001.getAccountPeriod()));
}
//HGCW001 hgcw001Last =HGCWTools.HgCw001.getByCondition(paramMap); //获取上月业务账期
DaoUtils.insert(HGCW001.INSERT, hgcw001);
} }
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) {
...@@ -167,15 +187,16 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -167,15 +187,16 @@ public class ServiceHGCW001 extends ServiceBase {
* @param inInfo * @param inInfo
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "账期维护",operType = "修改",operDesc = "修改") @OperationLogAnnotation(operModul = "业务账期维护",operType = "修改",operDesc = "修改")
@Override
public EiInfo update(EiInfo inInfo) { public EiInfo update(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (int i = 0; i < resultRows.size(); i++) { for (Map resultRow : resultRows) {
HGCW001 HGCW001 = new HGCW001(); HGCW001 hgcw001 = new HGCW001();
HGCW001.fromMap(resultRows.get(i)); hgcw001.fromMap(resultRow);
HGCW001.setAccountPeriod(DateUtils.formatShort(HGCW001.getAccountPeriod())); hgcw001.setAccountPeriod(DateUtils.formatShort(hgcw001.getAccountPeriod()));
DaoUtils.update("HGCW001.update", HGCW001); DaoUtils.update(HGCW001.UPDATE, hgcw001);
} }
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
...@@ -192,14 +213,24 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -192,14 +213,24 @@ public class ServiceHGCW001 extends ServiceBase {
* @param inInfo * @param inInfo
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "账期维护",operType = "删除",operDesc = "删除") @OperationLogAnnotation(operModul = "业务账期维护",operType = "删除",operDesc = "删除")
@Override
public EiInfo delete(EiInfo inInfo) { public EiInfo delete(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (int i = 0; i < resultRows.size(); i++) { for (Map resultRow : resultRows) {
DaoUtils.update("HGCW001.delete", resultRows.get(i)); if (resultRow.get(HGCW001.FIELD_ACCOUNT_PERIOD_STATUS).equals(0)){
throw new PlatException(String.format("公司[%s]会计期[%s]为关账状态,不能删除",resultRow.get(HGCW001.FIELD_COMPANY_CODE),resultRow.get(HGCW001.FIELD_ACCOUNT_PERIOD)));
}
Map paramMap = new HashMap<>();
paramMap.put(HGCW001.FIELD_COMPANY_CODE,resultRow.get(HGCW001.FIELD_COMPANY_CODE));
paramMap.put(HGCW001.FIELD_ACCOUNT_PERIOD,resultRow.get(HGCW001.FIELD_ACCOUNT_PERIOD));
HGCB001 hgcb001 = HGCBTools.HgCb001.select(paramMap);
if (hgcb001 != null && hgcb001.getAccountPeriodStatus() == 0) {
throw new PlatException(String.format("公司[%s]会计期[%s]为关账,不能删除",resultRow.get(HGCW001.FIELD_COMPANY_CODE),resultRow.get(HGCW001.FIELD_ACCOUNT_PERIOD)));
}
DaoUtils.update("HGCW001.delete", resultRow);
} }
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) {
...@@ -217,26 +248,46 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -217,26 +248,46 @@ public class ServiceHGCW001 extends ServiceBase {
public EiInfo switchRow(EiInfo inInfo) { public EiInfo switchRow(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
HGCW001 HGCW001 = new HGCW001(); HGCW001 hgcw001 = new HGCW001();
HGCW001.fromMap(resultRows.get(0)); hgcw001.fromMap(resultRows.get(0));
Map paramMap = new HashMap<>();
paramMap.put(HGCW001.FIELD_COMPANY_CODE,hgcw001.getCompanyCode());
paramMap.put(HGCW001.FIELD_ACCOUNT_PERIOD,hgcw001.getAccountPeriod());
Integer accountPeriodStatus = HGCW001.getAccountPeriodStatus(); Integer accountPeriodStatus = hgcw001.getAccountPeriodStatus();
if (accountPeriodStatus == 1) { if (accountPeriodStatus == 1) {
//开账 - 做关账 //开账 - 做关账 0
HGCW001.setAccountPeriodStatus(0); HGCW001 cw001 = HGCWTools.HgCw001.getAccountPeriodStart(hgcw001.getCompanyCode(), hgcw001.getAccountYear(), hgcw001.getAccountPeriod(), 1);
DaoUtils.update("HGCW001.updateSwitchRow", HGCW001); if (cw001 != null) {
} else if (accountPeriodStatus == 0) { throw new PlatException("关账失败,业务账期不能跨月关账!");
}
// 查询会计期是否为开账状态
HGCB001 hgcb001 = HGCBTools.HgCb001.select(paramMap);
//先找是否已经有开账的记录 //先找是否已经有开账的记录
int switchRowNum = dao.count("HGCW001.getSwitchRowNum", HGCW001); //int switchRowNum = dao.count("HGCW001.getSwitchRowNum", hgcw001);
if (switchRowNum > 0) { if (hgcb001 == null) {
inInfo.setStatus(EiConstant.STATUS_FAILURE); throw new PlatException(String.format("公司[%s]会计期[%s]会计期维护为空,业务账期关账失败!", hgcw001.getCompanyCode(),hgcw001.getAccountPeriod()));
inInfo.setMsg("操作失败!已经有一个会计期为开账状态!");
return inInfo;
} }
HGCW001.setAccountPeriodStatus(1); if (hgcb001.getAccountPeriodStatus() == 0) {
DaoUtils.update("HGCW001.updateSwitchRow", HGCW001); throw new PlatException(String.format("公司[%s]会计期[%s]会计期维护为关账状态,业务账期关账失败!", hgcb001.getCompanyCode(),hgcw001.getAccountPeriod()));
}
//检查数据
HGCWTools.HgCw001.checkAllData(hgcw001);
hgcw001.setAccountPeriodStatus(0); //关账
DaoUtils.update("HGCW001.updateSwitchRow", hgcw001);
} else if (accountPeriodStatus == 0) {
//关账 - 做开账 1
HGCW001 cw001 = HGCWTools.HgCw001.getAccountPeriodEnd(hgcw001.getCompanyCode(), hgcw001.getAccountYear(), hgcw001.getAccountPeriod(), 0);
if (cw001 != null) {
throw new PlatException("开账失败,业务账期不能跨月开账!");
}
hgcw001.setAccountPeriodStatus(1); //开账
DaoUtils.update("HGCW001.updateSwitchRow", hgcw001);
} }
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) {
...@@ -244,5 +295,19 @@ public class ServiceHGCW001 extends ServiceBase { ...@@ -244,5 +295,19 @@ public class ServiceHGCW001 extends ServiceBase {
} }
return inInfo; return inInfo;
} }
/**
* 查询上月的会计期
*/
public EiInfo queryLast(EiInfo inInfo) {
try {
Map paramMap =EiInfoUtils.getFirstRow(inInfo);
HGCWTools.HgCw001.getaccountPeriodDateStart(inInfo,paramMap);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "查询上月的会计期失败");
}
return inInfo;
}
} }
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
--> -->
<sqlMap namespace="HGCW001"> <sqlMap namespace="HGCW001">
<sql id="condition"> <sql id="no_auth_condition">
<include refid="HGXSDataAuth.authCondition"/>
<isNotEmpty prepend=" AND " property="id"> <isNotEmpty prepend=" AND " property="id">
ID = #id# ID = #id#
</isNotEmpty> </isNotEmpty>
...@@ -78,6 +77,67 @@ ...@@ -78,6 +77,67 @@
</isNotEmpty> </isNotEmpty>
</sql> </sql>
<sql id="condition">
<include refid="HGXSDataAuth.authCondition"/>
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyName">
COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountYear">
ACCOUNT_YEAR = #accountYear#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriod">
ACCOUNT_PERIOD = #accountPeriod#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodStatus">
ACCOUNT_PERIOD_STATUS = #accountPeriodStatus#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
ACCOUNT_PERIOD_DATE_START >= #accountPeriodDateStart#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
ACCOUNT_PERIOD_DATE_END &lt;= #accountPeriodDateEnd#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCodes">
COMPANY_CODE IN <iterate close=")" open="(" conjunction="," property="companyCodes">#companyCodes[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodStart">
ACCOUNT_PERIOD >= #accountPeriodStart#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodEnd">
ACCOUNT_PERIOD &lt;= #accountPeriodEnd#
</isNotEmpty>
</sql>
<select id="query" parameterClass="java.util.HashMap" <select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hggp.hg.cw.domain.HGCW001"> resultClass="com.baosight.hggp.hg.cw.domain.HGCW001">
SELECT SELECT
...@@ -104,7 +164,7 @@ ...@@ -104,7 +164,7 @@
$orderBy$ $orderBy$
</isNotEmpty> </isNotEmpty>
<isEmpty property="orderBy"> <isEmpty property="orderBy">
ID asc ACCOUNT_YEAR desc, ACCOUNT_PERIOD desc, ID desc
</isEmpty> </isEmpty>
</dynamic> </dynamic>
...@@ -332,4 +392,26 @@ ...@@ -332,4 +392,26 @@
</select> </select>
<select id="queryNoAuth" parameterClass="java.util.HashMap"
resultClass="com.baosight.hggp.hg.cw.domain.HGCW001">
SELECT
ID as "id",
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
ACCOUNT_YEAR as "accountYear", <!-- 会计年度 -->
ACCOUNT_PERIOD as "accountPeriod", <!-- 会计期 -->
ACCOUNT_PERIOD_STATUS as "accountPeriodStatus", <!-- 会计期状态0:关账1:开账 -->
ACCOUNT_PERIOD_DATE_START as "accountPeriodDateStart", <!-- 账期开始日期 -->
ACCOUNT_PERIOD_DATE_END as "accountPeriodDateEnd", <!-- 账期结束日期 -->
CREATED_BY as "createdBy", <!-- 记录创建者 -->
CREATED_NAME as "createdName", <!-- 记录创建名称 -->
CREATED_TIME as "createdTime", <!-- 记录创建时间 -->
UPDATED_BY as "updatedBy", <!-- 记录修改者 -->
UPDATED_NAME as "updatedName", <!-- 记录修改名称 -->
UPDATED_TIME as "updatedTime", <!-- 记录修改时间 -->
DEP_CODE as "depCode" <!-- 部门编码 -->
FROM ${hggpSchema}.HGCW001 WHERE 1=1
<include refid="no_auth_condition"/>
</select>
</sqlMap> </sqlMap>
...@@ -38,6 +38,39 @@ ...@@ -38,6 +38,39 @@
--> -->
<sqlMap namespace="HGCW012"> <sqlMap namespace="HGCW012">
<sql id="column">
ID as "id",
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
SETTLEMENT_NUMBER as "settlementNumber", <!-- 来源单号 -->
BILL_TYBE as "billTybe", <!-- 票据类型 -->
BILL_NUMBER as "billNumber", <!-- 发票号 -->
BILL_STATE as "billState", <!-- 开票状态 -->
SIGNING_DATE as "signingDate", <!-- 开票日期 -->
PARTY_A as "partyA", <!-- 供应商名称 -->
REVIEW_STATUS as "reviewStatus", <!-- 审批状态 -->
TAX_POINTS as "taxPoints", <!-- 税率 -->
THIS_SETTLEMENT_TAX as "thisSettlementTax", <!-- 税额 -->
THIS_SETTLEMENT_AMOUNT as "thisSettlementAmount", <!-- 不含税金额 -->
TOTAL_CONTRACT_PRICE_INCLUDING as "totalContractPriceIncluding", <!-- 发票总额 -->
CREATED_BY as "createdBy", <!-- 记录创建者 -->
CREATED_NAME as "createdName", <!-- 记录创建名称 -->
CREATED_TIME as "createdTime", <!-- 记录创建时间 -->
UPDATED_BY as "updatedBy", <!-- 记录修改者 -->
UPDATED_NAME as "updatedName", <!-- 记录修改名称 -->
UPDATED_TIME as "updatedTime", <!-- 记录修改时间 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
REMAINING_AMOUNT as "remainingAmount", <!-- 剩余开票/收票金额 -->
RECEIVE_DATE as "receiveDate", <!-- 收票日期 -->
CONTRACT_TYPE as "contractType", <!-- 合同类型;1.采购收货2.劳务3.租赁 -->
INVENT_TYPE_DETAIL as "inventTypeDetail", <!-- 存货大类 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
SPEC as "spec", <!-- 规格 -->
DEPOSIT_QTY as "depositQty", <!-- 入库数量 -->
RECEIVE_WEIGHT as "receiveWeight" <!-- 收货重量 -->
</sql>
<sql id="condition"> <sql id="condition">
<isNotEmpty prepend=" AND " property="id"> <isNotEmpty prepend=" AND " property="id">
ID = #id# ID = #id#
...@@ -137,37 +170,7 @@ ...@@ -137,37 +170,7 @@
<select id="query" parameterClass="java.util.HashMap" <select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hggp.hg.cw.domain.HGCW012"> resultClass="com.baosight.hggp.hg.cw.domain.HGCW012">
SELECT SELECT
ID as "id", <include refid="column" />
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
SETTLEMENT_NUMBER as "settlementNumber", <!-- 来源单号 -->
BILL_TYBE as "billTybe", <!-- 票据类型 -->
BILL_NUMBER as "billNumber", <!-- 发票号 -->
BILL_STATE as "billState", <!-- 开票状态 -->
SIGNING_DATE as "signingDate", <!-- 开票日期 -->
PARTY_A as "partyA", <!-- 供应商名称 -->
REVIEW_STATUS as "reviewStatus", <!-- 审批状态 -->
TAX_POINTS as "taxPoints", <!-- 税率 -->
THIS_SETTLEMENT_TAX as "thisSettlementTax", <!-- 税额 -->
THIS_SETTLEMENT_AMOUNT as "thisSettlementAmount", <!-- 不含税金额 -->
TOTAL_CONTRACT_PRICE_INCLUDING as "totalContractPriceIncluding", <!-- 发票总额 -->
CREATED_BY as "createdBy", <!-- 记录创建者 -->
CREATED_NAME as "createdName", <!-- 记录创建名称 -->
CREATED_TIME as "createdTime", <!-- 记录创建时间 -->
UPDATED_BY as "updatedBy", <!-- 记录修改者 -->
UPDATED_NAME as "updatedName", <!-- 记录修改名称 -->
UPDATED_TIME as "updatedTime", <!-- 记录修改时间 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
REMAINING_AMOUNT as "remainingAmount", <!-- 剩余开票/收票金额 -->
RECEIVE_DATE as "receiveDate", <!-- 收票日期 -->
CONTRACT_TYPE as "contractType", <!-- 合同类型;1.采购收货2.劳务3.租赁 -->
INVENT_TYPE_DETAIL as "inventTypeDetail", <!-- 存货大类 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
SPEC as "spec", <!-- 规格 -->
DEPOSIT_QTY as "depositQty", <!-- 入库数量 -->
RECEIVE_WEIGHT as "receiveWeight" <!-- 收货重量 -->
FROM ${hggpSchema}.HGCW012 WHERE 1=1 FROM ${hggpSchema}.HGCW012 WHERE 1=1
<include refid="condition" /> <include refid="condition" />
<dynamic prepend="ORDER BY"> <dynamic prepend="ORDER BY">
...@@ -360,4 +363,36 @@ ...@@ -360,4 +363,36 @@
ID = #id# ID = #id#
</update> </update>
<select id="queryCheckList" parameterClass="java.util.HashMap" resultClass="com.baosight.hggp.hg.cw.domain.HGCW012">
SELECT
<include refid="column" />
FROM ${hggpSchema}.HGCW012 WHERE 1=1
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
<![CDATA[ SIGNING_DATE >= #accountPeriodDateStart# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
<![CDATA[ SIGNING_DATE <= #accountPeriodDateEnd# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="billDate">
LEFT(SIGNING_DATE,6) = #billDate#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="submitStatus">
REVIEW_STATUS = #submitStatus#
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID desc
</isEmpty>
</dynamic>
</select>
</sqlMap> </sqlMap>
package com.baosight.hggp.hg.cw.tools; package com.baosight.hggp.hg.cw.tools;
import cn.hutool.core.util.StrUtil;
import com.baosight.hggp.common.AccountPeriodStatusEnum; import com.baosight.hggp.common.AccountPeriodStatusEnum;
import com.baosight.hggp.core.constant.CommonConstant; import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoBase; import com.baosight.hggp.core.dao.DaoBase;
...@@ -7,11 +8,14 @@ import com.baosight.hggp.core.dao.DaoUtils; ...@@ -7,11 +8,14 @@ import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.constant.HGSqlConstant; import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.cw.domain.*; import com.baosight.hggp.hg.cw.domain.*;
import com.baosight.hggp.hg.cw.vo.UserVO; import com.baosight.hggp.hg.cw.vo.UserVO;
import com.baosight.hggp.hg.kc.domain.*;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.pz.domain.HGPZ003; import com.baosight.hggp.hg.pz.domain.HGPZ003;
import com.baosight.hggp.hg.xs.domain.Org; import com.baosight.hggp.hg.xs.domain.Org;
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.*;
import com.baosight.iplat4j.core.ProjectInfo; import com.baosight.iplat4j.core.ProjectInfo;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -20,10 +24,8 @@ import java.math.BigDecimal; ...@@ -20,10 +24,8 @@ import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -35,6 +37,11 @@ public class HGCWTools { ...@@ -35,6 +37,11 @@ public class HGCWTools {
return DaoBase.getInstance().query("HGCW001.queryCheckList", paramMap); return DaoBase.getInstance().query("HGCW001.queryCheckList", paramMap);
} }
/**
* 查询公司最大关账会计期
* @param companyCode
* @return
*/
public static HGCW001 getMaxAccountPeriod(String companyCode) { public static HGCW001 getMaxAccountPeriod(String companyCode) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("companyCode", companyCode); params.put("companyCode", companyCode);
...@@ -43,6 +50,11 @@ public class HGCWTools { ...@@ -43,6 +50,11 @@ public class HGCWTools {
return list.get(0); return list.get(0);
} }
/**
* 根据条件查询业务账期
* @param paramMap
* @return
*/
public static HGCW001 getByCondition(Map paramMap){ public static HGCW001 getByCondition(Map paramMap){
List<HGCW001> results = DaoBase.getInstance().query(HGCW001.QUERY, paramMap); List<HGCW001> results = DaoBase.getInstance().query(HGCW001.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0); return CollectionUtils.isEmpty(results) ? null : results.get(0);
...@@ -59,6 +71,161 @@ public class HGCWTools { ...@@ -59,6 +71,161 @@ public class HGCWTools {
AssertUtils.isEmpty(list, "未找到公司符合"+bussinessTime+"开账的账期"); AssertUtils.isEmpty(list, "未找到公司符合"+bussinessTime+"开账的账期");
return list.get(0); return list.get(0);
} }
/**
* 查询上月业务账期维护
* @param companyCode 公司编码
* @param accountPeriod 会计期
* @return 上月业务账期
*/
public static HGCW001 getLastAccountPeriod(String companyCode,String accountPeriod) {
AssertUtils.isTrue(StringUtils.isBlank(companyCode), "公司编码不能为空!");
AssertUtils.isTrue(StringUtils.isBlank(accountPeriod), "会计期不能为空!");
Map params = new HashMap<>();
params.put("companyCode", companyCode);
params.put("accountPeriod", DateUtil.getMonthOfDays(accountPeriod+"01",-1,DateUtil.DATE10_PATTERN).substring(0,6));
List<HGCW001> list = DaoBase.getInstance().query(HGCW001.QUERY, params);
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
/**
* 查询会计期到年底业务账期维护
* @param companyCode 公司编码
* @param accountYear 会计年
* @param accountPeriod 会计期
* @param accountPeriodStatus 状态
*/
public static HGCW001 getAccountPeriodEnd(String companyCode,String accountYear,String accountPeriod, Integer accountPeriodStatus) {
String accountDate = DateUtils.getPlusYesMonth(accountPeriod.concat("01"),DateUtils.SHORT_DATE); //回去上月时间
Map params = new HashMap<>();
params.put("companyCode", companyCode);
params.put("accountPeriodStatus", accountPeriodStatus);
params.put("accountPeriodStart", accountDate.substring(0, 6));
params.put("accountPeriodEnd", accountYear.concat("12"));
List<HGCW001> list = DaoBase.getInstance().query(HGCW001.QUERY, params);
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
/**
* 查询会计期到年初业务账期维护
* @param companyCode 公司编码
* @param accountYear 会计年
* @param accountPeriod 会计期
* @param accountPeriodStatus 状态
*/
public static HGCW001 getAccountPeriodStart(String companyCode,String accountYear,String accountPeriod,Integer accountPeriodStatus) {
String accountDate = DateUtils.getYesMonth(accountPeriod.concat("01"),DateUtils.SHORT_DATE);
Map params = new HashMap<>();
params.put("companyCode", companyCode);
params.put("accountPeriodStatus", accountPeriodStatus);
params.put("accountPeriodStart", accountYear.concat("01"));
params.put("accountPeriodEnd", accountDate.substring(0, 6));
List<HGCW001> list = DaoBase.getInstance().query(HGCW001.QUERY, params);
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
/**
* 获取会计期上月业务账期结束时间为当月业务账期开始时间
* @param inInfo 入参
* @param paramMap 条件
*/
public static void getaccountPeriodDateStart(EiInfo inInfo, Map paramMap) {
try {
String accountPeriodStr = paramMap.get(HGCW001.FIELD_ACCOUNT_PERIOD).toString();
String accountPeriod = DateUtils.getYesMonth(accountPeriodStr); //回去上月时间
paramMap.put(HGCW001.FIELD_ACCOUNT_PERIOD, DateUtils.formatShort(accountPeriod.substring(0, 7)));
List<HGCW001> list =DaoBase.getInstance().query(HGCW001.QUERY, paramMap);
if (list.size() > 0) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
Date account = formatter.parse(list.get(0).getAccountPeriodDateEnd());
String dateEnd = DateUtil.getLastDayInMonth(account,0,0,DateUtil.DATE10_PATTERN);//DateUtils.yesterdayEnd(dateStart,-1);
inInfo.set(HGCW001.FIELD_ACCOUNT_PERIOD_DATE_START, dateEnd);
}else {
/*获取当前最后时间*/
//
//
inInfo.set(HGCW001.FIELD_ACCOUNT_PERIOD_DATE_START, (accountPeriodStr.substring(0,7).concat("-01")));
}
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
}
public static void checkAllData(HGCW001 hgcw001){
// 检查返回码
String resultCode = "100";
String resultDesc = "数据检查完成";
Map paramMap = new HashMap<>();
//paramMap.put("billDate", accountPeriod);
paramMap.put("submitStatus", 0);
paramMap.put("accountPeriodStatus", 1);
paramMap.put("companyCode", hgcw001.getCompanyCode());
paramMap.put("accountPeriodDateStart", hgcw001.getAccountPeriodDateStart());
paramMap.put("accountPeriodDateEnd", hgcw001.getAccountPeriodDateEnd());
// 点击数据检查按钮弹出窗口,点击执行进行数据检查,检查顺序和显示内容如下:
// 1.业务单据日期为当月会计期的日期范围采购入库单提交或未提交;HGKC001 采购入库
List<HGKC001> hgkc001List = HGKCTools.HgKc001.checkList(paramMap);
if (hgkc001List.size() > 0) {
resultCode = "101";
resultDesc = "采购入库单未提交";
throw new PlatException("采购入库单未提交");
}
// 2.业务单据日期为当月会计期的日期范围采购发票提交或未提交;HGCW012 采购发票
List<HGCW012> hgcw012List = HGCWTools.HgCw012.checkList(paramMap);
if (hgcw012List.size() > 0) {
resultCode = "102";
resultDesc = "采购发票未审核";
throw new PlatException("采购发票未审核");
}
// 3.业务单据日期为当月会计期的日期范围生产领用单提交或未提交;HGKC008 生产领料单
List<HGKC008> hgkc008List = HGKCTools.HgKc008.checkList(paramMap);
if (hgkc008List.size() > 0) {
resultCode = "103";
resultDesc = "生产领料单未提交";
throw new PlatException("生产领料单未提交");
}
// 4.业务单据日期为当月会计期的日期范围生产入库单提交或未提交;HGKC003 生产入库单
List<HGKC003> hgkc003List = HGKCTools.HgKc003.checkList(paramMap);
if (hgkc003List.size() > 0) {
resultCode = "104";
resultDesc = "生产入库单未提交";
throw new PlatException("生产入库单未提交");
}
// 5.业务单据日期为当月会计期的日期范围销售出库单提交或未提交;HGKC004 销售出库单
List<HGKC004> hgkc004List = HGKCTools.HgKc004.checkList(paramMap);
if (hgkc004List.size() > 0) {
resultCode = "105";
resultDesc = "销售出库单未提交";
throw new PlatException("销售出库单未提交");
}
// 6.业务单据日期为当月会计期的日期范围其他入库单提交或未提交;HGKC006 其他入库单
List<HGKC006> hgkc006List = HGKCTools.HgKc006.checkList(paramMap);
if (hgkc006List.size() > 0) {
resultCode = "106";
resultDesc = "其他入库单未提交";
throw new PlatException("其他入库单未提交");
}
// 7.业务单据日期为当月会计期的日期范围其他出库单提交或未提交;HGKC007 其他出库单
List<HGKC007> hgkc007List = HGKCTools.HgKc007.checkList(paramMap);
if (hgkc007List.size() > 0) {
resultCode = "107";
resultDesc = "其他出库单未提交";
throw new PlatException("其他出库单未提交");
}
}
public static List<HGCW001> queryNoAuth(Map paramMap){
List<HGCW001> list = DaoBase.getInstance().query(HGCW001.QUERY_NO_AUTH, paramMap);
return list;
}
public static HGCW001 getNoAuth(Map paramMap){
List<HGCW001> list = queryNoAuth(paramMap);
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
} }
public static class HgCw002 { public static class HgCw002 {
......
...@@ -317,6 +317,12 @@ ...@@ -317,6 +317,12 @@
<isNotEmpty prepend=" AND " property="companyCode"> <isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode# COMPANY_CODE = #companyCode#
</isNotEmpty> </isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
<![CDATA[ DEPOSIT_DATE >= #accountPeriodDateStart# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
<![CDATA[ DEPOSIT_DATE <= #accountPeriodDateEnd# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="billDate"> <isNotEmpty prepend=" AND " property="billDate">
LEFT(DEPOSIT_DATE,6) = #billDate# LEFT(DEPOSIT_DATE,6) = #billDate#
</isNotEmpty> </isNotEmpty>
......
...@@ -444,6 +444,18 @@ ...@@ -444,6 +444,18 @@
PROCESS_NAME as "processName", <!-- 工序名称 --> PROCESS_NAME as "processName", <!-- 工序名称 -->
PROCESS_ORDER as "processOrder" <!-- 加工顺序 --> PROCESS_ORDER as "processOrder" <!-- 加工顺序 -->
FROM ${hggpSchema}.HGKC003 WHERE 1=1 AND DELETE_FLAG = 0 FROM ${hggpSchema}.HGKC003 WHERE 1=1 AND DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
<![CDATA[ DEPOSIT_DATE >= #accountPeriodDateStart# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
<![CDATA[ DEPOSIT_DATE <= #accountPeriodDateEnd# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="billDate"> <isNotEmpty prepend=" AND " property="billDate">
LEFT(DEPOSIT_DATE,6) = #billDate# LEFT(DEPOSIT_DATE,6) = #billDate#
</isNotEmpty> </isNotEmpty>
......
...@@ -293,7 +293,19 @@ ...@@ -293,7 +293,19 @@
<select id="queryCheckList" parameterClass="HashMap" resultClass="HGKC004"> <select id="queryCheckList" parameterClass="HashMap" resultClass="HGKC004">
SELECT SELECT
<include refid="column"/> <include refid="column"/>
FROM ${hggpSchema}.HGKC004 WHERE 1=1 FROM ${hggpSchema}.HGKC004 WHERE 1=1 AND DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
<![CDATA[ RECEIPT_DATE >= #accountPeriodDateStart# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
<![CDATA[ RECEIPT_DATE <= #accountPeriodDateEnd# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="billDate"> <isNotEmpty prepend=" AND " property="billDate">
LEFT(RECEIPT_DATE,6) = #billDate# LEFT(RECEIPT_DATE,6) = #billDate#
</isNotEmpty> </isNotEmpty>
......
...@@ -311,6 +311,18 @@ ...@@ -311,6 +311,18 @@
SOURCE_CODE as "sourceCode", <!-- 数据来源编号 --> SOURCE_CODE as "sourceCode", <!-- 数据来源编号 -->
SOURCE as "source" <!-- 数据来源 --> SOURCE as "source" <!-- 数据来源 -->
FROM ${hggpSchema}.HGKC006 WHERE 1=1 and DELETE_FLAG = 0 FROM ${hggpSchema}.HGKC006 WHERE 1=1 and DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
<![CDATA[ OTHER_ENTER_DATE >= #accountPeriodDateStart# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
<![CDATA[ OTHER_ENTER_DATE <= #accountPeriodDateEnd# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="billDate"> <isNotEmpty prepend=" AND " property="billDate">
LEFT(OTHER_ENTER_DATE,6) = #billDate# LEFT(OTHER_ENTER_DATE,6) = #billDate#
</isNotEmpty> </isNotEmpty>
......
...@@ -307,6 +307,18 @@ ...@@ -307,6 +307,18 @@
SOURCE_CODE as "sourceCode", <!-- 数据来源编号 --> SOURCE_CODE as "sourceCode", <!-- 数据来源编号 -->
SOURCE as "source" <!-- 数据来源 --> SOURCE as "source" <!-- 数据来源 -->
FROM ${hggpSchema}.HGKC007 WHERE 1=1 and DELETE_FLAG = 0 FROM ${hggpSchema}.HGKC007 WHERE 1=1 and DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
<![CDATA[ OTHER_OUT_DATE >= #accountPeriodDateStart# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
<![CDATA[ OTHER_OUT_DATE <= #accountPeriodDateEnd# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="billDate"> <isNotEmpty prepend=" AND " property="billDate">
LEFT(OTHER_OUT_DATE,6) = #billDate# LEFT(OTHER_OUT_DATE,6) = #billDate#
</isNotEmpty> </isNotEmpty>
......
...@@ -211,7 +211,19 @@ ...@@ -211,7 +211,19 @@
PROJ_CODE as "projCode", <!-- 项目编码 --> PROJ_CODE as "projCode", <!-- 项目编码 -->
PROJ_NAME as "projName", <!-- 项目名称 --> PROJ_NAME as "projName", <!-- 项目名称 -->
RECEIVE_TYPE as "receiveType" <!-- 领料单类型 0:正常,1:退库 --> RECEIVE_TYPE as "receiveType" <!-- 领料单类型 0:正常,1:退库 -->
FROM ${hggpSchema}.HGKC008 WHERE 1=1 FROM ${hggpSchema}.HGKC008 WHERE 1=1 and DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
<![CDATA[ RECEIPT_DATE >= #accountPeriodDateStart# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
<![CDATA[ RECEIPT_DATE <= #accountPeriodDateEnd# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="billDate"> <isNotEmpty prepend=" AND " property="billDate">
LEFT(RECEIPT_DATE,6) = #billDate# LEFT(RECEIPT_DATE,6) = #billDate#
</isNotEmpty> </isNotEmpty>
......
...@@ -7,6 +7,7 @@ import java.text.ParseException; ...@@ -7,6 +7,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -22,6 +23,7 @@ public class DateUtil { ...@@ -22,6 +23,7 @@ public class DateUtil {
public static final String DATE8_PATTERN = "yyyyMMdd"; public static final String DATE8_PATTERN = "yyyyMMdd";
public static final String DATE10_PATTERN = "yyyy-MM-dd"; public static final String DATE10_PATTERN = "yyyy-MM-dd";
public static final String DATE11_PATTERN = "M月d日"; public static final String DATE11_PATTERN = "M月d日";
public static final String DATE12_PATTERN = "yyyyMM";
public static final String TIME6_PATTERN = "HHmmss"; public static final String TIME6_PATTERN = "HHmmss";
public static final String TIME8_PATTERN = "HH:mm:ss"; public static final String TIME8_PATTERN = "HH:mm:ss";
...@@ -56,6 +58,28 @@ public class DateUtil { ...@@ -56,6 +58,28 @@ public class DateUtil {
return ""; return "";
} }
/**
* 获取上个月的最后一天
* @param date 日期
* @param i 月数
* @return
*/
public static String getLastDayInMonth(Date date, int i) {
return getLastDayInMonth(date, i, -1,DATE8_PATTERN);
}
public static String getLastDayInMonth(Date date, int i, int day, String pattern) {
SimpleDateFormat format = new SimpleDateFormat(pattern);
if (date == null) {
return null;
} else {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(2, i + 1);
calendar.set(5, 1);
calendar.add(5, day);
return format.format(calendar.getTime());
}
}
/**、 /**、
* 返回月份天数 * 返回月份天数
* @param dateStr 日期 * @param dateStr 日期
......
...@@ -3,12 +3,15 @@ ...@@ -3,12 +3,15 @@
*/ */
package com.baosight.hggp.util; package com.baosight.hggp.util;
import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalAdjusters;
import java.util.Date;
import java.util.GregorianCalendar;
/** /**
* jdk8中新增的日期处理类,更安全、更精确也更明确 * jdk8中新增的日期处理类,更安全、更精确也更明确
...@@ -36,11 +39,26 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { ...@@ -36,11 +39,26 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
* @return * @return
*/ */
public static String getYesMonth(String date) { public static String getYesMonth(String date) {
LocalDate endLocalDate = LocalDate.parse(date, DateTimeFormatter.ISO_LOCAL_DATE); return getYesMonth(date,DateTimeFormatter.ISO_LOCAL_DATE);
}
public static String getYesMonth(String date,DateTimeFormatter dateTimeFormatter) {
LocalDate endLocalDate = LocalDate.parse(date, dateTimeFormatter);
endLocalDate = endLocalDate.minusMonths(1).with(TemporalAdjusters.firstDayOfMonth()); endLocalDate = endLocalDate.minusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
return endLocalDate.format(DateTimeFormatter.ISO_LOCAL_DATE); return endLocalDate.format(dateTimeFormatter);
} }
/**
* 获取下个月的1号日期
*
* @param date 2023-09-06 or 20230906
* @return
*/
public static String getPlusYesMonth(String date,DateTimeFormatter dateTimeFormatter) {
LocalDate endLocalDate = LocalDate.parse(date, dateTimeFormatter);
endLocalDate = endLocalDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
return endLocalDate.format(dateTimeFormatter);
}
/** /**
* 获取当前的日期字符串(yyyy-MM) * 获取当前的日期字符串(yyyy-MM)
* *
...@@ -68,6 +86,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { ...@@ -68,6 +86,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return LocalDate.now().minusDays(1).format(DATE); return LocalDate.now().minusDays(1).format(DATE);
} }
/** /**
* 获取后一天日期字符串(yyyy-MM-dd)
*
* @return
*/
public static String yesterdayEnd(String date,Integer day) {
return LocalDate.parse(date).minusDays(day).format(DATE);
}
/**
* 获取日期字符串(yyyy-MM-dd) * 获取日期字符串(yyyy-MM-dd)
* *
* @return * @return
......
$(function() { $(function () {
$(".row").children().attr("class", "col-md-3");
$("#QUERY").on("click", query);
// 查询 IPLATUI.EFGrid = {
$("#QUERY").on("click", function () { "result":{
query(); pageable: {
}); pageSize: 20,
$("#SWITCH").on("click", function () { pageSizes: [10,20,30,50,100,200],
switchRow(); },
}); columns: [
{
field: "accountPeriod",
title: "会计期",
editor:function (container, options) {
var input = $('<input name="' + options.field + '"/>');
input.appendTo(container);
input.kendoDatePicker({
start: "year",
depth: "year",
format: "yyyy-MM",
value:currDate(options.model.accountYear)
});
IPLATUI.EFGrid.result = { //resultGrid.setCellValue(options,'accountPeriod',accountPeriod)
pageable: { }
pageSize: 20, }
pageSizes: [10,20,30,50,100,200], ],
}, exportGrid: {
columns: [ /**
], * 导出前的事件
onSave: function (e) { *
// 阻止默认请求,使用自定义保存 * @param gridInstance kendoGrid 对象
e.preventDefault(); * @return {boolean} 是否执行导出的逻辑
saveFunc(); */
}, beforeExport: function (gridInstance) {
onDelete: function (e) { var validator1 = IPLAT.Validator({
// 阻止默认请求,使用自定义删除 id: "inqu"
e.preventDefault(); });
deleteFunc(); // 点击按钮后校验
}, if (!validator1.validate()) {
onSuccess: function (e) { var errorMsg = validator1.errors().toString();
if (e.eiInfo.extAttr.methodName == 'save' || e.eiInfo.extAttr.methodName == 'delete') { var errs = errorMsg.split(',');
query(); IPLAT.alert({
} message: '<b>错误:<br>' + errs.join('<br>') + '</b>',
}, okFn: function (e) {
} },
title: '错误'
});
return false;
}
return true;
},
// exportFileName: "result", // 默认值和 blockId 相同
exportFileName: function (gridInstance) {
// 导出的文件名包含时间戳 yyyy-MM-dd HH:mm:ss
return "业务账期维护_" + kendo.toString(new Date(), IPLAT.FORMAT.DATE_14_PR);
},
exportFileType: "xls", // 默认值是xls,可选值为pdf[规划中]
exportBlockId: "result", // 默认值和blockId相同,导出的EiInfo中的指定数据块被导出
},
loadComplete: function (grid) {
$("#SWITCH").on("click", function () {
switchRow();
});
grid.dataSource.bind("change",function(e){
var item = e.items[0];
/* if(e.field == "accountYear"){
let accountPeriod = currMonth(item.accountYear);
resultGrid.setCellValue(item,'accountPeriod',accountPeriod)
//loadChange(grid,e,"accountPeriod");
}else */
if(e.field == "accountPeriod"){
let accountPeriod = dateFormate(item.accountPeriod,"yyyy-MM-dd")
let accountPeriodDateStart = queryLast(item.companyCode,accountPeriod);
resultGrid.setCellValue(item,'accountYear',accountPeriod.substring(0,4));
resultGrid.setCellValue(item,'accountPeriodDateStart',dateFormate(new Date(accountPeriodDateStart),"yyyyMMdd"));
loadChange(grid,e,"accountPeriodDateEnd");
}
})
},
onSave: function (e) {
// 阻止默认请求,使用自定义保存
e.preventDefault();
saveFunc();
},
onDelete: function (e) {
// 阻止默认请求,使用自定义删除
e.preventDefault();
deleteFunc();
},
onSuccess: function (e) {
if (e.eiInfo.extAttr.methodName == 'save' || e.eiInfo.extAttr.methodName == 'delete') {
query();
}
},
}
window.document.addEventListener("keyup",function (event) { }
downKeyUp();
/*window.document.addEventListener("keyup",function (event) {
if(event.keyCode === 13){ if(event.keyCode === 13){
var grid = $("#ef_grid_result").data("kendoGrid"); var grid = $("#ef_grid_result").data("kendoGrid");
// 回填 // 回填
//grid.addRows(returnRows); //grid.addRows(returnRows);
grid.closeCell(); grid.closeCell();
} }
}) })*/
}); });
$(window).load(function () { $(window).load(function () {
// 查
query(); query();
}); });
/** /**
* 查询 * 查询
*/ */
let query = function () { var query = function () {
resultGrid.dataSource.page(1); resultGrid.dataSource.page(1);
} }
/** /**
* 保存 * 保存
*/ */
...@@ -153,8 +217,8 @@ function deleteFunc() { ...@@ -153,8 +217,8 @@ function deleteFunc() {
let flag = true; let flag = true;
$.each(rows, function(index, item) { $.each(rows, function(index, item) {
let accountPeriodStatus= item.get("accountPeriodStatus"); let accountPeriodStatus= item.get("accountPeriodStatus");
if(accountPeriodStatus === "1"){ if(accountPeriodStatus === "0"){
message("选中的第"+(index+1)+"行记录为账状态,不能删除!"); message("选中的第"+(index+1)+"行记录为账状态,不能删除!");
flag = false; flag = false;
return false; return false;
} }
...@@ -207,3 +271,26 @@ function switchRow() { ...@@ -207,3 +271,26 @@ function switchRow() {
}); });
} }
function queryLast(companyCode,accountPeriod) {
let accountPeriodDateStart = "";
let info = new EiInfo();
info.set("inqu_status-0-companyCode", companyCode);
info.set("inqu_status-0-accountPeriod", accountPeriod);
if(isBlank(info.get("inqu_status-0-companyCode"))){
message("公司名称不能为空!");
return;
}
if(isBlank(info.get("inqu_status-0-accountPeriod"))){
message("会计期不能为空!");
return;
}
EiCommunicator.send("HGCW001", "queryLast", info, {
onSuccess: function (ei) {
accountPeriodDateStart = ei.get("accountPeriodDateStart");
},
onFail: function (ei) {
IPLAT.alert(ei.getMsg());
}
},{async: false});
return accountPeriodDateStart;
}
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<c:set var="ctx" value="${pageContext.request.contextPath}"/> <c:set var="ctx" value="${pageContext.request.contextPath}"/>
<head> <head>
</head> </head>
<EF:EFPage title="账期维护"> <EF:EFPage title="业务账期维护">
<EF:EFRegion id="inqu" title="查询条件"> <EF:EFRegion id="inqu" title="查询条件">
<div class="row"> <div class="row">
...@@ -30,16 +30,15 @@ ...@@ -30,16 +30,15 @@
filter="contains" readonly="true"> filter="contains" readonly="true">
<EF:EFOptions blockId="roleCompany" textField="companyName" valueField="companyCode"/> <EF:EFOptions blockId="roleCompany" textField="companyName" valueField="companyCode"/>
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFColumn ename="accountYear" cname="会计年度" width="100" align="center" start="decade" depth="decade" <EF:EFColumn ename="accountYear" cname="会计年度" enable="false" width="100" align="center" start="decade" depth="decade"
editType="date" dateFormat="yyyy" parseFormats="['yyyy']" required="true"/> editType="date" dateFormat="yyyy" parseFormats="['yyyy']" required="true"/>
<EF:EFColumn ename="accountPeriod" cname="会计期" width="100" align="center" start="year" depth="year" <EF:EFColumn ename="accountPeriod" cname="会计期" readonly="true" width="100" align="center" start="year" depth="year"
editType="date" dateFormat="yyyy-MM" parseFormats="['yyyyMM']" required="true"/> editType="date" dateFormat="yyyy-MM" parseFormats="['yyyyMM']" required="true"/>
<EF:EFComboColumn ename="accountPeriodStatus" cname="会计期状态" width="100" align="center" required="true" <EF:EFComboColumn ename="accountPeriodStatus" cname="会计期状态" width="100" align="center" required="true"
columnTemplate="#=textField#" itemTemplate="#=textField#" enable="false" defaultValue="0"> columnTemplate="#=textField#" itemTemplate="#=textField#" enable="false" defaultValue="1">
<EF:EFCodeOption codeName="hggp.cw.accountPeriodStatus"/> <EF:EFCodeOption codeName="hggp.cw.accountPeriodStatus"/>
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFColumn ename="accountPeriodDateStart" cname="账期开始日期" width="100" align="center" <EF:EFColumn ename="accountPeriodDateStart" cname="账期开始日期" enable="false" width="100" align="center"
editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" required="true"/> editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" required="true"/>
<EF:EFColumn ename="accountPeriodDateEnd" cname="账期结束日期" width="100" align="center" <EF:EFColumn ename="accountPeriodDateEnd" cname="账期结束日期" width="100" align="center"
editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" required="true"/> editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" required="true"/>
......
...@@ -269,14 +269,26 @@ function currShortDate() { ...@@ -269,14 +269,26 @@ function currShortDate() {
* *
* @returns {string} * @returns {string}
*/ */
function currShortMonth() { function currShortMonth(getYear) {
const date = new Date(); const date = new Date(getYear);
const year = date.getFullYear(); const year = date.getFullYear();
const month = date.getMonth() + 1; // 月份从0开始,需要加1 const month = date.getMonth() + 1; // 月份从0开始,需要加1
return year + (month < 10 ? '0' + month : month); return year + (month < 10 ? '0' + month : month);
} }
/** /**
* 当前月份 YYYYMM
*
* @returns {string}
*/
function currMonth(getYear) {
const date = new Date(getYear);
const year = date.getFullYear();
const month = date.getMonth() + 1; // 月份从0开始,需要加1
return year + '-' + (month < 10 ? '0' + month : month);
}
/**
* cookie 操作 * cookie 操作
* *
* @param c_name * @param c_name
......
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