Commit 96de65f8 by wuwenlong

产副品制造成本核算dev

parent a2f7702f
...@@ -11,7 +11,9 @@ import com.baosight.hggp.hg.cb.domain.HGCB001; ...@@ -11,7 +11,9 @@ import com.baosight.hggp.hg.cb.domain.HGCB001;
import com.baosight.hggp.hg.cb.domain.HGCB002; import com.baosight.hggp.hg.cb.domain.HGCB002;
import com.baosight.hggp.hg.cb.domain.HGCB003; import com.baosight.hggp.hg.cb.domain.HGCB003;
import com.baosight.hggp.hg.cb.domain.HGCB004; import com.baosight.hggp.hg.cb.domain.HGCB004;
import com.baosight.hggp.hg.cb.domain.HGCB005;
import com.baosight.hggp.hg.cg.domain.HGCG003; import com.baosight.hggp.hg.cg.domain.HGCG003;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.constant.HGSqlConstant; import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.cw.domain.HGCW001; import com.baosight.hggp.hg.cw.domain.HGCW001;
import com.baosight.hggp.hg.cw.domain.HGCW012; import com.baosight.hggp.hg.cw.domain.HGCW012;
...@@ -19,9 +21,11 @@ import com.baosight.hggp.hg.cw.domain.HGCW012A; ...@@ -19,9 +21,11 @@ import com.baosight.hggp.hg.cw.domain.HGCW012A;
import com.baosight.hggp.hg.cw.domain.HGCW013; import com.baosight.hggp.hg.cw.domain.HGCW013;
import com.baosight.hggp.hg.cw.tools.HGCWTools; import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.kc.domain.*; import com.baosight.hggp.hg.kc.domain.*;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.pz.domain.HGPZ005; import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.pz.domain.HGPZ007; import com.baosight.hggp.hg.pz.domain.HGPZ007;
import com.baosight.hggp.hg.pz.tools.HGPZTools; import com.baosight.hggp.hg.pz.tools.HGPZTools;
import com.baosight.hggp.hg.sc.domain.HGSC005A;
import com.baosight.hggp.util.*; import com.baosight.hggp.util.*;
import com.baosight.iplat4j.core.data.DaoEPBase; import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
...@@ -29,6 +33,7 @@ import com.baosight.iplat4j.core.ei.EiInfo; ...@@ -29,6 +33,7 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.web.threadlocal.UserSession; import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
...@@ -613,4 +618,77 @@ public class HGCBTools { ...@@ -613,4 +618,77 @@ public class HGCBTools {
hgcb004.fromMap(hgcb002.toMap()); hgcb004.fromMap(hgcb002.toMap());
} }
} }
public static class THGCB005 {
/**
* 同步数据
*
* @return
*/
public static void synchData() {
HGCW001 hgcw001 = new HGCW001();
//通过业务账期信息查询入库单
Map kc003ParamMap = new HashMap();
kc003ParamMap.put(HGKC003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
kc003ParamMap.put(HGKC003.FIELD_COMPANY_CODE,hgcw001.getCompanyCode());
kc003ParamMap.put(HGKC003.FIELD_STORAGE_TYPE, HGConstant.StorageType.RK);
kc003ParamMap.put(HGKC003.FIELD_IS_RETURN, CommonConstant.YesNo.NO_0);
kc003ParamMap.put(HGCW001.FIELD_ACCOUNT_PERIOD_DATE_START,hgcw001.getAccountPeriodDateStart());
kc003ParamMap.put(HGCW001.FIELD_ACCOUNT_PERIOD_DATE_END,hgcw001.getAccountPeriodDateEnd());
List<HGKC003> hgkc003List = HGKCTools.HgKc003.list(kc003ParamMap);
//入库单按项目编码、产品编码、存货工序ID、规格、单重分组,分别取正向入库单数量、重量和退回数量
//生成制造成本基础数据
List<HGCB005> hgcb005List = constractHGCB005(hgcw001,hgkc003List);
//通过存货工序ID查询工序权重
List<Long> processIds = Optional.ofNullable(hgcb005List).orElse(new ArrayList<>()).stream().map(HGCB005::getInventProcessId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(processIds)){
List<HGPZ005> hgpz005List = HGPZTools.HgPz005.getIds(processIds);
Map<Long,HGPZ005> hgpz005Map = Optional.ofNullable(hgpz005List).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(
HGPZ005::getId,
o->o,
(o1,o2)->o1
));
}
//通过业务账期信息查询类型为分摊的费用归集数据,按项目分组金额求和
//计算成本:入库重量*工序权重=产副品权重,SUM(产副品权重)=项目权重,产副品权重/项目权重*总费用=产副品制造总成本
}
}
private static List<HGCB005> constractHGCB005(HGCW001 hgcw001, List<HGKC003> hgkc003List){
List<HGCB005> hgcb005List = Optional.ofNullable(hgkc003List).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(
o->o.getProjCode()+"-"+o.getPrdtCode()+"-"+o.getInventProcessId()+"-"+o.getPrdtSpec()+"-"+o.getInvUnitWeight(),
o->o,(v1,v2)->{
HGKC003 kc003 = new HGKC003();
BeanUtils.copyProperties(v1,kc003);
kc003.setInvQty(v1.getInvQty().add(v2.getInvQty()));
kc003.setInvWeight(v1.getInvWeight().add(v2.getInvWeight()));
return kc003;
}
)).values().stream().map(o -> {
HGCB005 cb005 = new HGCB005();
cb005.setAccountYear(hgcw001.getAccountYear());
cb005.setAccountMonth(hgcw001.getAccountPeriod().substring(4));
cb005.setCompanyCode(hgcw001.getCompanyCode());
cb005.setCompanyName(hgcw001.getCompanyName());
cb005.setProductCode(o.getPrdtCode());
cb005.setProductName(o.getPrdtName());
cb005.setTechFlowId(o.getTechFlowId());
cb005.setTechFlowName(o.getTechFlowName());
cb005.setInventProcessId(o.getInventProcessId());
cb005.setProcessCode(o.getProcessCode());
cb005.setProcessName(o.getProcessName());
cb005.setProcessOrder(o.getProcessOrder());
cb005.setProductLength(o.getPrdtLength());
cb005.setProductWidth(o.getPrdtWidth());
cb005.setProductThick(o.getPrdtThick());
cb005.setProductSpec(o.getPrdtSpec());
cb005.setSingleWeight(o.getInvUnitWeight());
cb005.setQuantity(o.getInvQty());
cb005.setTotalWeight(o.getInvWeight());
return cb005;
}).collect(Collectors.toList());
return hgcb005List;
}
} }
...@@ -157,6 +157,12 @@ ...@@ -157,6 +157,12 @@
<isNotEmpty prepend=" AND " property="processOrder"> <isNotEmpty prepend=" AND " property="processOrder">
PROCESS_ORDER = #processOrder# PROCESS_ORDER = #processOrder#
</isNotEmpty> </isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateStart">
<![CDATA[ DEPOSIT_DATE >= #accountPeriodDateStart# ]]>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountPeriodDateEnd">
<![CDATA[ DEPOSIT_DATE <= #accountPeriodDateEnd# ]]>
</isNotEmpty>
</sql> </sql>
<select id="query" parameterClass="java.util.HashMap" <select id="query" parameterClass="java.util.HashMap"
......
...@@ -387,6 +387,16 @@ public class HGKCTools { ...@@ -387,6 +387,16 @@ public class HGKCTools {
AssertUtils.isEmpty(paramMap, "时间不能为空"); AssertUtils.isEmpty(paramMap, "时间不能为空");
return DaoBase.getInstance().query("HGKC003.queryCheckList", paramMap); return DaoBase.getInstance().query("HGKC003.queryCheckList", paramMap);
} }
/**
* 查询
* 成本核算数据检查
* @param paramMap
* @return
*/
public static List<HGKC003> list(Map paramMap) {
return DaoBase.getInstance().query(HGKC003.QUERY, paramMap);
}
} }
/** /**
......
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