erp从ims中间表获取数据
This commit is contained in:
parent
6388114190
commit
ab130eac15
|
|
@ -0,0 +1,393 @@
|
|||
package nc.bs.uapbd.bip.workplugin;
|
||||
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.framework.common.InvocationInfoProxy;
|
||||
import nc.bs.pub.pa.PreAlertObject;
|
||||
import nc.bs.pub.taskcenter.BgWorkingContext;
|
||||
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
|
||||
import nc.bs.trade.business.HYPubBO;
|
||||
import nc.jdbc.framework.processor.MapListProcessor;
|
||||
import nc.pubimpl.ic.api.maintain.BillMaintainTool;
|
||||
import nc.vo.ia.mi2.entity.I2BillVO;
|
||||
import nc.vo.ia.mi2.entity.I2HeadVO;
|
||||
import nc.vo.ic.m45.entity.PurchaseInBodyVO;
|
||||
import nc.vo.ic.m45.entity.PurchaseInHeadVO;
|
||||
import nc.vo.ic.m45.entity.PurchaseInVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFDate;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.scmpub.res.billtype.ICBillType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
|
||||
|
||||
@Override
|
||||
public PreAlertObject executeTask(BgWorkingContext bgWorkingContext) throws BusinessException {
|
||||
BaseDAO imsDao= new BaseDAO("gyims");
|
||||
// 禁用时间戳ts
|
||||
imsDao.setAddTimeStamp(false);
|
||||
// 查询高压ims中间表需要同步的数据
|
||||
String sql = " \t\tSELECT\n" +
|
||||
"\t* \n" +
|
||||
"from BIPInputMainTab a " +
|
||||
"where a.status !='2'";
|
||||
List<Map<String,Object>> remain = (List<Map<String, Object>>) imsDao.executeQuery(sql, new MapListProcessor());
|
||||
|
||||
if (remain != null && remain.size() > 0) {
|
||||
List<PurchaseInVO> list = new ArrayList<PurchaseInVO>();
|
||||
for (Map<String, Object> map : remain) {
|
||||
HYPubBO hy = new HYPubBO();
|
||||
PurchaseInVO vo = new PurchaseInVO();
|
||||
PurchaseInHeadVO head = new PurchaseInHeadVO();
|
||||
|
||||
// 按数据库字段名直接调用对应setter方法(set+字段名)
|
||||
head.setCgeneralhid((String) map.get("cgeneralhid"));
|
||||
head.setPk_group(InvocationInfoProxy.getInstance().getGroupId());
|
||||
map.put("pk_org","C047");
|
||||
map.put("pk_org_v","C047");
|
||||
// OrgVO orgvo = (OrgVO)hy.queryByPrimaryKey(OrgVO.class, );
|
||||
Object pk_org = hy.findColValue("org_stockorg", "pk_org", "code = '"+map.get("pk_org")+"' and nvl(dr,0)=0 and islastversion='Y' ");
|
||||
|
||||
head.setPk_org((String) pk_org); // 对应字段pk_org
|
||||
|
||||
// Object pk_org_v = hy.findColValue("org_stockorg_v", "pk_vid", "pk_stockorg = '"+pk_org+"' ");
|
||||
|
||||
Object pk_org_v = hy.findColValue("org_stockorg_v", "pk_vid", "code = '"+map.get("pk_org")+"' ");
|
||||
|
||||
head.setPk_org((String) pk_org_v); // 对应字段pk_org_v
|
||||
|
||||
Object busicode = hy.findColValue("bd_busitype", "pk_busitype", "busicode = '"+map.get("busicode")+"' ");
|
||||
|
||||
head.setCbiztype((String) busicode);
|
||||
head.setVbillcode((String) map.get("vbillcode"));
|
||||
|
||||
// Object cwarehouseid = hy.findColValue("bd_stordoc", "pk_stordoc", " code = '"+map.get("cwarehouseid")+"' ");
|
||||
|
||||
Object cwarehouseid = hy.findColValue("bd_stordoc", "pk_stordoc", " code = '"+"C047002"+"' ");
|
||||
|
||||
head.setCwarehouseid((String) cwarehouseid);
|
||||
|
||||
head.setDbilldate(new UFDate(String.valueOf(map.get("dbilldate"))) ); // 日期类型
|
||||
|
||||
map.put("vtrantypecode","45-Cxx-C102");
|
||||
head.setVtrantypecode((String) map.get("vtrantypecode"));
|
||||
|
||||
Object ctrantypeid = hy.findColValue("bd_billtype", "pk_billtypeid", " pk_billtypecode = '"+map.get("vtrantypecode")+"' and dr='0' ");
|
||||
|
||||
head.setCtrantypeid((String) ctrantypeid);
|
||||
Object cwhsmanagerid = hy.findColValue("bd_psndoc", "pk_psndoc", " code = '"+map.get("cwhsmanagerid")+"' and dr='0' ");
|
||||
|
||||
head.setCwhsmanagerid((String)cwhsmanagerid);
|
||||
|
||||
Object cdptid = hy.findColValue("org_dept", "pk_dept", " code = '"+map.get("cdptid")+"' and dr='0' ");
|
||||
|
||||
head.setCdptid((String) cdptid);
|
||||
|
||||
Object cbizid = hy.findColValue("bd_psndoc", "pk_psndoc", " code = '"+map.get("cbizid")+"' and dr='0' ");
|
||||
|
||||
head.setCbizid((String) cbizid);
|
||||
head.setNtotalnum(new UFDouble(String.valueOf(map.get("ntotalnum")))); // 数字类型
|
||||
head.setVnote((String) map.get("vnote"));
|
||||
// head.setStatus((Integer) map.get("status"));
|
||||
head.setFbillflag(2);
|
||||
Object billmaker = hy.findColValue("sm_user", "cuserid", " user_code = '"+map.get("billmaker")+"' and dr='0' ");
|
||||
|
||||
head.setBillmaker((String) billmaker);
|
||||
Object approver = hy.findColValue("sm_user", "cuserid", " user_code = '"+map.get("approver")+"' and dr='0' ");
|
||||
|
||||
head.setApprover((String)approver);
|
||||
if(map.get("taudittime") !=null){
|
||||
head.setTaudittime(new UFDate(String.valueOf(map.get("taudittime"))) ); // 日期类型
|
||||
}
|
||||
|
||||
Object cpayfinorgoid = hy.findColValue("org_financeorg", "pk_financeorg", " code = '"+map.get("cpayfinorgoid")+"' and dr='0' ");
|
||||
|
||||
head.setCpayfinorgoid((String) cpayfinorgoid);
|
||||
|
||||
Object cfanaceorgoid = hy.findColValue("org_financeorg", "pk_financeorg", " code = '"+map.get("cfanaceorgoid")+"' and dr='0' ");
|
||||
|
||||
head.setCfanaceorgoid((String) cfanaceorgoid); // 注意原字段名是否正确org_financeorg
|
||||
|
||||
Object cpurorgoid = hy.findColValue("org_purchaseorg", "pk_purchaseorg", " code = '"+map.get("cpurorgoid")+"' and dr='0' ");
|
||||
|
||||
head.setCpurorgoid((String) cpurorgoid);
|
||||
head.setCvendorvid((String) map.get("cvendorvid"));
|
||||
head.setDmakedate(new UFDate(String.valueOf(map.get("dmakedate")))); // 日期类型
|
||||
|
||||
Object csendcountryid = hy.findColValue("bd_countryzone", "pk_country", " code = '"+"CN"+"' and dr='0' ");
|
||||
|
||||
head.setCsendcountryid((String) csendcountryid);
|
||||
|
||||
Object crececountryid = hy.findColValue("bd_countryzone", "pk_country", " code = '"+"CN"+"' and dr='0' ");
|
||||
|
||||
head.setCrececountryid((String) crececountryid);
|
||||
|
||||
Object ctaxcountryid = hy.findColValue("bd_countryzone", "pk_country", " code = '"+"CN"+"' and dr='0' ");
|
||||
|
||||
head.setCtaxcountryid((String) ctaxcountryid);
|
||||
head.setFbuysellflag(2 ); // 数值类型(按需调整)
|
||||
|
||||
// 将head设置到vo中
|
||||
vo.setParent(head);
|
||||
String bodysql = " \t\tSELECT\n" +
|
||||
"\t* \n" +
|
||||
"from BIPInputDetailTab a " +
|
||||
"where a.cgeneralhid ='"+map.get("cgeneralhid")+"'";
|
||||
List<Map<String,Object>> bodys = (List<Map<String, Object>>) imsDao.executeQuery(bodysql, new MapListProcessor());
|
||||
List<PurchaseInBodyVO> list1 = new ArrayList<>();
|
||||
for(Map<String,Object> body : bodys) {
|
||||
HYPubBO hy1 = new HYPubBO();
|
||||
PurchaseInBodyVO bodyVO = new PurchaseInBodyVO();
|
||||
|
||||
// 主键及关联字段
|
||||
bodyVO.setCgeneralbid((String) body.get("cgeneralbid")); // 主键(UFID)org_corp
|
||||
bodyVO.setCgeneralhid((String) body.get("cgeneralhid")); // 关联主表ID
|
||||
|
||||
body.put("corpoid","C003");
|
||||
Object corpoid = hy1.findColValue("org_corp", "pk_corp", " code = '"+body.get("corpoid")+"' and dr='0' ");
|
||||
|
||||
bodyVO.setCorpoid((String)corpoid); // 组织_业务单元_公司
|
||||
Object cfanaceorgoid1 = hy1.findColValue("org_financeorg", "pk_financeorg", " code = '"+"C003"+"' and dr='0' ");
|
||||
|
||||
bodyVO.setCfanaceorgoid((String) cfanaceorgoid1); // 组织_业务单元_财务组织org_financeorg
|
||||
// bodyVO.setVbillcode((String) body.get("vbillcode")); // 字符串
|
||||
bodyVO.setCrowno((String) body.get("crowno")); // 字符串
|
||||
Object cmaterialvid = hy1.findColValue("bd_material", "pk_material", " code = '"+body.get("cmaterialvid")+"' and dr='0' ");
|
||||
|
||||
bodyVO.setCmaterialvid((String)cmaterialvid); // 物料基本信息
|
||||
Object cunitid = hy1.findColValue("bd_material", "pk_measdoc", " code = '"+body.get("cmaterialvid")+"' and dr='0' ");
|
||||
|
||||
bodyVO.setCunitid((String)cunitid); // 计量单位bd_measdoc
|
||||
// Object castunitid = hy1.findColValue("bd_measdoc", "pk_measdoc", " code = '"+body.get("castunitid")+"' and dr='0' ");
|
||||
|
||||
bodyVO.setCastunitid((String)cunitid); // 计量单位
|
||||
bodyVO.setVchangerate((String) body.get("vchangerate")); // 字符串
|
||||
bodyVO.setVbatchcode((String) body.get("vbatchcode")); // 字符串
|
||||
|
||||
// 数值类型(UFDouble)
|
||||
bodyVO.setNshouldassistnum(new UFDouble(String.valueOf(body.get("nshouldassistnum")))); // 数值
|
||||
bodyVO.setNshouldnum(new UFDouble(String.valueOf(body.get("nshouldnum")))); // 数值
|
||||
bodyVO.setNassistnum(new UFDouble(String.valueOf(body.get("nassistnum")))); // 数值
|
||||
bodyVO.setNnum(new UFDouble(String.valueOf(body.get("nnum")))); // 数值
|
||||
if(body.get("cprojectid")!=null){
|
||||
Object cprojectid = hy1.findColValue("bd_project", "pk_project", " code = '"+body.get("cprojectid")+"' and dr='0' ");
|
||||
|
||||
bodyVO.setCprojectid((String) cprojectid); // 项目
|
||||
}
|
||||
|
||||
bodyVO.setVnotebody((String) body.get("vnotebody")); // 字符串
|
||||
|
||||
Object cbodytranstypecode = hy1.findColValue("bd_billtype", "pk_billtypeid", " pk_billtypecode = '"+body.get("cbodytranstypecode")+"' and dr='0' ");
|
||||
|
||||
bodyVO.setCbodytranstypecode((String)cbodytranstypecode); // 单据类型
|
||||
|
||||
// Object cbodywarehouseid = hy1.findColValue("bd_stordoc", "pk_stordoc", " code = '"+body.get("cbodywarehouseid")+"' and dr='0' ");
|
||||
|
||||
bodyVO.setCbodywarehouseid(head.getCwarehouseid()); // 仓库
|
||||
|
||||
Object cproductorid = hy1.findColValue("bd_defdoc", "pk_defdoc", " code = '" + body.get("cproductorid") + "' and dr='0' ");
|
||||
bodyVO.setCproductorid((String) cproductorid); // 生产厂商
|
||||
|
||||
// Object pk_creqwareid = hy1.findColValue("bd_stordoc", "pk_stordoc", " code = '"+body.get("pk_creqwareid")+"' and dr='0' ");
|
||||
|
||||
bodyVO.setPk_creqwareid(head.getCwarehouseid()); // 仓库
|
||||
Object creqstoorgoid = hy1.findColValue("org_stockorg", "pk_org", "code = '"+"C047"+"' and nvl(dr,0)=0 and islastversion='Y' ");
|
||||
|
||||
bodyVO.setCreqstoorgoid((String) creqstoorgoid); // 组织_业务单元_库存组织
|
||||
|
||||
Object corigcurrencyid = hy1.findColValue("bd_currtype", "pk_currtype", "code = '"+"CNY"+"' and nvl(dr,0)=0 ");
|
||||
|
||||
bodyVO.setCorigcurrencyid((String) corigcurrencyid); // 币种
|
||||
bodyVO.setNchangestdrate(new UFDouble(1)); // 数值
|
||||
|
||||
Object ccurrencyid = hy1.findColValue("bd_currtype", "pk_currtype", "code = '"+"CNY"+"' and nvl(dr,0)=0 ");
|
||||
|
||||
bodyVO.setCcurrencyid((String) ccurrencyid); // 币种
|
||||
|
||||
// 价格相关数值(UFDouble)
|
||||
// 处理UFDouble类型属性(值非null时才赋值)
|
||||
Object norignetpriceVal = body.get("norignetprice");
|
||||
if (norignetpriceVal != null) {
|
||||
bodyVO.setNorignetprice(new UFDouble(String.valueOf(norignetpriceVal)));
|
||||
}
|
||||
|
||||
Object norigtaxnetpriceVal = body.get("norigtaxnetprice");
|
||||
if (norigtaxnetpriceVal != null) {
|
||||
bodyVO.setNorigtaxnetprice(new UFDouble(String.valueOf(norigtaxnetpriceVal)));
|
||||
}
|
||||
|
||||
Object nnetpriceVal = body.get("nnetprice");
|
||||
if (nnetpriceVal != null) {
|
||||
bodyVO.setNnetprice(new UFDouble(String.valueOf(nnetpriceVal)));
|
||||
}
|
||||
|
||||
Object ntaxnetpriceVal = body.get("ntaxnetprice");
|
||||
if (ntaxnetpriceVal != null) {
|
||||
bodyVO.setNtaxnetprice(new UFDouble(String.valueOf(ntaxnetpriceVal)));
|
||||
}
|
||||
|
||||
// 计量单位(非null时赋值)
|
||||
Object cqtunitidVal = body.get("cqtunitid");
|
||||
if (cqtunitidVal != null) {
|
||||
bodyVO.setCqtunitid((String) cqtunitidVal);
|
||||
}
|
||||
|
||||
// 数值(UFDouble类型,非null时赋值)
|
||||
Object nqtunitnumVal = body.get("nqtunitnum");
|
||||
if (nqtunitnumVal != null) {
|
||||
bodyVO.setNqtunitnum(new UFDouble(String.valueOf(nqtunitnumVal)));
|
||||
}
|
||||
|
||||
// 字符串(非null时赋值)
|
||||
Object vqtunitrateVal = body.get("vqtunitrate");
|
||||
if (vqtunitrateVal != null) {
|
||||
bodyVO.setVqtunitrate((String) vqtunitrateVal);
|
||||
}
|
||||
|
||||
// 继续处理其他UFDouble类型属性
|
||||
Object nqtorignetpriceVal = body.get("nqtorignetprice");
|
||||
if (nqtorignetpriceVal != null) {
|
||||
bodyVO.setNqtorignetprice(new UFDouble(String.valueOf(nqtorignetpriceVal)));
|
||||
}
|
||||
|
||||
Object nqtorigtaxnetpriceVal = body.get("nqtorigtaxnetprice");
|
||||
if (nqtorigtaxnetpriceVal != null) {
|
||||
bodyVO.setNqtorigtaxnetprice(new UFDouble(String.valueOf(nqtorigtaxnetpriceVal)));
|
||||
}
|
||||
|
||||
Object nqtnetpriceVal = body.get("nqtnetprice");
|
||||
if (nqtnetpriceVal != null) {
|
||||
bodyVO.setNqtnetprice(new UFDouble(String.valueOf(nqtnetpriceVal)));
|
||||
}
|
||||
|
||||
Object nqttaxnetpriceVal = body.get("nqttaxnetprice");
|
||||
if (nqttaxnetpriceVal != null) {
|
||||
bodyVO.setNqttaxnetprice(new UFDouble(String.valueOf(nqttaxnetpriceVal)));
|
||||
}
|
||||
|
||||
Object norigpriceVal = body.get("norigprice");
|
||||
if (norigpriceVal != null) {
|
||||
bodyVO.setNorigprice(new UFDouble(String.valueOf(norigpriceVal)));
|
||||
}
|
||||
|
||||
Object norigtaxpriceVal = body.get("norigtaxprice");
|
||||
if (norigtaxpriceVal != null) {
|
||||
bodyVO.setNorigtaxprice(new UFDouble(String.valueOf(norigtaxpriceVal)));
|
||||
}
|
||||
|
||||
Object npriceVal = body.get("nprice");
|
||||
if (npriceVal != null) {
|
||||
bodyVO.setNprice(new UFDouble(String.valueOf(npriceVal)));
|
||||
}
|
||||
|
||||
Object ntaxpriceVal = body.get("ntaxprice");
|
||||
if (ntaxpriceVal != null) {
|
||||
bodyVO.setNtaxprice(new UFDouble(String.valueOf(ntaxpriceVal)));
|
||||
}
|
||||
|
||||
Object nqtorigpriceVal = body.get("nqtorigprice");
|
||||
if (nqtorigpriceVal != null) {
|
||||
bodyVO.setNqtorigprice(new UFDouble(String.valueOf(nqtorigpriceVal)));
|
||||
}
|
||||
|
||||
Object nqtorigtaxpriceVal = body.get("nqtorigtaxprice");
|
||||
if (nqtorigtaxpriceVal != null) {
|
||||
bodyVO.setNqtorigtaxprice(new UFDouble(String.valueOf(nqtorigtaxpriceVal)));
|
||||
}
|
||||
|
||||
Object nqtpriceVal = body.get("nqtprice");
|
||||
if (nqtpriceVal != null) {
|
||||
bodyVO.setNqtprice(new UFDouble(String.valueOf(nqtpriceVal)));
|
||||
}
|
||||
|
||||
Object nqttaxpriceVal = body.get("nqttaxprice");
|
||||
if (nqttaxpriceVal != null) {
|
||||
bodyVO.setNqttaxprice(new UFDouble(String.valueOf(nqttaxpriceVal)));
|
||||
}
|
||||
|
||||
Object nitemdiscountrateVal = body.get("nitemdiscountrate");
|
||||
if (nitemdiscountrateVal != null) {
|
||||
bodyVO.setNitemdiscountrate(new UFDouble(String.valueOf(nitemdiscountrateVal)));
|
||||
}
|
||||
|
||||
// 金额及税额相关(UFDouble类型,非null时赋值)
|
||||
Object norigmnyVal = body.get("norigmny");
|
||||
if (norigmnyVal != null) {
|
||||
bodyVO.setNorigmny(new UFDouble(String.valueOf(norigmnyVal)));
|
||||
}
|
||||
|
||||
Object norigtaxmnyVal = body.get("norigtaxmny");
|
||||
if (norigtaxmnyVal != null) {
|
||||
bodyVO.setNorigtaxmny(new UFDouble(String.valueOf(norigtaxmnyVal)));
|
||||
}
|
||||
|
||||
Object nmnyVal = body.get("nmny");
|
||||
if (nmnyVal != null) {
|
||||
bodyVO.setNmny(new UFDouble(String.valueOf(nmnyVal)));
|
||||
}
|
||||
|
||||
Object ntaxmnyVal = body.get("ntaxmny");
|
||||
if (ntaxmnyVal != null) {
|
||||
bodyVO.setNtaxmny(new UFDouble(String.valueOf(ntaxmnyVal)));
|
||||
}
|
||||
|
||||
Object ntaxVal = body.get("ntax");
|
||||
if (ntaxVal != null) {
|
||||
bodyVO.setNtax(new UFDouble(String.valueOf(ntaxVal)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 增值税税码税率(查询结果非null时赋值)
|
||||
Object ctaxcodeid = hy1.findColValue("bd_taxcode", "pk_taxcode",
|
||||
"code = '" + "CN13" + "' and dr=0 ");
|
||||
if (ctaxcodeid != null) {
|
||||
bodyVO.setCtaxcodeid((String) ctaxcodeid);
|
||||
}
|
||||
Object ntaxrateVal = hy1.findColValue("bd_taxrate", "taxrate",
|
||||
" pk_taxcode = '" + ctaxcodeid+ "' and dr=0 ");
|
||||
if (ntaxrateVal != null) {
|
||||
bodyVO.setNtaxrate(new UFDouble(String.valueOf(ntaxrateVal)));
|
||||
}
|
||||
// 继续处理其他UFDouble类型
|
||||
Object ncaltaxmnyVal = body.get("ncaltaxmny");
|
||||
if (ncaltaxmnyVal != null) {
|
||||
bodyVO.setNcaltaxmny(new UFDouble(String.valueOf(ncaltaxmnyVal)));
|
||||
}
|
||||
|
||||
// 扣税类别(非null时转换并赋值)
|
||||
Object ftaxtypeflagVal = body.get("ftaxtypeflag");
|
||||
if (ftaxtypeflagVal != null) {
|
||||
bodyVO.setFtaxtypeflag(Integer.valueOf((String) ftaxtypeflagVal));
|
||||
}
|
||||
|
||||
Object ncalcostmnyVal = body.get("ncalcostmny");
|
||||
if (ncalcostmnyVal != null) {
|
||||
bodyVO.setNcalcostmny(new UFDouble(String.valueOf(ncalcostmnyVal)));
|
||||
}
|
||||
|
||||
// 供应商基本信息(查询结果非null时赋值)
|
||||
String cvendorid = (String) hy1.findColValue("bd_supplierclass", "pk_supplierclass",
|
||||
" code = '" + body.get("cvendorid") + "' and dr=0 ");
|
||||
if (cvendorid != null) {
|
||||
bodyVO.setCvendorid(cvendorid);
|
||||
}
|
||||
|
||||
list1.add(bodyVO);
|
||||
}
|
||||
vo.setChildrenVO(list1.toArray(new PurchaseInBodyVO[list1.size()]));
|
||||
// 添加到集合
|
||||
list.add(vo);
|
||||
}
|
||||
BillMaintainTool<PurchaseInVO> tool = new BillMaintainTool<PurchaseInVO>(
|
||||
PurchaseInVO.class, ICBillType.PurchaseIn.getCode());
|
||||
tool.insert(list.toArray(new PurchaseInVO[list.size()]));
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue