Commit abfcdd85 by 宋祥

1.按月统计库存收发存

parent 23a9f843
......@@ -16,27 +16,22 @@ import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.pz.domain.HPPZ009;
import com.baosight.hpjx.hp.pz.domain.THppz004;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.xs.tools.HPXSUserTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.BeanUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.RsaUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import com.baosight.xservices.xs.constants.LoginConstants;
import org.apache.commons.collections.MapUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
......@@ -60,7 +55,7 @@ public class ServiceHPKC009 extends ServiceBase {
*/
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_QUERY_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_NAME_BLOCK_ID), null);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC009().eiMetadata);
} catch (PlatException e) {
......@@ -82,6 +77,7 @@ public class ServiceHPKC009 extends ServiceBase {
String receiptDate = MapUtils.getString(queryRow, "dateProc");
queryRow.put("dateProc", StringUtil.removeSpecifiedCharacter(receiptDate,
StringUtil.DEFAULT_CHARACTER_TO_BE_REMOVED));
queryRow.put("dateType", CommonConstant.DateType.MONTH);
inInfo = super.query(inInfo, "HPKC009.query", new HPPZ009());
List sum = dao.query("HPKC009.querySum", queryRow);
inInfo.getBlock(EiConstant.resultBlock).set(EiConstant.COLUMN_TOTAL_SUM, sum.get(0));
......@@ -102,18 +98,22 @@ public class ServiceHPKC009 extends ServiceBase {
List<HPKC009> results = new ArrayList<>();
// 取昨天的日期
Map queryMap = new HashMap();
LocalDate nowData = LocalDate.now();
queryMap.put("yesterday", nowData.minusDays(1).format(DateUtils.SHORT_DATE));
queryMap.put("beforeDay", nowData.minusDays(2).format(DateUtils.SHORT_DATE));
LocalDate nowDate = LocalDate.now();
String yesterDay = LocalDate.now().minusDays(1).format(DateUtils.SHORT_DATE);
queryMap.put("yesterFrom", yesterDay);
queryMap.put("yesterTo", yesterDay);
queryMap.put("yesterDate", yesterDay);
queryMap.put("beforeDate", nowDate.minusDays(2).format(DateUtils.SHORT_DATE));
queryMap.put("dateType", CommonConstant.DateType.DAY);
// 0.清除数据
queryMap.put("dateProc", queryMap.get("yesterday"));
queryMap.put("dateProc", queryMap.get("yesterDate"));
dao.delete(HPSqlConstant.HPKC009.DELETE_BY_TIME, queryMap);
// 1、统计采购库存
results.addAll(this.statDayCg(queryMap));
results.addAll(this.statCg(queryMap));
// 2、统计生产库存
results.addAll(this.statDaySc(queryMap));
results.addAll(this.statSc(queryMap));
// 3、统计其他库存
results.addAll(this.statDayQt(queryMap));
results.addAll(this.statQt(queryMap));
// 4、设置基础信息
this.setBaseInfo(results);
// 5、写入数据库
......@@ -121,7 +121,48 @@ public class ServiceHPKC009 extends ServiceBase {
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("按天统计成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
LogUtils.setDetailMsg(inInfo, e, "按天统计失败");
}
return inInfo;
}
/**
* 按月统计
*
* @param inInfo
* @return
*/
public EiInfo statMonth(EiInfo inInfo) {
try {
List<HPKC009> results = new ArrayList<>();
// 上个月的日期
Map queryMap = new HashMap();
LocalDate nowDate = LocalDate.now();
LocalDate yesterMonth = nowDate.minusMonths(1);
queryMap.put("yesterFrom", yesterMonth.with(TemporalAdjusters.firstDayOfMonth())
.format(DateUtils.SHORT_DATE));
queryMap.put("yesterTo", yesterMonth.with(TemporalAdjusters.lastDayOfMonth())
.format(DateUtils.SHORT_DATE));
queryMap.put("yesterDate", yesterMonth.format(DateUtils.SHORT_MONTH));
queryMap.put("beforeDate", nowDate.minusMonths(2).format(DateUtils.SHORT_MONTH));
queryMap.put("dateType", CommonConstant.DateType.MONTH);
// 0.清除数据
queryMap.put("dateProc", queryMap.get("yesterDate"));
dao.delete(HPSqlConstant.HPKC009.DELETE_BY_TIME, queryMap);
// 1、统计采购库存
results.addAll(this.statCg(queryMap));
// 2、统计生产库存
results.addAll(this.statSc(queryMap));
// 3、统计其他库存
results.addAll(this.statQt(queryMap));
// 4、设置基础信息
this.setBaseInfo(results);
// 5、写入数据库
DaoUtils.insert("HPKC009.insert", results);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("按月统计成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "按月统计失败");
}
return inInfo;
}
......@@ -131,26 +172,26 @@ public class ServiceHPKC009 extends ServiceBase {
*
* @return
*/
private List<HPKC009> statDayCg(Map queryMap) {
private List<HPKC009> statCg(Map queryMap) {
Map<String, HPKC009> kc009Map = new HashMap();
// 1.1、期末库存
List<HPKC001> aItems = dao.query("HPKC001.statDay", new HashMap<>());
List<HPKC001> aItems = dao.query("HPKC001.statDate", new HashMap<>());
// 1.2、收入
queryMap.put("createdTimeFrom", queryMap.get("yesterday") + "000000");
queryMap.put("createdTimeTo", queryMap.get("yesterday") + "235959");
List<HPKC001> bKc001s = dao.query("HPKC001.statDay", queryMap);
queryMap.put("createdTimeFrom", queryMap.get("yesterFrom") + "000000");
queryMap.put("createdTimeTo", queryMap.get("yesterTo") + "235959");
List<HPKC001> bKc001s = dao.query("HPKC001.statDate", queryMap);
Map<String, HPKC001> bKc001Map = bKc001s.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#"
+ item.getMaterialType() + "#" + item.getMaterialCode() + "#"
+ item.getSpec(), item -> item));
// 1.3、发出
List<HPKC002> cKc002s = dao.query("HPKC002.statDay", queryMap);
List<HPKC002> cKc002s = dao.query("HPKC002.statDate", queryMap);
Map<String, HPKC002> cKc001Map = cKc002s.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#"
+ item.getMaterialType() + "#" + item.getMaterialCode() + "#"
+ item.getSpec(), item -> item));
// 1.4、期初库存
queryMap.put("dateProc", queryMap.get("beforeDay"));
queryMap.put("dateProc", queryMap.get("beforeDate"));
queryMap.put("kcType", HPConstant.KcType.CG);
List<HPKC009> dKc009s = dao.query("HPKC009.query", new HashMap<>());
Map<String, HPKC009> dKc009Map = dKc009s.stream().collect(Collectors.toMap(item ->
......@@ -166,8 +207,8 @@ public class ServiceHPKC009 extends ServiceBase {
kc009.setInventType(aItem.getMaterialType());
kc009.setInventCode(aItem.getMaterialCode());
kc009.setKcType(HPConstant.KcType.CG);
kc009.setDateType(CommonConstant.DateType.DAY);
kc009.setDateProc(queryMap.get("yesterday").toString());
kc009.setDateType(queryMap.get("dateType").toString());
kc009.setDateProc(queryMap.get("yesterDate").toString());
// 期末
kc009.setEndAmount(BigDecimal.valueOf(aItem.getQuantity()));
kc009.setEndWeight(aItem.getWeight());
......@@ -201,24 +242,24 @@ public class ServiceHPKC009 extends ServiceBase {
* @param queryMap
* @return
*/
private List<HPKC009> statDaySc(Map queryMap) {
private List<HPKC009> statSc(Map queryMap) {
Map<String, HPKC009> kc009Map = new HashMap();
// 1.1、期末库存
List<HPKC003> aItems = dao.query("HPKC003.statDay", new HashMap<>());
List<HPKC003> aItems = dao.query("HPKC003.statDate", new HashMap<>());
// 1.2、收入
queryMap.put("createdTimeFrom", queryMap.get("yesterday") + "000000");
queryMap.put("createdTimeTo", queryMap.get("yesterday") + "235959");
List<HPKC003> bItems = dao.query("HPKC003.statDay", queryMap);
List<HPKC003> bItems = dao.query("HPKC003.statDate", queryMap);
Map<String, HPKC003> bItemMap = bItems.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWarehouseCode() + "#"
+ item.getMaterialType() + "#" + item.getMaterialCode(), item -> item));
// 1.3、发出
List<HPKC004> cItems = dao.query("HPKC004.statDay", queryMap);
List<HPKC004> cItems = dao.query("HPKC004.statDate", queryMap);
Map<String, HPKC004> cItemMap = cItems.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#"
+ item.getMatType() + "#" + item.getMatCode(), item -> item));
// 1.4、期初库存
queryMap.put("dateProc", queryMap.get("beforeDay"));
queryMap.put("dateProc", queryMap.get("beforeDate"));
queryMap.put("kcType", HPConstant.KcType.SC);
List<HPKC009> dItems = dao.query("HPKC009.query", new HashMap<>());
Map<String, HPKC009> dItemMap = dItems.stream().collect(Collectors.toMap(item ->
......@@ -234,8 +275,8 @@ public class ServiceHPKC009 extends ServiceBase {
kc009.setInventType(aItem.getMaterialType() + "");
kc009.setInventCode(aItem.getMaterialCode());
kc009.setKcType(HPConstant.KcType.SC);
kc009.setDateType(CommonConstant.DateType.DAY);
kc009.setDateProc(queryMap.get("yesterday").toString());
kc009.setDateType(queryMap.get("dateType").toString());
kc009.setDateProc(queryMap.get("yesterDate").toString());
// 期末
kc009.setEndAmount(new BigDecimal(aItem.getNumber()));
kc009.setEndWeight(new BigDecimal(aItem.getWeight()));
......@@ -269,24 +310,24 @@ public class ServiceHPKC009 extends ServiceBase {
* @param queryMap
* @return
*/
private List<HPKC009> statDayQt(Map queryMap) {
private List<HPKC009> statQt(Map queryMap) {
Map<String, HPKC009> kc009Map = new HashMap();
// 1.1、期末库存
List<HPKC006> aItems = dao.query("HPKC006.statDay", new HashMap<>());
List<HPKC006> aItems = dao.query("HPKC006.statDate", new HashMap<>());
// 1.2、收入
queryMap.put("createdTimeFrom", queryMap.get("yesterday") + "000000");
queryMap.put("createdTimeTo", queryMap.get("yesterday") + "235959");
List<HPKC006> bItems = dao.query("HPKC006.statDay", queryMap);
List<HPKC006> bItems = dao.query("HPKC006.statDate", queryMap);
Map<String, HPKC006> bItemMap = bItems.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#"
+ item.getMatType() + "#" + item.getMatCode(), item -> item));
// 1.3、发出
List<HPKC007> cItems = dao.query("HPKC007.statDay", queryMap);
List<HPKC007> cItems = dao.query("HPKC007.statDate", queryMap);
Map<String, HPKC007> cItemMap = cItems.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#"
+ item.getMatType() + "#" + item.getMatCode(), item -> item));
// 1.4、期初库存
queryMap.put("dateProc", queryMap.get("beforeDay"));
queryMap.put("dateProc", queryMap.get("beforeDate"));
queryMap.put("kcType", HPConstant.KcType.QT);
List<HPKC009> dItems = dao.query("HPKC009.query", new HashMap<>());
Map<String, HPKC009> dItemMap = dItems.stream().collect(Collectors.toMap(item ->
......@@ -300,8 +341,8 @@ public class ServiceHPKC009 extends ServiceBase {
kc009.setInventType(aItem.getMatType());
kc009.setInventCode(aItem.getMatCode());
kc009.setKcType(HPConstant.KcType.QT);
kc009.setDateType(CommonConstant.DateType.DAY);
kc009.setDateProc(queryMap.get("yesterday").toString());
kc009.setDateType(queryMap.get("dateType").toString());
kc009.setDateProc(queryMap.get("yesterDate").toString());
// 期末
kc009.setEndAmount(aItem.getAmount());
kc009.setEndWeight(aItem.getWeight());
......
......@@ -172,8 +172,8 @@
WHERE ID = #id#
</update>
<!-- 按天统计 -->
<select id="statDay" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC001">
<!-- 统计库存 -->
<select id="statDate" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC001">
SELECT
COMPANY_CODE AS "companyCode",
DEP_CODE AS "depCode",
......
......@@ -170,8 +170,8 @@
WHERE ID = #id#
</update>
<!-- 按天统计 -->
<select id="statDay" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC002">
<!-- 统计库存 -->
<select id="statDate" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC002">
SELECT
COMPANY_CODE AS "companyCode",
DEP_CODE AS "depCode",
......
......@@ -173,8 +173,8 @@
ID = #id#
</update>
<!-- 按天统计 -->
<select id="statDay" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC003">
<!-- 统计库存 -->
<select id="statDate" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC003">
SELECT
COMPANY_CODE AS "companyCode",
DEP_CODE AS "depCode",
......
......@@ -247,8 +247,8 @@
ID = #id#
</update>
<!-- 按天统计 -->
<select id="statDay" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC004">
<!-- 统计库存 -->
<select id="statDate" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC004">
SELECT
COMPANY_CODE AS "companyCode",
DEP_CODE AS "depCode",
......
......@@ -120,8 +120,8 @@
ID = #id#
</update>
<!-- 按天统计 -->
<select id="statDay" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC006">
<!-- 统计库存 -->
<select id="statDate" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC006">
SELECT
COMPANY_CODE AS "companyCode",
DEP_CODE AS "depCode",
......
......@@ -163,8 +163,8 @@
ID = #id#
</update>
<!-- 按天统计 -->
<select id="statDay" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC007">
<!-- 统计库存 -->
<select id="statDate" resultClass="com.baosight.hpjx.hp.kc.domain.HPKC007">
SELECT
COMPANY_CODE AS "companyCode",
DEP_CODE AS "depCode",
......
......@@ -27,6 +27,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static final DateTimeFormatter DATETIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
public static final DateTimeFormatter SHORT_DATE = DateTimeFormatter.ofPattern("yyyyMMdd");
public static final DateTimeFormatter DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd");
public static final DateTimeFormatter SHORT_MONTH = DateTimeFormatter.ofPattern("yyyyMM");
public static final DateTimeFormatter YEAR_MONTH = DateTimeFormatter.ofPattern("yyyy-MM");
/**
......
......@@ -8,12 +8,16 @@
<EF:EFPage title="库存收发存">
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFDatePicker ename="inqu_status-0-dateProc" cname="日期:"
role="date" format="yyyy-MM-dd" readonly="true"/>
<EF:EFDatePicker ename="inqu_status-0-dateProc" cname="日期:" start="year" depth="year"
role="date" format="yyyy-MM" readonly="true"/>
<EF:EFSelect ename="inqu_status-0-inventType" cname="存货类型:" filter="contains" defaultValue="">
<EF:EFOption label="请选择" value=""/>
<EF:EFCodeOption codeName="hpjx.hpkc.inventType"/>
</EF:EFSelect>
<EF:EFSelect ename="inqu_status-0-whCode" cname="仓库名称" filter="contains" defultValue="">
<EF:EFOption label="请选择" value=""/>
<EF:EFOptions blockId="whName_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
</div>
</EF:EFRegion>
......@@ -23,12 +27,9 @@
<EF:EFComboColumn cname="库存类型" ename="kcType" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="hpjx.hpkc.kcType"/>
</EF:EFComboColumn>
<EF:EFComboColumn cname="日期类型" ename="dateType" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="hpjx.hpkc.dateType"/>
</EF:EFComboColumn>
<EF:EFColumn cname="日期" ename="dateProc" enable="false" width="90" align="center"/>
<EF:EFComboColumn cname="仓库名称" ename="whCode" enable="false" columnTemplate="#=textField#"
itemTemplate="#=textField#" blockName="wh_record_block_id"
itemTemplate="#=textField#" blockName="whName_block_id"
textField="textField" valueField="valueField"
align="center" filter="contains" width="100">
</EF:EFComboColumn>
......
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