Commit 39298ec2 by liuyang

2024-07-05 1.原材料入库成本核算 2.原材料出库成本核算 3.收发存汇总查询

parent 0d0980af
......@@ -99,9 +99,9 @@ public class DaoUtils {
public static int insertBatch(String sql, Collection parameters) {
parameters.forEach(obj->{
if (obj instanceof DaoEPBase) {
setRevisor((DaoEPBase) obj, true);
setCreator((DaoEPBase) obj);
} else if (obj instanceof Map) {
setRevisor((Map) obj, true);
setCreator((Map) obj);
}
});
return DaoBase.getInstance().insertBatch(sql, parameters);
......
......@@ -45,7 +45,7 @@ public class HGCB002 extends DaoEPBase {
public static final String FIELD_INVENT_TYPE = "inventType"; /* 存货类型*/
public static final String FIELD_INVENT_CODE = "inventCode"; /* 存货编码*/
public static final String FIELD_INVENT_NAME = "inventName"; /* 存货名称*/
public static final String FIELD_SPEC_ID = "specId"; /* 规格ID*/
public static final String FIELD_INVENT_RECORD_ID = "inventRecordId"; /* 规格ID*/
public static final String FIELD_SPEC = "spec"; /* 规格*/
public static final String FIELD_UNIT = "unit"; /* 单位*/
public static final String FIELD_QUANTITY = "quantity"; /* 数量*/
......@@ -53,6 +53,7 @@ public class HGCB002 extends DaoEPBase {
public static final String FIELD_IS_ESTIMATE = "isEstimate"; /* 是否暂估:0-否 1-是*/
public static final String FIELD_PRICE = "price"; /* 单价*/
public static final String FIELD_AMOUNT = "amount"; /* 金额*/
public static final String FIELD_INVENT_TYPE_DETAIL = "inventTypeDetail"; /*存货类型明细*/
public static final String COL_ID = "ID"; /* ID*/
public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 企业编码*/
......@@ -91,6 +92,7 @@ public class HGCB002 extends DaoEPBase {
public static final String INSERT = "HGCB002.insert";
public static final String UPDATE = "HGCB002.update";
public static final String DELETE = "HGCB002.delete";
public static final String DELETE_PERIOD = "HGCB002.deleteByPeriod";
private Long id = new Long(0); /* ID*/
private String accountCode = " "; /* 企业编码*/
......@@ -115,7 +117,7 @@ public class HGCB002 extends DaoEPBase {
private String inventType = " "; /* 存货类型*/
private String inventCode = " "; /* 存货编码*/
private String inventName = " "; /* 存货名称*/
private Long specId = new Long(0); /* 规格ID*/
private Long inventRecordId = new Long(0); /* 规格ID*/
private String spec = " "; /* 规格*/
private String unit = " "; /* 单位*/
private BigDecimal quantity = new BigDecimal("0"); /* 数量*/
......@@ -123,6 +125,7 @@ public class HGCB002 extends DaoEPBase {
private Integer isEstimate = 0; /* 是否暂估:0-否 1-是*/
private BigDecimal price = new BigDecimal("0"); /* 单价*/
private BigDecimal amount = new BigDecimal("0"); /* 金额*/
private Integer inventTypeDetail;
/**
* initialize the metadata.
......@@ -223,7 +226,7 @@ public class HGCB002 extends DaoEPBase {
eiColumn.setDescName("存货名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_SPEC_ID);
eiColumn = new EiColumn(FIELD_INVENT_RECORD_ID);
eiColumn.setDescName("规格ID");
eiMetadata.addMeta(eiColumn);
......@@ -267,6 +270,9 @@ public class HGCB002 extends DaoEPBase {
eiColumn.setDescName("金额");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INVENT_TYPE_DETAIL);
eiColumn.setDescName("存货类型明细");
eiMetadata.addMeta(eiColumn);
}
......@@ -648,20 +654,20 @@ public class HGCB002 extends DaoEPBase {
this.inventName = inventName;
}
/**
* get the specId - 规格ID.
* @return the specId
* get the inventRecordId - 规格ID.
* @return the inventRecordId
*/
public Long getSpecId() {
return this.specId;
public Long getInventRecordId() {
return this.inventRecordId;
}
/**
* set the specId - 规格ID.
* set the inventRecordId - 规格ID.
*
* @param specId - 规格ID
* @param inventRecordId - 规格ID
*/
public void setSpecId(Long specId) {
this.specId = specId;
public void setInventRecordId(Long inventRecordId) {
this.inventRecordId = inventRecordId;
}
/**
* get the spec - 规格.
......@@ -775,6 +781,15 @@ public class HGCB002 extends DaoEPBase {
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public Integer getInventTypeDetail() {
return inventTypeDetail;
}
public void setInventTypeDetail(Integer inventTypeDetail) {
this.inventTypeDetail = inventTypeDetail;
}
/**
* get the value from Map.
*
......@@ -806,7 +821,7 @@ public class HGCB002 extends DaoEPBase {
setInventType(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_TYPE)), inventType));
setInventCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_CODE)), inventCode));
setInventName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_NAME)), inventName));
setSpecId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_SPEC_ID)), specId));
setInventRecordId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_INVENT_RECORD_ID)), inventRecordId));
setSpec(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SPEC)), spec));
setUnit(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UNIT)), unit));
setQuantity(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_QUANTITY)), quantity));
......@@ -814,6 +829,7 @@ public class HGCB002 extends DaoEPBase {
setIsEstimate(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_IS_ESTIMATE)), isEstimate));
setPrice(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_PRICE)), price));
setAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_AMOUNT)), amount));
setInventTypeDetail(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_INVENT_TYPE_DETAIL)), inventTypeDetail));
}
/**
......@@ -846,7 +862,7 @@ public class HGCB002 extends DaoEPBase {
map.put(FIELD_INVENT_TYPE, StringUtils.toString(inventType, eiMetadata.getMeta(FIELD_INVENT_TYPE)));
map.put(FIELD_INVENT_CODE, StringUtils.toString(inventCode, eiMetadata.getMeta(FIELD_INVENT_CODE)));
map.put(FIELD_INVENT_NAME, StringUtils.toString(inventName, eiMetadata.getMeta(FIELD_INVENT_NAME)));
map.put(FIELD_SPEC_ID, StringUtils.toString(specId, eiMetadata.getMeta(FIELD_SPEC_ID)));
map.put(FIELD_INVENT_RECORD_ID, StringUtils.toString(inventRecordId, eiMetadata.getMeta(FIELD_INVENT_RECORD_ID)));
map.put(FIELD_SPEC, StringUtils.toString(spec, eiMetadata.getMeta(FIELD_SPEC)));
map.put(FIELD_UNIT, StringUtils.toString(unit, eiMetadata.getMeta(FIELD_UNIT)));
map.put(FIELD_QUANTITY, StringUtils.toString(quantity, eiMetadata.getMeta(FIELD_QUANTITY)));
......@@ -854,7 +870,7 @@ public class HGCB002 extends DaoEPBase {
map.put(FIELD_IS_ESTIMATE, StringUtils.toString(isEstimate, eiMetadata.getMeta(FIELD_IS_ESTIMATE)));
map.put(FIELD_PRICE, StringUtils.toString(price, eiMetadata.getMeta(FIELD_PRICE)));
map.put(FIELD_AMOUNT, StringUtils.toString(amount, eiMetadata.getMeta(FIELD_AMOUNT)));
map.put(FIELD_INVENT_TYPE_DETAIL, StringUtils.toString(inventTypeDetail, eiMetadata.getMeta(FIELD_INVENT_TYPE_DETAIL)));
return map;
}
}
......@@ -44,7 +44,7 @@ public class HGCB003 extends DaoEPBase {
public static final String FIELD_INVENT_TYPE = "inventType"; /* 存货类型*/
public static final String FIELD_INVENT_CODE = "inventCode"; /* 存货编码*/
public static final String FIELD_INVENT_NAME = "inventName"; /* 存货名称*/
public static final String FIELD_SPEC_ID = "specId"; /* 规格ID*/
public static final String FIELD_INVENT_RECORD_ID = "inventRecordId"; /* 规格ID*/
public static final String FIELD_SPEC = "spec"; /* 规格*/
public static final String FIELD_UNIT = "unit"; /* 单位*/
public static final String FIELD_QUANTITY = "quantity"; /* 数量*/
......@@ -52,6 +52,7 @@ public class HGCB003 extends DaoEPBase {
public static final String FIELD_IS_ESTIMATE = "isEstimate"; /* 是否暂估:0-否 1-是*/
public static final String FIELD_PRICE = "price"; /* 单价*/
public static final String FIELD_AMOUNT = "amount"; /* 金额*/
public static final String FIELD_INVENT_TYPE_DETAIL = "inventTypeDetail"; /*存货类型明细*/
public static final String COL_ID = "ID"; /* ID*/
public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 企业编码*/
......@@ -90,6 +91,7 @@ public class HGCB003 extends DaoEPBase {
public static final String INSERT = "HGCB003.insert";
public static final String UPDATE = "HGCB003.update";
public static final String DELETE = "HGCB003.delete";
public static final String DELETE_PERIOD = "HGCB003.deleteByPeriod";
private Long id = new Long(0); /* ID*/
private String accountCode = " "; /* 企业编码*/
......@@ -113,7 +115,7 @@ public class HGCB003 extends DaoEPBase {
private String inventType = " "; /* 存货类型*/
private String inventCode = " "; /* 存货编码*/
private String inventName = " "; /* 存货名称*/
private Long specId = new Long(0); /* 规格ID*/
private Long inventRecordId = new Long(0); /* 规格ID*/
private String spec = " "; /* 规格*/
private String unit = " "; /* 单位*/
private BigDecimal quantity = new BigDecimal("0"); /* 数量*/
......@@ -121,6 +123,7 @@ public class HGCB003 extends DaoEPBase {
private Integer isEstimate = 0; /* 是否暂估:0-否 1-是*/
private BigDecimal price = new BigDecimal("0"); /* 单价*/
private BigDecimal amount = new BigDecimal("0"); /* 金额*/
private Integer inventTypeDetail;
/**
* initialize the metadata.
......@@ -217,7 +220,7 @@ public class HGCB003 extends DaoEPBase {
eiColumn.setDescName("存货名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_SPEC_ID);
eiColumn = new EiColumn(FIELD_INVENT_RECORD_ID);
eiColumn.setDescName("规格ID");
eiMetadata.addMeta(eiColumn);
......@@ -261,6 +264,9 @@ public class HGCB003 extends DaoEPBase {
eiColumn.setDescName("金额");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INVENT_TYPE_DETAIL);
eiColumn.setDescName("存货类型明细");
eiMetadata.addMeta(eiColumn);
}
......@@ -624,20 +630,20 @@ public class HGCB003 extends DaoEPBase {
this.inventName = inventName;
}
/**
* get the specId - 规格ID.
* @return the specId
* get the inventRecordId - 规格ID.
* @return the inventRecordId
*/
public Long getSpecId() {
return this.specId;
public Long getInventRecordId() {
return this.inventRecordId;
}
/**
* set the specId - 规格ID.
* set the inventRecordId - 规格ID.
*
* @param specId - 规格ID
* @param inventRecordId - 规格ID
*/
public void setSpecId(Long specId) {
this.specId = specId;
public void setInventRecordId(Long inventRecordId) {
this.inventRecordId = inventRecordId;
}
/**
* get the spec - 规格.
......@@ -751,6 +757,15 @@ public class HGCB003 extends DaoEPBase {
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public Integer getInventTypeDetail() {
return inventTypeDetail;
}
public void setInventTypeDetail(Integer inventTypeDetail) {
this.inventTypeDetail = inventTypeDetail;
}
/**
* get the value from Map.
*
......@@ -781,7 +796,7 @@ public class HGCB003 extends DaoEPBase {
setInventType(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_TYPE)), inventType));
setInventCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_CODE)), inventCode));
setInventName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_NAME)), inventName));
setSpecId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_SPEC_ID)), specId));
setInventRecordId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_INVENT_RECORD_ID)), inventRecordId));
setSpec(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SPEC)), spec));
setUnit(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UNIT)), unit));
setQuantity(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_QUANTITY)), quantity));
......@@ -789,6 +804,7 @@ public class HGCB003 extends DaoEPBase {
setIsEstimate(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_IS_ESTIMATE)), isEstimate));
setPrice(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_PRICE)), price));
setAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_AMOUNT)), amount));
setInventTypeDetail(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_INVENT_TYPE_DETAIL)), inventTypeDetail));
}
/**
......@@ -820,7 +836,7 @@ public class HGCB003 extends DaoEPBase {
map.put(FIELD_INVENT_TYPE, StringUtils.toString(inventType, eiMetadata.getMeta(FIELD_INVENT_TYPE)));
map.put(FIELD_INVENT_CODE, StringUtils.toString(inventCode, eiMetadata.getMeta(FIELD_INVENT_CODE)));
map.put(FIELD_INVENT_NAME, StringUtils.toString(inventName, eiMetadata.getMeta(FIELD_INVENT_NAME)));
map.put(FIELD_SPEC_ID, StringUtils.toString(specId, eiMetadata.getMeta(FIELD_SPEC_ID)));
map.put(FIELD_INVENT_RECORD_ID, StringUtils.toString(inventRecordId, eiMetadata.getMeta(FIELD_INVENT_RECORD_ID)));
map.put(FIELD_SPEC, StringUtils.toString(spec, eiMetadata.getMeta(FIELD_SPEC)));
map.put(FIELD_UNIT, StringUtils.toString(unit, eiMetadata.getMeta(FIELD_UNIT)));
map.put(FIELD_QUANTITY, StringUtils.toString(quantity, eiMetadata.getMeta(FIELD_QUANTITY)));
......@@ -828,7 +844,7 @@ public class HGCB003 extends DaoEPBase {
map.put(FIELD_IS_ESTIMATE, StringUtils.toString(isEstimate, eiMetadata.getMeta(FIELD_IS_ESTIMATE)));
map.put(FIELD_PRICE, StringUtils.toString(price, eiMetadata.getMeta(FIELD_PRICE)));
map.put(FIELD_AMOUNT, StringUtils.toString(amount, eiMetadata.getMeta(FIELD_AMOUNT)));
map.put(FIELD_INVENT_TYPE_DETAIL, StringUtils.toString(inventTypeDetail, eiMetadata.getMeta(FIELD_INVENT_TYPE_DETAIL)));
return map;
}
}
......@@ -42,6 +42,7 @@ public class HGCB004 extends DaoEPBase {
public static final String FIELD_INVENT_CODE = "inventCode"; /* 存货编码*/
public static final String FIELD_INVENT_NAME = "inventName"; /* 存货名称*/
public static final String FIELD_INVENT_RECORD_ID = "inventRecordId"; /* 规格ID*/
public static final String FIELD_SPEC = "spec"; /* 规格*/
public static final String FIELD_INIT_QUANTITY = "initQuantity"; /* 期初数量*/
public static final String FIELD_INIT_WEIGHT = "initWeight"; /* 期初重量*/
public static final String FIELD_INIT_AMOUNT = "initAmount"; /* 期初金额*/
......@@ -159,6 +160,7 @@ public class HGCB004 extends DaoEPBase {
private String inventCode = " "; /* 存货编码*/
private String inventName = " "; /* 存货名称*/
private Long inventRecordId = new Long(0); /* 规格ID*/
private String spec = " "; /* 规格*/
private BigDecimal initQuantity = new BigDecimal(0); /* 期初数量*/
private BigDecimal initWeight = new BigDecimal(0.000); /* 期初重量*/
private BigDecimal initAmount = new BigDecimal(0.000); /* 期初金额*/
......@@ -280,6 +282,10 @@ public class HGCB004 extends DaoEPBase {
eiColumn.setDescName("规格ID");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_SPEC);
eiColumn.setDescName("规格");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INIT_QUANTITY);
eiColumn.setType("N");
eiColumn.setScaleLength(0);
......@@ -842,6 +848,15 @@ public class HGCB004 extends DaoEPBase {
public void setInventRecordId(Long inventRecordId) {
this.inventRecordId = inventRecordId;
}
public String getSpec() {
return spec;
}
public void setSpec(String spec) {
this.spec = spec;
}
/**
* get the initQuantity - 期初数量.
* @return the initQuantity
......@@ -1398,6 +1413,7 @@ public class HGCB004 extends DaoEPBase {
setInventCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_CODE)), inventCode));
setInventName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_NAME)), inventName));
setInventRecordId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_INVENT_RECORD_ID)), inventRecordId));
setSpec(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SPEC)), spec));
setInitQuantity(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_INIT_QUANTITY)), initQuantity));
setInitWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_INIT_WEIGHT)), initWeight));
setInitAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_INIT_AMOUNT)), initAmount));
......@@ -1460,6 +1476,7 @@ public class HGCB004 extends DaoEPBase {
map.put(FIELD_INVENT_CODE, StringUtils.toString(inventCode, eiMetadata.getMeta(FIELD_INVENT_CODE)));
map.put(FIELD_INVENT_NAME, StringUtils.toString(inventName, eiMetadata.getMeta(FIELD_INVENT_NAME)));
map.put(FIELD_INVENT_RECORD_ID, StringUtils.toString(inventRecordId, eiMetadata.getMeta(FIELD_INVENT_RECORD_ID)));
map.put(FIELD_SPEC, StringUtils.toString(spec, eiMetadata.getMeta(FIELD_SPEC)));
map.put(FIELD_INIT_QUANTITY, StringUtils.toString(initQuantity, eiMetadata.getMeta(FIELD_INIT_QUANTITY)));
map.put(FIELD_INIT_WEIGHT, StringUtils.toString(initWeight, eiMetadata.getMeta(FIELD_INIT_WEIGHT)));
map.put(FIELD_INIT_AMOUNT, StringUtils.toString(initAmount, eiMetadata.getMeta(FIELD_INIT_AMOUNT)));
......
package com.baosight.hggp.hg.cb.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cb.domain.HGCB001;
import com.baosight.hggp.hg.cb.domain.HGCB002;
import com.baosight.hggp.hg.cb.domain.HGCB004;
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.utils.HGUtils;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.*;
import com.baosight.hggp.util.contants.ACConstants;
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.ServiceEPBase;
import java.util.Arrays;
......@@ -47,12 +51,43 @@ public class ServiceHGCB002 extends ServiceEPBase {
return super.query(inInfo, HGCB002.QUERY, new HGCB002());
}
@OperationLogAnnotation(operModul = "原材料入库成本核算",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
return super.delete(inInfo, HGCB002.DELETE);
}
@OperationLogAnnotation(operModul = "原材料入库成本核算",operType = "查询",operDesc = "数据同步操作")
public EiInfo select(EiInfo inInfo) {
Map params= EiInfoUtils.getFirstRow(inInfo);
HGCW001 hgcw001 = HGCWTools.HgCw001.getMaxAccountPeriod(params.get(HGCB002.FIELD_COMPANY_CODE).toString());
params.put(HGCW001.FIELD_ACCOUNT_CODE, hgcw001.getAccountCode());
params.put(HGCW001.FIELD_ACCOUNT_PERIOD, hgcw001.getAccountPeriod());
HGCBTools.HgCb002.select(params);
try {
Map params= EiInfoUtils.getFirstRow(inInfo);
HGUtils.setCondition(params);
HGCB001 hgcw001Today = HGCBTools.HgCb001.select(params);
if (hgcw001Today != null && hgcw001Today.getAccountPeriodStatus() == 0) {
throw new PlatException(String.format("公司[%s]会计期[%s]状态为关账状态,数据同步失败!", hgcw001Today.getCompanyCode(), hgcw001Today.getAccountPeriod()));
}
HGCB001 hgcw001Last = HGCBTools.HgCb001.selectLast(params);
if (hgcw001Last != null && hgcw001Last.getAccountPeriodStatus() == 1) {
throw new PlatException(String.format("公司[%s]上月会计期[%s]为开账状态,数据同步失败!", hgcw001Last.getCompanyCode(), hgcw001Last.getAccountPeriod()));
}
HGCBTools.HgCb002.select(params);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "同步数据失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "原材料入库成本核算",operType = "查询",operDesc = "查询业务账期")
public EiInfo selectAll(EiInfo inInfo) {
try {
Map params= EiInfoUtils.getFirstRow(inInfo);
HGCW001 hgcw001 = HGCWTools.HgCw001.getMaxAccountPeriod(params.get(HGCB002.FIELD_COMPANY_CODE).toString());
EiInfoUtils.addBlock(inInfo,"hgcw001_block_id", hgcw001, HGCW001.class);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "同步数据失败");
}
return inInfo;
}
}
package com.baosight.hggp.hg.cb.service;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cb.domain.HGCB001;
import com.baosight.hggp.hg.cb.domain.HGCB003;
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.utils.HGUtils;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.hggp.util.*;
import com.baosight.hggp.util.contants.ACConstants;
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.ServiceEPBase;
import java.util.Arrays;
import java.util.Map;
/**
......@@ -26,6 +28,7 @@ public class ServiceHGCB003 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
inInfo = super.initLoad(inInfo, EiConstant.resultBlock, new HGCB003());
EiInfoUtils.addBlock(inInfo,"company_code_block_id", UserSessionUtils.getRoleCompany(), Company.class);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
......@@ -43,11 +46,26 @@ public class ServiceHGCB003 extends ServiceEPBase {
}
public EiInfo select(EiInfo inInfo) {
Map params= EiInfoUtils.getFirstRow(inInfo);
HGCW001 hgcw001 = HGCWTools.HgCw001.getMaxAccountPeriod(params.get(HGCB003.FIELD_COMPANY_CODE).toString());
params.put(HGCW001.FIELD_ACCOUNT_CODE, hgcw001.getAccountCode());
params.put(HGCW001.FIELD_ACCOUNT_PERIOD, hgcw001.getAccountPeriod());
HGCBTools.HgCb003.select(params);
try{
Map params= EiInfoUtils.getFirstRow(inInfo);
HGUtils.setCondition(params);
HGCB001 hgcw001Today = HGCBTools.HgCb001.select(params);
if (hgcw001Today != null && hgcw001Today.getAccountPeriodStatus() == 0) {
throw new PlatException(String.format("公司[%s]会计期[%s]状态为关账状态,数据同步失败!", hgcw001Today.getCompanyCode(), hgcw001Today.getAccountPeriod()));
}
HGCB001 hgcw001Last = HGCBTools.HgCb001.selectLast(params);
if (hgcw001Last != null && hgcw001Last.getAccountPeriodStatus() == 1) {
throw new PlatException(String.format("公司[%s]上月会计期[%s]为开账状态,数据同步失败!", hgcw001Last.getCompanyCode(), hgcw001Last.getAccountPeriod()));
}
HGCBTools.HgCb003.select(params);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "同步数据失败");
}
return inInfo;
}
@Override
public EiInfo delete(EiInfo inInfo) {
return super.delete(inInfo, HGCB003.DELETE);
}
}
......@@ -3,6 +3,7 @@ package com.baosight.hggp.hg.cb.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cb.domain.HGCB001;
import com.baosight.hggp.hg.cb.domain.HGCB002;
import com.baosight.hggp.hg.cb.domain.HGCB004;
......@@ -14,6 +15,8 @@ import com.baosight.hggp.hg.kc.domain.*;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.pz.domain.HGPZ007;
import com.baosight.hggp.hg.pz.tools.HGPZTools;
import com.baosight.hggp.hg.utils.HGUtils;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.*;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiConstant;
......@@ -39,12 +42,13 @@ public class ServiceHGCB004 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
EiInfoUtils.addBlock(inInfo,"company_code_block_id", UserSessionUtils.getRoleCompany(), Company.class);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_TYPE_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_RECORD_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SPEC_RECORD_BLOCK_ID), null, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCB004().eiMetadata);
} catch (PlatException e) {
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
......@@ -73,17 +77,23 @@ public class ServiceHGCB004 extends ServiceEPBase {
* @return
*/
@OperationLogAnnotation(operModul = "收发存汇总",operType = "同步数据",operDesc = "同步数据")
public EiInfo synchData(EiInfo inInfo) {
public EiInfo select(EiInfo inInfo) {
try {
Map<String, Object> queryRow = EiInfoUtils.getFirstRow(inInfo);
HGCW001 hgcw001 = HGCWTools.HgCw001.getMaxAccountPeriod(queryRow.get(HGCB002.FIELD_COMPANY_CODE).toString());
queryRow.put(HGCB004.FIELD_ACCOUNT_CODE, hgcw001.getAccountCode());
queryRow.put(HGCB004.FIELD_ACCOUNT_PERIOD, hgcw001.getAccountPeriod());
List<HGCB004> cb004s =HGCBTools.HgCb004.synchData(queryRow);
Map params = EiInfoUtils.getFirstRow(inInfo);
HGUtils.setCondition(params);
HGCB001 hgcw001Today = HGCBTools.HgCb001.select(params);
if (hgcw001Today != null && hgcw001Today.getAccountPeriodStatus() == 0) {
throw new PlatException(String.format("公司[%s]会计期[%s]状态为关账状态,数据同步失败!", hgcw001Today.getCompanyCode(), hgcw001Today.getAccountPeriod()));
}
HGCB001 hgcw001Last = HGCBTools.HgCb001.selectLast(params);
if (hgcw001Last != null && hgcw001Last.getAccountPeriodStatus() == 1) {
throw new PlatException(String.format("公司[%s]上月会计期[%s]为开账状态,数据同步失败!", hgcw001Last.getCompanyCode(), hgcw001Last.getAccountPeriod()));
}
HGCBTools.HgCb004.synchData(params);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + cb004s.size() + "]条数据同步成功!");
inInfo.setMsg("操作成功!本次数据同步成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "同步数据失败");
LogUtils.setDetailMsg(inInfo, e, "数据同步失败");
}
return inInfo;
}
......
......@@ -68,6 +68,51 @@
DEP_CODE = #depCode#
</isNotEmpty>
</sql>
<sql id="lastCondition">
<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 = (select DATE_FORMAT(DATE_SUB(concat(#accountPeriod#,'01'), INTERVAL 1 MONTH), '%Y%m'))
</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>
<select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hggp.hg.cb.domain.HGCB001">
......@@ -199,10 +244,38 @@
ID = #id#
</update>
<select id="getSwitchRowNum" resultClass="com.baosight.hggp.hg.cw.domain.HGCB001">
<select id="getSwitchRowNum" resultClass="com.baosight.hggp.hg.cb.domain.HGCB001">
SELECT * FROM ${hggpSchema}.HGCB001 WHERE ACCOUNT_PERIOD_STATUS = 1
</select>
<select id="getLastRow" 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
<include refid="lastCondition" />
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID asc
</isEmpty>
</dynamic>
</select>
<update id="updateSwitchRow">
UPDATE ${hggpSchema}.HGCB001
SET
......
......@@ -62,36 +62,30 @@
INVENT_TYPE as "inventType", <!-- 存货类型 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
SPEC_ID as "specId", <!-- 规格ID -->
INVENT_RECORD_ID as "inventRecordId", <!-- 规格ID -->
SPEC as "spec", <!-- 规格 -->
UNIT as "unit", <!-- 单位 -->
QUANTITY as "quantity", <!-- 数量 -->
WEIGHT as "weight", <!-- 重量 -->
IS_ESTIMATE as "isEstimate", <!-- 是否暂估:0-否 1-是 -->
PRICE as "price", <!-- 单价 -->
AMOUNT as "amount" <!-- 金额 -->
AMOUNT as "amount", <!-- 金额 -->
INVENT_TYPE_DETAIL as "inventTypeDetail" <!-- 存货类型明细 -->
</sql>
<sql id="columnLast">
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
ACCOUNT_YEAR as "accountYear", <!-- 会计年度 -->
ACCOUNT_PERIOD as "accountPeriod", <!-- 会计期 -->
BIZ_TYPE as "bizType", <!-- 业务类型 -->
RECEIPT_DATE as "receiptDate", <!-- 单据日期 -->
RECEIPT_CODE as "receiptCode", <!-- 单据号 -->
RECEIVE_NO as "receiveNo", <!-- 收货单号 -->
WH_CODE as "whCode", <!-- 仓库编码 -->
WH_NAME as "whName", <!-- 仓库名称 -->
INVENT_TYPE as "inventType", <!-- 存货类型 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
SPEC_ID as "specId", <!-- 规格ID -->
INVENT_RECORD_ID as "inventRecordId", <!-- 规格ID -->
SPEC as "spec", <!-- 规格 -->
UNIT as "unit", <!-- 单位 -->
INVENT_TYPE_DETAIL as "inventTypeDetail",
sum(QUANTITY) as "quantity", <!-- 数量 -->
sum(WEIGHT) as "weight", <!-- 重量 -->
IS_ESTIMATE as "isEstimate", <!-- 是否暂估:0-否 1-是 -->
CASE WHEN IFNULL(SUM(QUANTITY), 0) = 0 THEN 0 ELSE SUM(AMOUNT)/SUM(QUANTITY) END as "price", <!-- 单价 -->
sum(AMOUNT) as "amount" <!-- 金额 -->
</sql>
......@@ -166,8 +160,8 @@
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="specId">
SPEC_ID = #specId#
<isNotEmpty prepend=" AND " property="inventRecordId">
INVENT_RECORD_ID = #inventRecordId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="spec">
SPEC = #spec#
......@@ -190,6 +184,12 @@
<isNotEmpty prepend=" AND " property="amount">
AMOUNT = #amount#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetail">
INVENT_TYPE_DETAIL = #inventTypeDetail#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetails">
INVENT_TYPE_DETAIL IN <iterate close=")" open="(" conjunction="," property="inventTypeDetails">#inventTypeDetails[]#</iterate>
</isNotEmpty>
</sql>
<sql id="order">
<dynamic prepend="ORDER BY">
......@@ -206,12 +206,18 @@
SELECT <include refid="column" />
FROM ${hggpSchema}.HGCB002 WHERE 1=1
<include refid="condition" />
<isNotEmpty prepend=" AND " property="accountDate">
ACCOUNT_PERIOD = $accountDate$
</isNotEmpty>
<include refid="order"/>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGCB002 WHERE 1=1
<include refid="condition" />
<include refid="condition" />
<isNotEmpty prepend=" AND " property="accountDate">
ACCOUNT_PERIOD = $accountDate$
</isNotEmpty>
</select>
<select id="queryDetail" parameterClass="java.util.HashMap" resultClass="HGCB002">
......@@ -223,7 +229,8 @@
WH_CODE as "whCode", <!-- 仓库编码 -->
INVENT_TYPE as "inventType", <!-- 存货类型 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
SPEC_ID as "specId", <!-- 规格ID -->
INVENT_RECORD_ID as "inventRecordId", <!-- 规格ID -->
INVENT_TYPE_DETAIL as "inventTypeDetail",
SPEC as "spec", <!-- 规格 -->
SUM(QUANTITY) as "quantity", <!-- 数量 -->
SUM(WEIGHT) as "weight", <!-- 重量 -->
......@@ -231,14 +238,17 @@
SUM(AMOUNT) as "amount" <!-- 金额 -->
FROM ${hggpSchema}.HGCB002 WHERE 1=1
<include refid="condition" />
group by ACCOUNT_CODE, DEP_CODE, COMPANY_CODE, ACCOUNT_PERIOD, WH_CODE, INVENT_TYPE, INVENT_CODE, SPEC_ID, SPEC, IS_ESTIMATE
group by ACCOUNT_CODE, DEP_CODE, COMPANY_CODE, ACCOUNT_PERIOD, WH_CODE, INVENT_TYPE, INVENT_CODE, INVENT_RECORD_ID,INVENT_TYPE_DETAIL, SPEC, IS_ESTIMATE
</select>
<!--查询上月-->
<select id="queryLast" parameterClass="java.util.HashMap" resultClass="HGCB002">
SELECT <include refid="columnLast" />
FROM ${hggpSchema}.HGCB002 WHERE 1=1
<include refid="condition" />
group by ACCOUNT_CODE, COMPANY_CODE, COMPANY_NAME, ACCOUNT_YEAR, ACCOUNT_PERIOD, BIZ_TYPE, RECEIPT_DATE, RECEIPT_CODE, RECEIVE_NO, WH_CODE, WH_NAME, INVENT_TYPE, INVENT_CODE, INVENT_NAME, SPEC_ID, SPEC, UNIT, IS_ESTIMATE
<isNotEmpty prepend=" AND " property="accountDate">
ACCOUNT_PERIOD = $accountDate$
</isNotEmpty>
group by ACCOUNT_CODE, DEP_CODE, COMPANY_CODE, COMPANY_NAME, ACCOUNT_YEAR, ACCOUNT_PERIOD, WH_CODE, INVENT_CODE, INVENT_RECORD_ID,INVENT_TYPE_DETAIL, SPEC
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
......@@ -366,19 +376,20 @@
INVENT_TYPE, <!-- 存货类型 -->
INVENT_CODE, <!-- 存货编码 -->
INVENT_NAME, <!-- 存货名称 -->
SPEC_ID, <!-- 规格ID -->
INVENT_RECORD_ID, <!-- 规格ID -->
SPEC, <!-- 规格 -->
UNIT, <!-- 单位 -->
QUANTITY, <!-- 数量 -->
WEIGHT, <!-- 重量 -->
IS_ESTIMATE, <!-- 是否暂估:0-否 1-是 -->
PRICE, <!-- 单价 -->
AMOUNT <!-- 金额 -->
AMOUNT, <!-- 金额 -->
INVENT_TYPE_DETAIL
)
VALUES (#id#, #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#,
#updatedTime#, #deleteFlag#, #companyCode#, #companyName#, #accountYear#, #accountPeriod#, #bizType#,
#receiptDate#, #receiptCode#, #receiveNo#, #whCode#, #whName#, #inventType#, #inventCode#, #inventName#, #specId#, #spec#,
#unit#, #quantity#, #weight#, #isEstimate#, #price#, #amount#)
#receiptDate#, #receiptCode#, #receiveNo#, #whCode#, #whName#, #inventType#, #inventCode#, #inventName#, #inventRecordId#, #spec#,
#unit#, #quantity#, #weight#, #isEstimate#, #price#, #amount#, #inventTypeDetail#)
<selectKey resultClass="long" keyProperty="id">
SELECT MAX(ID) AS "id" FROM ${hggpSchema}.HGCB002
</selectKey>
......@@ -387,6 +398,14 @@
<delete id="delete">
DELETE FROM ${hggpSchema}.HGCB002 WHERE ID = #id#
</delete>
<!-- 按时间删除数据 -->
<delete id="deleteByPeriod">
DELETE FROM ${hggpSchema}.HGCB002
WHERE ACCOUNT_CODE = #accountCode#
AND COMPANY_CODE = #companyCode#
AND ACCOUNT_YEAR = #accountYear#
AND ACCOUNT_PERIOD = #accountPeriod#
</delete>
<update id="update">
UPDATE ${hggpSchema}.HGCB002
......@@ -413,14 +432,15 @@
INVENT_TYPE = #inventType#, <!-- 存货类型 -->
INVENT_CODE = #inventCode#, <!-- 存货编码 -->
INVENT_NAME = #inventName#, <!-- 存货名称 -->
SPEC_ID = #specId#, <!-- 规格ID -->
INVENT_RECORD_ID = #inventRecordId#, <!-- 规格ID -->
SPEC = #spec#, <!-- 规格 -->
UNIT = #unit#, <!-- 单位 -->
QUANTITY = #quantity#, <!-- 数量 -->
WEIGHT = #weight#, <!-- 重量 -->
IS_ESTIMATE = #isEstimate#, <!-- 是否暂估:0-否 1-是 -->
PRICE = #price#, <!-- 单价 -->
AMOUNT = #amount# <!-- 金额 -->
AMOUNT = #amount#, <!-- 金额 -->
INVENT_TYPE_DETAIL = #inventTypeDetail#
WHERE
ID = #id#
</update>
......
......@@ -61,14 +61,15 @@
INVENT_TYPE as "inventType", <!-- 存货类型 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
SPEC_ID as "specId", <!-- 规格ID -->
INVENT_RECORD_ID as "inventRecordId", <!-- 规格ID -->
SPEC as "spec", <!-- 规格 -->
UNIT as "unit", <!-- 单位 -->
QUANTITY as "quantity", <!-- 数量 -->
WEIGHT as "weight", <!-- 重量 -->
IS_ESTIMATE as "isEstimate", <!-- 是否暂估:0-否 1-是 -->
PRICE as "price", <!-- 单价 -->
AMOUNT as "amount" <!-- 金额 -->
AMOUNT as "amount", <!-- 金额 -->
INVENT_TYPE_DETAIL as "inventTypeDetail" <!-- 存货类型明细 -->
</sql>
<sql id="condition">
<include refid="HGXSDataAuth.authCondition"/>
......@@ -138,8 +139,8 @@
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="specId">
SPEC_ID = #specId#
<isNotEmpty prepend=" AND " property="inventRecordId">
INVENT_RECORD_ID = #inventRecordId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="spec">
SPEC = #spec#
......@@ -162,6 +163,12 @@
<isNotEmpty prepend=" AND " property="amount">
AMOUNT = #amount#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetail">
INVENT_TYPE_DETAIL = #inventTypeDetail#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetails">
INVENT_TYPE_DETAIL IN <iterate close=")" open="(" conjunction="," property="inventTypeDetails">#inventTypeDetails[]#</iterate>
</isNotEmpty>
</sql>
<sql id="order">
<dynamic prepend="ORDER BY">
......@@ -191,18 +198,23 @@
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
ACCOUNT_YEAR as "accountYear", <!-- 会计年度 -->
ACCOUNT_PERIOD as "accountPeriod", <!-- 会计期 -->
WH_CODE as "whCode", <!-- 仓库编码 -->
WH_NAME as "whName", <!-- 仓库名称 -->
INVENT_TYPE as "inventType", <!-- 存货类型 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
SPEC_ID as "specId", <!-- 规格ID -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
INVENT_RECORD_ID as "inventRecordId", <!-- 规格ID -->
INVENT_TYPE_DETAIL as "inventTypeDetail",
SPEC as "spec", <!-- 规格 -->
SUM(QUANTITY) as "quantity", <!-- 数量 -->
SUM(WEIGHT) as "weight", <!-- 重量 -->
IS_ESTIMATE as "isEstimate", <!-- 是否暂估:0-否 1-是 -->
SUM(AMOUNT) as "amount" <!-- 金额 -->
FROM ${hggpSchema}.HGCB003 WHERE 1=1
<include refid="condition" />
GROUP BY ACCOUNT_CODE, DEP_CODE, COMPANY_CODE, ACCOUNT_PERIOD, WH_CODE, INVENT_TYPE, INVENT_CODE, SPEC_ID, IS_ESTIMATE
GROUP BY ACCOUNT_CODE, DEP_CODE, COMPANY_CODE, COMPANY_NAME, ACCOUNT_YEAR, ACCOUNT_PERIOD, WH_CODE, WH_NAME, INVENT_TYPE, INVENT_CODE, INVENT_NAME, INVENT_RECORD_ID,INVENT_TYPE_DETAIL, SPEC
</select>
<!--
<isNotEmpty prepend=" AND " property="id">
......@@ -320,24 +332,33 @@
INVENT_TYPE, <!-- 存货类型 -->
INVENT_CODE, <!-- 存货编码 -->
INVENT_NAME, <!-- 存货名称 -->
SPEC_ID, <!-- 规格ID -->
INVENT_RECORD_ID, <!-- 规格ID -->
SPEC, <!-- 规格 -->
UNIT, <!-- 单位 -->
QUANTITY, <!-- 数量 -->
WEIGHT, <!-- 重量 -->
IS_ESTIMATE, <!-- 是否暂估:0-否 1-是 -->
PRICE, <!-- 单价 -->
AMOUNT <!-- 金额 -->
AMOUNT, <!-- 金额 -->
INVENT_TYPE_DETAIL
)
VALUES (#id#, #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#,
#updatedTime#, #deleteFlag#, #companyCode#, #companyName#, #accountYear#, #accountPeriod#, #bizType#,
#receiptDate#, #receiptCode#, #whCode#, #whName#, #inventType#, #inventCode#, #inventName#, #specId#, #spec#,
#unit#, #quantity#, #weight#, #isEstimate#, #price#, #amount#)
#receiptDate#, #receiptCode#, #whCode#, #whName#, #inventType#, #inventCode#, #inventName#, #inventRecordId#, #spec#,
#unit#, #quantity#, #weight#, #isEstimate#, #price#, #amount#, #inventTypeDetail#)
</insert>
<delete id="delete">
DELETE FROM ${hggpSchema}.HGCB003 WHERE ID = #id#
</delete>
<!-- 按时间删除数据 -->
<delete id="deleteByPeriod">
DELETE FROM ${hggpSchema}.HGCB003
WHERE ACCOUNT_CODE = #accountCode#
AND COMPANY_CODE = #companyCode#
AND ACCOUNT_YEAR = #accountYear#
AND ACCOUNT_PERIOD = #accountPeriod#
</delete>
<update id="update">
UPDATE ${hggpSchema}.HGCB003
......@@ -363,14 +384,15 @@
INVENT_TYPE = #inventType#, <!-- 存货类型 -->
INVENT_CODE = #inventCode#, <!-- 存货编码 -->
INVENT_NAME = #inventName#, <!-- 存货名称 -->
SPEC_ID = #specId#, <!-- 规格ID -->
INVENT_RECORD_ID = #inventRecordId#, <!-- 规格ID -->
SPEC = #spec#, <!-- 规格 -->
UNIT = #unit#, <!-- 单位 -->
QUANTITY = #quantity#, <!-- 数量 -->
WEIGHT = #weight#, <!-- 重量 -->
IS_ESTIMATE = #isEstimate#, <!-- 是否暂估:0-否 1-是 -->
PRICE = #price#, <!-- 单价 -->
AMOUNT = #amount# <!-- 金额 -->
AMOUNT = #amount#, <!-- 金额 -->
INVENT_TYPE_DETAIL = #inventTypeDetail#
WHERE
ID = #id#
</update>
......
......@@ -81,6 +81,7 @@
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
INVENT_RECORD_ID as "inventRecordId", <!-- 规格ID -->
SPEC as "spec", <!-- 规格 -->
INIT_QUANTITY as "initQuantity", <!-- 期初数量 -->
INIT_WEIGHT as "initWeight", <!-- 期初重量 -->
INIT_AMOUNT as "initAmount", <!-- 期初金额 -->
......@@ -160,7 +161,7 @@
WH_CODE = #whCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="whName">
WH_NAME = #whName#
WH_NAME like concat('%',#whName#,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
......@@ -169,11 +170,14 @@
INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
INVENT_NAME like concat('%',#inventName#,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventRecordId">
INVENT_RECORD_ID = #inventRecordId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="spec">
SPEC = #spec#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="initQuantity">
INIT_QUANTITY = #initQuantity#
</isNotEmpty>
......@@ -386,7 +390,52 @@
</select>
<!--查询上月-->
<select id="queryLast" parameterClass="java.util.HashMap" resultClass="HGCB004">
SELECT <include refid="column" />
SELECT
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
ACCOUNT_PERIOD as "accountPeriod", <!-- 日期 -->
WH_CODE as "whCode", <!-- 仓库编码 -->
WH_NAME as "whName", <!-- 仓库名称 -->
INVENT_TYPE_DETAIL as "inventTypeDetail", <!-- 存货类型明细 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
INVENT_RECORD_ID as "inventRecordId", <!-- 规格ID -->
SPEC as "spec", <!-- 规格 -->
SUM(INIT_QUANTITY) as "initQuantity", <!-- 期初数量 -->
SUM(INIT_WEIGHT) as "initWeight", <!-- 期初重量 -->
SUM(INIT_AMOUNT) as "initAmount", <!-- 期初金额 -->
SUM(CG_ENTER_QUANTITY) as "cgEnterQuantity", <!-- 采购入库数量 -->
SUM(CG_ENTER_WEIGHT) as "cgEnterWeight", <!-- 采购入库重量 -->
SUM(CG_ENTER_AMOUNT) as "cgEnterAmount", <!-- 采购入库金额 -->
SUM(SC_ENTER_QUANTITY) as "scEnterQuantity", <!-- 生产入库数量 -->
SUM(SC_ENTER_WEIGHT) as "scEnterWeight", <!-- 生产入库重量 -->
SUM(SC_ENTER_AMOUNT) as "scEnterAmount", <!-- 生产入库金额 -->
SUM(QT_ENTER_QUANTITY) as "qtEnterQuantity", <!-- 其它入库数量 -->
SUM(QT_ENTER_WEIGHT) as "qtEnterWeight", <!-- 其它入库重量 -->
SUM(QT_ENTER_AMOUNT) as "qtEnterAmount", <!-- 其它入库重量 -->
SUM(ENTER_QUANTITY) as "enterQuantity", <!-- 入库数量 -->
SUM(ENTER_WEIGHT) as "enterWeight", <!-- 入库重量 -->
SUM(ENTER_AMOUNT) as "enterAmount", <!-- 入库金额 -->
SUM(SC_OUTER_QUANTITY) as "scOuterQuantity", <!-- 生产领料数量 -->
SUM(SC_OUTER_WEIGHT) as "scOuterWeight", <!-- 生产领料重量 -->
SUM(SC_OUTER_AMOUNT) as "scOuterAmount", <!-- 生产领料金额 -->
SUM(XS_OUTER_QUANTITY) as "xsOuterQuantity", <!-- 销售出库数量 -->
SUM(XS_OUTER_WEIGHT) as "xsOuterWeight", <!-- 销售出库重量 -->
SUM(XS_OUTER_AMOUNT) as "xsOuterAmount", <!-- 销售出库金额 -->
SUM(QT_OUTER_QUANTITY) as "qtOuterQuantity", <!-- 其它出库数量 -->
SUM(QT_OUTER_WEIGHT) as "qtOuterWeight", <!-- 其它出库重量 -->
SUM(QT_OUTER_AMOUNT) as "qtOuterAmount", <!-- 其它出库数量 -->
SUM(OUTER_QUANTITY) as "outerQuantity", <!-- 出库数量 -->
SUM(OUTER_WEIGHT) as "outerWeight", <!-- 出库重量 -->
SUM(OUTER_AMOUNT) as "outerAmount", <!-- 出库金额 -->
SUM(PD_DIFF_QUANTITY) as "pdDiffQuantity", <!-- 盘点差异数量 -->
SUM(PD_DIFF_WEIGHT) as "pdDiffWeight", <!-- 盘点差异重量 -->
SUM(PD_DIFF_AMOUNT) as "pdDiffAmount", <!-- 盘点差异金额 -->
SUM(END_QUANTITY) as "endQuantity", <!-- 期末数量 -->
SUM(END_WEIGHT) as "endWeight", <!-- 期末重量 -->
SUM(END_AMOUNT) as "endAmount" <!-- 期末金额 -->
FROM ${hggpSchema}.HGCB004 WHERE 1=1
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
......@@ -398,7 +447,48 @@
DATE_TYPE = #dateType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriod">
ACCOUNT_PERIOD = DATE_FORMAT(DATE_SUB(concat(#accountPeriod#,'01'), INTERVAL 1 MONTH), '%Y%m')
ACCOUNT_PERIOD = (select DATE_FORMAT(DATE_SUB(concat(#accountPeriod#,'01'), INTERVAL 1 MONTH), '%Y%m'))
</isNotEmpty>
<isNotEmpty prepend=" AND " property="whCode">
WH_CODE = #whCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetail">
INVENT_TYPE_DETAIL = #inventTypeDetail#
</isNotEmpty>
GROUP BY ACCOUNT_CODE, DEP_CODE, COMPANY_CODE, COMPANY_NAME, ACCOUNT_PERIOD, WH_CODE, WH_NAME, INVENT_TYPE_DETAIL, INVENT_CODE, INVENT_NAME, INVENT_RECORD_ID, SPEC
</select>
<select id="querySum1" parameterClass="java.util.HashMap" resultClass="HGCB004">
SELECT
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
WH_CODE as "whCode", <!-- 仓库编码 -->
WH_NAME as "whName", <!-- 仓库名称 -->
INVENT_TYPE as "inventType", <!-- 存货类型 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
SPEC_ID as "inventRecordId", <!-- 规格ID -->
SPEC as "spec", <!-- 规格 -->
UNIT as "unit", <!-- 单位 -->
INVENT_TYPE_DETAIL as "inventTypeDetail"
FROM ${hggpSchema}.HGKC010
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="whCode">
WH_CODE = #whCode#
......@@ -596,6 +686,7 @@
INVENT_CODE, <!-- 存货编码 -->
INVENT_NAME, <!-- 存货名称 -->
INVENT_RECORD_ID, <!-- 规格ID -->
SPEC,
INIT_QUANTITY, <!-- 期初数量 -->
INIT_WEIGHT, <!-- 期初重量 -->
INIT_AMOUNT, <!-- 期初金额 -->
......@@ -631,8 +722,8 @@
END_AMOUNT <!-- 期末金额 -->
)
VALUES (#id#, #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#,
#updatedTime#, #companyCode#, #companyName#, #dateType#, #accountPeriod#, #whCode#, #whName#, #inventType#,#inventTypeDetail#,
#inventCode#, #inventName#, #inventRecordId#, #initQuantity#, #initWeight#, #initAmount#, #cgEnterQuantity#,
#updatedTime#, #companyCode#, #companyName#, #dateType#, #accountPeriod#, #whCode#, #whName#, #inventType#, #inventTypeDetail#,
#inventCode#, #inventName#, #inventRecordId#, #spec#, #initQuantity#, #initWeight#, #initAmount#, #cgEnterQuantity#,
#cgEnterWeight#, #cgEnterAmount#, #scEnterQuantity#, #scEnterWeight#, #scEnterAmount#, #qtEnterQuantity#,
#qtEnterWeight#, #qtEnterAmount#, #enterQuantity#, #enterWeight#, #enterAmount#, #scOuterQuantity#,
#scOuterWeight#, #scOuterAmount#, #xsOuterQuantity#, #xsOuterWeight#, #xsOuterAmount#, #qtOuterQuantity#,
......@@ -671,6 +762,7 @@
INVENT_CODE = #inventCode#, <!-- 存货编码 -->
INVENT_NAME = #inventName#, <!-- 存货名称 -->
INVENT_RECORD_ID = #inventRecordId#, <!-- 规格ID -->
SPEC = #spec#,
INIT_QUANTITY = #initQuantity#, <!-- 期初数量 -->
INIT_WEIGHT = #initWeight#, <!-- 期初重量 -->
INIT_AMOUNT = #initAmount#, <!-- 期初金额 -->
......
......@@ -6,6 +6,8 @@ import com.baosight.hggp.common.InventTypeDetailEnum;
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.security.UserSessionUtils;
import com.baosight.hggp.hg.cb.domain.HGCB001;
import com.baosight.hggp.hg.cb.domain.HGCB002;
import com.baosight.hggp.hg.cb.domain.HGCB003;
import com.baosight.hggp.hg.cb.domain.HGCB004;
......@@ -24,6 +26,7 @@ import com.baosight.hggp.util.*;
import com.baosight.iplat4j.core.data.DaoEPBase;
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.web.threadlocal.UserSession;
import org.apache.commons.collections.CollectionUtils;
......@@ -41,21 +44,24 @@ import java.util.stream.Collectors;
public class HGCBTools {
public static void setBaseInfo(List<HGCB004> cb004s) {
// 仓库名称
List<String> whCodes = cb004s.stream().map(HGCB004::getWhCode).collect(Collectors.toList());
Map<String, HGPZ007> mapPz007 = HGPZTools.HgPz007.map(whCodes);
// 存货名称
List<Long> recordIds = cb004s.stream().map(HGCB004::getInventRecordId).collect(Collectors.toList());
Map<Long, HGPZ005> mapPz005 = HGPZTools.HgPz005.maps(recordIds);
for (HGCB004 hgcb004 : cb004s) {
// 仓库名称
String whCode = hgcb004.getWhCode();
HGPZ007 pz007 = mapPz007 == null ? null : mapPz007.get(whCode);
hgcb004.setWhName(pz007 == null ? "" : pz007.getWhName());
// 存货名称
Long recordId = hgcb004.getInventRecordId();
HGPZ005 pz005 = mapPz005 == null ? null : mapPz005.get(recordId);
hgcb004.setInventName(pz005 == null ? "" : pz005.getInventName());
// 创建人企业编码
try {
String accountCode = UserSessionUtils.getAccountCode();
AssertUtils.isEmpty(accountCode, "当前用户未绑定公司,无法操作数据,请联系管理员!");
hgcb004.setAccountCode(accountCode);
} catch (Exception e) {
throw new PlatException("写入创建人信息失败", e);
}
// 创建人组织机构
try {
List<String> orgIds = UserSessionUtils.getOrgId();
AssertUtils.isEmpty(orgIds, "当前用户未绑定部门,无法操作数据,请联系管理员!");
hgcb004.setDepCode(orgIds.get(0));
} catch (Exception e) {
throw new PlatException("写入创建人部门编码失败", e);
}
// 创建时间
hgcb004.setCreatedBy(UserSession.getLoginName());
hgcb004.setCreatedName(UserSession.getLoginCName());
......@@ -63,33 +69,70 @@ public class HGCBTools {
}
}
public static class HgCb001 {
/**
* 查询当前公司账期
* @param params 业务账期
* @return 会计期
*/
public static HGCB001 select(Map<String, String> params) {
AssertUtils.isEmpty(params.get(HGCB001.FIELD_COMPANY_CODE), "公司不能为空!");
AssertUtils.isEmpty(params.get(HGCB001.FIELD_ACCOUNT_PERIOD), "会计期不能为空!");
List<HGCB001> hgcb001s = DaoBase.getInstance().query(HGCB001.QUERY, params);
return hgcb001s.size() == 0 ? null : hgcb001s.get(0);
}
/**
* 查询上月公司账期
* @param params 业务账期
* @return 会计期
*/
public static HGCB001 selectLast(Map<String, String> params) {
AssertUtils.isEmpty(params.get(HGCB001.FIELD_COMPANY_CODE), "公司不能为空!");
AssertUtils.isEmpty(params.get(HGCB001.FIELD_ACCOUNT_PERIOD), "会计期不能为空!");
List<HGCB001> hgcb001s = DaoBase.getInstance().query("HGCB001.getLastRow", params);
return hgcb001s.size() == 0 ? null : hgcb001s.get(0);
}
}
/**
* HGCB002 工具类
*/
public static class HgCb002 {
public static void select(Map<String, String> params) {
AssertUtils.isEmpty(params.get(HGCB002.FIELD_COMPANY_CODE), "公司不能为空!");
//AssertUtils.isEmpty(params.get(HGCB002.FIELD_COMPANY_CODE), "公司不能为空!");
//HGCW001 hgcb001 = HGCWTools.HgCw001.getMaxAccountPeriod(params.get(HGCB002.FIELD_COMPANY_CODE));
//params.put(HGCB002.FIELD_ACCOUNT_PERIOD, hgcb001.getAccountPeriod());
params.put(HGKC001.FIELD_SUBMIT_STATUS, String.valueOf(1));
params.put(HGKC001.FIELD_INVENT_TYPE_DETAIL, InventTypeDetailEnum.RAW.getCode().toString());
saveHgkc001s(params); //保存采购入库单
saveHgkc006s(params); //保存其他入库单
//删除当月同时数据
DaoBase.getInstance().delete(HGCB002.DELETE_PERIOD, params);
List<HGCB002> results = new ArrayList<>();
saveHgkc001s(results,params); //保存采购入库单
DaoUtils.insertBatch(HGCB002.INSERT, results);
results.clear();
saveHgkc006s(results,params); //保存其他入库单
//写入数据
DaoUtils.insertBatch(HGCB002.INSERT, results);
}
// 保存采购入库单
public static void saveHgkc001s(Map<String, String> params){
public static void saveHgkc001s(List<HGCB002> results,Map<String, String> params){
List<HGKC001> hgkc001List = DaoBase.getInstance().query(HGKC001.QUERY_LIST, params); //查询采购入库单
//获取上月原材料入库成本核算单
Map<String, List<HGCB002>> hgcb002Map = HGCBTools.HgCb002.synchList(
new HashMap<String, Object>(){{
put(HGCB002.FIELD_COMPANY_CODE, params.get(HGCB002.FIELD_COMPANY_CODE));
put(HGCB002.FIELD_ACCOUNT_PERIOD, params.get(HGCB002.FIELD_ACCOUNT_PERIOD));
put("accountDate", "(SELECT DATE_FORMAT(DATE_SUB(concat('"+params.get(HGCB002.FIELD_ACCOUNT_PERIOD)+"','01'), INTERVAL 1 MONTH), '%Y%m'))");
put(HGCB002.FIELD_BIZ_TYPE, BizTypeEnum.CGRK.getCode());
put(HGCB002.FIELD_IS_ESTIMATE, 1); //是否是暂估价 1是暂估,0不是暂估
}});
AssertUtils.isEmpty(hgkc001List, "当前会计期采购入库单为空!");
for (HGKC001 hgkc001: hgkc001List) {
/*初始化原材料*/
HGCB002 hgcb002 = addHgcb002(hgkc001,params);
......@@ -101,20 +144,19 @@ public class HGCBTools {
hgcb002.setAmount(amount);
hgcb002.setPrice(price);
hgcb002.setIsEstimate(0); //有采购开票,不是暂估
List<HGCB002> hgcb0021 = hgcb002Map.get(hgkc001.getDepositNo()) == null ? null : hgcb002Map.get(hgkc001.getReceiveNo());
List<HGCB002> hgcb0021 = hgcb002Map.get(hgkc001.getDepositNo()) == null ? null : hgcb002Map.get(hgkc001.getDepositNo());
if (hgcb0021 != null){
//宏冲金额
addInvoic(hgcb0021, hgcb002);
addInvoic(results,hgcb0021, hgcb002);
}
}
DaoUtils.insert(HGCB002.INSERT, hgcb002);
results.add(hgcb002);
}
}
//保存其他出库单
public static void saveHgkc006s(Map<String, String> params) {
public static void saveHgkc006s(List<HGCB002> results,Map<String, String> params) {
Map<String, HGCB002> hgcb002List = HgCb004.listInvData(params,"HGCB002.queryLast"); //查询当月原材料成本核算
Map<String, HGCB004> hgcb004List = HgCb004.listInvData(params, "HGCB004.queryLast"); //查询上月期末
params.put(HGKC006.FIELD_OTHER_ENTER_DATE, params.get(HGCB002.FIELD_ACCOUNT_PERIOD));
Map<String, HGCB004> hgcb004List = HgCb004.listInvData(params, HGCB004.QUERY_LAST); //查询上月期末
Map<String, HGKC006A> hgKC006AList = HgCb004.listInvData(params,"HGKC006A.queryList"); //查询其他出库单
for (Map.Entry<String, HGKC006A> entry : hgKC006AList.entrySet()) {
......@@ -132,12 +174,14 @@ public class HGCBTools {
BigDecimal endAmount = hgcb002 == null ? BigDecimal.ZERO : hgcb004.getEndAmount();
quantity = quantity.add(endQuantity);
amount = amount.add(endAmount);
BigDecimal price = amount.divide(quantity, 3, RoundingMode.HALF_UP);
cb002.setPrice(price);
cb002.setAmount(cb002.getQuantity().multiply(price));
cb002.setIsEstimate(0);
if (quantity.compareTo(BigDecimal.ZERO) > 0){
BigDecimal price = amount.divide(quantity, 3, RoundingMode.HALF_UP);
cb002.setPrice(price);
cb002.setAmount(cb002.getQuantity().multiply(price));
}
cb002.setBizType(BizTypeEnum.QTRK.getCode());
DaoUtils.insert(HGCB002.INSERT, cb002);
cb002.setIsEstimate(0);
results.add(cb002);
}
}
......@@ -151,7 +195,7 @@ public class HGCBTools {
HGCB002 hgcb002 = new HGCB002();
//BeanUtil.copyProperties(hgkc001, hgcb002);
hgcb002.setCompanyCode(params.get(HGCB002.FIELD_COMPANY_CODE));
hgcb002.setCompanyName(params.get(HGCB002.FIELD_COMPANY_NAME));
hgcb002.setCompanyName(hgkc001.getCompanyName());
hgcb002.setAccountYear(params.get(HGCB002.FIELD_ACCOUNT_PERIOD).substring(0, 4));
hgcb002.setAccountPeriod(params.get(HGCB002.FIELD_ACCOUNT_PERIOD));
hgcb002.setBizType(BizTypeEnum.CGRK.getCode());
......@@ -163,14 +207,15 @@ public class HGCBTools {
hgcb002.setInventType(hgkc001.getInventType());
hgcb002.setInventCode(hgkc001.getInventCode());
hgcb002.setInventName(hgkc001.getInventName());
hgcb002.setSpecId(hgkc001.getSpecId());
hgcb002.setInventRecordId(hgkc001.getSpecId());
hgcb002.setSpec(hgkc001.getSpec());
hgcb002.setUnit(hgkc001.getUnit());
hgcb002.setIsEstimate(1); //默认是暂估1
hgcb002.setQuantity(hgkc001.getDepositQty());
hgcb002.setWeight(hgkc001.getDepositWeight());
hgcb002.setPrice(hgkc001.getPrice());
hgcb002.setAmount(hgkc001.getAmount());
hgcb002.setInventTypeDetail(hgkc001.getInventTypeDetail());
hgcb002.setPrice(StringUtils.isNull(hgkc001.getPrice())?BigDecimal.ZERO:hgkc001.getPrice());
hgcb002.setAmount(StringUtils.isNull(hgkc001.getAmount())?BigDecimal.ZERO:hgkc001.getAmount());
return hgcb002;
}
......@@ -194,13 +239,14 @@ public class HGCBTools {
hgcb002.setInventType(hgkc006A.getInventType());
hgcb002.setInventCode(hgkc006A.getInventCode());
hgcb002.setInventName(hgkc006A.getInventName());
hgcb002.setSpecId(hgkc006A.getInventRecordId());
hgcb002.setInventRecordId(hgkc006A.getInventRecordId());
hgcb002.setSpec(hgkc006A.getPartSpec());
hgcb002.setIsEstimate(0);
hgcb002.setQuantity(hgkc006A.getInvQty());
hgcb002.setWeight(hgkc006A.getInvWeight());
hgcb002.setPrice(hgkc006A.getPrice());
hgcb002.setAmount(hgkc006A.getAmount());
hgcb002.setInventTypeDetail(hgkc006A.getInventTypeDetail());
return hgcb002;
}
......@@ -209,8 +255,7 @@ public class HGCBTools {
* @param queryMap
*/
public static Map<String, List<HGCB002>> synchList(Map<String,Object> queryMap) {
queryMap.put(HGCB002.FIELD_ACCOUNT_PERIOD, "DATE_FORMAT(DATE_SUB(concat("+queryMap.get(HGCB002.FIELD_ACCOUNT_PERIOD)+",'01'), INTERVAL 1 MONTH), '%Y%m')");
List<HGCB002> list = DaoBase.getInstance().query("HGCB002.queryLast", queryMap);
List<HGCB002> list = DaoBase.getInstance().query("HGCB002.query", queryMap);
return list.stream().collect(Collectors.groupingBy(HGCB002::getReceiptCode));
}
......@@ -219,12 +264,13 @@ public class HGCBTools {
* @param hgcb0021
* @param hgcb002
*/
public static void addInvoic(List<HGCB002> hgcb0021, HGCB002 hgcb002){
public static void addInvoic(List<HGCB002> hgcb002ArrayList,List<HGCB002> hgcb0021, HGCB002 hgcb002){
for (HGCB002 cb002: hgcb0021) {
cb002.setId(0L);
cb002.setAccountPeriod(hgcb002.getAccountPeriod());
cb002.setQuantity(cb002.getQuantity().multiply(new BigDecimal(-1)));
cb002.setAmount(cb002.getAmount().multiply(new BigDecimal(-1)));
DaoUtils.insert(HGCB002.INSERT, hgcb0021);
hgcb002ArrayList.add(cb002);
}
......@@ -234,20 +280,25 @@ public class HGCBTools {
public static class HgCb003 {
public static void select(Map<String, String> params) {
AssertUtils.isEmpty(params.get(HGCB003.FIELD_COMPANY_CODE), "公司不能为空!");
params.put(HGKC001.FIELD_SUBMIT_STATUS, String.valueOf(1));
params.put(HGKC001.FIELD_INVENT_TYPE_DETAIL, InventTypeDetailEnum.RAW.getCode().toString());
saveHgkc008s(params); //保存生产领料单
saveHgkc007s(params); //保存其他出库单
//删除当月同时数据
DaoBase.getInstance().delete(HGCB003.DELETE_PERIOD, params);
List<HGCB003> results = new ArrayList<>();
saveHgkc008s(results,params); //保存生产领料单
saveHgkc007s(results,params); //保存其他出库单
//写入数据
DaoUtils.insertBatch(HGCB003.INSERT, results);
}
// 保存生产领料单
public static void saveHgkc008s(Map<String, String> params){
public static void saveHgkc008s(List<HGCB003> results,Map<String, String> params){
Map<String, HGCB002> hgcb002List = HgCb004.listInvData(params,"HGCB002.queryLast"); //查询当月原材料入库成本
Map<String, HGCB004> hgcb004List = HgCb004.listInvData(params, "HGCB004.queryLast"); //查询上月收发存汇总期末
params.put(HGKC008.FIELD_RECEIPT_DATE, params.get(HGCB002.FIELD_ACCOUNT_PERIOD));
Map<String, HGCB004> hgcb004List = HgCb004.listInvData(params, HGCB004.QUERY_LAST); //查询上月收发存汇总期末
Map<String, HGKC008B> hgKC008BList = HgCb004.listInvData(params,"HGKC008A.queryList"); //查询其他出库单
for (Map.Entry<String, HGKC008B> entry : hgKC008BList.entrySet()) {
String key = entry.getKey();
HGKC008B endKc = entry.getValue();
......@@ -263,18 +314,22 @@ public class HGCBTools {
BigDecimal endAmount = hgcb004 == null ? BigDecimal.ZERO : hgcb004.getEndAmount();
quantity = quantity.add(endQuantity);
amount = amount.add(endAmount);
BigDecimal price = amount.divide(quantity, 3, RoundingMode.HALF_UP);
cb003.setPrice(price);
cb003.setAmount(cb003.getQuantity().multiply(price));
if (quantity.compareTo(BigDecimal.ZERO) > 0){
BigDecimal price = amount.divide(quantity, 3, RoundingMode.HALF_UP);
cb003.setPrice(price);
cb003.setAmount(cb003.getQuantity().multiply(price));
}
cb003.setIsEstimate(0);
DaoUtils.insert(HGCB003.INSERT, cb003);
results.add(cb003);
//DaoUtils.insert(HGCB003.INSERT, cb003);
}
}
//保存其他出库单
public static void saveHgkc007s(Map<String, String> params){
public static void saveHgkc007s(List<HGCB003> results,Map<String, String> params){
Map<String, HGCB002> hgcb002List = HgCb004.listInvData(params,"HGCB002.queryLast"); //查询当月原材料成本核算
Map<String, HGCB004> hgcb004List = HgCb004.listInvData(params, "HGCB004.queryLast"); //查询上月期末
Map<String, HGCB004> hgcb004List = HgCb004.listInvData(params, HGCB004.QUERY_LAST); //查询上月期末
params.put(HGKC007.FIELD_OTHER_OUT_DATE, params.get(HGCB002.FIELD_ACCOUNT_PERIOD));
Map<String, HGKC007B> hgkc007BList = HgCb004.listInvData(params,"HGKC007A.queryList"); //查询其他出库单
......@@ -297,7 +352,8 @@ public class HGCBTools {
cb003.setPrice(price);
cb003.setAmount(cb003.getQuantity().multiply(price));
cb003.setIsEstimate(0);
DaoUtils.insert(HGCB003.INSERT, cb003);
results.add(cb003);
//DaoUtils.insert(HGCB003.INSERT, cb003);
}
}
......@@ -310,7 +366,7 @@ public class HGCBTools {
public static HGCB003 addHgcb003(HGKC008B hgkc008b, Map<String, String> params) {
HGCB003 hgcb003 = new HGCB003();
hgcb003.setCompanyCode(params.get(HGCB002.FIELD_COMPANY_CODE));
hgcb003.setCompanyName(params.get(HGCB002.FIELD_COMPANY_NAME));
hgcb003.setCompanyName(hgkc008b.getCompanyName());
hgcb003.setAccountYear(params.get(HGCB002.FIELD_ACCOUNT_PERIOD).substring(0, 4));
hgcb003.setAccountPeriod(params.get(HGCB002.FIELD_ACCOUNT_PERIOD));
hgcb003.setBizType(BizTypeEnum.SCLL.getCode());
......@@ -321,13 +377,14 @@ public class HGCBTools {
hgcb003.setInventType(hgkc008b.getInventType());
hgcb003.setInventCode(hgkc008b.getInventCode());
hgcb003.setInventName(hgkc008b.getInventName());
hgcb003.setSpecId(hgkc008b.getInvSpecId());
hgcb003.setInventRecordId(hgkc008b.getInvSpecId());
hgcb003.setSpec(hgkc008b.getInvSpec());
hgcb003.setIsEstimate(0); //默认是暂估0
hgcb003.setQuantity(hgkc008b.getInvQty());
hgcb003.setWeight(hgkc008b.getInvWeight());
hgcb003.setPrice(hgkc008b.getPrice());
hgcb003.setAmount(hgkc008b.getAmount());
hgcb003.setInventTypeDetail(hgkc008b.getInventTypeDetail());
return hgcb003;
}
......@@ -351,13 +408,14 @@ public class HGCBTools {
hgcb003.setInventType(hgkc007b.getInventType());
hgcb003.setInventCode(hgkc007b.getInventCode());
hgcb003.setInventName(hgkc007b.getInventName());
hgcb003.setSpecId(hgkc007b.getInventRecordId());
hgcb003.setInventRecordId(hgkc007b.getInventRecordId());
hgcb003.setSpec(hgkc007b.getPartSpec());
hgcb003.setIsEstimate(0);
hgcb003.setQuantity(hgkc007b.getInvQty());
hgcb003.setWeight(hgkc007b.getInvWeight());
hgcb003.setPrice(hgkc007b.getPrice());
hgcb003.setAmount(hgkc007b.getAmount());
hgcb003.setInventTypeDetail(hgkc007b.getInventTypeDetail());
return hgcb003;
}
}
......@@ -391,11 +449,13 @@ public class HGCBTools {
* @return
*/
public static List<HGCB004> statData(Map queryMap) {
Map<String ,HGCB004> hgkc010 = listInvData(queryMap, "HGCB004.querySum1");
// 1.1、期初库存
queryMap.put(HGCB004.FIELD_INVENT_TYPE_DETAIL, InventTypeDetailEnum.RAW.getCode());
Map<String, HGCB004> initCb4Map = listInvData(queryMap, HGCB004.QUERY_LAST);
// 1.2、原材料入库成本核算库存
Map<String, HGCB002> initCb2Map = listInvData(queryMap, HGCB002.QUERY_DETAIL);
Map<String, HGCB002> initCb2Map = listInvData(queryMap, "HGCB002.queryLast");
// 1.2、原材料出库成本核算库存
Map<String, HGCB003> initCb3Map = listInvData(queryMap, HGCB003.QUERY_DETAIL);
// 1.2、采购入库单
......@@ -415,30 +475,31 @@ public class HGCBTools {
// 2.0 销售出库
Map<String, HGKC004A> xsCkMap = listInvData(queryMap, HGKC004A.QUERY_DETAIL);
// 根据期末库存生成收发存对象
return buildKcBean(queryMap, initCb4Map, initCb2Map, initCb3Map, cgRkMap, qtRkMap, scCkMap, qtCkMap, scRkMap, xsCkMap);
return buildKcBean(queryMap, hgkc010, initCb4Map, initCb2Map, initCb3Map, cgRkMap, qtRkMap, scCkMap, qtCkMap, scRkMap, xsCkMap);
}
public static List<HGCB004> buildKcBean( Map queryMap,
public static List<HGCB004> buildKcBean( Map queryMap,Map<String, HGCB004> hgkc010,
Map<String, HGCB004> initCb4Map, Map<String, HGCB002> initCb2Map, Map<String, HGCB003> initCb3Map,
Map<String, HGCB002> cgRkMap, Map<String, HGCB002> qtRkMap, Map<String, HGCB003> scCkMap,
Map<String, HGCB003> qtCkMap, Map<String, HGKC003> scRkMap, Map<String, HGKC004A> xsCkMap
) {
List<HGCB004> newcB004s = new ArrayList<>();
Set<String> keyList = initCb4Map.keySet();
keyList.addAll(initCb2Map.keySet());
for (String key: keyList) {
HGCB004 hgcb004 = initCb4Map.get(key);
for (Map.Entry<String, HGCB004> entry : hgkc010.entrySet()) {
String key = entry.getKey();
HGCB004 hgcb004 = hgkc010.get(key);
if (hgcb004 == null) {
setHgcb004(hgcb004, initCb2Map.get(key));
}
HGCB004 cb004 = BeanUtils.copy(hgcb004, HGCB004.class);
cb004.setId(0L);
cb004.setDateType(queryMap.get(HGCB004.FIELD_DATE_TYPE).toString());
cb004.setAccountPeriod(queryMap.get(HGCB004.FIELD_ACCOUNT_PERIOD).toString());
// 1.1期初库存
cb004.setInitQuantity(hgcb004.getEndQuantity());
cb004.setInitWeight(hgcb004.getEndWeight());
cb004.setInitAmount(hgcb004.getEndAmount());
HGCB004 hgcb0041 = initCb4Map.get(key);
cb004.setInitQuantity(hgcb0041 == null ? BigDecimal.ZERO : hgcb0041.getEndQuantity());
cb004.setInitWeight(hgcb0041 == null ? BigDecimal.ZERO : hgcb0041.getEndWeight());
cb004.setInitAmount(hgcb0041 == null ? BigDecimal.ZERO : hgcb0041.getEndAmount());
// 1.2、采购入库
HGCB002 cgRk = cgRkMap.get(key);
......@@ -513,8 +574,15 @@ public class HGCBTools {
* @return
*/
public static String buildKey(Map dataMap) {
return buildKey(dataMap.get(HGCB004.FIELD_COMPANY_CODE), dataMap.get(HGCB004.FIELD_DEP_CODE), dataMap.get(HGCB004.FIELD_INVENT_RECORD_ID),
dataMap.get(HGCB004.FIELD_INVENT_CODE), dataMap.get(HGCB004.FIELD_WH_CODE), dataMap.get(HGCB004.FIELD_INVENT_RECORD_ID));
if (dataMap.containsKey(HGKC006A.FIELD_PART_SPEC)){
dataMap.put(HGCB004.FIELD_SPEC, dataMap.get(HGKC006A.FIELD_PART_SPEC));
}else if (dataMap.containsKey(HGKC008A.FIELD_INV_SPEC)){
dataMap.put(HGCB004.FIELD_SPEC, dataMap.get(HGKC008A.FIELD_INV_SPEC));
}else if (dataMap.containsKey(HGKC007A.FIELD_PART_SPEC)){
dataMap.put(HGCB004.FIELD_SPEC, dataMap.get(HGKC007A.FIELD_PART_SPEC));
}
return buildKey(dataMap.get(HGCB004.FIELD_COMPANY_CODE), dataMap.get(HGCB004.FIELD_DEP_CODE), dataMap.get(HGCB004.FIELD_INVENT_TYPE_DETAIL),
dataMap.get(HGCB004.FIELD_INVENT_CODE), dataMap.get(HGCB004.FIELD_WH_CODE), dataMap.get(HGCB004.FIELD_SPEC));
}
/**
......@@ -525,17 +593,17 @@ public class HGCBTools {
* @param inventType
* @param inventCode
* @param whCode
* @param inventRecordId
* @param spec
* @return
*/
public static String buildKey(Object companyCode, Object depCode, Object inventType, Object inventCode,
Object whCode, Object inventRecordId) {
Object whCode, Object spec) {
return ObjectUtils.trimToEmpty(companyCode) + "#"
+ ObjectUtils.trimToEmpty(depCode) + "#"
+ ObjectUtils.trimToEmpty(inventType) + "#"
+ ObjectUtils.trimToEmpty(inventCode) + "#"
+ ObjectUtils.trimToEmpty(whCode) + "#"
+ ObjectUtils.trimToEmpty(inventRecordId);
+ ObjectUtils.trimToEmpty(spec);
}
public static void setHgcb004(HGCB004 hgcb004,HGCB002 hgcb002){
......
......@@ -273,13 +273,20 @@
select
ACCOUNT_CODE as "accountCode",
COMPANY_CODE as "companyCode",
ACCOUNT_YEAR as "accountYear",
MAX(ACCOUNT_PERIOD) as "accountPeriod"
ACCOUNT_YEAR as "accountYear",
ACCOUNT_PERIOD as "accountPeriod",
ACCOUNT_PERIOD_DATE_START as "accountPeriodDateStart",
ACCOUNT_PERIOD_DATE_END as "accountPeriodDateEnd"
from ${hggpSchema}.HGCW001
where 1=1
<include refid="condition" />
group by
ACCOUNT_CODE, COMPANY_CODE, ACCOUNT_YEAR
where ACCOUNT_PERIOD_STATUS = 0
AND ACCOUNT_CODE = #accountCode#
AND COMPANY_CODE = #companyCode#
AND ACCOUNT_PERIOD = (
select MAX(ACCOUNT_PERIOD) from ${hggpSchema}.HGCW001
where ACCOUNT_CODE = #accountCode#
and COMPANY_CODE = #companyCode#
and ACCOUNT_PERIOD_STATUS = 0
)
</select>
</sqlMap>
......@@ -35,9 +35,8 @@ public class HGCWTools {
public static HGCW001 getMaxAccountPeriod(String companyCode) {
Map<String, Object> params = new HashMap<>();
params.put("companyCode", companyCode);
params.put("accountPeriodStatus",0);
List<HGCW001> list = DaoBase.getInstance().query("HGCW001.getMaxAccountPeriod", params);
AssertUtils.isEmpty(list, "未找到公司对应的会计期");
AssertUtils.isEmpty(list, "未找到公司对应的会计期");
return list.get(0);
}
}
......
......@@ -273,7 +273,7 @@
WHERE
ID = #id#
</update>
<!--查询月累计入库数据-->
<select id="queryList" resultClass="com.baosight.hggp.hg.kc.domain.HGKC001">
SELECT <include refid="column"/>
FROM ${hggpSchema}.HGKC001
......@@ -288,12 +288,18 @@
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriod">
LEFT(DEPOSIT_DATE,6) = #accountPeriod#
<isNotEmpty prepend=" AND " property="receiveNo">
RECEIVE_NO = #receiveNo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTimeFrom">
DEPOSIT_DATE BETWEEN #createdTimeFrom# AND #createdTimeTo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetail">
INVENT_TYPE_DETAIL = #inventTypeDetail#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="submitStatus">
SUBMIT_STATUS = #submitStatus#
</isNotEmpty>
<include refid="orderBy"/>
</select>
......
......@@ -460,6 +460,10 @@
DEP_CODE as "depCode", <!-- 部门编码 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
WH_CODE as "whCode", <!-- 仓库编码 -->
PRDT_CODE as "prdtCode", <!-- 产品编码 -->
PRDT_NAME as "prdtName", <!-- 产品名称 -->
PRDT_SPEC as "prdtSpec", <!-- 产品规格 -->
INVENT_TYPE_DETAIL as "inventTypeDetail",
SUM(INV_QTY) as "invQty", <!-- 数量 -->
SUM(INV_WEIGHT) as "invWeight", <!-- 重量 -->
SUM(AMOUNT) as "amount" <!-- 金额 -->
......@@ -471,8 +475,8 @@
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriod">
LEFT(DEPOSIT_DATE,6) = #accountPeriod#
<isNotEmpty prepend=" AND " property="createdTimeFrom">
DEPOSIT_DATE BETWEEN #createdTimeFrom# AND #createdTimeTo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="whCode">
WH_CODE = #whCode#
......@@ -486,7 +490,7 @@
<isEmpty prepend=" AND " property="submitStatus">
SUBMIT_STATUS = 1
</isEmpty>
GROUP BY ACCOUNT_CODE, DEP_CODE, COMPANY_CODE, WH_CODE
GROUP BY ACCOUNT_CODE, DEP_CODE, COMPANY_CODE, WH_CODE,PRDT_CODE,PRDT_NAME,PRDT_SPEC,INVENT_TYPE_DETAIL
</select>
</sqlMap>
......@@ -250,6 +250,8 @@
a.INVENT_RECORD_ID as "inventRecordId",
a.INVENT_TYPE as "inventType",
a.INVENT_CODE AS "inventCode",
a.SPEC as "spec",
a.INVENT_TYPE_DETAIL as "inventTypeDetail",
COALESCE(SUM(a.QUANTITY), 0) AS "quantity",
COALESCE(SUM(a.WEIGHT), 0) AS "weight",
COALESCE(SUM(a.AMOUNT)) as "amount"
......@@ -264,8 +266,8 @@
<isNotEmpty prepend=" AND " property="whCode">
b.WH_CODE = #whCode#
</isNotEmpty>
<isNotEmpty property=" AND " prepend="accountPeriod">
LEFT(b.RECEIPT_DATE,6) = #accountPeriod#
<isNotEmpty prepend=" AND " property="createdTimeFrom">
b.RECEIPT_DATE BETWEEN #createdTimeFrom# AND #createdTimeTo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetail">
a.INVENT_TYPE_DETAIL = #inventTypeDetail#
......@@ -276,7 +278,7 @@
<isEmpty prepend=" AND " property="submitStatus">
b.STATUS = 1
</isEmpty>
GROUP BY a.ACCOUNT_CODE, a.DEP_CODE, a.COMPANY_CODE, b.WH_CODE, a.INVENT_RECORD_ID, a.INVENT_TYPE, a.INVENT_CODE
GROUP BY a.ACCOUNT_CODE, a.DEP_CODE, a.COMPANY_CODE, b.WH_CODE, a.INVENT_RECORD_ID, a.INVENT_TYPE, a.INVENT_CODE, a.SPEC,a.INVENT_TYPE_DETAIL
</select>
</sqlMap>
......@@ -377,7 +377,7 @@
A.DEP_CODE as "depCode", <!-- 部门编码 -->
A.COMPANY_CODE as "companyCode", <!-- 公司编码 -->
A.COMPANY_NAME as "companyName", <!-- 公司名称 -->
B.FIELD_OTHER_ENTER_DATE as "otherEnterDate", <!-- 其他入库日期 -->
B.OTHER_ENTER_DATE as "otherEnterDate", <!-- 其他入库日期 -->
A.OTHER_ENTER_NO as "otherEnterNo", <!-- 其他入库单号 -->
A.WH_CODE as "whCode", <!-- 仓库编码 -->
A.WH_NAME as "whName", <!-- 仓库名称 -->
......@@ -424,8 +424,8 @@
<isNotEmpty prepend=" AND " property="companyCode">
A.COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="otherEnterDate">
LEFT(B.OTHER_ENTER_DATE,6) = #otherEnterDate#
<isNotEmpty prepend=" AND " property="createdTimeFrom">
B.OTHER_ENTER_DATE BETWEEN #createdTimeFrom# AND #createdTimeTo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="otherEnterNo">
A.OTHER_ENTER_NO = #otherEnterNo#
......
......@@ -419,8 +419,8 @@
<isNotEmpty prepend=" AND " property="companyCode">
A.COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="otherOutDate">
B.OTHER_OUT_DATE = #otherOutDate#
<isNotEmpty prepend=" AND " property="createdTimeFrom">
B.OTHER_OUT_DATE BETWEEN #createdTimeFrom# AND #createdTimeTo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="otherOutNo">
B.OTHER_OUT_NO = #otherOutNo#
......
......@@ -304,8 +304,8 @@
<isNotEmpty prepend=" AND " property="whCode">
A.WH_CODE = #whCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiptDate">
B.RECEIPT_DATE = #receiptDate#
<isNotEmpty prepend=" AND " property="createdTimeFrom">
B.RECEIPT_DATE BETWEEN #createdTimeFrom# AND #createdTimeTo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="applyCode">
B.APPLY_CODE = #applyCode#
......
......@@ -142,6 +142,32 @@
<include refid="condition"/>
</select>
<select id="querySum" resultClass="com.baosight.hggp.hg.kc.domain.HGKC010">
SELECT
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
DELETE_FLAG as "deleteFlag", <!-- 0-未删除,1-已删除 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
WH_CODE as "whCode", <!-- 仓库编码 -->
WH_NAME as "whName", <!-- 仓库名称 -->
INVENT_TYPE as "inventType", <!-- 存货类型 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
SPEC_ID as "specId", <!-- 规格ID -->
SPEC as "spec", <!-- 规格 -->
MATERIAL as "material", <!-- 材质 -->
UNIT as "unit", <!-- 单位 -->
INV_QTY as "invQty", <!-- 库存数量 -->
INV_UNIT_WEIGHT as "invUnitWeight", <!-- 库存单重 -->
INV_WEIGHT as "invWeight", <!-- 库存重量 -->
INVENT_TYPE_DETAIL as "inventTypeDetail"
FROM ${hggpSchema}.HGKC010
WHERE 1=1
<include refid="condition"/>
<include refid="orderBy"/>
</select>
<insert id="insert">
INSERT INTO ${hggpSchema}.HGKC010 (
ACCOUNT_CODE, <!-- 企业编码 -->
......
......@@ -13,6 +13,7 @@
<sqlMap resource="com/baosight/hggp/hg/xs/sql/HGXSDataAuth.xml"/>
<!--成本-->
<sqlMap resource="com/baosight/hggp/hg/cb/sql/HGCB001.xml"/>
<sqlMap resource="com/baosight/hggp/hg/cb/sql/HGCB002.xml"/>
<sqlMap resource="com/baosight/hggp/hg/cb/sql/HGCB003.xml"/>
<sqlMap resource="com/baosight/hggp/hg/cb/sql/HGCB004.xml"/>
......
......@@ -57,7 +57,7 @@ $(function (){
grid.dataSource.bind("change", function(e) {
// 判断父级节点是否发生变化
if (e.field === "price") {
let items = e.items[0];
let items = e.items;
for (let i = 0; i < items.length; i++) {
let amount = items[i].price * items[i].quantity;
resultGrid.setCellValue(e.items[i],"amount",amount);
......@@ -154,26 +154,28 @@ function showDetail(id) {
JSColorbox.open({
href: "HGCB002A?methodName=initLoad",
title: "<div style='text-align: center;'>选择公司</div>",
width: "60%",
height: "60%",
width: "30%",
height: "45%",
callbackName: windowCallback
});
}
function windowCallback(companyCode) {
synchData(companyCode);
function windowCallback(item) {
synchData(item);
// 关闭弹窗
JSColorbox.close();
// 刷新列表
query();
}
/**
* 确认
*/
let synchData = function (companyCode) {
let synchData = function (item) {
let info = new EiInfo();
info.set("inqu_status-0-companyCode", companyCode);
info.set("inqu_status-0-companyCode", item.companyCode);
info.set("inqu_status-0-accountYear", item.accountYear);
info.set("inqu_status-0-accountPeriod", item.accountPeriod);
info.set("inqu_status-0-createdTimeFrom", item.accountPeriodDateStart);
info.set("inqu_status-0-createdTimeTo", item.accountPeriodDateEnd);
EiCommunicator.send("HGCB002", "select", info, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
......@@ -182,6 +184,8 @@ let synchData = function (companyCode) {
} else {
NotificationUtil(ei);
}
// 刷新列表
query();
} else {
NotificationUtil(ei, "error");
}
......
......@@ -24,7 +24,7 @@
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="company_code_block_id" textField="companyName" valueField="companyCode"/>
</EF:EFSelect>
<EF:EFSelect blockId="inqu_status" row="0" ename="status" cname="业务类型" colWidth="3" filter="contains">
<EF:EFSelect blockId="inqu_status" row="0" ename="bizType" cname="业务类型" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="hggp.hgcb.bizType"/>
</EF:EFSelect>
......@@ -45,13 +45,13 @@
<EF:EFOptions blockId="company_code_block_id" textField="companyName" valueField="companyCode"/>
</EF:EFComboColumn>
<EF:EFColumn ename="accountPeriod" cname="会计期" enable="false" width="120" align="center"
editType="date" dateFormat="yyyy-MM" parseFormats="['yyyyMM']"/>
editType="date" dateFormat="yyyy-MM" parseFormats="['yyyyMM']" required="true"/>
<EF:EFComboColumn ename="bizType" cname="业务类型" width="120" enable="true" align="center" required="true">
<EF:EFCodeOption codeName="hggp.hgcb.bizType"/>
</EF:EFComboColumn>
<EF:EFColumn ename="receiptDate" cname="单据日期" width="120" align="center" editType="date"
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" readonly="false" required="true"/>
<EF:EFColumn ename="receiptCode" cname="单据号" enable="false" width="120" align="center" required="true"/>
<EF:EFColumn ename="receiptCode" cname="单据号" enable="false" width="140" align="center" required="true"/>
<EF:EFComboColumn ename="whCode" cname="仓库名称"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
......@@ -76,7 +76,7 @@
displayType="0.000" sort="true" align="right" maxLength="17" required="true" defaultValue="0"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
<EF:EFComboColumn ename="computeType" cname="是否暂估" width="100" enable="true" align="center" required="true">
<EF:EFComboColumn ename="isEstimate" cname="是否暂估" width="100" enable="true" align="center" required="true">
<EF:EFCodeOption codeName="hggp.common.yesNo"/>
</EF:EFComboColumn>
<EF:EFColumn ename="price" cname="单价" width="120" enable="true" format="{0:N3}" editType="text"
......
$(function() {
let companyCodeBox = __eiInfo.getBlock("roleCompany").getMappedRows();
$(".row").children().attr("class", "col-md-3");
$("#CONFIRM").on("click", function () {
confirm();
let companyCode = $("#inqu_status-0-companyCode").val();
if (companyCode.length < 1) {
message("请选择公司");
return;
}
let hgcw001 = queryHgcw001(companyCode);
let companyName;
let accountPeriod = hgcw001[0].accountPeriod;
for (let i = 0; i <companyCodeBox.length ; i++) {
if (companyCodeBox[i].companyCode == hgcw001[0].companyCode) {
companyName = companyCodeBox[i].companyName;
break;
}
}
JSUtils.confirm("确定要对[" + companyName + " 会计期"+accountPeriod+"]做\"数据同步\"操作? ", {
ok: function () {
parent.JSColorbox.setValueCallback(hgcw001[0]);
}
});
});
});
/**
* 确认
*/
let confirm = function () {
let companyCode = $("#inqu_status-0-companyCode").val();
if (companyCode.length < 1) {
message("请选择公司");
return;
}
parent.JSColorbox.setValueCallback(companyCode);
let queryHgcw001 = function (companyCode){
var hgcw001_block_id =[];
let info = new EiInfo();
info.set("inqu_status-0-companyCode", companyCode);
EiCommunicator.send("HGCB002", "selectAll", info, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
if (ei.getStatus() == 0) {
NotificationUtil(ei, 'warning');
} else {
NotificationUtil(ei);
}
hgcw001_block_id = ei.getBlock("hgcw001_block_id").getMappedRows();
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
},{async: false});
return hgcw001_block_id;
}
\ No newline at end of file
$(function (){
var companyCodeBox = __eiInfo.getBlock("company_code_block_id").getMappedRows();
var whCodeBox = __eiInfo.getBlock("wh_code_block_id").getMappedRows();
$(".row").children().attr("class", "col-md-3");
$("#QUERY").on("click", function (e) {
query();
})
$("#SYNC").on("click", function () {
showDetail();
});
IPLATUI.EFGrid= {
"result": {
pageable: {
......@@ -37,7 +44,7 @@ $(function (){
exportGrid: {
exportFileName: function (gridInstance) {
// 导出的文件名包含时间戳 yyyy-MM-dd HH:mm:ss
return "原材料库成本核算_" + kendo.toString(new Date(), IPLAT.FORMAT.DATE_14_PR);
return "原材料库成本核算_" + kendo.toString(new Date(), IPLAT.FORMAT.DATE_14_PR);
},
exportFileType: "xls", // 默认值是xls,可选值为pdf[规划中]
exportBlockId: "result", // 默认值和blockId相同,导出的EiInfo中的指定数据块被导出
......@@ -146,27 +153,29 @@ function showDetail(id) {
JSColorbox.open({
href: "HGCB002A?methodName=initLoad",
title: "<div style='text-align: center;'>选择公司</div>",
width: "60%",
height: "60%",
width: "30%",
height: "45%",
callbackName: windowCallback
});
}
function windowCallback(companyCode) {
synchData(companyCode);
function windowCallback(item) {
synchData(item);
// 关闭弹窗
JSColorbox.close();
// 刷新列表
query();
}
/**
* 确认
*/
let synchData = function (companyCode) {
let synchData = function (item) {
let info = new EiInfo();
info.set("inqu_status-0-companyCode", companyCode);
EiCommunicator.send("HGCB004", "synchData", info, {
info.set("inqu_status-0-companyCode", item.companyCode);
info.set("inqu_status-0-accountYear", item.accountYear);
info.set("inqu_status-0-accountPeriod", item.accountPeriod);
info.set("inqu_status-0-createdTimeFrom", item.accountPeriodDateStart);
info.set("inqu_status-0-createdTimeTo", item.accountPeriodDateEnd);
EiCommunicator.send("HGCB003", "select", info, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
if (ei.getStatus() == 0) {
......@@ -174,6 +183,8 @@ let synchData = function (companyCode) {
} else {
NotificationUtil(ei);
}
// 刷新列表
query();
} else {
NotificationUtil(ei, "error");
}
......
......@@ -22,11 +22,11 @@
<div class="row">
<EF:EFSelect blockId="inqu_status" row="0" ename="companyCode" cname="公司名称" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="companyBox_block_id" textField="textField" valueField="valueField"/>
<EF:EFOptions blockId="company_code_block_id" textField="companyName" valueField="companyCode"/>
</EF:EFSelect>
<EF:EFSelect blockId="inqu_status" row="0" ename="status" cname="业务类型" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="hpjx.hpjx.status"/>
<EF:EFCodeOption codeName="hggp.common.yesNo"/>
</EF:EFSelect>
<EF:EFDatePicker blockId="inqu_status" row="0" ename="accountPeriod" cname="会计期" colWidth="3"
format="yyyy-MM" depth="year" start="year" required="true"/>
......@@ -37,7 +37,7 @@
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true">
<EF:EFColumn ename="id" primaryKey="true" cname="内码" hidden="true"/>
<EF:EFColumn ename="accountCode" cname="企业编码" hidden="true"/>
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="80" align="center"/>
<%--<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="80" align="center"/>--%>
<EF:EFComboColumn ename="companyCode" cname="公司名称"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
......@@ -76,8 +76,8 @@
displayType="0.000" sort="true" align="right" maxLength="17" required="false" defaultValue="0"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
<EF:EFComboColumn ename="computeType" cname="是否暂估" width="80" enable="true" align="center" required="true">
<EF:EFCodeOption codeName="hggp.hgsj.computeType"/>
<EF:EFComboColumn ename="isEstimate" cname="是否暂估" width="80" enable="true" align="center" hidden="true" required="true">
<EF:EFCodeOption codeName="hggp.common.yesNo"/>
</EF:EFComboColumn>
<EF:EFColumn ename="price" cname="单价" width="100" enable="true" format="{0:N3}" editType="text"
displayType="0.000" sort="true" align="right" maxLength="17" required="false" defaultValue="0"
......
$(function (){
$(".row").children().attr("class", "col-md-3");
$("#QUERY").on("click", function (e) {
query();
})
IPLATUI.EFGrid= {
"result": {
pageable: {
......@@ -97,18 +101,22 @@ function showDetail() {
});
}
function windowCallback(companyCode) {
synchData(companyCode);
function windowCallback(item) {
synchData(item);
JSColorbox.close();
}
/**
* 确认
*/
let synchData = function (companyCode) {
let synchData = function (item) {
let info = new EiInfo();
info.set("inqu_status-0-companyCode", companyCode);
EiCommunicator.send("HGCB004", "synchData", info, {
info.set("inqu_status-0-companyCode", item.companyCode);
info.set("inqu_status-0-accountYear", item.accountYear);
info.set("inqu_status-0-accountPeriod", item.accountPeriod);
info.set("inqu_status-0-createdTimeFrom", item.accountPeriodDateStart);
info.set("inqu_status-0-createdTimeTo", item.accountPeriodDateEnd);
EiCommunicator.send("HGCB004", "select", info, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
if (ei.getStatus() == 0) {
......
......@@ -22,14 +22,15 @@
<div class="row">
<EF:EFSelect blockId="inqu_status" row="0" ename="companyCode" cname="公司名称" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="companyBox_block_id" textField="textField" valueField="valueField"/>
<EF:EFOptions blockId="company_code_block_id" textField="companyName" valueField="companyCode"/>
</EF:EFSelect>
<EF:EFDatePicker blockId="inqu_status" row="0" ename="accountPeriod" cname="会计期" colWidth="3"
format="yyyy-MM" depth="year" start="year" required="true"/>
<EF:EFSelect blockId="inqu_status" row="0" ename="whCode" cname="仓库名称" colWidth="3" filter="contains">
<%--<EF:EFSelect blockId="inqu_status" row="0" ename="whCode" cname="仓库名称" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="wh_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
</EF:EFSelect>--%>
<EF:EFInput blockId="inqu_status" row="0" ename="whName" cname="仓库名称" placeholder="模糊查询" colWidth="3"/>
<EF:EFInput blockId="inqu_status" row="0" ename="inventName" cname="存货名称" placeholder="模糊查询" colWidth="3"/>
</div>
</EF:EFRegion>
......@@ -38,30 +39,32 @@
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true">
<EF:EFColumn ename="id" primaryKey="true" cname="内码" hidden="true"/>
<EF:EFColumn ename="accountCode" cname="企业编码" hidden="true"/>
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="80" align="center"/>
<%--<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="80" align="center"/>--%>
<EF:EFComboColumn ename="companyCode" cname="公司名称"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
maxLength="16" width="200" required="true"
align="center" filter="contains" sort="true">
<EF:EFOptions blockId="companyBox_block_id" textField="textField" valueField="valueField"/>
<EF:EFOptions blockId="company_code_block_id" textField="companyName" valueField="companyCode"/>
</EF:EFComboColumn>
<EF:EFColumn ename="accountPeriod" cname="会计期" enable="false" width="120" align="center"
editType="date" dateFormat="yyyy-MM" parseFormats="['yyyyMM']"/>
<EF:EFComboColumn ename="whCode" cname="仓库名称"
<%--<EF:EFComboColumn ename="whCode" cname="仓库名称"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
maxLength="16" readonly="false" width="140" required="true"
align="center" filter="contains" sort="true">
<EF:EFOptions blockId="wh_code_block_id" textField="textField" valueField="valueField"/>
</EF:EFComboColumn>
</EF:EFComboColumn>--%>
<EF:EFColumn ename="whName" cname="仓库名称" width="140" enable="true" readonly="true" align="center" required="true"/>
<EF:EFColumn ename="inventCode" cname="物料编码" width="120" enable="true" readonly="true" align="center" required="true"/>
<EF:EFColumn ename="inventName" cname="物料名称" width="120" enable="true" readonly="true" align="center" required="true"/>
<EF:EFComboColumn ename="spec" cname="规格" enable="true" width="120" align="center" required="true"
<EF:EFColumn ename="spec" cname="规格" width="120" enable="true" readonly="true" align="center" required="true"/>
<%--<EF:EFComboColumn ename="spec" cname="规格" enable="true" width="120" align="center" required="true"
blockName="spec_box_block_id" textField="textField" valueField="valueField"
columnTemplate="#=textField#" itemTemplate="#=textField#" readonly="false"
filter="contains">
</EF:EFComboColumn>
</EF:EFComboColumn>--%>
<EF:EFColumn ename="inventRecordId" cname="规格ID" width="80" enable="true" readonly="false" type="hidden" align="center"/>
<EF:EFColumn ename="initQuantity" cname="期初数量" width="100" enable="true" format="{0:N0}" editType="text"
displayType="0" sort="true" align="right" maxLength="15" required="false" defaultValue="0"
......
......@@ -21,11 +21,11 @@ $(function () {
if(item.inventCode){
for(let i=0;i<inventRecordBoxBlocks.length;i++){
if(item.inventCode === inventRecordBoxBlocks[i]['valueField']){
template = inventRecordBoxBlocks[i]['valueField'];
return inventRecordBoxBlocks[i]['valueField'];
}
}
}
return template;
return item.inventCode;
},
editor: function (container, options) {
var input = $('<input />');
......@@ -51,11 +51,11 @@ $(function () {
if(item.partSpec){
for(let i=0;i<specBoxBlocks.length;i++){
if(item.partSpec === specBoxBlocks[i]['valueField']){
template = specBoxBlocks[i]['valueField'];
return specBoxBlocks[i]['valueField'];
}
}
}
return template;
return item.partSpec;
},
editor: function (container, options) {
var input = $('<input />');
......
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