Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
558fdc53ab
|
@ -51,40 +51,69 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule<SCOrderVO> {
|
|||
}
|
||||
|
||||
private void buildSyncData(SCOrderHeaderVO head, SCOrderItemVO[] bodys, JSONArray details) throws BusinessException {
|
||||
|
||||
String vbillcode = head.getVbillcode();
|
||||
String pkOrder = head.getPk_order();
|
||||
for (SCOrderItemVO body : bodys) {
|
||||
JSONObject singleObj = new JSONObject();
|
||||
|
||||
//htmx_wbid varchar(100) 第三方系统主键id 必填
|
||||
singleObj.put("htmx_wbid", pkOrder+"_"+body.getPk_order_b());
|
||||
|
||||
//cght_wbid varchar(100) 第三方系统合同ID 必填
|
||||
singleObj.put("cght_wbid", pkOrder);
|
||||
|
||||
//操作状态 1新增/修改、2删除(删除时只需上传wbid)
|
||||
singleObj.put("operate", 1);
|
||||
// 单据类型
|
||||
singleObj.put("cgjh_wbid", body.getVsrctrantype()); // 第三方系统采购计划id
|
||||
singleObj.put("cgxh", body.getVsrcrowno()); // 采购计划序号
|
||||
singleObj.put("cgbh", body.getVsrccode()); // 采购计划编号
|
||||
singleObj.put("bzsm", body.getVbmemo()); // 备注说明
|
||||
singleObj.put("cght_wbid", head.getVbillcode()); // 第三方系统合同ID
|
||||
singleObj.put("htxsbh", head.getVbillcode()); // 合同编号
|
||||
// 供应商
|
||||
singleObj.put("zbxx_gycs_wbid", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, head.getPk_supplier())); // 第三方系统厂商id
|
||||
// 仓库
|
||||
singleObj.put("sdck", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getPk_recvstordoc())); // 送达仓库
|
||||
// 物料
|
||||
singleObj.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getPk_material())); // 第三方系统材料id
|
||||
|
||||
UFDouble nqtunitnum = body.getNqtunitnum() == null ? UFDouble.ZERO_DBL : body.getNqtunitnum();
|
||||
singleObj.put("cgsl", nqtunitnum.getDouble()); // 采购数量
|
||||
if (body.getDplanarrvdate() != null) {
|
||||
singleObj.put("jhrq", body.getDplanarrvdate().toString()); // 交货日期
|
||||
}
|
||||
// zbxx_cglb_wbid varchar(100) 第三方系统采购类别id 必填
|
||||
singleObj.put("zbxx_cglb_wbid", head.getVtrantypecode());
|
||||
|
||||
//zbxx_cgrq datetime 采购日期 必填 表头采购日期
|
||||
if (head.getDbilldate() != null) {
|
||||
singleObj.put("zbxx_cgrq", head.getDbilldate().toString()); // 采购日期
|
||||
}
|
||||
|
||||
//htxsbh varchar(100) 合同编号
|
||||
singleObj.put("htxsbh", head.getVbillcode());
|
||||
|
||||
// 合同序号
|
||||
singleObj.put("htxh", body.getCrowno());
|
||||
|
||||
// 第三方系统材料id
|
||||
singleObj.put("wlbm_wbid", body.getPk_material());
|
||||
|
||||
// 采购数量
|
||||
UFDouble nqtunitnum = body.getNqtunitnum() == null ? UFDouble.ZERO_DBL : body.getNqtunitnum();
|
||||
singleObj.put("cgsl", nqtunitnum.getDouble());
|
||||
|
||||
// 采购日期
|
||||
if (head.getDbilldate() != null) {
|
||||
singleObj.put("cgrq", head.getDbilldate().toString()); // 采购日期
|
||||
singleObj.put("cgrq", head.getDbilldate().toString());
|
||||
}
|
||||
|
||||
singleObj.put("htxh", body.getCrowno()); // 合同序号
|
||||
singleObj.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC, head.getCemployeeid())); // 第三方系统采购员id
|
||||
// 第三方系统厂商id
|
||||
singleObj.put("zbxx_gycs_wbid", head.getPk_supplier());
|
||||
|
||||
//zbxx_cgy_wbid varchar(100) 第三方系统采购员id
|
||||
singleObj.put("zbxx_cgy_wbid", head.getCemployeeid());
|
||||
|
||||
// 交货日期
|
||||
if (body.getDplanarrvdate() != null) {
|
||||
singleObj.put("jhrq", body.getDplanarrvdate().toString());
|
||||
}
|
||||
|
||||
singleObj.put("cgjh_wbid", body.getVsrctrantype()); // 第三方系统采购计划id
|
||||
singleObj.put("cgxh", body.getVsrcrowno()); // 采购计划序号
|
||||
singleObj.put("cgbh", body.getVsrccode()); // 采购计划编号
|
||||
|
||||
singleObj.put("sdck", body.getPk_recvstordoc()); // 送达仓库
|
||||
|
||||
singleObj.put("bzsm", body.getVbmemo()); // 备注说明
|
||||
|
||||
//sdbj int 锁定标记 必填 上位单据审核传输,默认=1
|
||||
singleObj.put("sdbj", 1);
|
||||
//qfbj int 签发标记 必填 上位单据审核传输,默认=1
|
||||
singleObj.put("qfbj", 1);
|
||||
|
||||
details.add(singleObj);
|
||||
}
|
||||
|
@ -96,7 +125,7 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule<SCOrderVO> {
|
|||
String pkOrg = aggvo.getParentVO().getPk_org();
|
||||
Integer fstatusflag = aggvo.getParentVO().getFstatusflag();
|
||||
String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if ("30401".equals(orgCode) && 3 == fstatusflag) {
|
||||
if ("C022".equals(orgCode) && 3 == fstatusflag&&aggvo.getChildrenVO()!=null && aggvo.getChildrenVO().length>0) {
|
||||
aggvoList.add(aggvo);
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +157,8 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule<SCOrderVO> {
|
|||
JSONObject resultObj = JSONObject.parseObject(result);
|
||||
if ("false".equals(resultObj.getString("success"))) {
|
||||
throw new BusinessException("RZMOM同步失败,原因:" + resultObj.getString("msg"));
|
||||
}else{
|
||||
log.error("RZMOM同步成功,返回参数【"+resultObj.toJSONString()+"】");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
|
|||
for(SaleOutVO aggvo:saleOutVOS){
|
||||
String pkOrg = aggvo.getHead().getPk_org();
|
||||
String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if("30401".equals(orgCode)){
|
||||
if("C022".equals(orgCode)&& aggvo.getBodys()!=null && aggvo.getBodys().length>0){
|
||||
aggvoList.add(aggvo);
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,8 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
|
|||
JSONObject resultObj = JSONObject.parseObject(result);
|
||||
if("false".equals(resultObj.getString("success"))){
|
||||
throw new BusinessException("RZMOM同步失败,原因:"+resultObj.getString("msg"));
|
||||
}else{
|
||||
log.error("RZMOM同步成功,返回参数【"+resultObj.toJSONString()+"】");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +102,7 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
|
|||
String vbillcode = head.getVbillcode();//单据号
|
||||
String vtrantypecode = head.getVtrantypecode();//出入库类型编码
|
||||
//部门
|
||||
String cdptCode =transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE,DeptVO.PK_DEPT,head.getCdptid());
|
||||
// String cdptCode =transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE,DeptVO.PK_DEPT,head.getCdptid());
|
||||
|
||||
for(SaleOutBodyVO body:bodys){
|
||||
JSONObject singleObj = new JSONObject();
|
||||
|
@ -111,31 +113,38 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
|
|||
String casscustid = body.getCasscustid();//客户
|
||||
String cbodywarehouseid = body.getCbodywarehouseid();//仓库
|
||||
UFDate dbizdate = body.getDbizdate();//出库日期
|
||||
singleObj.put("wbid",cgeneralhid+"_"+cgeneralbid+"_"+vtrantypecode);//第三方系统主键id
|
||||
singleObj.put("wbpid",cgeneralhid);//第三方系统分组id
|
||||
singleObj.put("operate",1);//operate int 操作状态 必填 1新增/修改、2删除(删除时只需上传wbid)
|
||||
singleObj.put("djly",1013);//djly varchar(20) 来源单据
|
||||
singleObj.put("djbh_id",cgeneralhid+"_"+cgeneralbid);//单据id
|
||||
singleObj.put("djbh",vbillcode);//单据编号
|
||||
singleObj.put("djxh",crowno);//单据序号
|
||||
singleObj.put("djrq",dbizdate.toString());//单据日期--出库日期
|
||||
singleObj.put("wbid",cgeneralhid);//第三方系统主键id
|
||||
singleObj.put("wbpid",cgeneralbid);//第三方系统分组id
|
||||
|
||||
|
||||
//第三方系统物料名称id--编码
|
||||
singleObj.put("wlbm_wbid",transferCodeByPk(MaterialVO.getDefaultTableName(),MaterialVO.CODE,MaterialVO.PK_MATERIAL,cmaterialvid));
|
||||
singleObj.put("wlbm_wbid",cmaterialvid);
|
||||
|
||||
//单据数量
|
||||
singleObj.put("djsl",body.getNshouldassistnum().getDouble());
|
||||
|
||||
//第三方系统客户id--编码
|
||||
singleObj.put("khbh_wbid",transferCodeByPk(CustomerVO.getDefaultTableName(),CustomerVO.CODE,CustomerVO.PK_CUSTOMER,casscustid));
|
||||
//送达地点-code
|
||||
String storeCode = transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, cbodywarehouseid);
|
||||
singleObj.put("sddd",storeCode);
|
||||
//第三方系统仓库id -code
|
||||
singleObj.put("ckbh_wbid",storeCode);
|
||||
//部门
|
||||
singleObj.put("bzsm",cdptCode);
|
||||
//签发标记
|
||||
singleObj.put("qfbj",1);
|
||||
singleObj.put("khbh_wbid",casscustid);
|
||||
//订单编号
|
||||
singleObj.put("ddbh",body.getVsourcebillcode());
|
||||
//订单序号
|
||||
singleObj.put("ddxh",body.getVsourcerowno());
|
||||
//单据数量
|
||||
singleObj.put("djsl",body.getNshouldassistnum().getDouble());
|
||||
//送达地点-code
|
||||
singleObj.put("sddd",cbodywarehouseid);
|
||||
//第三方系统仓库id -code
|
||||
singleObj.put("ckbh_wbid",cbodywarehouseid);
|
||||
//部门
|
||||
singleObj.put("bzsm",head.getCdptid());
|
||||
//签发标记
|
||||
singleObj.put("qfbj",1);
|
||||
|
||||
|
||||
//操作状态 1新增/修改、2删除(删除时只需上传wbid)
|
||||
singleObj.put("operate",1);
|
||||
details.add(singleObj);
|
||||
|
|
|
@ -48,22 +48,47 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
|
|||
}
|
||||
|
||||
private void buildSyncData(PickmHeadVO head, PickmItemVO[] bodys, JSONArray details) throws BusinessException {
|
||||
Integer fsourcetype = head.getFsourcetype();
|
||||
if(fsourcetype!=0){
|
||||
return;
|
||||
}
|
||||
for (PickmItemVO body : bodys) {
|
||||
JSONObject singleObj = new JSONObject();
|
||||
String vsourcebillcode = head.getVsourcebillcode();
|
||||
String wlbm_wbid = transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getCbmaterialvid());
|
||||
String scgx_wbid = transferCodeByPk(RcVO.getDefaultTableName(), RcVO.VRCCODE, RcVO.CRCID, head.getVstdprocid());
|
||||
String wbid = vsourcebillcode + "_" + wlbm_wbid + "_" + scgx_wbid;
|
||||
String wlbm_wbid =body.getCbmaterialvid();
|
||||
|
||||
String scgx_wbid =head.getVstdprocid();
|
||||
//wbid varchar (200) 第三方系统主键id
|
||||
singleObj.put("wbid", head.getCpickmid()+"_"+body.getCpickm_bid()); // 第三方系统主键id
|
||||
//wbzbid varchar (200) 第三方系统分组id
|
||||
singleObj.put("wbzbid", head.getCpickmid());
|
||||
//operate int 操作状态 必填 1新增/修改、2删除(删除时只需上传wbid)
|
||||
singleObj.put("operate", "1");
|
||||
|
||||
//wbqjpx varchar(2000) 全局排序 必填 BOM表物料行号
|
||||
singleObj.put("wbqjpx", body.getVrowno());
|
||||
|
||||
//scjh_wbid varchar(100) 第三方系统生产计划ID 必填 生产计划号外部ID,一般ERP系统的生产订单号。
|
||||
singleObj.put("scjh_wbid", head.getCsourcebillid());
|
||||
|
||||
//jhxh numeric(5) 计划序号 -生产订单行号
|
||||
singleObj.put("jhxh", head.getVsourcebillrowno());
|
||||
|
||||
singleObj.put("wlbm_wbid", wlbm_wbid); // 第三方系统材料id
|
||||
|
||||
//bomlx int BOM类型 必填 默认=0,即传入生产BOM(1为包装BOM)。
|
||||
singleObj.put("bomlx", 0);
|
||||
|
||||
singleObj.put("scgx_wbid", scgx_wbid); // 第三方系统使用工序id
|
||||
singleObj.put("scjh_wbid", vsourcebillcode); // 第三方系统生产计划ID
|
||||
singleObj.put("dwyl", body.getNplanoutastnum().getDouble()); // 单位用量
|
||||
singleObj.put("djyl", body.getNplanoutastnum().getDouble()); // 单据用量
|
||||
singleObj.put("clyl", body.getNplanoutastnum().getDouble()); // 材料用量
|
||||
singleObj.put("wlbm_wbid", wlbm_wbid); // 第三方系统材料id
|
||||
singleObj.put("wbid", wbid); // 第三方系统主键id
|
||||
singleObj.put("operate", "1");
|
||||
|
||||
String rccode = transferCodeByPk(RcVO.getDefaultTableName(), RcVO.VRCCODE, RcVO.CRCID, head.getVstdprocid());
|
||||
singleObj.put("scgx_wbid", rccode); // 第三方系统使用工序id
|
||||
//sdbj int 锁定标记 必填 默认1:正常业务ERP审核后,传输至锐制MOM
|
||||
singleObj.put("sdbj", 1);
|
||||
//shbj int 审核标记 必填 默认1:正常业务ERP审核后,传输至锐制MOM
|
||||
singleObj.put("shbj", 1);
|
||||
details.add(singleObj);
|
||||
|
||||
}
|
||||
|
@ -74,7 +99,7 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
|
|||
for (AggPickmVO aggvo : aggPickmVOS) {
|
||||
String pkOrg = aggvo.getParentVO().getPk_org();
|
||||
String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if ("30401".equals(orgCode)) {
|
||||
if ("C022".equals(orgCode)&& 1 == aggvo.getParentVO().getFbillstatus()&&aggvo.getChildrenVO()!=null && aggvo.getChildrenVO().length > 0) {
|
||||
aggvoList.add(aggvo);
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +131,8 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
|
|||
if (resultObj == null || !"true".equals(resultObj.getString("success"))) {
|
||||
String errorMsg = resultObj == null ? "接口返回为空" : resultObj.getString("msg");
|
||||
throw new BusinessException("RZ同步失败,原因:" + errorMsg);
|
||||
}else{
|
||||
log.error("RZMOM同步成功,返回参数【"+resultObj.toJSONString()+"】");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<PMOAggVO> {
|
|||
String pkOrg = aggvo.getParentVO().getPk_org();
|
||||
Integer fbillstatus = aggvo.getParentVO().getFbillstatus();
|
||||
String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if ("30401".equals(orgCode)&&1==fbillstatus) {
|
||||
if ("C022".equals(orgCode) && 1 == fbillstatus&&aggvo.getChildrenVO()!=null && aggvo.getChildrenVO().length>0) {
|
||||
aggvoList.add(aggvo);
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,8 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<PMOAggVO> {
|
|||
JSONObject resultObj = JSONObject.parseObject(result);
|
||||
if ("false".equals(resultObj.getString("success"))) {
|
||||
throw new BusinessException("RZMOM同步失败,原因:" + resultObj.getString("msg"));
|
||||
}else{
|
||||
log.error("RZMOM同步成功,返回参数【"+resultObj.toJSONString()+"】");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,41 +114,59 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<PMOAggVO> {
|
|||
for (PMOItemVO body : bodys) {
|
||||
JSONObject detailItem = new JSONObject();
|
||||
// jhmx_wbid varchar(100) 第三方系统主键id 必填 上位系统后台唯一ID
|
||||
detailItem.put("jhmx_wbid", head.getCpmohid());
|
||||
detailItem.put("scbh", vbillcode);
|
||||
detailItem.put("scjh_wbid", vbillcode);
|
||||
//jhxh numeric(5) 计划序号 必填 生产订单的产品行号,有按实际。
|
||||
//若无默认1。
|
||||
detailItem.put("scjh_wbid", body.getVrowno());
|
||||
detailItem.put("jhbhzdsc", 1);//如果直接把第三方系统的编号作为我们的计划编号传0,如果我们系统自己取号则传1。
|
||||
detailItem.put("jhmx_wbid", head.getCpmohid() + "_" + body.getCmoid());
|
||||
|
||||
//计划ID 必填 用于标识哪些数据属于同一个生产计划下 cpmohid
|
||||
detailItem.put("scjh_wbid", head.getCpmohid());
|
||||
|
||||
// 操作状态 必填 1新增/修改、2删除(删除时只需上传wbid)
|
||||
detailItem.put("operate", 1);
|
||||
// 计划编号 必填 前台计划编号
|
||||
detailItem.put("jhbh", vbillcode);
|
||||
//jhxh numeric(5) 计划序号 必填 生产订单的产品行号,有按实际。
|
||||
detailItem.put("jhxh", body.getVrowno());
|
||||
// 第三方系统计划类别id
|
||||
detailItem.put("jhlb_wbid", head.getVtrantypecode());
|
||||
|
||||
|
||||
|
||||
// 第三方系统产品ID 物料ID
|
||||
detailItem.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getCmaterialvid()));
|
||||
// detailItem.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getCmaterialvid()));
|
||||
detailItem.put("wlbm_wbid", body.getCmaterialvid());
|
||||
// 预计开工日期
|
||||
if(body.getTplanstarttime()!=null){
|
||||
if (body.getTplanstarttime() != null) {
|
||||
detailItem.put("sxrq", body.getTplanstarttime().toString());
|
||||
}
|
||||
// 预计完工日期
|
||||
if(body.getTplanendtime()!=null){
|
||||
if (body.getTplanendtime() != null) {
|
||||
detailItem.put("wcrq", body.getTplanendtime().toString());
|
||||
}
|
||||
// bzsm varchar(400) 备注说明
|
||||
detailItem.put("bzsm", body.getVnote());
|
||||
// qfbj int 签发标记 默认0;上位ERP签发后传MOM时,签发仍=0;
|
||||
detailItem.put("qfbj", body.getFitemstatus());
|
||||
// 计划产出数量
|
||||
detailItem.put("jhsl", body.getNmmastnum().getDouble());
|
||||
//jhlx int 计划类型 必填 0成品入库、1半成品入库
|
||||
//有销售订单号的默认为0;属于零部件生产计划的默认为1;
|
||||
// detailItem.put("jhlx", body.getVsalebillcode() == null ? 1 : 0);
|
||||
detailItem.put("jhlx", 1);
|
||||
// 入库仓库
|
||||
detailItem.put("sdck", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getCinwarehouseid()));
|
||||
detailItem.put("wlzdycs01", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getCinwarehouseid()));
|
||||
// detailItem.put("sdck", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getCinwarehouseid()));
|
||||
detailItem.put("sdck", body.getCinwarehouseid());
|
||||
// detailItem.put("wlzdycs01", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getCinwarehouseid()));
|
||||
// detailItem.put("wlzdycs01", body.getCinwarehouseid());
|
||||
// 工作中心 生产部门ID
|
||||
detailItem.put("scgc_wbid", transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE, DeptVO.PK_DEPT, body.getCdeptid()));
|
||||
// 订单序号
|
||||
detailItem.put("ddbh", body.getVsalebillcode());
|
||||
// 订单序号
|
||||
detailItem.put("khddh", null);
|
||||
detailItem.put("ddxh", 1);
|
||||
// detailItem.put("scgc_wbid", transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE, DeptVO.PK_DEPT, body.getCdeptid()));
|
||||
detailItem.put("scgc_wbid", body.getCdeptid());
|
||||
|
||||
// 备注说明
|
||||
detailItem.put("bzsm", body.getVnote());
|
||||
//zdscjhlyb int 自动生成计划来源表 必填 默认传1 1
|
||||
detailItem.put("zdscjhlyb", 1);
|
||||
//如果直接把第三方系统的编号作为我们的计划编号传0,如果我们系统自己取号则传1。
|
||||
detailItem.put("jhbhzdsc", 0);
|
||||
|
||||
// 项目编号
|
||||
detailItem.put("wlzdycs06", body.getVdef1());
|
||||
details.add(detailItem);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<OrderVO> {
|
|||
String pkOrg = aggvo.getHVO().getPk_org();
|
||||
Integer forderstatus = aggvo.getHVO().getForderstatus();
|
||||
String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if ("30401".equals(orgCode)&& 3==forderstatus) {
|
||||
if ("C022".equals(orgCode) && 3 == forderstatus && aggvo.getBVO()!=null && aggvo.getBVO().length > 0) {
|
||||
aggvoList.add(aggvo);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,8 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<OrderVO> {
|
|||
|
||||
if ("false".equals(resultObj.getString("success"))) {
|
||||
throw new BusinessException("RZMOM同步失败,原因:" + resultObj.getString("msg"));
|
||||
} else {
|
||||
log.error("RZMOM同步成功,返回参数【" + resultObj.toJSONString() + "】");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,14 +131,17 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<OrderVO> {
|
|||
UFDate dbilldate = item.getDbilldate();
|
||||
// 设置订单基本信息
|
||||
// 第三方系统表体主键id
|
||||
detailItem.put("htmx_wbid", item.getPk_order_b());
|
||||
detailItem.put("htmx_wbid", head.getPk_order() + "_" + item.getPk_order_b());
|
||||
//第三方系统合同ID
|
||||
detailItem.put("cght_wbid", head.getVbillcode());
|
||||
detailItem.put("cght_wbid", head.getPk_order());
|
||||
//操作状态 1新增/修改、2删除(删除时只需上传wbid)
|
||||
detailItem.put("operate", OPERATION_ADD);
|
||||
//zbxx_cglb_wbid varchar(100) 第三方系统采购类别id 必填 维护对应关系
|
||||
detailItem.put("zbxx_cglb_wbid", head.getVtrantypecode());
|
||||
|
||||
//zbxx_cgrq datetime 采购日期 必填 表头采购日期
|
||||
detailItem.put("zbxx_cgrq", head.getDbilldate().toString());
|
||||
|
||||
// detailItem.put("zbxx_cglb_wbid", null);
|
||||
// detailItem.put("zbxx_cglx", DEFAULT_PURCHASE_TYPE);
|
||||
|
||||
// 设置合同信息
|
||||
// 合同编号 必填 例如:采购订单编号:1001
|
||||
|
@ -145,20 +150,19 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<OrderVO> {
|
|||
detailItem.put("htxh", item.getCrowno());
|
||||
|
||||
// 设置物料信息
|
||||
detailItem.put("wlbm_wbid",transferCodeByPk(MaterialVO.getDefaultTableName(),MaterialVO.CODE,MaterialVO.PK_MATERIAL,item.getPk_material()));
|
||||
detailItem.put("wlbm_wbid", item.getPk_material());
|
||||
|
||||
// 设置数量信息
|
||||
UFDouble nastnum = item.getNastnum()==null?UFDouble.ZERO_DBL:item.getNastnum();
|
||||
UFDouble nastnum = item.getNastnum() == null ? UFDouble.ZERO_DBL : item.getNastnum();
|
||||
detailItem.put("cgsl", nastnum.getDouble());
|
||||
|
||||
//采购日期 必填 明细行的采购日期
|
||||
if (dbilldate != null) {
|
||||
detailItem.put("cgrq", dbilldate.toString());
|
||||
}
|
||||
// 设置供应商和采购员信息
|
||||
detailItem.put("zbxx_gycs_wbid", transferCodeByPk(SupplierVO.getDefaultTableName(),SupplierVO.CODE,SupplierVO.PK_SUPPLIER,head.getPk_supplier()));
|
||||
detailItem.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC,head.getCemployeeid()));
|
||||
|
||||
// zbxx_gycs_wbid varchar(100) 第三方系统厂商id 必填 厂商名称的ID
|
||||
detailItem.put("zbxx_gycs_wbid", head.getPk_supplier());
|
||||
//zbxx_cgy_wbid varchar(100) 第三方系统采购员id 维护对应关系
|
||||
detailItem.put("zbxx_cgy_wbid", head.getCemployeeid());
|
||||
// 设置计划日期
|
||||
// 交货日期 必填 明细行的交货日期
|
||||
if (item.getDplanarrvdate() != null) {
|
||||
|
@ -174,16 +178,12 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<OrderVO> {
|
|||
detailItem.put("cgxh", item.getVsourcerowno());
|
||||
|
||||
// 设置仓库和备注信息
|
||||
detailItem.put("sdck",transferCodeByPk(StordocVO.getDefaultTableName(),StordocVO.CODE, StordocVO.PK_STORDOC,item.getPk_reqstordoc()));
|
||||
detailItem.put("sdck", item.getPk_reqstordoc());
|
||||
detailItem.put("bzsm", item.getVbmemo());
|
||||
|
||||
// 设置状态信息
|
||||
detailItem.put("sdbj", STATUS_LOCKED);
|
||||
detailItem.put("qfbj", STATUS_ISSUED);
|
||||
|
||||
// 设置单位信息
|
||||
detailItem.put("jldw", null);
|
||||
|
||||
details.add(detailItem);
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<OrderVO> {
|
|||
* 根据主键查询编码
|
||||
*/
|
||||
private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException {
|
||||
if(StringUtils.isEmpty(pk)){
|
||||
if (StringUtils.isEmpty(pk)) {
|
||||
return null;
|
||||
}
|
||||
SqlBuilder sqlBuilder = new SqlBuilder();
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package nccloud.api.impl.so.m30;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import nc.bd.itf.tools.BFPubTools;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Logger;
|
||||
import nc.bs.trade.business.HYSuperDMO;
|
||||
import nc.bs.uapbd.bip.workplugin.IgnoreSslUtil;
|
||||
import nc.impl.pubapp.pattern.data.bill.BillQuery;
|
||||
import nc.itf.scmpub.reference.uap.bd.customer.CustomerPubService;
|
||||
import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil;
|
||||
|
@ -51,8 +55,17 @@ import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
|
|||
import nccloud.putitf.riart.billtype.IBilltypeService;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
* @Description: 销售订单维护实现类
|
||||
|
@ -61,7 +74,6 @@ import java.util.*;
|
|||
* @Copyright:
|
||||
*/
|
||||
public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
||||
|
||||
private static String BODYTABLE = "so_saleorder_b";
|
||||
private static String HEADTABLE = "so_saleorder";
|
||||
|
||||
|
@ -551,7 +563,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
if (vtrantypecode != null && !vtrantypecode.isEmpty()) {
|
||||
targetHVO.setVtrantypecode(vtrantypecode);
|
||||
}
|
||||
//订单关联合同号
|
||||
// 订单关联合同号
|
||||
|
||||
String vdef19 = sourceHVO.getVdef19();
|
||||
if (vdef19 != null && !vdef19.isEmpty()) {
|
||||
|
@ -1175,15 +1187,15 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
newBvo.setNqtunitnum(nastnum);// 报价单位数量
|
||||
|
||||
// 自定义项赋值
|
||||
String vbdef1 = bodydata.getOrDefault("vbdef1","") + "";// 合同编号
|
||||
String vbdef1 = bodydata.getOrDefault("vbdef1", "") + "";// 合同编号
|
||||
Map<String, String> defList = getDefList("zdy-001");
|
||||
newBvo.setVbdef1(defList.getOrDefault(vbdef1, ""));
|
||||
String vbdef5 = bodydata.getOrDefault("vbdef5","") + "";// 合同销售订单号
|
||||
String vbdef5 = bodydata.getOrDefault("vbdef5", "") + "";// 合同销售订单号
|
||||
defList.clear();
|
||||
defList = getDefList("BIP-ddh");
|
||||
newBvo.setVbdef5(defList.getOrDefault(vbdef5, ""));
|
||||
newBvo.setVbdef10(bodydata.getOrDefault("vbdef10","") + "");// 项目名称
|
||||
newBvo.setVbdef13(bodydata.getOrDefault("vbdef13","") + "");// 国网行项目号
|
||||
newBvo.setVbdef10(bodydata.getOrDefault("vbdef10", "") + "");// 项目名称
|
||||
newBvo.setVbdef13(bodydata.getOrDefault("vbdef13", "") + "");// 国网行项目号
|
||||
|
||||
bvoList.add(newBvo);
|
||||
}
|
||||
|
@ -1253,4 +1265,280 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
return new UFDouble(value.toString().trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* 回写BIP旗舰版的合同销售订单
|
||||
*
|
||||
* @author mzr
|
||||
* @date 2025/5/23
|
||||
*/
|
||||
@Override
|
||||
public void updateBipFlagSo(Map<String, Object> paramMap) throws Exception {
|
||||
String csaleorderbid = (String) paramMap.get("csaleorderbid");
|
||||
Map<String, Object> soMap = getSaleOrderInfo(csaleorderbid);
|
||||
// 如果没有存合同销售订单信息则不回写
|
||||
if (soMap.get("vbdef11") == null || soMap.get("vdef9") == null) {
|
||||
return;
|
||||
}
|
||||
Map<String, String> bipParamMap = checkBipParam();
|
||||
if (bipParamMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String baseUrl = bipParamMap.get("baseUrl");
|
||||
String soUpdateUrl = bipParamMap.get("contractSaleOrder");
|
||||
if (StringUtils.isEmpty(soUpdateUrl)) {
|
||||
return;
|
||||
}
|
||||
String accessToken = getAccessToken(baseUrl, bipParamMap);
|
||||
Map<String, String> tokenParam = new HashMap<>();
|
||||
tokenParam.put("access_token", accessToken);
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Content-Type", "application/json");
|
||||
String updateUrl = baseUrl + soUpdateUrl;
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
JSONObject updateJson = new JSONObject();
|
||||
List<Map<String, Object>> l_map_f = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// bomConfigureFinishDate BOM配置完成日期
|
||||
map.put("bomConfigureFinishDate", paramMap.get("vbdef16"));
|
||||
// craftConfigureFinishDate 工艺配置完成日期
|
||||
map.put("craftConfigureFinishDate", paramMap.get("vbdef17"));
|
||||
// BIP合同销售订单更新 子表id
|
||||
map.put("id", soMap.get("vbdef11"));
|
||||
l_map_f.add(map);
|
||||
updateJson.put("contractOrdersList", l_map_f);
|
||||
// BIP合同销售订单更新 主表id
|
||||
updateJson.put("id", soMap.get("vdef9"));
|
||||
bodyJson.put("HTXSDD", updateJson);
|
||||
String resultString = doSendHttp(updateUrl, "POST", tokenParam, "", headers, bodyJson.toJSONString());
|
||||
NCCForUAPLogger.debug("updateBipFlagSo-resultString:" + resultString);
|
||||
Logger.error("updateBipFlagSo-resultString:" + resultString);
|
||||
}
|
||||
|
||||
private Map<String, Object> getSaleOrderInfo(String csaleorderbid) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " select s.vdef9,s.csaleorderid," +
|
||||
" sb.csaleorderbid,sb.vbdef11" +
|
||||
" from so_saleorder_b sb" +
|
||||
" inner join so_saleorder s on sb.csaleorderid=s.csaleorderid" +
|
||||
" where sb.csaleorderbid='" + csaleorderbid + "' ";
|
||||
return (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
}
|
||||
|
||||
private Map<String, String> checkBipParam() {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='BIP-sq' and dr=0 ) and dr=0";
|
||||
try {
|
||||
DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
|
||||
if (defdocVOs != null && defdocVOs.length > 0) {
|
||||
for (DefdocVO defdocVO : defdocVOs) {
|
||||
map.put(defdocVO.getCode().trim(), defdocVO.getName());
|
||||
}
|
||||
}
|
||||
} catch (DAOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
private String getAccessToken(String baseUrl, Map<String, String> bipParamMap) throws Exception {
|
||||
String tokenUrl = baseUrl + "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";
|
||||
// String appKey = "f10c4bf17b1d4e1fb08eb82bf8540eab";
|
||||
String appKey = bipParamMap.get("appKey");
|
||||
|
||||
// String appSecret = "71dc2a58ca378c1a1143231a62e73e75a60e9236";
|
||||
String appSecret = bipParamMap.get("appSecret");
|
||||
String accessToken = "";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
|
||||
params.put("appKey", appKey);
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
params.put("timestamp", timestamp);
|
||||
// 计算签名
|
||||
Map<String, String> treeMap;
|
||||
if (params instanceof TreeMap) {
|
||||
treeMap = params;
|
||||
} else {
|
||||
treeMap = new TreeMap<>(params);
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : treeMap.entrySet()) {
|
||||
stringBuilder.append(entry.getKey()).append(entry.getValue());
|
||||
}
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
|
||||
mac.init(new SecretKeySpec(appSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
|
||||
byte[] signData = mac.doFinal(stringBuilder.toString().getBytes(StandardCharsets.UTF_8));
|
||||
String base64String = Base64.getEncoder().encodeToString(signData);
|
||||
String signature = URLEncoder.encode(base64String, "UTF-8");
|
||||
params.put("signature", signature);
|
||||
|
||||
String responseString = doGet(tokenUrl, params);
|
||||
|
||||
Gson gson = new Gson();
|
||||
Map result = gson.fromJson(responseString, Map.class);
|
||||
if (com.yonyou.cloud.utils.StringUtils.equals("00000", result.get("code").toString())) {
|
||||
Map<String, Object> tokenInfo = (Map<String, Object>) result.get("data");
|
||||
accessToken = (String) tokenInfo.get("access_token");
|
||||
|
||||
}
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public static String doSendHttp(String baseUrl, String method, Map<String, String> paramMap, String mediaType, Map<String, String> headers, String json) {
|
||||
HttpURLConnection urlConnection = null;
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
String result = null;
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(baseUrl);
|
||||
if (paramMap != null) {
|
||||
sb.append("?");
|
||||
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
sb.append(key).append("=").append(value).append("&");
|
||||
baseUrl = sb.substring(0, sb.toString().length() - 1);
|
||||
}
|
||||
}
|
||||
URL urlobj = new URL(baseUrl);
|
||||
if ("https".equalsIgnoreCase(urlobj.getProtocol())) {// 判定网址是否信任,不信任则调用忽略信任工具类SslUtil
|
||||
IgnoreSslUtil.ignoreSsl();
|
||||
}
|
||||
urlConnection = (HttpURLConnection) urlobj.openConnection();
|
||||
urlConnection.setConnectTimeout(50000);
|
||||
urlConnection.setRequestMethod(method);
|
||||
urlConnection.setDoInput(true);
|
||||
urlConnection.setUseCaches(false);
|
||||
// 如果设置了自定义头,则打印它们
|
||||
if (headers != null && !headers.isEmpty()) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
urlConnection.addRequestProperty(entry.getKey(), entry.getValue());
|
||||
// log.error("Request Header: " + entry.getKey() + ": " + entry.getValue());
|
||||
}
|
||||
}
|
||||
if (json != null && !json.isEmpty()) {
|
||||
// log.error("Request Body: " + json);
|
||||
urlConnection.setDoInput(true);
|
||||
urlConnection.setDoOutput(true);
|
||||
out = urlConnection.getOutputStream();
|
||||
out.write(json.getBytes(StandardCharsets.UTF_8));
|
||||
out.flush();
|
||||
}
|
||||
int resCode = urlConnection.getResponseCode();
|
||||
String ecod = urlConnection.getContentEncoding();
|
||||
if (resCode == HttpURLConnection.HTTP_OK || resCode == HttpURLConnection.HTTP_CREATED
|
||||
|| resCode == HttpURLConnection.HTTP_ACCEPTED) {
|
||||
if (com.yonyou.cloud.utils.StringUtils.isNotEmpty(ecod) && ecod.equals("gzip")) {
|
||||
in = new GZIPInputStream(urlConnection.getInputStream());
|
||||
} else {
|
||||
in = urlConnection.getInputStream();
|
||||
}
|
||||
} else {
|
||||
in = urlConnection.getErrorStream();
|
||||
}
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
StringBuilder temp = new StringBuilder();
|
||||
String line = bufferedReader.readLine();
|
||||
while (line != null) {
|
||||
temp.append(line).append("\r\n");
|
||||
line = bufferedReader.readLine();
|
||||
}
|
||||
if (ecod == null || ecod.equals("gzip")) {
|
||||
ecod = StandardCharsets.UTF_8.name();
|
||||
}
|
||||
result = new String(temp.toString().getBytes(StandardCharsets.UTF_8), ecod);
|
||||
} catch (Exception e) {
|
||||
JSONObject js = new JSONObject();
|
||||
js.put("", -1);
|
||||
js.put("message", "调用外系统接口失败:" + e.getMessage());
|
||||
result = js.toString();
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (null != bufferedReader) {
|
||||
try {
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != out) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != in) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
urlConnection.disconnect();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String doGet(String path, Map<String, String> params) throws Exception {
|
||||
HttpURLConnection conn = null;
|
||||
InputStream is = null;
|
||||
BufferedReader br = null;
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
if (params != null) {
|
||||
String paramStr = "";
|
||||
for (String key : params.keySet()) {
|
||||
if (!paramStr.isEmpty()) {
|
||||
paramStr += '&';
|
||||
}
|
||||
paramStr += key + '=' + params.get(key);
|
||||
}
|
||||
|
||||
if (path.indexOf('?') > 0) {
|
||||
path += '&' + paramStr;
|
||||
} else {
|
||||
path += '?' + paramStr;
|
||||
}
|
||||
}
|
||||
// 创建远程url连接对象
|
||||
URL url = new URL(path);
|
||||
if ("https".equalsIgnoreCase(url.getProtocol())) {// 判定网址是否信任,不信任则调用忽略信任工具类SslUtil
|
||||
IgnoreSslUtil.ignoreSsl();
|
||||
}
|
||||
// 通过远程url连接对象打开一个连接,强转成HTTPURLConnection类
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
// 设置连接超时时间和读取超时时间
|
||||
conn.setConnectTimeout(120000);
|
||||
conn.setReadTimeout(120000);
|
||||
conn.setRequestProperty("Accept", "application/json");
|
||||
// 发送请求
|
||||
conn.connect();
|
||||
// 通过conn取得输入流,并使用Reader读取
|
||||
if (200 == conn.getResponseCode()) {
|
||||
is = conn.getInputStream();
|
||||
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
result.append(line);
|
||||
System.out.println(line);
|
||||
}
|
||||
} else {
|
||||
System.out.println("ResponseCode is an error code:" + conn.getResponseCode());
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,4 +21,6 @@ public interface IAPISaleOrderMaitain {
|
|||
SaleOrderVO[] unApprove(String[] paramArrayOfString) throws BusinessException;
|
||||
|
||||
public SaleOrderVO[] save(SaleOrderVO[] vos) throws BusinessException;
|
||||
|
||||
public void updateBipFlagSo(Map<String, Object> paramMap) throws Exception;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package nccloud.openapi.so.m30;
|
||||
|
||||
import nc.bd.itf.tools.BFPubTools;
|
||||
|
@ -75,8 +74,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
}
|
||||
}
|
||||
|
||||
IAPISaleOrderMaitain service = (IAPISaleOrderMaitain) NCLocator.getInstance()
|
||||
.lookup(IAPISaleOrderMaitain.class);
|
||||
IAPISaleOrderMaitain service = (IAPISaleOrderMaitain) NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class);
|
||||
SaleOrderVO[] results = service.save(paramList);
|
||||
|
||||
return ResultMessageUtil.toJSON(results, "销售订单新增保存成功");
|
||||
|
@ -143,16 +141,14 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
List<Object> bodyArr = (List<Object>) map.get(BODYTABLE);
|
||||
for (Object body : bodyArr) {
|
||||
Map<String, Object> bodydata = (Map<String, Object>) body;
|
||||
String sql = " select pk_project from bd_project where project_code='" + headdata.get("vdef6")
|
||||
+ "' and nvl(dr,0)=0 ";
|
||||
String sql = " select pk_project from bd_project where project_code='" + headdata.get("vdef6") + "' and nvl(dr,0)=0 ";
|
||||
String o_pk_project = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
|
||||
bodydata.put("cprojectid", o_pk_project);
|
||||
}
|
||||
}
|
||||
|
||||
// 参数形式转换为vo并翻译
|
||||
List<SaleOrderVO> vosList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, SaleOrderVO.class);
|
||||
List<SaleOrderVO> vosList = TransferMapToVOTool.transferMapToAggVO(paramList, SaleOrderVO.class);
|
||||
vosList = TransferCodeToPKTool.transferAggVO(vosList);
|
||||
SaleOrderVO[] vos = vosList.toArray(new SaleOrderVO[vosList.size()]);
|
||||
|
||||
|
@ -171,8 +167,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
ArrayList<String> arrhth = new ArrayList<String>();
|
||||
ArrayList<String> arrxmh = new ArrayList<String>();
|
||||
ArrayList<String> arrxsddh = new ArrayList<String>();
|
||||
String sql = " select pk_org,pk_vid from org_orgs where org_orgs.code='" + salevos[0].getParentVO().getPk_org()
|
||||
+ "' and nvl(dr,0)=0 and isbusinessunit='Y' ";
|
||||
String sql = " select pk_org,pk_vid from org_orgs where org_orgs.code='" + salevos[0].getParentVO().getPk_org() + "' and nvl(dr,0)=0 and isbusinessunit='Y' ";
|
||||
|
||||
Map map = (Map) baseDAO.executeQuery(sql, new MapProcessor());
|
||||
if (map == null) {
|
||||
|
@ -183,8 +178,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
String cprocode = salevos[0].getChildrenVO()[0].getCprojectid();
|
||||
String cproname = salevos[0].getChildrenVO()[0].getVbdef10();
|
||||
if (!BFPubTools.getString_TrimAsNull(cprocode).equals("")) {
|
||||
sql = " select pk_project from bd_project where project_code='" + cprocode + "' and pk_duty_org='" + o
|
||||
+ "' and nvl(dr,0)=0 ";
|
||||
sql = " select pk_project from bd_project where project_code='" + cprocode + "' and pk_duty_org='" + o + "' and nvl(dr,0)=0 ";
|
||||
String o_pk_project = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
|
||||
if (o_pk_project == null) {
|
||||
// 新增项目档案
|
||||
|
@ -210,8 +204,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
|
||||
}
|
||||
if (arrhth.size() > 0) {
|
||||
sql = " select code from bd_defdoc where pk_defdoclist in(select pk_defdoclist from bd_defdoclist where code='zdy-001') and pk_org='"
|
||||
+ o + "' and ";
|
||||
sql = " select code from bd_defdoc where pk_defdoclist in(select pk_defdoclist from bd_defdoclist where code='zdy-001') and pk_org='" + o + "' and ";
|
||||
sql += BFPubTools.getInSqlWithOutAnd("code", arrhth, 0, arrhth.size());
|
||||
ArrayList<String> obj_arrhth = (ArrayList<String>) baseDAO.executeQuery(sql, new ColumnListProcessor());
|
||||
if (obj_arrhth != null && obj_arrhth.size() > 0) {
|
||||
|
@ -221,13 +214,11 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
|
||||
// 组装销售订单数据
|
||||
if (arrhth.size() > 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(o,
|
||||
createDefVO(arrhth, "zdy-001", o.toString()));
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(o, createDefVO(arrhth, "zdy-001", o.toString()));
|
||||
}
|
||||
|
||||
if (arrxmh.size() > 0) {
|
||||
sql = " select code from bd_defdoc where pk_defdoclist in(select pk_defdoclist from bd_defdoclist where code='BQxmh') and pk_org='"
|
||||
+ o + "' and ";
|
||||
sql = " select code from bd_defdoc where pk_defdoclist in(select pk_defdoclist from bd_defdoclist where code='BQxmh') and pk_org='" + o + "' and ";
|
||||
sql += BFPubTools.getInSqlWithOutAnd("code", arrxmh, 0, arrxmh.size());
|
||||
ArrayList<String> obj_arrhth = (ArrayList<String>) baseDAO.executeQuery(sql, new ColumnListProcessor());
|
||||
|
||||
|
@ -238,13 +229,11 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
|
||||
}
|
||||
if (arrxmh.size() > 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(o,
|
||||
createDefVO(arrxmh, "BQxmh", o.toString()));
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(o, createDefVO(arrxmh, "BQxmh", o.toString()));
|
||||
}
|
||||
|
||||
if (arrxsddh.size() > 0) {
|
||||
sql = " select code from bd_defdoc where pk_defdoclist in( select pk_defdoclist from bd_defdoclist where code='BIP-ddh') and pk_org='"
|
||||
+ o + "' and ";
|
||||
sql = " select code from bd_defdoc where pk_defdoclist in( select pk_defdoclist from bd_defdoclist where code='BIP-ddh') and pk_org='" + o + "' and ";
|
||||
sql += BFPubTools.getInSqlWithOutAnd("code", arrxsddh, 0, arrxsddh.size());
|
||||
ArrayList<String> obj_arrhth = (ArrayList<String>) baseDAO.executeQuery(sql, new ColumnListProcessor());
|
||||
if (obj_arrhth != null && obj_arrhth.size() > 0) {
|
||||
|
@ -252,8 +241,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
}
|
||||
}
|
||||
if (arrxsddh.size() > 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(o,
|
||||
createDefVO(arrxsddh, "BIP-ddh", o.toString()));
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(o, createDefVO(arrxsddh, "BIP-ddh", o.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -307,8 +295,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
}
|
||||
|
||||
private void setMaterl(Map<String, Object> bodydata) throws BusinessException {
|
||||
String sql = " select a.pk_material,a.pk_source, a.pk_measdoc cunitid,nvl(b.pk_measdoc,a.pk_measdoc) castunitid,nvl(b.measrate,'1/1') measrate from bd_material a left join bd_materialconvert b on a.pk_material=b.pk_material where a.code='"
|
||||
+ bodydata.get("cmaterialvid") + "' ";
|
||||
String sql = " select a.pk_material,a.pk_source, a.pk_measdoc cunitid,nvl(b.pk_measdoc,a.pk_measdoc) castunitid,nvl(b.measrate,'1/1') measrate from bd_material a left join bd_materialconvert b on a.pk_material=b.pk_material where a.code='" + bodydata.get("cmaterialvid") + "' ";
|
||||
Map map = (Map) getDao().executeQuery(sql, new MapProcessor());
|
||||
if (map == null) {
|
||||
throw new BusinessException(bodydata.get("cmaterialvid") + "物料未查到");
|
||||
|
@ -322,13 +309,10 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
bodydata.put("cmaterialid", map.get("pk_material"));
|
||||
bodydata.put("cmaterialvid", map.get("pk_source"));
|
||||
|
||||
bodydata.put("nqtunitnum", BFPubTools.getUFDouble_NullAsZero(bodydata.get("nnum"))
|
||||
.div(BFPubTools.getUFDouble_NullAsZero(map.get("measrate").toString().split("/")[0])));
|
||||
bodydata.put("nqtunitnum", BFPubTools.getUFDouble_NullAsZero(bodydata.get("nnum")).div(BFPubTools.getUFDouble_NullAsZero(map.get("measrate").toString().split("/")[0])));
|
||||
|
||||
bodydata.put("nastnum", BFPubTools.getUFDouble_NullAsZero(bodydata.get("nnum"))
|
||||
.div(BFPubTools.getUFDouble_NullAsZero(map.get("measrate").toString().split("/")[0])));
|
||||
sql = "select sl.pk_taxcode from bd_taxrate sl inner join bd_taxcode sm on sl.pk_taxcode=sm.pk_taxcode where sl.taxrate="
|
||||
+ bodydata.get("ntaxrate") + " and sm.pk_group<>'~' " + "";
|
||||
bodydata.put("nastnum", BFPubTools.getUFDouble_NullAsZero(bodydata.get("nnum")).div(BFPubTools.getUFDouble_NullAsZero(map.get("measrate").toString().split("/")[0])));
|
||||
sql = "select sl.pk_taxcode from bd_taxrate sl inner join bd_taxcode sm on sl.pk_taxcode=sm.pk_taxcode where sl.taxrate=" + bodydata.get("ntaxrate") + " and sm.pk_group<>'~' " + "";
|
||||
|
||||
String o_pk_project = (String) getDao().executeQuery(sql, new ColumnProcessor());
|
||||
bodydata.put("ctaxcodeid", o_pk_project);
|
||||
|
@ -348,14 +332,12 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
|
||||
paramList.add(paramMap);
|
||||
|
||||
IAPISaleOrderMaitain service = (IAPISaleOrderMaitain) NCLocator.getInstance()
|
||||
.lookup(IAPISaleOrderMaitain.class);
|
||||
IAPISaleOrderMaitain service = (IAPISaleOrderMaitain) NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class);
|
||||
SaleOrderVO[] results = service.update(paramList);
|
||||
|
||||
// return ResultMessageUtil.toJSON(results, "销售订单修改成功");
|
||||
// 包装返回信息
|
||||
return NCCRestUtils.toJSONString(CallReturnBuildUtil.buildSuccessResult(
|
||||
results, "ÏúÊÛ¶©µ¥Ð޸ijɹ¦"));
|
||||
return NCCRestUtils.toJSONString(CallReturnBuildUtil.buildSuccessResult(results, "销售订单修改成功"));
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
|
@ -397,8 +379,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
SaleOrderVO[] resultVOs = null;
|
||||
|
||||
try {
|
||||
resultVOs = ((IAPISaleOrderQuery) NCLocator.getInstance().lookup(IAPISaleOrderQuery.class))
|
||||
.queryByScheme(paramMap);
|
||||
resultVOs = ((IAPISaleOrderQuery) NCLocator.getInstance().lookup(IAPISaleOrderQuery.class)).queryByScheme(paramMap);
|
||||
|
||||
return ResultMessageUtil.toJSON(resultVOs, "查询销售订单成功");
|
||||
} catch (Exception e) {
|
||||
|
@ -419,8 +400,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
}
|
||||
|
||||
try {
|
||||
sendApprove = ((IAPISaleOrderMaitain) NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class))
|
||||
.sendApprove(hids);
|
||||
sendApprove = ((IAPISaleOrderMaitain) NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class)).sendApprove(hids);
|
||||
return ResultMessageUtil.toJSON(sendApprove, "销售订单提交成功");
|
||||
} catch (BusinessException e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
|
@ -440,8 +420,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
}
|
||||
|
||||
try {
|
||||
unSend = ((IAPISaleOrderMaitain) NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class))
|
||||
.unSendApprove(hids);
|
||||
unSend = ((IAPISaleOrderMaitain) NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class)).unSendApprove(hids);
|
||||
return ResultMessageUtil.toJSON(unSend, "销售订单收回成功");
|
||||
} catch (BusinessException e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
|
@ -479,8 +458,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
return ResultMessageUtil.exceptionToJSON("传入参数为空,请检查", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
try {
|
||||
unaprove = ((IAPISaleOrderMaitain) NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class))
|
||||
.unApprove(hids);
|
||||
unaprove = ((IAPISaleOrderMaitain) NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class)).unApprove(hids);
|
||||
return ResultMessageUtil.toJSON(unaprove, "销售订单取消审批成功");
|
||||
} catch (BusinessException e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
|
@ -521,8 +499,12 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
parameter.addParam(csaleorderbid);
|
||||
BaseDAO baseDAO = new BaseDAO();
|
||||
int num = baseDAO.executeUpdate(sql.toString(), parameter);
|
||||
if (num > 0) {
|
||||
// 回写合同平台的对应字段
|
||||
NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class).updateBipFlagSo(paramMap);
|
||||
}
|
||||
return ResultMessageUtil.toJSON(num, "销售订单修改成功");
|
||||
} catch (BusinessException e) {
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,12 @@ import java.io.InputStream;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
@ -20,6 +18,9 @@ import com.google.gson.Gson;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.itf.uap.IUAPQueryBS;
|
||||
import nc.jdbc.framework.processor.MapProcessor;
|
||||
import org.apache.http.client.config.CookieSpecs;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
@ -44,210 +45,214 @@ import nccloud.framework.web.action.itf.ICommonAction;
|
|||
import nccloud.framework.web.container.IRequest;
|
||||
import nccloud.itf.sscivm.ivsale.service.IVSaleQueryService;
|
||||
import nccloud.pubitf.platform.attachment.IAttachmentService;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class InvoiceDownloadAction implements ICommonAction {
|
||||
|
||||
IAttachmentService ncservice = ServiceLocator.find(IAttachmentService.class);
|
||||
IAttachmentService ncservice = ServiceLocator.find(IAttachmentService.class);
|
||||
|
||||
@Override
|
||||
public Object doAction(IRequest request) {
|
||||
@Override
|
||||
public Object doAction(IRequest request) {
|
||||
Map<String, String[]> params_1 = request.readParameters();
|
||||
String[] pks = params_1.get("pk"); // 获取所有 pk
|
||||
String[] arrInvoiceTypes = params_1.get("arrInvoiceTypes");
|
||||
String isdoc = "z";
|
||||
WebFile file = null;
|
||||
|
||||
Map<String, String[]> params_1 = request.readParameters();
|
||||
try {
|
||||
// 创建内存中的 ZIP 输出流
|
||||
ByteArrayOutputStream zipOut = new ByteArrayOutputStream();
|
||||
ZipOutputStream zipStream = new ZipOutputStream(zipOut);
|
||||
String zipName = "";
|
||||
// 遍历所有 pk
|
||||
for (String pk : pks) {
|
||||
List<IVMInvoiceHeadVO> headVOList = ServiceLocator.find(IVSaleQueryService.class).queryIVMInvoiceHeadVOsByPks(new String[]{pk});
|
||||
IVMInvoiceHeadVO headVO = headVOList.get(0);
|
||||
|
||||
String[] pk = params_1.get("pk");
|
||||
String[] invoiceTypes = params_1.get("invoiceType");
|
||||
String isdoc = "z";
|
||||
WebFile file = null;
|
||||
try {
|
||||
List<IVMInvoiceHeadVO> headVOList =ServiceLocator.find(IVSaleQueryService.class).queryIVMInvoiceHeadVOsByPks(new String[] {pk[0]});
|
||||
IVMInvoiceHeadVO headVO = headVOList.get(0);
|
||||
String invoiceType = invoiceTypes[0];
|
||||
// 获取旗舰版的token
|
||||
String appKey = "8c9eb1ea1ba54b3f9683a8b355f8e615";
|
||||
String appSecret = "999e15c2a13ee4eab480534be4bf52fdf9032a6d";
|
||||
String tokenUrl = "https://c2.yonyoucloud.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";
|
||||
String getbsfileUrl = "https://c2.yonyoucloud.com/iuap-api-gateway/yonbip/tax/output-tax/api/einvoice/getbsfile?access_token=";
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("appKey", appKey);
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
params.put("timestamp", timestamp);
|
||||
|
||||
// 计算签名
|
||||
Map<String, String> treeMap = new TreeMap<>(params);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : treeMap.entrySet()) {
|
||||
stringBuilder.append(entry.getKey()).append(entry.getValue());
|
||||
}
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(new SecretKeySpec(appSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
|
||||
byte[] signData = mac.doFinal(stringBuilder.toString().getBytes(StandardCharsets.UTF_8));
|
||||
String base64String = Base64.getEncoder().encodeToString(signData);
|
||||
String signature = URLEncoder.encode(base64String, "UTF-8");
|
||||
params.put("signature", signature);
|
||||
|
||||
String responseString = doGet(tokenUrl, params);
|
||||
Gson gson = new Gson();
|
||||
Map result = gson.fromJson(responseString, Map.class);
|
||||
|
||||
if (StringUtils.equals("00000", result.get("code").toString())) {
|
||||
Map<String, Object> tokenInfo = (Map<String, Object>) result.get("data");
|
||||
String access_token = (String) tokenInfo.get("access_token");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("fplx", headVO.getInvoice_type());
|
||||
map.put("slfphm", headVO.getFphm());
|
||||
map.put("yypdf", "0");
|
||||
map.put("taxpdf", Arrays.asList(arrInvoiceTypes).contains("1") ? "1" : "0");
|
||||
map.put("taxxml", Arrays.asList(arrInvoiceTypes).contains("2") ? "1" : "0");
|
||||
map.put("taxofd", Arrays.asList(arrInvoiceTypes).contains("3") ? "1" : "0");
|
||||
|
||||
String resString = doPost(getbsfileUrl + access_token, map);
|
||||
gson = new Gson();
|
||||
Map resultMap = gson.fromJson(resString, Map.class);
|
||||
|
||||
if (StringUtils.equals("200", resultMap.get("code").toString())) {
|
||||
Map<String, Object> infoMap = (Map<String, Object>) resultMap.get("data");
|
||||
String pdfData = (String) infoMap.get("taxpdf");
|
||||
String xmlData = (String) infoMap.get("taxxml");
|
||||
String ofdData = (String) infoMap.get("taxofd");
|
||||
|
||||
if (MMValueCheck.isEmpty(pdfData) && MMValueCheck.isEmpty(xmlData) && MMValueCheck.isEmpty(ofdData)) {
|
||||
throw new Exception("未查询到发票信息");
|
||||
}
|
||||
|
||||
String ctcode = "";
|
||||
HYSuperDMO dmo = new HYSuperDMO();
|
||||
IVApplogVO[] ivApplogVO = (IVApplogVO[]) dmo.queryByWhereClause(IVApplogVO.class, "fphm='" + headVO.getFphm() + "' and dr=0 ");
|
||||
if (ivApplogVO != null && ivApplogVO.length > 0) {
|
||||
IVApplicationHeadVO ivApplicationHeadVO = (IVApplicationHeadVO) dmo.queryByPrimaryKey(IVApplicationHeadVO.class, ivApplogVO[0].getLyid());
|
||||
// ctcode = ivApplicationHeadVO.getDef2(); // 合同号
|
||||
String operationSql = "SELECT bd.NAME name from bd_defdoc bd LEFT join bd_defdoclist bdl ON bd.pk_defdoclist=bdl.pk_defdoclist WHERE bdl.code ='zdy-001'\n" +
|
||||
"AND bd.pk_defdoc = '" + ivApplicationHeadVO.getDef2().toString() + "' ";
|
||||
// List<Map<String,Object>> operationresult = (List<Map<String,Object>>) getQueryService().executeQuery(operationSql, new ArrayListProcessor());
|
||||
Map<String, Object> valList = (Map<String, Object>) getQueryService().executeQuery(operationSql, new MapProcessor());
|
||||
ctcode = (String) valList.get("name");
|
||||
}
|
||||
|
||||
// 添加 PDF
|
||||
if (!MMValueCheck.isEmpty(pdfData)) {
|
||||
byte[] pdfBytes = DatatypeConverter.parseBase64Binary(pdfData);
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + "_" + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".pdf"));
|
||||
zipStream.write(pdfBytes);
|
||||
zipStream.closeEntry();
|
||||
}
|
||||
|
||||
// 添加 XML
|
||||
if (!MMValueCheck.isEmpty(xmlData)) {
|
||||
byte[] xmlBytes = DatatypeConverter.parseBase64Binary(xmlData);
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + "_" + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".xml"));
|
||||
zipStream.write(xmlBytes);
|
||||
zipStream.closeEntry();
|
||||
}
|
||||
|
||||
// 添加 OFD
|
||||
if (!MMValueCheck.isEmpty(ofdData)) {
|
||||
byte[] ofdBytes = DatatypeConverter.parseBase64Binary(ofdData);
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + "_" + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".ofd"));
|
||||
zipStream.write(ofdBytes);
|
||||
zipStream.closeEntry();
|
||||
}
|
||||
zipName=ctcode + "_" + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble());
|
||||
} else {
|
||||
throw new Exception("获取发票信息失败");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("获取access_token失败");
|
||||
}
|
||||
}
|
||||
|
||||
zipStream.finish();
|
||||
zipStream.close();
|
||||
if(pks.length > 1){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
zipName = "发票下载_" + sdf.format(new Date());
|
||||
}
|
||||
// 构造 WebFile 返回 ZIP 文件
|
||||
InputStream ins = new ByteArrayInputStream(zipOut.toByteArray());
|
||||
file = new WebFile(zipName+".zip", ins);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
ExceptionUtils.wrappException(e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
// 获取旗舰版的token
|
||||
String appKey = "8c9eb1ea1ba54b3f9683a8b355f8e615";
|
||||
String appSecret = "999e15c2a13ee4eab480534be4bf52fdf9032a6d";
|
||||
String tokenUrl="https://c2.yonyoucloud.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";
|
||||
String getbsfileUrl="https://c2.yonyoucloud.com/iuap-api-gateway/yonbip/tax/output-tax/api/einvoice/getbsfile?access_token=";
|
||||
private String doPost(String requestUrl, Map<String, Object> param) throws IOException {
|
||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
||||
cm.setMaxTotal(500);
|
||||
cm.setDefaultMaxPerRoute(50);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
RequestConfig globalConfig = RequestConfig.custom().setConnectionRequestTimeout(5000) // 连接池获取连接超时
|
||||
.setConnectTimeout(5000) // 连接建立超时
|
||||
.setSocketTimeout(20000) // 等待响应超时
|
||||
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
|
||||
|
||||
// 除签名外的其他参数
|
||||
params.put("appKey", appKey);
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
params.put("timestamp", timestamp);
|
||||
// 计算签名
|
||||
Map<String, String> treeMap;
|
||||
if (params instanceof TreeMap) {
|
||||
treeMap = params;
|
||||
} else {
|
||||
treeMap = new TreeMap<>(params);
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : treeMap.entrySet()) {
|
||||
stringBuilder.append(entry.getKey()).append(entry.getValue());
|
||||
}
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm)
|
||||
.setDefaultRequestConfig(globalConfig).build();
|
||||
HttpPost post = new HttpPost(requestUrl);
|
||||
post.setHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
post.setEntity(new StringEntity(JSONObject.toJSONString(param), "utf-8"));
|
||||
String responseString = httpClient.execute(post, response -> EntityUtils.toString(response.getEntity()));
|
||||
return responseString;
|
||||
|
||||
mac.init(new SecretKeySpec(appSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
|
||||
byte[] signData = mac.doFinal(stringBuilder.toString().getBytes(StandardCharsets.UTF_8));
|
||||
String base64String = Base64.getEncoder().encodeToString(signData);
|
||||
String signature = URLEncoder.encode(base64String, "UTF-8");
|
||||
params.put("signature", signature);
|
||||
// String responseString = doGet(
|
||||
// "https://c1.yonyoucloud.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken", params);
|
||||
String responseString = doGet(tokenUrl, params);
|
||||
Gson gson = new Gson();
|
||||
Map result = gson.fromJson(responseString, Map.class);
|
||||
|
||||
if (StringUtils.equals("00000", result.get("code").toString())) {
|
||||
|
||||
Map<String, Object> tokenInfo = (Map<String, Object>) result.get("data");
|
||||
String access_token = (String) tokenInfo.get("access_token");
|
||||
// 税务服务-调用销项发票管理-已开票-版式文件查询接口
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 发票类型 1:增值税电子普通发票; 2:增值税电子专用发票; 3:增值税普通发票; 4:增值税专用发票 、增值税专用发票(机动车); 5:机动车销售统一发票; 8:增值税电子普通发票(成品油); 10:成品油普通发票; 11:成品油专用发票; 15:二手车销售统一发票; 31:数电专用发票; 32:数电普通发票; 33:数电纸质发票(增值税专用发票); 34:数电纸质发票(普通发票);
|
||||
map.put("fplx", headVO.getInvoice_type());
|
||||
// 数电发票号码
|
||||
map.put("slfphm", headVO.getFphm());
|
||||
// 用友自画pdf
|
||||
map.put("yypdf", "0");
|
||||
// 税局pdf
|
||||
map.put("taxpdf", "1".equals(invoiceType) ? "1" : "0");
|
||||
// 税局xml
|
||||
map.put("taxxml", "2".equals(invoiceType) ? "1" : "0");
|
||||
// 税局ofd
|
||||
map.put("taxofd", "3".equals(invoiceType) ? "1" : "0");
|
||||
// String resString = doPost(
|
||||
// "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/tax/output-tax/api/einvoice/getbsfile?access_token=" + access_token,
|
||||
// map);
|
||||
|
||||
String resString = doPost(getbsfileUrl + access_token,map);
|
||||
gson = new Gson();
|
||||
|
||||
Map resultMap = gson.fromJson(resString, Map.class);
|
||||
if (StringUtils.equals("200", resultMap.get("code").toString())) {
|
||||
Map<String, Object> infoMap = (Map<String, Object>) resultMap.get("data");
|
||||
String tax = "1".equals(invoiceType) ? (String) infoMap.get("taxpdf") : "2".equals(invoiceType) ? (String) infoMap.get("taxxml") : "3".equals(invoiceType) ? (String) infoMap.get("taxofd") : "";
|
||||
if (MMValueCheck.isEmpty(tax)) {
|
||||
throw new Exception("未查询到发票信息");
|
||||
}
|
||||
byte[] imageBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary(tax);
|
||||
InputStream ins = new ByteArrayInputStream(imageBytes);
|
||||
String Fphm = headVO.getFphm();
|
||||
|
||||
//发票号码+单位名称+合同号(开票申请字段)+金额(发票上的价税合计)
|
||||
String filename = "1".equals(invoiceType) ? ".pdf" : "2".equals(invoiceType) ? ".xml" : "3".equals(invoiceType) ? ".ofd" : "";
|
||||
}
|
||||
|
||||
|
||||
String ctcode="";
|
||||
HYSuperDMO dmo = new HYSuperDMO();
|
||||
IVApplogVO[] ivApplogVO=(IVApplogVO[]) dmo.queryByWhereClause(IVApplogVO.class, "fphm='"+Fphm+"' and dr=0 ");
|
||||
if(ivApplogVO!=null&&ivApplogVO.length>0) {
|
||||
ivApplogVO[0].getLyid();//开票申请单主键
|
||||
IVApplicationHeadVO ivApplicationHeadVO =(IVApplicationHeadVO) dmo.queryByPrimaryKey(IVApplicationHeadVO.class, ivApplogVO[0].getLyid());
|
||||
ctcode=ivApplicationHeadVO.getDef2();//合同号
|
||||
}
|
||||
//发票号码+单位名称+合同号(开票申请字段)+金额(发票上的价税合计) 合同号_单位名称_发票号码_金额
|
||||
private String doGet(String requestUrl, Map<String, String> paramMap) throws IOException {
|
||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
||||
cm.setMaxTotal(500);
|
||||
cm.setDefaultMaxPerRoute(50);
|
||||
|
||||
// 合同号_单位名称_发票号码_金额
|
||||
RequestConfig globalConfig = RequestConfig.custom().setConnectionRequestTimeout(5000) // 连接池获取连接超时
|
||||
.setConnectTimeout(5000) // 连接建立超时
|
||||
.setSocketTimeout(20000) // 等待响应超时
|
||||
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
|
||||
|
||||
String name = ctcode+"_"+headVO.getGmfmc()+"_"+Fphm+"_"+String.valueOf(headVO.getJshj().toDouble()) + filename;
|
||||
|
||||
// String name = Fphm+"_"+headVO.getGmfmc()+"_"+ctcode+"_"+String.valueOf(headVO.getJshj().toDouble()) + filename;
|
||||
file = new WebFile(name, ins);
|
||||
} else {
|
||||
throw new Exception("获取发票信息失败");
|
||||
}
|
||||
|
||||
}else {
|
||||
throw new Exception("获取access_token失败");
|
||||
}
|
||||
// String url = "";
|
||||
// IVMInvoiceHeadVO headVO = headVOList.get(0);
|
||||
//
|
||||
// if (headVOList != null && headVOList.size() > 0) {
|
||||
// url = headVO.getViewurl();
|
||||
// }
|
||||
// InputStream ins = this.ncservice.download(isdoc, url, "sscivm");
|
||||
// String Fpdm = headVO.getFpdm();
|
||||
// String Fphm = headVO.getFphm();
|
||||
// String name = headVO.getFilename();
|
||||
// String filename = ".pdf";
|
||||
// if(name!=null && name.endsWith(".ofd")){
|
||||
// filename = ".ofd";
|
||||
// }
|
||||
// file = new WebFile(Fpdm + "_" + Fphm + filename, ins);
|
||||
} catch (BusinessException e) {
|
||||
ExceptionUtils.wrappException(e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
private String doPost(String requestUrl, Map<String, Object> param) throws IOException {
|
||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
||||
cm.setMaxTotal(500);
|
||||
cm.setDefaultMaxPerRoute(50);
|
||||
|
||||
RequestConfig globalConfig = RequestConfig.custom().setConnectionRequestTimeout(5000) // 连接池获取连接超时
|
||||
.setConnectTimeout(5000) // 连接建立超时
|
||||
.setSocketTimeout(20000) // 等待响应超时
|
||||
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm)
|
||||
.setDefaultRequestConfig(globalConfig).build();
|
||||
HttpPost post = new HttpPost(requestUrl);
|
||||
post.setHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
post.setEntity(new StringEntity(JSONObject.toJSONString(param), "utf-8"));
|
||||
String responseString = httpClient.execute(post, response -> EntityUtils.toString(response.getEntity()));
|
||||
return responseString;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String doGet(String requestUrl, Map<String, String> paramMap) throws IOException {
|
||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
||||
cm.setMaxTotal(500);
|
||||
cm.setDefaultMaxPerRoute(50);
|
||||
|
||||
RequestConfig globalConfig = RequestConfig.custom().setConnectionRequestTimeout(5000) // 连接池获取连接超时
|
||||
.setConnectTimeout(5000) // 连接建立超时
|
||||
.setSocketTimeout(20000) // 等待响应超时
|
||||
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm)
|
||||
.setDefaultRequestConfig(globalConfig).build();
|
||||
StringBuilder param = new StringBuilder("?");
|
||||
if (paramMap != null) {
|
||||
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
|
||||
param.append(entry.getKey());
|
||||
param.append("=");
|
||||
param.append(entry.getValue());
|
||||
param.append("&");
|
||||
}
|
||||
param.deleteCharAt(param.length() - 1);
|
||||
}
|
||||
String url = requestUrl + param;
|
||||
HttpGet get = new HttpGet(url);
|
||||
String responseString = httpClient.execute(get, response -> EntityUtils.toString(response.getEntity()));
|
||||
get.releaseConnection();
|
||||
return responseString;
|
||||
}
|
||||
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm)
|
||||
.setDefaultRequestConfig(globalConfig).build();
|
||||
StringBuilder param = new StringBuilder("?");
|
||||
if (paramMap != null) {
|
||||
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
|
||||
param.append(entry.getKey());
|
||||
param.append("=");
|
||||
param.append(entry.getValue());
|
||||
param.append("&");
|
||||
}
|
||||
param.deleteCharAt(param.length() - 1);
|
||||
}
|
||||
String url = requestUrl + param;
|
||||
HttpGet get = new HttpGet(url);
|
||||
String responseString = httpClient.execute(get, response -> EntityUtils.toString(response.getEntity()));
|
||||
get.releaseConnection();
|
||||
return responseString;
|
||||
}
|
||||
public IUAPQueryBS getQueryService() {
|
||||
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,673 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nc.impl.bd.material.baseinfo;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import nc.bs.bd.cache.CacheProxy;
|
||||
import nc.bs.businessevent.IBusinessEvent;
|
||||
import nc.bs.businessevent.IBusinessListener;
|
||||
import nc.bs.businessevent.bd.BDCommonEvent;
|
||||
import nc.bs.businessevent.bd.BDCommonEventUtil;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.InvocationInfoProxy;
|
||||
import nc.bs.logging.Logger;
|
||||
import nc.impl.bd.material.prod.MaterialProdAsstFrameChangedListner;
|
||||
import nc.jdbc.framework.SQLParameter;
|
||||
import nc.jdbc.framework.processor.ColumnListProcessor;
|
||||
import nc.md.persist.framework.IMDPersistenceQueryService;
|
||||
import nc.md.persist.framework.MDPersistenceService;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
import nc.vo.bd.material.cost.MaterialCostVO;
|
||||
import nc.vo.bd.material.cost.MaterialCostmodeVO;
|
||||
import nc.vo.bd.material.marassistant.MarAssistantVO;
|
||||
import nc.vo.bd.material.plan.MaterialPlanVO;
|
||||
import nc.vo.bd.material.prod.MaterialProdVO;
|
||||
import nc.vo.bd.material.stock.MaterialStockVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.SuperVO;
|
||||
import nc.vo.pub.lang.UFBoolean;
|
||||
import nc.vo.trade.sqlutil.IInSqlBatchCallBack;
|
||||
import nc.vo.trade.sqlutil.InSqlBatchCaller;
|
||||
import nc.vo.util.BDPKLockUtil;
|
||||
import nccloud.commons.lang.ArrayUtils;
|
||||
import nccloud.commons.lang.StringUtils;
|
||||
|
||||
public class MaterialAsstFrame1ChangedListener implements IBusinessListener {
|
||||
private BaseDAO baseDAO = new BaseDAO();
|
||||
private static final String FIXPRECODE = "fixasst";
|
||||
private static final String FREEPRECODE = "freeasst";
|
||||
private IMDPersistenceQueryService mdPersistenceQueryService = null;
|
||||
|
||||
|
||||
public MaterialAsstFrame1ChangedListener() {
|
||||
}
|
||||
|
||||
public void doAction(IBusinessEvent e) throws BusinessException {
|
||||
if (e instanceof BDCommonEvent event) {
|
||||
if ("c7dc0ccd-8872-4eee-8882-160e8f49dfad".equals(event.getSourceID())) {
|
||||
if ("1004".equals(event.getEventType()) ) {
|
||||
this.dealMaterialStockAssts(event, false);//库存信息分配后
|
||||
this.dealMaterialPlanUpdateAssts(event, false);//计划信息分配后
|
||||
// this.dealMaterialProdUpdateAssts(event, false);//生产信息
|
||||
// this.dealMaterialCostAssts(event, false);//成本信息分配后
|
||||
|
||||
} else if ("1061".equals(event.getEventType())) {
|
||||
this.dealMaterialStockAssts(event, true);
|
||||
this.dealMaterialPlanUpdateAssts(event, true);
|
||||
}
|
||||
// else if ("1002".equals(event.getEventType())) {
|
||||
// this.dealMaterialStockAssts1(event, false);
|
||||
// this.dealMaterialPlanUpdateAssts1(event, false);
|
||||
// }
|
||||
}else if("8b7d49ab-7a65-4885-bcf1-7df89b84df4b".equals(event.getSourceID())){
|
||||
//计划信息分配后
|
||||
if ("1009".equals(event.getEventType()) ) {
|
||||
this.dealMaterialStockAssts1(event, false);
|
||||
this.dealMaterialPlanUpdateAssts1(event, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dealMaterialStockAssts(BDCommonEvent event, boolean isBatchUp) throws BusinessException {
|
||||
for(int i = 0; i < event.getOldObjs().length; ++i) {
|
||||
MaterialVO oldVO = (MaterialVO)event.getOldObjs()[i];
|
||||
MaterialVO newVO = (MaterialVO)event.getNewObjs()[i];
|
||||
if (!StringUtils.equals(oldVO.getPk_marasstframe(), newVO.getPk_marasstframe())) {
|
||||
String pk_material = newVO.getPk_material();
|
||||
String pk_marasstframe = newVO.getPk_marasstframe();
|
||||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
//库存
|
||||
this.updateMaterialStockUpdateAssts(pk_marasstframe, pk_material);
|
||||
//成本
|
||||
this.updateMaterialCostUpdateAssts(pk_marasstframe, pk_material);
|
||||
//生产信息
|
||||
this.updateMaterialProdAssts(pk_marasstframe, pk_material);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dealMaterialStockAssts1(BDCommonEvent event, boolean isBatchUp) throws BusinessException {
|
||||
for(int i = 0; i < event.getNewObjs().length; ++i) {
|
||||
MaterialStockVO newVO = (MaterialStockVO)event.getNewObjs()[i];
|
||||
String pk_material = newVO.getPk_material();
|
||||
String pk_marasstframe = this.getmarasstframe(pk_material).get(0);
|
||||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
|
||||
this.updateMaterialStockUpdateAssts(pk_marasstframe, pk_material);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updateMaterialStockUpdateAssts(String pk_marasstframe, String materialVID) throws BusinessException {
|
||||
List<String> pks = this.queryToUpdateStockPks(materialVID);
|
||||
if (!pks.isEmpty()) {
|
||||
this.updateMaterialStockAsstByPks1(this.getField(pk_marasstframe), pks);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> queryToUpdateStockPks(String materialVID) throws BusinessException {
|
||||
String sql = "select pk_materialstock from " + MaterialStockVO.getDefaultTableName() + " where pk_material = ? ";
|
||||
SQLParameter param = new SQLParameter();
|
||||
param.addParam(materialVID);
|
||||
return (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor());
|
||||
}
|
||||
private void updateMaterialStockAsstByPks1(Set<String> notAllowFields, List<String> pks) throws BusinessException {
|
||||
Map<String, MaterialStockVO> pk_stock_map = this.queryToUpdateVOs(pks);
|
||||
List<MaterialStockVO> newVOs = this.getUpdateStockVOs1(notAllowFields, pk_stock_map);
|
||||
if (!newVOs.isEmpty()) {
|
||||
MaterialStockVO[] vos = (MaterialStockVO[])newVOs.toArray(new MaterialStockVO[0]);
|
||||
MaterialStockVO[] oldVOs = this.getOldVOs(vos, pk_stock_map);
|
||||
BDCommonEventUtil eventUtil = new BDCommonEventUtil("13636fc1-0215-4102-a11e-af4be73a05ab");
|
||||
eventUtil.setOldObjs(oldVOs);
|
||||
eventUtil.dispatchUpdateBeforeEvent((Object[])vos);
|
||||
this.getBaseDAO().updateVOArray(vos, (String[])notAllowFields.toArray(new String[0]));
|
||||
CacheProxy.fireDataUpdated(MaterialStockVO.getDefaultTableName());
|
||||
eventUtil.dispatchUpdateAfterEvent((Object[])vos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Map<String, MaterialStockVO> queryToUpdateVOs(List<String> pks) throws BusinessException {
|
||||
InSqlBatchCaller caller = new InSqlBatchCaller((String[])pks.toArray(new String[0]));
|
||||
|
||||
try {
|
||||
return (Map)caller.execute(new IInSqlBatchCallBack() {
|
||||
Map<String, MaterialStockVO> pk_stock_map = new HashMap();
|
||||
|
||||
public Object doWithInSql(String inSql) throws BusinessException, SQLException {
|
||||
Collection<MaterialStockVO> col = MaterialAsstFrame1ChangedListener.this.getBaseDAO().retrieveByClause(MaterialStockVO.class, "pk_materialstock in " + inSql);
|
||||
if (col != null) {
|
||||
for(MaterialStockVO vo : col) {
|
||||
this.pk_stock_map.put(vo.getPrimaryKey(), vo);
|
||||
}
|
||||
}
|
||||
|
||||
return this.pk_stock_map;
|
||||
}
|
||||
});
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.getMessage(), e);
|
||||
throw new BusinessException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<MaterialStockVO> getUpdateStockVOs1(Set<String> notAllowFields, Map<String, MaterialStockVO> pk_stock_map) {
|
||||
List<MaterialStockVO> newVOs = new ArrayList();
|
||||
if (pk_stock_map != null && !pk_stock_map.isEmpty()) {
|
||||
for(MaterialStockVO oldVO : pk_stock_map.values()) {
|
||||
boolean valueChanged = false;
|
||||
MaterialStockVO newVO = (MaterialStockVO)oldVO.clone();
|
||||
|
||||
for(String field : notAllowFields) {
|
||||
valueChanged = true;
|
||||
newVO.setAttributeValue(field, UFBoolean.TRUE);
|
||||
}
|
||||
|
||||
if (valueChanged) {
|
||||
newVOs.add(newVO);
|
||||
}
|
||||
}
|
||||
|
||||
return newVOs;
|
||||
} else {
|
||||
return newVOs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private MaterialStockVO[] getOldVOs(MaterialStockVO[] vos, Map<String, MaterialStockVO> pk_stock_map) {
|
||||
MaterialStockVO[] oldVOs = new MaterialStockVO[vos.length];
|
||||
|
||||
for(int i = 0; i < vos.length; ++i) {
|
||||
oldVOs[i] = (MaterialStockVO)pk_stock_map.get(vos[i].getPrimaryKey());
|
||||
}
|
||||
|
||||
return oldVOs;
|
||||
}
|
||||
private Set<String> getField(String pk_marasstframe) throws DAOException {
|
||||
List<String> codes = this.queryMarasstCodesByFrameID(pk_marasstframe);
|
||||
Set<String> allowFields = new HashSet();
|
||||
//如果项目被更改项目需要被默认选中
|
||||
for(int i = 2; i <= 16; ++i) {
|
||||
if (codes.contains(Integer.toString(i)) ) {
|
||||
allowFields.add(this.getAsstCodeByIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
return allowFields;
|
||||
}
|
||||
|
||||
public String getAsstCodeByIndex(int index) {
|
||||
if (Integer.parseInt("16") == index) {
|
||||
return "fixasst100";
|
||||
} else {
|
||||
return index >= 6 && index <= 15 ? "freeasst" + (index - 5) : "fixasst" + index;
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> queryMarasstCodesByFrameID(String pk_marasstframe) throws DAOException {
|
||||
String sql = "select code from " + MarAssistantVO.getDefaultTableName() + " where pk_marasstframe = ?";
|
||||
SQLParameter param = new SQLParameter();
|
||||
param.addParam(pk_marasstframe);
|
||||
List<String> codes = (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor());
|
||||
return codes;
|
||||
}
|
||||
|
||||
private BaseDAO getBaseDAO() {
|
||||
if (this.baseDAO == null) {
|
||||
this.baseDAO = new BaseDAO();
|
||||
}
|
||||
|
||||
return this.baseDAO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void dealMaterialPlanUpdateAssts(BDCommonEvent event, boolean isBatchUp) throws BusinessException {
|
||||
for(int i = 0; i < event.getOldObjs().length; ++i) {
|
||||
MaterialVO oldVO = (MaterialVO)event.getOldObjs()[i];
|
||||
MaterialVO newVO = (MaterialVO)event.getNewObjs()[i];
|
||||
if (!StringUtils.equals(oldVO.getPk_marasstframe(), newVO.getPk_marasstframe())) {
|
||||
String pk_material = newVO.getPk_material();
|
||||
String pk_marasstframe = newVO.getPk_marasstframe();
|
||||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
|
||||
this.updateMaterialPlanAssts(pk_marasstframe, pk_material);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void dealMaterialPlanUpdateAssts1(BDCommonEvent event, boolean isBatchUp) throws BusinessException {
|
||||
for(int i = 0; i < event.getNewObjs().length; ++i) {
|
||||
MaterialPlanVO newVO = (MaterialPlanVO)event.getNewObjs()[i];
|
||||
String pk_material = newVO.getPk_material();
|
||||
String pk_marasstframe = this.getmarasstframe(pk_material).get(0);
|
||||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
|
||||
this.updateMaterialPlanAssts(pk_marasstframe, pk_material);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateMaterialPlanAssts(String pk_marasstframe, String materialVID) throws BusinessException {
|
||||
List<String> pks = this.queryToUpdatePlanPks(materialVID);
|
||||
if (!pks.isEmpty()) {
|
||||
this.updateMaterialPlanAsstByPks(this.getField1(pk_marasstframe), pks);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> queryToUpdatePlanPks(String materialVID) throws BusinessException {
|
||||
String sql = "select pk_materialplan from " + MaterialPlanVO.getDefaultTableName() + " where pk_material = ? ";
|
||||
SQLParameter param = new SQLParameter();
|
||||
param.addParam(materialVID);
|
||||
return (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor());
|
||||
}
|
||||
|
||||
private void updateMaterialPlanAsstByPks(Set<String> notAllowFields, List<String> pks) throws BusinessException {
|
||||
Map<String, MaterialPlanVO> pk_plan_map = this.queryToUpdateVOs1(pks);
|
||||
List<MaterialPlanVO> newVOs = this.getUpdatePlanVOs2(notAllowFields, pk_plan_map);
|
||||
if (!newVOs.isEmpty()) {
|
||||
MaterialPlanVO[] vos = (MaterialPlanVO[])newVOs.toArray(new MaterialPlanVO[0]);
|
||||
MaterialPlanVO[] oldVOs = this.getOldVOs1(vos, pk_plan_map);
|
||||
BDCommonEventUtil eventUtil = new BDCommonEventUtil("8b7d49ab-7a65-4885-bcf1-7df89b84df4b");
|
||||
eventUtil.setOldObjs(oldVOs);
|
||||
eventUtil.dispatchUpdateBeforeEvent((Object[])vos);
|
||||
this.getBaseDAO().updateVOArray(vos, (String[])notAllowFields.toArray(new String[0]));
|
||||
CacheProxy.fireDataUpdated(MaterialPlanVO.getDefaultTableName());
|
||||
eventUtil.dispatchUpdateAfterEvent((Object[])vos);
|
||||
}
|
||||
}
|
||||
private Map<String, MaterialPlanVO> queryToUpdateVOs1(List<String> pks) throws BusinessException {
|
||||
InSqlBatchCaller caller = new InSqlBatchCaller((String[])pks.toArray(new String[0]));
|
||||
|
||||
try {
|
||||
return (Map)caller.execute(new IInSqlBatchCallBack() {
|
||||
Map<String, MaterialPlanVO> pk_plan_map = new HashMap();
|
||||
|
||||
public Object doWithInSql(String inSql) throws BusinessException, SQLException {
|
||||
Collection<MaterialPlanVO> col = MaterialAsstFrame1ChangedListener.this.getBaseDAO().retrieveByClause(MaterialPlanVO.class, "pk_materialplan in " + inSql);
|
||||
if (col != null) {
|
||||
for(MaterialPlanVO vo : col) {
|
||||
this.pk_plan_map.put(vo.getPrimaryKey(), vo);
|
||||
}
|
||||
}
|
||||
|
||||
return this.pk_plan_map;
|
||||
}
|
||||
});
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.getMessage(), e);
|
||||
throw new BusinessException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
private List<MaterialPlanVO> getUpdatePlanVOs2(Set<String> notAllowFields, Map<String, MaterialPlanVO> pk_plan_map) {
|
||||
List<MaterialPlanVO> newVOs = new ArrayList();
|
||||
if (pk_plan_map != null && !pk_plan_map.isEmpty()) {
|
||||
for(MaterialPlanVO oldVO : pk_plan_map.values()) {
|
||||
boolean valueChanged = false;
|
||||
MaterialPlanVO newVO = (MaterialPlanVO)oldVO.clone();
|
||||
|
||||
for(String field : notAllowFields) {
|
||||
valueChanged = true;
|
||||
newVO.setAttributeValue(field, UFBoolean.TRUE);
|
||||
}
|
||||
|
||||
if (valueChanged) {
|
||||
newVOs.add(newVO);
|
||||
}
|
||||
}
|
||||
|
||||
return newVOs;
|
||||
} else {
|
||||
return newVOs;
|
||||
}
|
||||
}
|
||||
private MaterialPlanVO[] getOldVOs1(MaterialPlanVO[] vos, Map<String, MaterialPlanVO> pk_plan_map) {
|
||||
MaterialPlanVO[] oldVOs = new MaterialPlanVO[vos.length];
|
||||
|
||||
for(int i = 0; i < vos.length; ++i) {
|
||||
oldVOs[i] = (MaterialPlanVO)pk_plan_map.get(vos[i].getPrimaryKey());
|
||||
}
|
||||
|
||||
return oldVOs;
|
||||
}
|
||||
private Set<String> getField1(String pk_marasstframe) throws DAOException {
|
||||
List<String> codes = this.queryMarasstCodesByFrameID(pk_marasstframe);
|
||||
Set<String> allowFields = new HashSet();
|
||||
//如果项目被更改项目需要被默认选中
|
||||
for(int i = 2; i <= 16; ++i) {
|
||||
String code = this.getNewCodeOfMarasst(i);
|
||||
if (codes.contains(code) ) {
|
||||
allowFields.add("marasst" + code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return allowFields;
|
||||
}
|
||||
private String getNewCodeOfMarasst(int i) {
|
||||
return i == 16 ? "100" : Integer.toString(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private List<String> getmarasstframe(String materialVID) throws BusinessException {
|
||||
String sql = "select pk_marasstframe from " + MaterialVO.getDefaultTableName() + " where pk_material = ? ";
|
||||
SQLParameter param = new SQLParameter();
|
||||
param.addParam(materialVID);
|
||||
return (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void updateMaterialCostUpdateAssts(String pk_marasstframe, String materialVID) throws BusinessException {
|
||||
List<MaterialCostVO> materialCostVOs = this.queryMarCostVOsByMaterialPK(materialVID);
|
||||
if (materialCostVOs != null && materialCostVOs.size() != 0) {
|
||||
Set<String> allowFields = this.getCostAsstField(pk_marasstframe);
|
||||
Set<String> notallowFields = this.getnotCostAsstField(pk_marasstframe);
|
||||
|
||||
this.updateMaterialCostAsstByPks(notallowFields,allowFields, materialCostVOs);
|
||||
}
|
||||
}
|
||||
private List<MaterialCostVO> queryMarCostVOsByMaterialPK(String pk_material) throws BusinessException {
|
||||
List<MaterialCostVO> voList = new ArrayList();
|
||||
String wherePart = "pk_material = '" + pk_material + "'";
|
||||
Collection<MaterialCostVO> col = this.getMdPersistenceQueryService().queryBillOfVOByCondWithOrder(MaterialCostVO.class, wherePart, false, new String[]{"materialcostmode"}, (String[])null);
|
||||
if (col != null && col.size() > 0) {
|
||||
voList.addAll(col);
|
||||
}
|
||||
|
||||
return voList;
|
||||
}
|
||||
public IMDPersistenceQueryService getMdPersistenceQueryService() {
|
||||
if (this.mdPersistenceQueryService == null) {
|
||||
this.mdPersistenceQueryService = MDPersistenceService.lookupPersistenceQueryService();
|
||||
}
|
||||
|
||||
return this.mdPersistenceQueryService;
|
||||
}
|
||||
private Set<String> getCostAsstField(String pk_marasstframe) throws BusinessException {
|
||||
List<String> codes = this.queryMarasstCodesByFrameID(pk_marasstframe);
|
||||
Set<String> notAllowFields = new HashSet();
|
||||
|
||||
for(int i = 2; i <= 16; ++i) {
|
||||
String code = this.getNewCodeOfMarasst(i);
|
||||
if (codes.contains(code)) {
|
||||
notAllowFields.add("marasst" + code);
|
||||
}
|
||||
}
|
||||
|
||||
return notAllowFields;
|
||||
}
|
||||
private Set<String> getnotCostAsstField(String pk_marasstframe) throws BusinessException {
|
||||
List<String> codes = this.queryMarasstCodesByFrameID(pk_marasstframe);
|
||||
Set<String> notAllowFields = new HashSet();
|
||||
|
||||
for(int i = 2; i <= 16; ++i) {
|
||||
String code = this.getNewCodeOfMarasst(i);
|
||||
if (!codes.contains(code)) {
|
||||
notAllowFields.add("marasst" + code);
|
||||
}
|
||||
}
|
||||
|
||||
return notAllowFields;
|
||||
}
|
||||
private void updateMaterialCostAsstByPks(Set<String> notAllowFields,Set<String> allowFields, List<MaterialCostVO> materialCostVOs) throws BusinessException {
|
||||
Map<String, MaterialCostVO> pk_cost_map = new HashMap();
|
||||
|
||||
for(MaterialCostVO materialCostVO : materialCostVOs) {
|
||||
pk_cost_map.put(materialCostVO.getPrimaryKey(), materialCostVO);
|
||||
}
|
||||
|
||||
String pk_group = InvocationInfoProxy.getInstance().getGroupId();
|
||||
List<MaterialCostVO> oldMaterialCostVOs = new ArrayList();
|
||||
List<MaterialCostmodeVO> oldMaterialCostmodeVOs = new ArrayList();
|
||||
|
||||
for(MaterialCostVO oldCostVO : pk_cost_map.values()) {
|
||||
oldMaterialCostVOs.add(oldCostVO);
|
||||
MaterialCostmodeVO[] costmodeVOs = oldCostVO.getMaterialcostmode();
|
||||
if (!ArrayUtils.isEmpty(costmodeVOs)) {
|
||||
for(MaterialCostmodeVO oldCostmodeVO : costmodeVOs) {
|
||||
// if (!oldCostmodeVO.getPk_costregion().equals(pk_group)) {
|
||||
oldMaterialCostmodeVOs.add(oldCostmodeVO);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<MaterialCostmodeVO> newCostmodeVOs = this.valueChangedCostModeVOs(notAllowFields,allowFields, oldMaterialCostmodeVOs);
|
||||
if (!newCostmodeVOs.isEmpty()) {
|
||||
Map<String, List<MaterialCostmodeVO>> changedCostmodeMap = new HashMap();
|
||||
|
||||
for(MaterialCostmodeVO maCostmodeVO : newCostmodeVOs) {
|
||||
List<MaterialCostmodeVO> list = (List)changedCostmodeMap.get(maCostmodeVO.getPk_materialcost());
|
||||
if (list != null && list.size() != 0) {
|
||||
list.add(maCostmodeVO);
|
||||
changedCostmodeMap.put(maCostmodeVO.getPk_materialcost(), list);
|
||||
} else {
|
||||
list = new ArrayList();
|
||||
list.add(maCostmodeVO);
|
||||
changedCostmodeMap.put(maCostmodeVO.getPk_materialcost(), list);
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> pk_materialcosts = changedCostmodeMap.keySet();
|
||||
List<MaterialCostVO> newMaterialCostVOs = new ArrayList();
|
||||
List<MaterialCostmodeVO> newMaterialCostmodeVOs = new ArrayList();
|
||||
|
||||
for(String pk_materialcost : pk_materialcosts) {
|
||||
MaterialCostVO newCostVO = (MaterialCostVO)pk_cost_map.get(pk_materialcost);
|
||||
newMaterialCostVOs.add(newCostVO);
|
||||
}
|
||||
|
||||
for(List<MaterialCostmodeVO> list : changedCostmodeMap.values()) {
|
||||
newMaterialCostmodeVOs.addAll(list);
|
||||
}
|
||||
|
||||
this.dispatchUpdateUpdateEvent(oldMaterialCostVOs, oldMaterialCostmodeVOs, newMaterialCostVOs, newMaterialCostmodeVOs, notAllowFields,allowFields);
|
||||
}
|
||||
}
|
||||
private List<MaterialCostmodeVO> valueChangedCostModeVOs(Set<String> notAllowFields,Set<String> allowFields, List<MaterialCostmodeVO> costmodeVOs) {
|
||||
List<MaterialCostmodeVO> newCostmodeVOs = new ArrayList();
|
||||
|
||||
for(MaterialCostmodeVO oldcCostmodeVO : costmodeVOs) {
|
||||
boolean valueChanged = false;
|
||||
MaterialCostmodeVO newcCostmodeVO = (MaterialCostmodeVO)oldcCostmodeVO.clone();
|
||||
|
||||
for(String field : allowFields) {
|
||||
valueChanged = true;
|
||||
newcCostmodeVO.setAttributeValue(field, UFBoolean.TRUE);
|
||||
}
|
||||
for(String field : notAllowFields) {
|
||||
valueChanged = true;
|
||||
newcCostmodeVO.setAttributeValue(field, UFBoolean.FALSE);
|
||||
}
|
||||
|
||||
if (valueChanged) {
|
||||
newCostmodeVOs.add(newcCostmodeVO);
|
||||
}
|
||||
}
|
||||
|
||||
return newCostmodeVOs;
|
||||
}
|
||||
private void dispatchUpdateUpdateEvent(List<MaterialCostVO> oldMaterialCostVOs, List<MaterialCostmodeVO> oldMaterialCostmodeVOs, List<MaterialCostVO> newMaterialCostVOs, List<MaterialCostmodeVO> newMaterialCostmodeVOs, Set<String> notAllowFields, Set<String> allowFields) throws BusinessException {
|
||||
BDCommonEventUtil costeventUtil = new BDCommonEventUtil("d0ff92c6-1059-46b4-97fd-ed8b3d0a85d9");
|
||||
BDCommonEventUtil costmodeeventUtil = new BDCommonEventUtil("bc230e0a-68c1-4cf9-bd78-58e55953596b");
|
||||
costeventUtil.setOldObjs(oldMaterialCostVOs.toArray(new MaterialCostVO[0]));
|
||||
costeventUtil.dispatchUpdateBeforeEvent(oldMaterialCostVOs.toArray(new MaterialCostVO[0]));
|
||||
costmodeeventUtil.setOldObjs(oldMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0]));
|
||||
costmodeeventUtil.dispatchUpdateBeforeEvent(oldMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0]));
|
||||
this.getBaseDAO().updateVOArray((SuperVO[])newMaterialCostVOs.toArray(new MaterialCostVO[0]));
|
||||
CacheProxy.fireDataUpdated(MaterialCostVO.getDefaultTableName());
|
||||
this.getBaseDAO().updateVOArray((SuperVO[])newMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0]), (String[])notAllowFields.toArray(new String[0]));
|
||||
this.getBaseDAO().updateVOArray((SuperVO[])newMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0]), (String[])allowFields.toArray(new String[0]));
|
||||
|
||||
CacheProxy.fireDataUpdated(MaterialCostmodeVO.getDefaultTableName());
|
||||
costeventUtil.dispatchUpdateAfterEvent(newMaterialCostVOs.toArray(new MaterialCostVO[0]));
|
||||
costmodeeventUtil.dispatchUpdateAfterEvent(newMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void updateMaterialProdAssts(String pk_marasstframe, String materialVID) throws BusinessException {
|
||||
List<String> pks = this.queryToUpdateProdPks(materialVID);
|
||||
if (!pks.isEmpty()) {
|
||||
Set<String> notAllowFields = this.getNotProdAsstField(pk_marasstframe);
|
||||
this.updateMaterialProdAsstByPks(notAllowFields, pks);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> queryToUpdateProdPks(String materialVID) throws BusinessException {
|
||||
String sql = "select pk_materialprod from " + MaterialProdVO.getDefaultTableName() + " where pk_material = ? ";
|
||||
SQLParameter param = new SQLParameter();
|
||||
param.addParam(materialVID);
|
||||
return (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor());
|
||||
}
|
||||
|
||||
private void updateMaterialProdAsstByPks(Set<String> notAllowFields, List<String> pks) throws BusinessException {
|
||||
Map<String, MaterialProdVO> pk_prod_map = this.queryToUpdateVOsProd(pks);
|
||||
List<MaterialProdVO> newVOs = this.getUpdateProdVOs(notAllowFields, pk_prod_map);
|
||||
if (!newVOs.isEmpty()) {
|
||||
MaterialProdVO[] vos = (MaterialProdVO[])newVOs.toArray(new MaterialProdVO[0]);
|
||||
MaterialProdVO[] oldVOs = this.getOldVOs(vos, pk_prod_map);
|
||||
BDCommonEventUtil eventUtil = new BDCommonEventUtil("a3133495-8c94-47b4-83d4-0d32bd08ac82");
|
||||
eventUtil.setOldObjs(oldVOs);
|
||||
eventUtil.dispatchUpdateBeforeEvent((Object[])vos);
|
||||
this.getBaseDAO().updateVOArray(vos, (String[])notAllowFields.toArray(new String[0]));
|
||||
CacheProxy.fireDataUpdated(MaterialProdVO.getDefaultTableName());
|
||||
eventUtil.dispatchUpdateAfterEvent((Object[])vos);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, MaterialProdVO> queryToUpdateVOsProd(List<String> pks) throws BusinessException {
|
||||
InSqlBatchCaller caller = new InSqlBatchCaller((String[])pks.toArray(new String[0]));
|
||||
|
||||
try {
|
||||
return (Map)caller.execute(new IInSqlBatchCallBack() {
|
||||
Map<String, MaterialProdVO> pk_prod_map = new HashMap();
|
||||
|
||||
public Object doWithInSql(String inSql) throws BusinessException, SQLException {
|
||||
Collection<MaterialProdVO> col = MaterialAsstFrame1ChangedListener.this.getBaseDAO().retrieveByClause(MaterialProdVO.class, "pk_materialprod in " + inSql);
|
||||
if (col != null) {
|
||||
for(MaterialProdVO vo : col) {
|
||||
this.pk_prod_map.put(vo.getPrimaryKey(), vo);
|
||||
}
|
||||
}
|
||||
|
||||
return this.pk_prod_map;
|
||||
}
|
||||
});
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.getMessage(), e);
|
||||
throw new BusinessException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<MaterialProdVO> getUpdateProdVOs(Set<String> notAllowFields, Map<String, MaterialProdVO> pk_prod_map) {
|
||||
List<MaterialProdVO> newVOs = new ArrayList();
|
||||
if (pk_prod_map != null && !pk_prod_map.isEmpty()) {
|
||||
for(MaterialProdVO oldVO : pk_prod_map.values()) {
|
||||
boolean valueChanged = false;
|
||||
MaterialProdVO newVO = (MaterialProdVO)oldVO.clone();
|
||||
|
||||
for(String field : notAllowFields) {
|
||||
// if (UFBoolean.TRUE.equals(oldVO.getAttributeValue(field))) {
|
||||
valueChanged = true;
|
||||
newVO.setAttributeValue(field, UFBoolean.TRUE);
|
||||
// }
|
||||
}
|
||||
|
||||
if (valueChanged) {
|
||||
newVOs.add(newVO);
|
||||
}
|
||||
}
|
||||
|
||||
return newVOs;
|
||||
} else {
|
||||
return newVOs;
|
||||
}
|
||||
}
|
||||
|
||||
private MaterialProdVO[] getOldVOs(MaterialProdVO[] vos, Map<String, MaterialProdVO> pk_prod_map) {
|
||||
MaterialProdVO[] oldVOs = new MaterialProdVO[vos.length];
|
||||
|
||||
for(int i = 0; i < vos.length; ++i) {
|
||||
oldVOs[i] = (MaterialProdVO)pk_prod_map.get(vos[i].getPrimaryKey());
|
||||
}
|
||||
|
||||
return oldVOs;
|
||||
}
|
||||
|
||||
private Set<String> getNotProdAsstField(String pk_marasstframe) throws DAOException {
|
||||
List<String> codes = this.queryMarasstCodesByFrameID(pk_marasstframe);
|
||||
Set<String> notAllowFields = new HashSet();
|
||||
|
||||
for(int i = 2; i <= 16; ++i) {
|
||||
String code = this.getNewCodeOfMarasst(i);
|
||||
if (codes.contains(code)) {
|
||||
notAllowFields.add("costvalutasst" + code);
|
||||
}
|
||||
}
|
||||
|
||||
return notAllowFields;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -17,8 +17,8 @@ import java.net.URL;
|
|||
*/
|
||||
public class ThirdPartyPostRequestUtil {
|
||||
|
||||
private static final int DEFAULT_CONNECT_TIMEOUT = 30000;
|
||||
private static final int DEFAULT_READ_TIMEOUT = 30000;
|
||||
private static final int DEFAULT_CONNECT_TIMEOUT = 300000;
|
||||
private static final int DEFAULT_READ_TIMEOUT = 300000;
|
||||
|
||||
/**
|
||||
* 向第三方系统发送 POST 请求,并根据 HTTP 状态码返回数据
|
||||
|
|
|
@ -14,10 +14,7 @@ import javax.ws.rs.Consumes;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
// import java.util.StringJoiner; // 不再需要
|
||||
|
||||
|
||||
|
@ -37,8 +34,15 @@ public class QuerySync extends AbstractNCCRestResource {
|
|||
|
||||
if (tsObj instanceof String) {
|
||||
String ts = (String) tsObj;
|
||||
UFDate ufdate = new UFDate(ts);
|
||||
Date date = ufdate.toDate();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.HOUR_OF_DAY, -3); // 减去 3 小时
|
||||
//提前三小时,防止ts与现实时间差别
|
||||
UFDate adjustedUfDate = new UFDate(calendar.getTimeInMillis());
|
||||
if (!ts.contains(",")) { // 单个时间戳
|
||||
tsCondition = "ts >= '" + ts + "' AND ts <= '" + new UFDate(new Date()) + "'";
|
||||
tsCondition = "ts >= '" + adjustedUfDate + "' AND ts <= '" + new UFDate(new Date()) + "'";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue