合同到货单删除后回写bip
This commit is contained in:
parent
5bdd9d2929
commit
2d1034c6a0
|
@ -46,6 +46,13 @@ public class N_F2_DELETE extends N_BASE_ACTION {
|
|||
AggGatheringBillVO aggvo = (AggGatheringBillVO)paraVo.m_preValueVo;
|
||||
NCLocator.getInstance().lookup(IDevArapBill2R6Service.class).updateR6Info(aggvo);
|
||||
}
|
||||
|
||||
if(paraVo.m_preValueVo instanceof AggGatheringBillVO){
|
||||
AggGatheringBillVO aggvo = (AggGatheringBillVO)paraVo.m_preValueVo;
|
||||
if(null !=aggvo.getHeadVO().getDef20()){
|
||||
NCLocator.getInstance().lookup(IDevArapBill2R6Service.class).updateR6(aggvo);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
} catch (Exception ex) {
|
||||
throw ExceptionHandler.handleException(this.getClass(), ex);
|
||||
|
|
|
@ -76,6 +76,48 @@ public class DevArapBill2R6Impl implements IDevArapBill2R6Service {
|
|||
pushBipCtOrderUpdate(jsonObject,saleOrderHVOList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateR6(AggGatheringBillVO aggvo) throws Exception {
|
||||
String id = aggvo.getHeadVO().getDef20();
|
||||
pushBipUpdate(id);
|
||||
}
|
||||
private void pushBipUpdate(String id) throws BusinessException {
|
||||
String baseUrl = "";
|
||||
Map<String, String> bipParamMap = checkBipParam();
|
||||
if (bipParamMap.isEmpty()) {
|
||||
return ;
|
||||
}
|
||||
baseUrl = bipParamMap.get("baseUrl");
|
||||
String contractSaleOrderUrl = bipParamMap.get("updateGatheringbill");// 开票申请单回传
|
||||
if (StringUtils.isEmpty(contractSaleOrderUrl)) {
|
||||
return ;
|
||||
}
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
String accessToken = getAccessToken(baseUrl, bipParamMap);
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id", id);
|
||||
jsonObject.put("generateStatus", "1");
|
||||
if (accessToken != "") {
|
||||
Map<String, String> tokenParam = new HashMap<>();
|
||||
tokenParam.put("access_token", accessToken);
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("Content-Type", "application/json");
|
||||
String custUpdateUrl = baseUrl + contractSaleOrderUrl;
|
||||
String resultString = doSendHttp(custUpdateUrl, "POST", tokenParam, "", headers,jsonObject.toString()
|
||||
);
|
||||
Map updateMap = gson.fromJson(resultString, Map.class);
|
||||
if ("200".equals(updateMap.get("code"))) {// 保存更新成功后需要更新日志表
|
||||
// getSuperDMO().updateArray(saleOrderHVOList.toArray(new SaleOrderHVO[0]));
|
||||
} else {
|
||||
throw new BusinessException("合同销售订单同步plm失败【"+updateMap.get("message")+"】");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("合同销售订单同步plm失败【"+e.getMessage()+"】");
|
||||
}
|
||||
}
|
||||
private JSONObject afterChangeMny(String csaleorderid, String pk_org, String ctid, String pk_gatherid) throws BusinessException {
|
||||
try {
|
||||
// ºÏͬid
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package nc.api.arap.resource;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
|
@ -14,6 +15,7 @@ import nc.itf.bd.defdoc.IDefdocService;
|
|||
import nc.itf.pmpub.project.pub.IProjectServiceForPu;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.jdbc.framework.processor.MapProcessor;
|
||||
import nc.uif.pub.exception.UifException;
|
||||
import nc.vo.arap.basebill.BaseAggVO;
|
||||
import nc.vo.arap.gathering.AggGatheringBillVO;
|
||||
import nc.vo.arap.gathering.GatheringBillItemVO;
|
||||
|
@ -77,14 +79,40 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
@Path("/bipinsert")
|
||||
@Consumes({"application/json"})
|
||||
@Produces({"application/json"})
|
||||
public JSONString bipInsertPaybill(JSONString str) {
|
||||
public JSONString bipInsertPaybill(JSONString str) throws BusinessException {
|
||||
// String json = str.toJSONString();
|
||||
// Map<String, Object> billMap = (Map) fromJson(json, Map.class);
|
||||
// String csaleorderid = "";
|
||||
// List<Map<String, Object>> itemMaps = (List) billMap.get("items");
|
||||
// List<GatheringBillItemVO> itemvos = new ArrayList<GatheringBillItemVO>();
|
||||
// if (itemMaps != null && itemMaps.size() > 0) {
|
||||
// for (Map<String, Object> item : itemMaps) {
|
||||
// GatheringBillItemVO itemvo = (GatheringBillItemVO) fromJsonToVO(item, GatheringBillItemVO.class);
|
||||
// csaleorderid = itemvo.getDef37();
|
||||
// }
|
||||
// }
|
||||
// if(!csaleorderid.equals("")){
|
||||
// HYPubBO hybo = new HYPubBO();
|
||||
// //查询销售订单编码 如果销售订单查不到去期初接口 查得到 走原来接口
|
||||
// Object vbillcode = hybo.findColValue("so_saleorder", "vbillcode",
|
||||
// "csaleorderid = '" + csaleorderid + "' ");
|
||||
// if(vbillcode != null){
|
||||
// return bipInsert(str);
|
||||
// }
|
||||
// }
|
||||
return bipInsert3(str);
|
||||
}
|
||||
public JSONString bipInsert(JSONString str){
|
||||
InvocationInfoProxy.getInstance().setGroupId("0001A110000000000677");
|
||||
NCCRestUtils.initInvocationInfo();
|
||||
String json = str.toJSONString();
|
||||
Map<String, Object> billMap = (Map) fromJson(json, Map.class);
|
||||
billMap.put("recaccount", billMap.get("ar_recaccount"));// 收款银行账户
|
||||
GatheringBillVO headvo = (GatheringBillVO) fromJsonToVO(billMap, GatheringBillVO.class);
|
||||
// bipInsert(str);
|
||||
// 根据收款银行账户带出银行类别
|
||||
String pkBalatype= (String) billMap.get("pk_balatype");
|
||||
|
||||
String def5 = getBankTypeByAccount(headvo.getRecaccount());
|
||||
headvo.setDef5(def5); // 银行类别
|
||||
headvo.setDef28(headvo.getBilldate().toStdString());// 交易日期
|
||||
|
@ -152,12 +180,12 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
if (cemployeeid != null) {// 能够获取到值,但是该值可能在销售订单生成的时候,没有翻译,依然存的是人员编码,如果存的是人员编码,则说明该人员在erp系统中不存在
|
||||
Object cemployeeCode = hybo.findColValue("bd_psndoc", "code", "pk_psndoc = '" + cemployeeid + "' ");
|
||||
if (cemployeeCode != null) {
|
||||
headvo.setPk_psndoc(cemployeeCode.toString());
|
||||
headvo.setPk_psndoc(cemployeeid.toString());
|
||||
// 部门
|
||||
Object deptCode = hybo.findColValue("org_orgs", "code",
|
||||
Object deptID = hybo.findColValue("org_orgs", "pk_org",
|
||||
" pk_org in( select pk_dept from bd_psnjob where pk_psndoc = '" + cemployeeid + "')");
|
||||
if (deptCode != null) {
|
||||
headvo.setPk_deptid(deptCode.toString());
|
||||
if (deptID != null) {
|
||||
headvo.setPk_deptid(deptID.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,6 +218,10 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
// 合同金额
|
||||
// 结算组织
|
||||
headvo.setSett_org(headvo.getPk_org());
|
||||
// pk_balatype =02、03、04、05时 收款银行账户字段无需赋值;
|
||||
if(pkBalatype != null && ("02".equals(pkBalatype) || "03".equals(pkBalatype) || "04".equals(pkBalatype) || "05".equals(pkBalatype))){
|
||||
headvo.setRecaccount(null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
|
@ -203,6 +235,9 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
itemvo.setRecaccount(headvo.getRecaccount());
|
||||
// pk_balatype 结算方式 表头带出
|
||||
itemvo.setPk_balatype(headvo.getPk_balatype());
|
||||
if(pkBalatype != null && ("02".equals(pkBalatype) || "03".equals(pkBalatype) || "04".equals(pkBalatype) || "05".equals(pkBalatype))){
|
||||
itemvo.setRecaccount(null);
|
||||
}
|
||||
// 票据类型 checktype 结算方式:银行承兑汇票-电子、银行承兑汇票-纸质=银行承兑汇票;商业承兑汇票-电子、商业承兑汇票-纸质=商业承兑汇票
|
||||
String checktypeName = "";
|
||||
if ("银行承兑汇票-电子".equals(balatypeName)) {
|
||||
|
@ -226,9 +261,13 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
// supplier 客户编码 表头带出
|
||||
itemvo.setCustomer(headvo.getCustomer());
|
||||
// pk_dept 部门编码 表头带出
|
||||
itemvo.setPk_deptid(headvo.getPk_deptid());
|
||||
if(headvo.getPk_deptid() != null){
|
||||
itemvo.setPk_deptid(headvo.getPk_deptid());
|
||||
}
|
||||
// pk_psndoc 业务员编码 表头带出
|
||||
itemvo.setPk_psndoc(headvo.getPk_psndoc());
|
||||
if(headvo.getPk_psndoc() != null){
|
||||
itemvo.setPk_psndoc(headvo.getPk_psndoc());
|
||||
}
|
||||
// pk_currtype 币种编码 表头带出
|
||||
itemvo.setPk_currtype(headvo.getPk_currtype());
|
||||
// prepay 收款性质 默认应收款 0
|
||||
|
@ -259,16 +298,16 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
itemvo.getMoney_cr().multiply(itemvo.getRate()).setScale(2, UFDouble.ROUND_HALF_UP));
|
||||
Object def2 = itemvo.getDef2();
|
||||
if (def2 != null)
|
||||
itemvo.setDef2(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def2 + "' ") + "");
|
||||
itemvo.setDef2(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def2 + "' ") + "");
|
||||
Object def3 = itemvo.getDef3();
|
||||
if (def3 != null)
|
||||
itemvo.setDef3(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def3 + "' ") + "");
|
||||
itemvo.setDef3(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def3 + "' ") + "");
|
||||
Object def6 = itemvo.getDef6();
|
||||
if (def6 != null)
|
||||
itemvo.setDef6(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def6 + "' ") + "");
|
||||
itemvo.setDef6(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def6 + "' ") + "");
|
||||
Object def36 = itemvo.getDef36();
|
||||
if (def36 != null)
|
||||
itemvo.setDef36(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def36 + "' ") + "");
|
||||
itemvo.setDef36(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def36 + "' ") + "");
|
||||
|
||||
HYSuperDMO dmo = new HYSuperDMO();
|
||||
SaleOrderHVO[] hvo = (SaleOrderHVO[]) dmo.queryByWhereClause(SaleOrderHVO.class,
|
||||
|
@ -287,6 +326,10 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
itemvo.setTop_itemid(bvos[0].getCsaleorderbid());
|
||||
itemvo.setTop_billtype("30");
|
||||
}
|
||||
String projectOrg= (String) hybo.findColValue("org_orgs", "pk_org", " code = '" + headvo.getPk_org() + "' ");
|
||||
if(itemvo.getProject()!=null){
|
||||
itemvo.setProject(hybo.findColValue("bd_project", "pk_project", " project_code = '" + itemvo.getProject() + "' and pk_org = '" + projectOrg + "' " ) + "");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
|
@ -343,6 +386,9 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
if (StringUtils.isEmpty(ctid)) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isEmpty(csaleorderid)) {
|
||||
return;
|
||||
}
|
||||
// 获取销售订单表头
|
||||
SaleOrderHVO hvo = (SaleOrderHVO) getSuperDMO().queryByPrimaryKey(SaleOrderHVO.class, csaleorderid);
|
||||
if (hvo == null) {
|
||||
|
@ -436,13 +482,15 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
headers.put("Content-Type", "application/json");
|
||||
String custUpdateUrl = baseUrl + contractSaleOrderUrl;
|
||||
JSONObject js_apct_detail = new JSONObject();
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject js_apct = new JSONObject();
|
||||
js_apct.put("id", hvo.getVdef9());
|
||||
js_apct.put("isShipRecdAmt", vdef11);
|
||||
js_apct.put("isPreRecv", vdef14);
|
||||
js_apct.put("actRecvAmt", hvo.getNreceivedmny().floatValue());
|
||||
js_apct.put("actPreRecvAmt", hvo.getNpreceivemny().floatValue());
|
||||
js_apct_detail.put("HTXSDD", js_apct);
|
||||
array.add(js_apct);
|
||||
js_apct_detail.put("HTXSDD", array);
|
||||
String resultString = doSendHttp(custUpdateUrl, "POST", tokenParam, "", headers,
|
||||
js_apct_detail.toJSONString());
|
||||
Map updateMap = gson.fromJson(resultString, Map.class);
|
||||
|
@ -809,6 +857,7 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
Map<String, Object> billMap = (Map) fromJson(json, Map.class);
|
||||
billMap.put("recaccount", billMap.get("ar_recaccount"));
|
||||
GatheringBillVO headvo = (GatheringBillVO) fromJsonToVO(billMap, GatheringBillVO.class);
|
||||
String pkBalatype= (String) billMap.get("pk_balatype");
|
||||
// 根据收款银行账户带出银行类别
|
||||
String def5 = getBankTypeByAccount(headvo.getRecaccount());
|
||||
headvo.setDef5(def5); // 银行类别
|
||||
|
@ -887,6 +936,11 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
// 合同金额
|
||||
// 结算组织
|
||||
headvo.setSett_org(headvo.getPk_org());
|
||||
|
||||
// pk_balatype =02、03、04、05时 收款银行账户字段无需赋值;
|
||||
if(pkBalatype != null && ("02".equals(pkBalatype) || "03".equals(pkBalatype) || "04".equals(pkBalatype) || "05".equals(pkBalatype))){
|
||||
headvo.setRecaccount(null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
|
@ -896,21 +950,33 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
// def6 合同编号
|
||||
// def3 标前项目号
|
||||
if (itemMaps.size() > 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def6"))
|
||||
.collect(Collectors.toList()), "zdy-001", org));
|
||||
}
|
||||
if (itemMaps.size() > 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def2"))
|
||||
.collect(Collectors.toList()), "BIP-ddh", org));
|
||||
}
|
||||
if (itemMaps.size() > 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def3"))
|
||||
.collect(Collectors.toList()), "zdy-023", org));
|
||||
|
||||
createProjectHeadVO(itemMaps, headvo.getPk_org().toString());
|
||||
DefdocVO[] defdocVOS=createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def6"))
|
||||
.collect(Collectors.toList()), "zdy-001", org);
|
||||
|
||||
if(defdocVOS.length != 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), defdocVOS);
|
||||
}
|
||||
}
|
||||
if (itemMaps.size() > 0) {
|
||||
DefdocVO[] defdocVOS=createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def2"))
|
||||
.collect(Collectors.toList()), "BIP-ddh", org);
|
||||
|
||||
if(defdocVOS.length != 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), defdocVOS);
|
||||
|
||||
}
|
||||
}
|
||||
if (itemMaps.size() > 0) {
|
||||
DefdocVO[] defdocVOS=createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def3"))
|
||||
.collect(Collectors.toList()), "zdy-023", org);
|
||||
if(defdocVOS.length != 0){
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), defdocVOS);
|
||||
}
|
||||
// createProjectHeadVO(itemMaps, headvo.getPk_org().toString());
|
||||
}
|
||||
|
||||
if (itemMaps != null && itemMaps.size() > 0) {
|
||||
|
@ -925,6 +991,11 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
itemvo.setRecaccount(headvo.getRecaccount());
|
||||
// pk_balatype 结算方式 表头带出
|
||||
itemvo.setPk_balatype(headvo.getPk_balatype());
|
||||
//
|
||||
// =02、03、04、05时 收款银行账户字段无需赋值;
|
||||
if(pkBalatype != null && ("02".equals(pkBalatype) || "03".equals(pkBalatype) || "04".equals(pkBalatype) || "05".equals(pkBalatype))){
|
||||
itemvo.setRecaccount(null);
|
||||
}
|
||||
// 票据类型 checktype 结算方式:银行承兑汇票-电子、银行承兑汇票-纸质=银行承兑汇票;商业承兑汇票-电子、商业承兑汇票-纸质=商业承兑汇票
|
||||
String checktypeName = "";
|
||||
if ("银行承兑汇票-电子".equals(balatypeName)) {
|
||||
|
@ -981,18 +1052,22 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
itemvo.getMoney_cr().multiply(itemvo.getRate()).setScale(2, UFDouble.ROUND_HALF_UP));
|
||||
Object def2 = itemvo.getDef2();
|
||||
if (def2 != null)
|
||||
itemvo.setDef2(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def2 + "' ") + "");
|
||||
itemvo.setDef2(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def2 + "' ") + "");
|
||||
Object def3 = itemvo.getDef3();
|
||||
if (def3 != null)
|
||||
itemvo.setDef3(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def3 + "' ") + "");
|
||||
itemvo.setDef3(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def3 + "' ") + "");
|
||||
Object def6 = itemvo.getDef6();
|
||||
if (def6 != null)
|
||||
itemvo.setDef6(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def6 + "' ") + "");
|
||||
itemvo.setDef6(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def6 + "' ") + "");
|
||||
// Object def36 = itemvo.getDef36();
|
||||
// if (def36 != null)
|
||||
// itemvo.setDef36(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def36 + "' ") + "");
|
||||
// 新增自定义档案
|
||||
|
||||
String projectOrg= (String) hybo.findColValue("org_orgs", "pk_org", " code = '" + headvo.getPk_org() + "' ");
|
||||
if(itemvo.getProject()!=null){
|
||||
itemvo.setProject(hybo.findColValue("bd_project", "pk_project", " project_code = '" + itemvo.getProject() + "' and pk_org = '" + projectOrg + "' " ) + "");
|
||||
}
|
||||
HYSuperDMO dmo = new HYSuperDMO();
|
||||
// SaleOrderHVO[] hvo = (SaleOrderHVO[]) dmo.queryByWhereClause(SaleOrderHVO.class,
|
||||
// "vbillcode='" + def2 + "' and dr=0");
|
||||
|
@ -1054,18 +1129,27 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
|
||||
private DefdocVO[] createDefVO(List<String> newhth, String defdoclistcode, String pk_org) throws BusinessException {
|
||||
String sql = " select pk_defdoclist from bd_defdoclist where code='" + defdoclistcode + "' ";
|
||||
|
||||
newhth = newhth.stream().distinct().collect(Collectors.toList());
|
||||
BaseDAO dao = new BaseDAO();
|
||||
String o = (String) dao.executeQuery(sql, new ColumnProcessor());
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
|
||||
ArrayList<DefdocVO> arrvo = new ArrayList<DefdocVO>();
|
||||
for (int i = 0; i < newhth.size(); i++) {
|
||||
if(newhth.get(i)==null){
|
||||
continue;
|
||||
}
|
||||
Object pk_defdoc = hybo.findColValue("bd_defdoc", "pk_defdoc", " (name = '" + newhth.get(i) + "' or code='" + newhth.get(i) + "') and pk_org = '" + pk_org + "'");
|
||||
|
||||
Object pk_defdoc = hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + newhth.get(i) + "' ");
|
||||
if (pk_defdoc != null) {
|
||||
continue;
|
||||
}
|
||||
if(defdoclistcode.equals("zdy-001") || defdoclistcode.equals("zdy-023")){
|
||||
Object project = hybo.findColValue("bd_project", "project_code", " project_code = '" + newhth.get(i) + "' and pk_org = '" + pk_org + "'");
|
||||
if (project != null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
DefdocVO vo = new DefdocVO();
|
||||
vo.setEnablestate(2);
|
||||
vo.setPk_defdoclist(o);
|
||||
|
@ -1133,4 +1217,351 @@ public class GatheringbillRestResource extends ArapBaseRestResource {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public JSONString bipInsert3(JSONString str) throws BusinessException {
|
||||
InvocationInfoProxy.getInstance().setGroupId("0001A110000000000677");
|
||||
NCCRestUtils.initInvocationInfo();
|
||||
String json = str.toJSONString();
|
||||
Map<String, Object> billMap = (Map) fromJson(json, Map.class);
|
||||
billMap.put("recaccount", billMap.get("ar_recaccount"));// 收款银行账户
|
||||
GatheringBillVO headvo = (GatheringBillVO) fromJsonToVO(billMap, GatheringBillVO.class);
|
||||
// bipInsert(str);
|
||||
// 根据收款银行账户带出银行类别
|
||||
String pkBalatype= (String) billMap.get("pk_balatype");
|
||||
|
||||
String def5 = getBankTypeByAccount(headvo.getRecaccount());
|
||||
headvo.setDef5(def5); // 银行类别
|
||||
headvo.setDef28(headvo.getBilldate().toStdString());// 交易日期
|
||||
// 汇率为空时,默认为1
|
||||
if (headvo.getRate() == null) {
|
||||
headvo.setRate(UFDouble.ONE_DBL);
|
||||
}
|
||||
// 结算方式名称
|
||||
Object balatypeName = "";
|
||||
// 金额
|
||||
UFDouble money = new UFDouble(0);
|
||||
// 税率
|
||||
UFDouble ntaxrate = new UFDouble(0);
|
||||
// 税码
|
||||
String ctaxcode = "";
|
||||
BaseDAO dao = new BaseDAO();
|
||||
// 销售订单号 从表体拿
|
||||
String csaleorderid = "";
|
||||
List<Map<String, Object>> itemMaps = (List) billMap.get("items");
|
||||
List<GatheringBillItemVO> itemvos = new ArrayList<GatheringBillItemVO>();
|
||||
HYPubBO hybo1 = new HYPubBO();
|
||||
String org = hybo1.findColValue("org_adminorg", "pk_adminorg", " code = '" + headvo.getPk_org() + "' ") + "";
|
||||
// headvo.setPk_org(org);
|
||||
// 根据BIP传的值进行创建自定义档案 def2 合同销售订单号
|
||||
// def6 合同编号
|
||||
// def3 标前项目号
|
||||
if (itemMaps.size() > 0) {
|
||||
|
||||
DefdocVO[] defdocVOS=createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def6"))
|
||||
.collect(Collectors.toList()), "zdy-001", org);
|
||||
|
||||
if(defdocVOS.length != 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), defdocVOS);
|
||||
}
|
||||
}
|
||||
if (itemMaps.size() > 0) {
|
||||
DefdocVO[] defdocVOS=createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def2"))
|
||||
.collect(Collectors.toList()), "BIP-ddh", org);
|
||||
|
||||
if(defdocVOS.length != 0) {
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), defdocVOS);
|
||||
|
||||
}
|
||||
}
|
||||
if (itemMaps.size() > 0) {
|
||||
DefdocVO[] defdocVOS=createDefVO(itemMaps.stream()
|
||||
.map(map -> (String) map.get("def3"))
|
||||
.collect(Collectors.toList()), "zdy-023", org);
|
||||
if(defdocVOS.length != 0){
|
||||
NCLocator.getInstance().lookup(IDefdocService.class).insertDefdocs(headvo.getPk_org(), defdocVOS);
|
||||
}
|
||||
// createProjectHeadVO(itemMaps, headvo.getPk_org().toString());
|
||||
}
|
||||
try {
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
headvo.setIsinit(new UFBoolean(false));
|
||||
// 默认 收款类型 默认合同收款单
|
||||
Object pk_billtypecode = hybo.findColValue("bd_billtype", "PK_BILLTYPECODE", "billtypename = '合同收款单' ");
|
||||
headvo.setPk_tradetype(pk_billtypecode.toString());
|
||||
// 业务流程 默认【收款传结算】
|
||||
Object pk_busitype = hybo.findColValue("bd_busitype", "busicode", "businame = '收款传结算' ");
|
||||
headvo.setPk_busitype(pk_busitype.toString());
|
||||
// 往来对象0-客户 2-部门 3-业务员 默认客户
|
||||
headvo.setObjtype(0);
|
||||
|
||||
// pk_currtype 币种编码 默认人民币
|
||||
if (headvo.getPk_currtype() == null || headvo.getPk_currtype().isEmpty()) {
|
||||
headvo.setPk_currtype("CNY");
|
||||
}
|
||||
|
||||
// accessorynum 附件张数 默认2
|
||||
headvo.setAccessorynum(2);
|
||||
// 制单人 默认BIP
|
||||
headvo.setBillmaker("BIP");
|
||||
// 结算方式名称
|
||||
String balatypeCode = headvo.getPk_balatype();
|
||||
if (!StringUtils.isEmpty(balatypeCode)) {
|
||||
Object pk_balatype = hybo.findColValue("bd_balatype", "pk_balatype", " code = '" + balatypeCode + "' ");
|
||||
// headvo.setPk_balatype(pk_balatype.toString());
|
||||
if (pk_balatype != null) {
|
||||
balatypeName = hybo.findColValue("bd_balatype", "name", " code = '" + balatypeCode + "' ");
|
||||
}
|
||||
|
||||
}
|
||||
headvo.setDef20((String) billMap.get("ID"));
|
||||
// 银行收款账号
|
||||
// 原币金额
|
||||
// 单据状态
|
||||
headvo.setBillstatus(-1);
|
||||
// 单据来源系统编码
|
||||
headvo.setSrc_syscode(17);
|
||||
// 合同金额
|
||||
// 结算组织
|
||||
headvo.setSett_org(headvo.getPk_org());
|
||||
// pk_balatype =02、03、04、05时 收款银行账户字段无需赋值;
|
||||
if(pkBalatype != null && ("02".equals(pkBalatype) || "03".equals(pkBalatype) || "04".equals(pkBalatype) || "05".equals(pkBalatype))){
|
||||
headvo.setRecaccount(null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
|
||||
if (itemMaps != null && itemMaps.size() > 0) {
|
||||
for (Map<String, Object> item : itemMaps) {
|
||||
GatheringBillItemVO itemvo = (GatheringBillItemVO) fromJsonToVO(item, GatheringBillItemVO.class);
|
||||
|
||||
try {
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
itemvo.setRecaccount(headvo.getRecaccount());
|
||||
// pk_balatype 结算方式 表头带出
|
||||
itemvo.setPk_balatype(headvo.getPk_balatype());
|
||||
if(pkBalatype != null && ("02".equals(pkBalatype) || "03".equals(pkBalatype) || "04".equals(pkBalatype) || "05".equals(pkBalatype))){
|
||||
itemvo.setRecaccount(null);
|
||||
}
|
||||
// 票据类型 checktype 结算方式:银行承兑汇票-电子、银行承兑汇票-纸质=银行承兑汇票;商业承兑汇票-电子、商业承兑汇票-纸质=商业承兑汇票
|
||||
String checktypeName = "";
|
||||
if ("银行承兑汇票-电子".equals(balatypeName)) {
|
||||
checktypeName = "电子银行承兑汇票";
|
||||
} else if ("商业承兑汇票-电子".equals(balatypeName)) {
|
||||
checktypeName = "电子商业承兑汇票";
|
||||
} else if ("商业承兑汇票-纸质".equals(balatypeName)) {
|
||||
checktypeName = "商业承兑汇票";
|
||||
} else if ("银行承兑汇票-纸质".equals(balatypeName)) {
|
||||
checktypeName = "银行承兑汇票";
|
||||
}
|
||||
|
||||
// objtype 往来对象0-客户 2-部门 3-业务员
|
||||
itemvo.setObjtype(headvo.getObjtype());
|
||||
csaleorderid = itemvo.getDef37();
|
||||
Object vbillcode = hybo.findColValue("so_saleorder", "vbillcode",
|
||||
"csaleorderid = '" + csaleorderid + "' ");
|
||||
if(vbillcode != null){
|
||||
// 客户
|
||||
Object customerid = hybo.findColValue("so_saleorder", "ccustomerid",
|
||||
"csaleorderid = '" + csaleorderid + "' ");
|
||||
Object customerCode = hybo.findColValue("bd_customer", "code", "pk_customer = '" + customerid + "' ");
|
||||
if (customerid != null || customerCode != null) {
|
||||
itemvo.setCustomer(customerid.toString());
|
||||
}else{
|
||||
// itemvo.setCustomer(headvo.getCustomer());
|
||||
Object custorm = hybo.findColValue("bd_customer", "pk_customer", "code = '" + itemvo.getCustomer() + "' ");
|
||||
itemvo.setCustomer((String) custorm);
|
||||
}
|
||||
// 税码
|
||||
Object ctaxcodeid = hybo.findColValue("so_saleorder_b", "ctaxcodeid",
|
||||
"csaleorderid = '" + csaleorderid + "' ");
|
||||
Object tc = hybo.findColValue("bd_taxcode", "code", "pk_taxcode = '" + ctaxcodeid + "' ");
|
||||
ctaxcode = getString_TrimAsNull(tc);
|
||||
// 业务员
|
||||
Object cemployeeid = hybo.findColValue("so_saleorder", "cemployeeid",
|
||||
"csaleorderid = '" + csaleorderid + "' ");
|
||||
if (cemployeeid != null) {// 能够获取到值,但是该值可能在销售订单生成的时候,没有翻译,依然存的是人员编码,如果存的是人员编码,则说明该人员在erp系统中不存在
|
||||
Object cemployeeCode = hybo.findColValue("bd_psndoc", "code", "pk_psndoc = '" + cemployeeid + "' ");
|
||||
if (cemployeeCode != null) {
|
||||
itemvo.setPk_psndoc(cemployeeid.toString());
|
||||
// 部门
|
||||
Object deptID = hybo.findColValue("org_orgs", "pk_org",
|
||||
" pk_org in( select pk_dept from bd_psnjob where pk_psndoc = '" + cemployeeid + "')");
|
||||
if (deptID != null) {
|
||||
itemvo.setPk_deptid(deptID.toString());
|
||||
}else{
|
||||
itemvo.setPk_deptid(headvo.getPk_deptid());
|
||||
}
|
||||
}else{
|
||||
|
||||
Object deptid = hybo.findColValue("org_dept", "pk_dept", "code = '" + itemvo.getPk_deptid() + "' ");
|
||||
itemvo.setPk_deptid((String) deptid);
|
||||
Object psndoc = hybo.findColValue("bd_psndoc", "pk_psndoc", "code = '" + itemvo.getPk_psndoc() + "' ");
|
||||
itemvo.setPk_psndoc((String) psndoc);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// Object custorm = hybo.findColValue("bd_customer", "pk_customer", "code = '" + "K31102276" + "' ");
|
||||
|
||||
Object custorm = hybo.findColValue("bd_customer", "pk_customer", "code = '" + itemvo.getCustomer() + "' ");
|
||||
itemvo.setCustomer((String) custorm);
|
||||
Object deptid = hybo.findColValue("org_dept", "pk_dept", "code = '" + itemvo.getPk_deptid() + "' ");
|
||||
itemvo.setPk_deptid((String) deptid);
|
||||
Object psndoc = hybo.findColValue("bd_psndoc", "pk_psndoc", "code = '" + itemvo.getPk_psndoc() + "' ");
|
||||
itemvo.setPk_psndoc((String) psndoc);
|
||||
|
||||
}
|
||||
|
||||
// pk_currtype 币种编码 表头带出
|
||||
itemvo.setPk_currtype(headvo.getPk_currtype());
|
||||
if (checktypeName != "") {
|
||||
Object checktypeCode = hybo.findColValue("bd_notetype", "code",
|
||||
" name = '" + checktypeName + "' ");
|
||||
itemvo.setChecktype(checktypeCode.toString());
|
||||
}
|
||||
|
||||
// pk_currtype 币种编码 表头带出
|
||||
itemvo.setPk_currtype(headvo.getPk_currtype());
|
||||
// prepay 收款性质 默认应收款 0
|
||||
itemvo.setPrepay(0);
|
||||
//
|
||||
UFDouble money_cr = itemvo.getMoney_cr();
|
||||
UFDouble local_tax_cr = money_cr.multiply(ntaxrate).div(100);
|
||||
itemvo.setLocal_tax_cr(local_tax_cr);
|
||||
//
|
||||
UFDouble notax_cr = money_cr.sub(local_tax_cr);
|
||||
itemvo.setNotax_cr(notax_cr);
|
||||
// zhangxinah增加组织本币无税金额(贷方)
|
||||
itemvo.setLocal_notax_cr(notax_cr);
|
||||
// 汇率为空时,默认为1
|
||||
if (headvo.getRate() == null) {
|
||||
itemvo.setRate(UFDouble.ONE_DBL);
|
||||
} else {
|
||||
itemvo.setRate(headvo.getRate());
|
||||
}
|
||||
//
|
||||
itemvo.setTaxcodeid(ctaxcode);
|
||||
//
|
||||
itemvo.setTaxrate(ntaxrate);
|
||||
// 收支项目
|
||||
itemvo.setPk_subjcode("201");
|
||||
money = money.add(itemvo.getMoney_cr());
|
||||
itemvo.setLocal_money_cr(
|
||||
itemvo.getMoney_cr().multiply(itemvo.getRate()).setScale(2, UFDouble.ROUND_HALF_UP));
|
||||
Object def2 = itemvo.getDef2();
|
||||
if (def2 != null)
|
||||
itemvo.setDef2(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def2 + "' or code='" +def2 + "'") + "");
|
||||
Object def3 = itemvo.getDef3();
|
||||
if (def3 != null){
|
||||
|
||||
Object pk= hybo.findColValue("bd_defdoc", "pk_defdoc", " (name = '" + def3 + "' or code='" + def3+ "') and pk_org = '" + org + "'");
|
||||
if(pk != null){
|
||||
itemvo.setDef3((String) pk);
|
||||
}else{
|
||||
Object project = hybo.findColValue("bd_project", "pk_project", " project_code = '" + def3 + "' and pk_org = '" + org + "'");
|
||||
if (project != null) {
|
||||
itemvo.setDef3((String) project);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object def6 = itemvo.getDef6();
|
||||
if (def6 != null){
|
||||
itemvo.setContractno(def6.toString());
|
||||
Object pk= hybo.findColValue("bd_defdoc", "pk_defdoc", " (name = '" + def6 + "' or code='" + def6+ "') and pk_org = '" + org + "'");
|
||||
if(pk != null){
|
||||
itemvo.setDef6((String) pk);
|
||||
}else{
|
||||
Object project = hybo.findColValue("bd_project", "pk_project", " project_code = '" + def6 + "' and pk_org = '" + org + "'");
|
||||
if (project != null) {
|
||||
itemvo.setDef6((String) project);
|
||||
itemvo.setProject((String)project);
|
||||
}
|
||||
}
|
||||
// itemvo.setDef6(hybo.findColValue("bd_defdoc", "pk_defdoc", " name = '" + def6 + "' or code='" +def6 + "'") + "");
|
||||
}
|
||||
Object def36 = itemvo.getDef36();
|
||||
Object def36Value = itemvo.getDef36();
|
||||
if (def36Value != null) {
|
||||
// 转义单引号:将 ' 替换为 ''
|
||||
String escapedValue = def36Value.toString().replace("'", "''");
|
||||
// 拼接转义后的字符串(若无法使用参数化查询时的临时方案)
|
||||
Object pkDefdoc = hybo.findColValue(
|
||||
"bd_defdoc",
|
||||
"pk_defdoc",
|
||||
"name = '" + escapedValue + "' or code = '" + escapedValue + "'"
|
||||
);
|
||||
itemvo.setDef36(pkDefdoc != null ? pkDefdoc.toString() : null);
|
||||
}
|
||||
HYSuperDMO dmo = new HYSuperDMO();
|
||||
SaleOrderHVO[] hvo = (SaleOrderHVO[]) dmo.queryByWhereClause(SaleOrderHVO.class,
|
||||
"csaleorderid='" + csaleorderid + "' and dr=0");
|
||||
if (hvo != null && hvo.length != 0) {
|
||||
SaleOrderBVO[] bvos = (SaleOrderBVO[]) dmo.queryByWhereClause(SaleOrderBVO.class,
|
||||
"csaleorderid='" + hvo[0].getPrimaryKey() + "'");
|
||||
if (bvos != null) {
|
||||
itemvo.setSrc_billid(bvos[0].getCsaleorderid());
|
||||
itemvo.setSrc_itemid(bvos[0].getCsaleorderbid());
|
||||
itemvo.setSrc_billtype("30");
|
||||
itemvo.setSrc_tradetype(hvo[0].getVtrantypecode());
|
||||
itemvo.setTop_billid(bvos[0].getCsaleorderid());
|
||||
itemvo.setTop_itemid(bvos[0].getCsaleorderbid());
|
||||
itemvo.setTop_billtype("30");
|
||||
}
|
||||
}
|
||||
itemvo.setOccupationmny(money_cr);//预占用原币余额
|
||||
itemvo.setMoney_bal(money_cr);//原币余额
|
||||
// itemvo.setLocal_money_cr(money_cr);//组织本币余额
|
||||
// String projectOrg= (String) hybo.findColValue("org_orgs", "pk_org", " code = '" + headvo.getPk_org() + "' ");
|
||||
// if(itemvo.getProject()!=null){
|
||||
// itemvo.setProject(hybo.findColValue("bd_project", "pk_project", " project_code = '" + itemvo.getProject() + "' and pk_org = '" + projectOrg + "' " ) + "");
|
||||
// }
|
||||
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
|
||||
itemvos.add(itemvo);
|
||||
}
|
||||
}
|
||||
|
||||
headvo.setMoney(money);
|
||||
headvo.setGloballocal(money);
|
||||
// headvo.setRate(new UFDouble(1));
|
||||
headvo.setLocal_money(money.multiply(headvo.getRate()).setScale(2, UFDouble.ROUND_HALF_UP));
|
||||
AggGatheringBillVO bill = new AggGatheringBillVO();
|
||||
bill.setParentVO(headvo);
|
||||
bill.setChildrenVO((CircularlyAccessibleValueObject[]) itemvos.toArray(new GatheringBillItemVO[0]));
|
||||
try {
|
||||
Map<String, String> returnMap = ((IGatheringbillOpenService) NCLocator.getInstance()
|
||||
.lookup(IGatheringbillOpenService.class)).saveBill(bill);
|
||||
JSONString resultJson = ResultMessageUtil.toJSON(returnMap);
|
||||
// 保存后动作
|
||||
JSONObject js_result = JSON.parseObject(resultJson.toJSONString());
|
||||
if (js_result.containsKey("success")) {
|
||||
if (js_result.getString("success").equals("true")) {
|
||||
if (js_result.containsKey("data")) {
|
||||
JSONObject js_data = js_result.getJSONObject("data");
|
||||
String pk_gatherid = js_data.getString("pk_bill");
|
||||
String pk_org = js_data.getString("pk_org");
|
||||
GatheringBillItemVO[] billItemVOs = (GatheringBillItemVO[]) bill.getChildrenVO();
|
||||
for (GatheringBillItemVO gatheringBillItemVO : billItemVOs) {
|
||||
// if(gatheringBillItemVO.getSrc_billid()==null){
|
||||
// continue;
|
||||
// }
|
||||
afterChangeMny(gatheringBillItemVO.getSrc_billid(), pk_org, gatheringBillItemVO.getDef6(),
|
||||
pk_gatherid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultJson;
|
||||
} catch (BusinessException e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,7 @@ import nc.vo.arap.gathering.AggGatheringBillVO;
|
|||
*/
|
||||
public interface IDevArapBill2R6Service {
|
||||
void updateR6Info(AggGatheringBillVO aggvo) throws Exception;
|
||||
|
||||
|
||||
void updateR6(AggGatheringBillVO aggvo) throws Exception;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue