Commit 9dc93347 by liuyang

2024-07-15 业务账期维护变更

parent fd05d0ae
......@@ -70,7 +70,7 @@ public class HGCW001 extends DaoEPBase {
private String companyName = " "; /* 公司名称*/
private String accountYear = " "; /* 会计年度*/
private String accountPeriod = " "; /* 会计期*/
private Integer accountPeriodStatus; /* 会计期状态0:关账1:开账*/
private Integer accountPeriodStatus = 1; /* 会计期状态0:关账1:开账*/
private String accountPeriodDateStart = " "; /* 账期开始日期*/
private String accountPeriodDateEnd = " "; /* 账期结束日期*/
private String createdBy = " "; /* 记录创建者*/
......
......@@ -47,10 +47,10 @@
ACCOUNT_PERIOD_STATUS = #accountPeriodStatus#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
ACCOUNT_PERIOD_DATE_START = #accountPeriodDateStart#
ACCOUNT_PERIOD_DATE_START >= #accountPeriodDateStart#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
ACCOUNT_PERIOD_DATE_END = #accountPeriodDateEnd#
ACCOUNT_PERIOD_DATE_END &lt;= #accountPeriodDateEnd#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
......@@ -76,6 +76,12 @@
<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"
......@@ -104,7 +110,7 @@
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID asc
ACCOUNT_YEAR desc, ACCOUNT_PERIOD desc, ID desc
</isEmpty>
</dynamic>
......
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;
......@@ -7,11 +8,14 @@ import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.cw.domain.*;
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.xs.domain.Org;
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.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -20,10 +24,8 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
......@@ -35,6 +37,11 @@ public class HGCWTools {
return DaoBase.getInstance().query("HGCW001.queryCheckList", paramMap);
}
/**
* 查询公司最大关账会计期
* @param companyCode
* @return
*/
public static HGCW001 getMaxAccountPeriod(String companyCode) {
Map<String, Object> params = new HashMap<>();
params.put("companyCode", companyCode);
......@@ -43,6 +50,11 @@ public class HGCWTools {
return list.get(0);
}
/**
* 根据条件查询业务账期
* @param paramMap
* @return
*/
public static HGCW001 getByCondition(Map paramMap){
List<HGCW001> results = DaoBase.getInstance().query(HGCW001.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
......@@ -59,6 +71,150 @@ public class HGCWTools {
AssertUtils.isEmpty(list, "未找到公司符合"+bussinessTime+"开账的账期");
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 class HgCw002 {
......
......@@ -7,6 +7,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Objects;
/**
......@@ -56,6 +57,28 @@ public class DateUtil {
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 日期
......
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