nc添加南光
This commit is contained in:
+517
-5
@@ -432,7 +432,8 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
||||
reconciliationDTO.setInnerNumber(reconciliation.getInnerNumber());
|
||||
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
|
||||
String makerCodeNc="";
|
||||
if(reconciliation.getOrganizationName().contains("南岐")){
|
||||
//if(reconciliation.getOrganizationName().contains("南岐")){
|
||||
if(reconciliation.getOrganizationId()==2839){
|
||||
if(result.getCode()==200){
|
||||
String url = "";
|
||||
SysDepartInterfaceInfoDTO query= new SysDepartInterfaceInfoDTO();
|
||||
@@ -633,8 +634,12 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(reconciliation.getOrganizationName().contains("通宇")){
|
||||
}//else if(reconciliation.getOrganizationName().contains("通宇")){
|
||||
else if(reconciliation.getOrganizationId()==2830){//通宇
|
||||
boolean b = synchronousNc_TY(businessDocumentDetaliId);
|
||||
}//南光本部
|
||||
else if(reconciliation.getOrganizationId()==2840){
|
||||
boolean b = synchronousNc_NG(businessDocumentDetaliId);
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
e.printStackTrace();
|
||||
@@ -894,6 +899,257 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean synchronousNc_NG(String businessDocumentDetaliId) {
|
||||
Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId);
|
||||
if(reconciliation.getSynchronousStatus()==1){
|
||||
throw new ServiceException("该记录已同步,不需要再次同步");
|
||||
}
|
||||
try {
|
||||
Date date = reconciliation.getCreateTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy");
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
|
||||
String dateString = sdf.format(date);
|
||||
String invoiceId = reconciliation.getInvoiceId();
|
||||
ReconciliationDTO makeQuery=new ReconciliationDTO();
|
||||
makeQuery.setInnerNumber(invoiceId);
|
||||
R<List<TmsMakeOutInvoice>> makeList=wlhyServiceFeign.selectMakeOutInvoiceListByReconciliation(makeQuery);
|
||||
if (makeList.getCode()==200){
|
||||
int count = 0;
|
||||
for (TmsMakeOutInvoice make : makeList.getData()) {
|
||||
count++;
|
||||
List<Ysitem> ysitemList=new ArrayList<Ysitem>();
|
||||
ReconciliationDTO reconciliationDTO=new ReconciliationDTO();
|
||||
reconciliationDTO.setInnerNumber(reconciliation.getInnerNumber());
|
||||
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
|
||||
TmsOrder order = null;
|
||||
if (result.getCode()==200){
|
||||
order = result.getData()!=null && result.getData().size()>0?result.getData().get(0):null;
|
||||
}
|
||||
if (order==null){
|
||||
throw new ServiceException("未找到对应订单信息");
|
||||
}
|
||||
String url = "";
|
||||
SysDepartInterfaceInfoDTO query= new SysDepartInterfaceInfoDTO();
|
||||
query.setOrganizationId(reconciliation.getOrganizationId());
|
||||
query.setOrganizationName(reconciliation.getOrganizationName());
|
||||
query.setInterfaceType("nc");
|
||||
List<SysDepartInterfaceInfoPo> urlList = thirdPartyServiceFeign.queryList(query);
|
||||
if (urlList != null && urlList.size() > 0) {
|
||||
url = urlList.get(0).getInterfaceTypeValue();
|
||||
} else {
|
||||
throw new ServiceException("未找到该组织的推送地址!");
|
||||
}
|
||||
|
||||
String makerCodeNc=order.getMakerCodeNc();
|
||||
String salesmanCodeNc=order.getSalesmanCodeNc();
|
||||
//String customerCodeNc=order.getCustomerCodeNc();
|
||||
String appointShipper=make.getActualInvoiceCustomerName();
|
||||
String actualInvoiceCustomerId = make.getActualInvoiceCustomerId();
|
||||
String customerCodeNc = reconciliationMapper.getCustomerCodeNc(actualInvoiceCustomerId);
|
||||
String settlementCurrency=order.getSettlementCurrency();
|
||||
String salesmanId = order.getSalesmanId();
|
||||
String customerUserDept = reconciliationMapper.getCustomerUserDept(salesmanId);
|
||||
String deptValue = reconciliationMapper.getDeptValue(customerUserDept);
|
||||
String deptName = reconciliationMapper.getDeptName(customerUserDept);
|
||||
String documentPreparerNcCode = reconciliationMapper.getDocumentPreparerNcCode(salesmanId);
|
||||
makerCodeNc= documentPreparerNcCode;
|
||||
String settlementCurrencyNcCode = settlementCurrency;
|
||||
String invoiceNumber=make.getInvoiceNumber();
|
||||
R<List<TmsMakeOutInvoiceItem>> itemR = wlhyServiceFeign.selectMakeOutInvoiceItemList(make);
|
||||
if (itemR.getCode()==200) {
|
||||
List<TmsMakeOutInvoiceItem> data = itemR.getData();
|
||||
for (TmsMakeOutInvoiceItem item1 : data) {
|
||||
if(item1.getInvoiceValue().compareTo(BigDecimal.ZERO)>0){
|
||||
Ysitem item=new Ysitem();
|
||||
if (deptValue != null && !deptValue.isEmpty()) {
|
||||
item.setSo_deptid(deptValue);
|
||||
} else {
|
||||
item.setSo_deptid("NG0109");
|
||||
}
|
||||
if (deptValue != null && !deptValue.isEmpty()) {
|
||||
item.setPk_deptid(deptValue);
|
||||
} else {
|
||||
item.setPk_deptid("NG0109");
|
||||
}
|
||||
//业务员nc
|
||||
item.setPk_psndoc(salesmanCodeNc);
|
||||
//客户nc
|
||||
item.setCustomer(customerCodeNc);
|
||||
item.setObjtype("0");
|
||||
item.setDirection("1");
|
||||
String invoiceItem = item1.getInvoiceItem();
|
||||
List<String> names = new ArrayList<>();
|
||||
if (invoiceItem != null && !invoiceItem.isEmpty()) {
|
||||
String[] items = invoiceItem.split(",");
|
||||
for (String s : items) {
|
||||
String invoiceItemName1 = reconciliationMapper.getInvoiceItemName(s);
|
||||
names.add(invoiceItemName1);
|
||||
}
|
||||
}
|
||||
String invoiceItemName = String.join(",", names);
|
||||
//item.setDef29(invoiceItemName);
|
||||
if (deptName != null && !deptName.isEmpty()) {
|
||||
item.setScomment(deptName+":应收"+appointShipper+invoiceItemName+invoiceNumber);
|
||||
} else {
|
||||
item.setScomment("业务部:应收"+appointShipper+invoiceItemName+invoiceNumber);
|
||||
}
|
||||
// item.setPk_currtype("CNY");
|
||||
item.setPk_currtype(settlementCurrencyNcCode);
|
||||
item.setPurchaseorder("");
|
||||
item.setTaxrate(String.valueOf(item1.getTaxRate()));
|
||||
item.setQuantity_de("0");
|
||||
item.setMoney_de(String.valueOf(item1.getInvoiceValue()));
|
||||
item.setMoney_bal(String.valueOf(item1.getInvoiceValue()));
|
||||
BigDecimal tax_de=item1.getTaxAmount();
|
||||
BigDecimal notax_de=item1.getTaxFreeFee();
|
||||
item.setNotax_de(String.valueOf(notax_de));
|
||||
item.setLocal_tax_de(String.valueOf(tax_de));
|
||||
item.setTax_de(String.valueOf(tax_de));
|
||||
item.setPrice(String.valueOf(item1.getInvoiceValue()));
|
||||
item.setTaxprice(String.valueOf(item1.getInvoiceValue()));
|
||||
// 费用类别
|
||||
String feeType = item1.getFeeType();
|
||||
String serviceItemsCodeNc = reconciliationMapper.getServiceItemsCodeNc(feeType);
|
||||
if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) {
|
||||
item.setDef75(serviceItemsCodeNc);
|
||||
} else {
|
||||
item.setDef75("T10");
|
||||
}
|
||||
item.setTaxcodeid("ZL01");
|
||||
item.setInvoiceno(invoiceNumber);
|
||||
ysitemList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ysbodys bodys=new Ysbodys();
|
||||
bodys.setItem(ysitemList);
|
||||
Ysbillhead billhead=new Ysbillhead();
|
||||
billhead.setPk_group("CNK");
|
||||
billhead.setPk_org("NG01");
|
||||
billhead.setSett_org("NG01");
|
||||
billhead.setCreationtime(dateString);
|
||||
billhead.setCreator(makerCodeNc);
|
||||
billhead.setPk_billtype("F0");
|
||||
billhead.setPk_tradetype("D0");
|
||||
billhead.setBillclass("ys");
|
||||
billhead.setIsinit("N");
|
||||
date=reconciliation.getCreateTime();
|
||||
dateString = sdf.format(date);
|
||||
billhead.setBilldate(dateString);
|
||||
billhead.setSyscode("0");
|
||||
billhead.setBillno("");
|
||||
billhead.setDef59("");
|
||||
billhead.setSrc_syscode("0");
|
||||
billhead.setBillstatus("0");
|
||||
billhead.setBillmaker(makerCodeNc);
|
||||
billhead.setPk_busitype("");
|
||||
billhead.setBillyear(sdf1.format(date));
|
||||
billhead.setBillperiod(sdf2.format(date));
|
||||
billhead.setEffectstatus("0");
|
||||
billhead.setDef28("nqyw");
|
||||
billhead.setDef29(reconciliation.getInnerNumber());
|
||||
billhead.setBodys(bodys);
|
||||
Ysbill bill=new Ysbill();
|
||||
bill.setId("ys"+String.valueOf(reconciliation.getReconciliationId())+"_"+count);
|
||||
bill.setBillhead(billhead);
|
||||
Ysufinterface ufinterface=new Ysufinterface();
|
||||
ufinterface.setAccount("NKNC");
|
||||
ufinterface.setBilltype("F0");
|
||||
ufinterface.setBusinessunitcode("");
|
||||
ufinterface.setFilename("");
|
||||
ufinterface.setIsexchange("Y");
|
||||
ufinterface.setOrgcode("NG01");
|
||||
ufinterface.setReceiver("NG01");
|
||||
ufinterface.setReplace("Y");
|
||||
ufinterface.setRoottag("");
|
||||
ufinterface.setSender("nqyw");
|
||||
ufinterface.setBill(bill);
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class);
|
||||
Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
|
||||
StringWriter sw = new StringWriter();
|
||||
marshaller.marshal(ufinterface, sw);
|
||||
String xmlString = sw.toString(); // 这是要发送的XML字符串
|
||||
System.out.println(xmlString);
|
||||
NcLog ncLog=new NcLog();
|
||||
ncLog.setOrderId(reconciliation.getReconciliationId());
|
||||
ncLog.setRequestBody(xmlString);
|
||||
ncLog.setResponeBody("");
|
||||
ncLog.setType(0L);
|
||||
ncLog.setOrganizationId(reconciliation.getOrganizationId());
|
||||
ncLog.setOrganizationName(reconciliation.getOrganizationName());
|
||||
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
|
||||
ncLogMapper.insert(ncLog);
|
||||
reconciliation.setSynchronousStatus(1);
|
||||
reconciliation.setSynchronousTime(new Date());
|
||||
reconciliation.setNcId("ys"+String.valueOf(reconciliation.getReconciliationId()));
|
||||
//reconciliationMapper.updateById(reconciliation);
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
|
||||
httpPost.setEntity(postingString);
|
||||
httpPost.setHeader("Content-type", "application/xml");
|
||||
try {
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
System.out.println(responseString);
|
||||
ncLog.setResponeBody(responseString);
|
||||
// 创建DOM解析器
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document document = builder.parse(new InputSource(new StringReader(responseString)));
|
||||
|
||||
// 获取根元素
|
||||
Element root = document.getDocumentElement();
|
||||
|
||||
// 获取ufinterface元素的属性
|
||||
String billtype = root.getAttribute("billtype");
|
||||
String filename = root.getAttribute("filename");
|
||||
System.out.println("billtype: " + billtype);
|
||||
System.out.println("filename: " + filename);
|
||||
|
||||
// 获取sendresult节点
|
||||
NodeList sendResultList = root.getElementsByTagName("sendresult");
|
||||
if (sendResultList.getLength() > 0) {
|
||||
Element sendResult = (Element) sendResultList.item(0);
|
||||
|
||||
// 获取子元素内容
|
||||
String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent();
|
||||
String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent();
|
||||
String content = sendResult.getElementsByTagName("content").item(0).getTextContent();
|
||||
|
||||
System.out.println("bdocid: " + bdocid);
|
||||
System.out.println("resultcode: " + resultcode);
|
||||
System.out.println("content: " + content);
|
||||
if(resultcode.equals("1")){
|
||||
reconciliation.setSynchronousStatus(1);
|
||||
}else{
|
||||
reconciliation.setSynchronousStatus(2);
|
||||
}
|
||||
}
|
||||
ncLogMapper.updateById(ncLog);
|
||||
reconciliationMapper.updateById(reconciliation);
|
||||
response.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean synchronousNcSK(String businessDocumentDetaliIds) {
|
||||
String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(",");
|
||||
@@ -924,7 +1180,8 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
||||
throw new ServiceException("没有结算方,请核对");
|
||||
}*/
|
||||
String makerCodeNc="";
|
||||
if(reconciliation.getOrganizationName().contains("南岐")){
|
||||
//if(reconciliation.getOrganizationName().contains("南岐")){
|
||||
if(reconciliation.getOrganizationId()==2839){
|
||||
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
|
||||
String url = "";
|
||||
SysDepartInterfaceInfoDTO query= new SysDepartInterfaceInfoDTO();
|
||||
@@ -1090,9 +1347,13 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}else if(reconciliation.getOrganizationName().contains("通宇")){
|
||||
}//else if(reconciliation.getOrganizationName().contains("通宇")){
|
||||
else if(reconciliation.getOrganizationId()==2830){//通宇
|
||||
boolean b = synchronousNcSK_TY(businessDocumentDetaliId);
|
||||
}
|
||||
else if(reconciliation.getOrganizationId()==2840){//南光本部
|
||||
boolean b = synchronousNcSK_NG(businessDocumentDetaliId);
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -1350,4 +1611,255 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean synchronousNcSK_NG(String businessDocumentDetaliId) {
|
||||
Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId);
|
||||
if(reconciliation.getSkSynchronousStatus()==1){
|
||||
throw new ServiceException("该记录已同步,不需要再次同步");
|
||||
}
|
||||
try {
|
||||
Date date = reconciliation.getCreateTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy");
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
|
||||
String dateString = sdf.format(date);
|
||||
String invoiceId = reconciliation.getInvoiceId();
|
||||
ReconciliationDTO makeQuery=new ReconciliationDTO();
|
||||
makeQuery.setInnerNumber(invoiceId);
|
||||
R<List<TmsMakeOutInvoice>> makeList=wlhyServiceFeign.selectMakeOutInvoiceListByReconciliation(makeQuery);
|
||||
if (makeList.getCode()==200){
|
||||
int count= 0;
|
||||
for (TmsMakeOutInvoice make : makeList.getData()) {
|
||||
count++;
|
||||
List<SKitem> ysitemList=new ArrayList<SKitem>();
|
||||
ReconciliationDTO reconciliationDTO=new ReconciliationDTO();
|
||||
reconciliationDTO.setInnerNumber(reconciliation.getInnerNumber());
|
||||
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
|
||||
TmsOrder order = null;
|
||||
if (result.getCode()==200){
|
||||
order = result.getData()!=null && result.getData().size()>0?result.getData().get(0):null;
|
||||
}
|
||||
if (order==null){
|
||||
throw new ServiceException("未找到对应订单信息");
|
||||
}
|
||||
String url = "";
|
||||
SysDepartInterfaceInfoDTO query= new SysDepartInterfaceInfoDTO();
|
||||
query.setOrganizationId(reconciliation.getOrganizationId());
|
||||
query.setOrganizationName(reconciliation.getOrganizationName());
|
||||
query.setInterfaceType("nc");
|
||||
List<SysDepartInterfaceInfoPo> urlList = thirdPartyServiceFeign.queryList(query);
|
||||
if (urlList != null && urlList.size() > 0) {
|
||||
url = urlList.get(0).getInterfaceTypeValue();
|
||||
} else {
|
||||
throw new ServiceException("未找到该组织的推送地址!");
|
||||
}
|
||||
R<List<TmsMakeOutInvoiceItem>> itemR = wlhyServiceFeign.selectMakeOutInvoiceItemList(make);
|
||||
String makerCodeNc = "";
|
||||
if(itemR.getCode()==200){
|
||||
List<TmsMakeOutInvoiceItem> list=itemR.getData();
|
||||
if(ObjectUtil.isNotNull(list)){
|
||||
// 汇总 list 中 invoiceValue 的总值
|
||||
BigDecimal totalInvoiceValue = list.stream()
|
||||
.map(TmsMakeOutInvoiceItem::getInvoiceValue)
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 将 feeType 用、拼接起来
|
||||
String feeTypes = list.stream()
|
||||
.map(TmsMakeOutInvoiceItem::getFeeType)
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.collect(java.util.stream.Collectors.joining("、"));
|
||||
// 按 createTime 倒序排序并获取第一条记录
|
||||
TmsMakeOutInvoiceItem firstItem = list.stream()
|
||||
.sorted((a, b) -> {
|
||||
if (a.getCreateTime() == null) return 1;
|
||||
if (b.getCreateTime() == null) return -1;
|
||||
return b.getCreateTime().compareTo(a.getCreateTime());
|
||||
})
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
String salesmanCodeNc=order.getSalesmanCodeNc();
|
||||
String salesmanId = order.getSalesmanId();
|
||||
String customerUserDept = reconciliationMapper.getCustomerUserDept(salesmanId);
|
||||
String deptValue = reconciliationMapper.getDeptValue(customerUserDept);
|
||||
String deptName = reconciliationMapper.getDeptName(customerUserDept);
|
||||
//String customerCodeNc=order.getCustomerCodeNc();
|
||||
String appointShipper=make.getActualInvoiceCustomerName();
|
||||
String actualInvoiceCustomerId = make.getActualInvoiceCustomerId();
|
||||
String customerCodeNc = reconciliationMapper.getCustomerCodeNc(actualInvoiceCustomerId);
|
||||
String documentPreparerNcCode = reconciliationMapper.getDocumentPreparerNcCode(salesmanId);
|
||||
String settlementCurrency=order.getSettlementCurrency();
|
||||
String settlementCurrencyNcCode = settlementCurrency;
|
||||
makerCodeNc=documentPreparerNcCode;
|
||||
SKitem item=new SKitem();
|
||||
if (deptValue != null && !deptValue.isEmpty()) {
|
||||
item.setSo_deptid(deptValue);
|
||||
} else {
|
||||
item.setSo_deptid("NG0109");
|
||||
}
|
||||
if (deptValue != null && !deptValue.isEmpty()) {
|
||||
item.setPk_deptid(deptValue);
|
||||
} else {
|
||||
item.setPk_deptid("NG0109");
|
||||
}
|
||||
item.setCheckdirection("ar");
|
||||
item.setPk_psndoc(salesmanCodeNc);
|
||||
item.setCustomer(customerCodeNc);
|
||||
item.setPurchaseorder("");
|
||||
item.setObjtype("0");
|
||||
item.setDirection("1");
|
||||
if (deptName != null && !deptName.isEmpty()) {
|
||||
if (feeTypes != null && !feeTypes.isEmpty()) {
|
||||
item.setScomment(deptName+":"+appointShipper+feeTypes);
|
||||
} else {
|
||||
item.setScomment(deptName+":"+appointShipper+feeTypes);
|
||||
}
|
||||
} else {
|
||||
if (feeTypes != null && !feeTypes.isEmpty()) {
|
||||
item.setScomment("业务部:"+appointShipper+feeTypes);
|
||||
} else {
|
||||
item.setScomment("业务部:"+appointShipper+feeTypes);
|
||||
}
|
||||
}
|
||||
// 费用类别
|
||||
String feeType = firstItem.getFeeType();
|
||||
String serviceItemsCodeNc = reconciliationMapper.getServiceItemsCodeNc(feeType);
|
||||
if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) {
|
||||
item.setDef75(serviceItemsCodeNc);
|
||||
} else {
|
||||
item.setDef75("T10");
|
||||
}
|
||||
item.setPk_currtype(settlementCurrencyNcCode);
|
||||
item.setMoney_cr(String.valueOf(totalInvoiceValue));
|
||||
item.setMoney_bal(String.valueOf(totalInvoiceValue));
|
||||
ysitemList.add(item);
|
||||
}
|
||||
}
|
||||
SKbodys bodys=new SKbodys();
|
||||
bodys.setItem(ysitemList);
|
||||
SKbillhead billhead=new SKbillhead();
|
||||
billhead.setPk_group("CNK");
|
||||
billhead.setPk_org("NG01");
|
||||
billhead.setSett_org("NG01");
|
||||
billhead.setCreationtime(dateString);
|
||||
billhead.setPk_billtype("F2");
|
||||
billhead.setCreator(makerCodeNc);
|
||||
billhead.setPk_tradetype("D2");
|
||||
billhead.setBillclass("sk");
|
||||
billhead.setBilldate(dateString);
|
||||
billhead.setSyscode("0");
|
||||
billhead.setBillno("");
|
||||
billhead.setDef59("");
|
||||
billhead.setSrc_syscode("0");
|
||||
billhead.setBillstatus("0");
|
||||
billhead.setBillmaker(makerCodeNc);
|
||||
billhead.setPk_busitype("");
|
||||
billhead.setBillyear(sdf1.format(date));
|
||||
billhead.setBillperiod(sdf2.format(date));
|
||||
billhead.setEffectstatus("0");
|
||||
billhead.setDef28("nqyw");
|
||||
billhead.setDef29(reconciliation.getInnerNumber());
|
||||
billhead.setBodys(bodys);
|
||||
SKbill bill=new SKbill();
|
||||
bill.setId("sk"+String.valueOf(reconciliation.getReconciliationId())+"_"+count);
|
||||
bill.setBillhead(billhead);
|
||||
SKufinterface ufinterface=new SKufinterface();
|
||||
ufinterface.setAccount("NKNC");
|
||||
ufinterface.setBilltype("F2");
|
||||
ufinterface.setBusinessunitcode("");
|
||||
ufinterface.setFilename("");
|
||||
ufinterface.setIsexchange("Y");
|
||||
ufinterface.setOrgcode("NG01");
|
||||
ufinterface.setReceiver("NG01");
|
||||
ufinterface.setReplace("Y");
|
||||
ufinterface.setRoottag("");
|
||||
ufinterface.setSender("nqyw");
|
||||
ufinterface.setBill(bill);
|
||||
JAXBContext jaxbContext = null;
|
||||
//String xmlString ="<ufinterface account=\"NKNC\" billtype=\"F0\" businessunitcode=\"\" filename=\"\" groupcode=\"CNK\" isexchange=\"Y\" orgcode=\"NG10\" receiver=\"NG10\" replace=\"Y\" roottag=\"\" sender=\"NKT_MY\">";
|
||||
jaxbContext = JAXBContext.newInstance(SKufinterface.class);
|
||||
Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
|
||||
StringWriter sw = new StringWriter();
|
||||
marshaller.marshal(ufinterface, sw);
|
||||
String xmlString = sw.toString(); // 这是要发送的XML字符串
|
||||
System.out.println(xmlString);
|
||||
NcLog ncLog=new NcLog();
|
||||
ncLog.setOrderId(reconciliation.getReconciliationId());
|
||||
ncLog.setRequestBody(xmlString);
|
||||
ncLog.setResponeBody("");
|
||||
ncLog.setType(1L);
|
||||
ncLog.setOrganizationId(reconciliation.getOrganizationId());
|
||||
ncLog.setOrganizationName(reconciliation.getOrganizationName());
|
||||
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
|
||||
ncLogMapper.insert(ncLog);
|
||||
reconciliation.setSkSynchronousStatus(1);
|
||||
reconciliation.setSkSynchronousTime(new Date());
|
||||
reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId()));
|
||||
//reconciliationMapper.updateById(reconciliation);
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
|
||||
httpPost.setEntity(postingString);
|
||||
httpPost.setHeader("Content-type", "application/xml");
|
||||
try {
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
System.out.println(responseString);
|
||||
ncLog.setResponeBody(responseString);
|
||||
// 创建DOM解析器
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document document = builder.parse(new InputSource(new StringReader(responseString)));
|
||||
|
||||
// 获取根元素
|
||||
Element root = document.getDocumentElement();
|
||||
|
||||
// 获取ufinterface元素的属性
|
||||
String billtype = root.getAttribute("billtype");
|
||||
String filename = root.getAttribute("filename");
|
||||
System.out.println("billtype: " + billtype);
|
||||
System.out.println("filename: " + filename);
|
||||
|
||||
// 获取sendresult节点
|
||||
NodeList sendResultList = root.getElementsByTagName("sendresult");
|
||||
if (sendResultList.getLength() > 0) {
|
||||
Element sendResult = (Element) sendResultList.item(0);
|
||||
|
||||
// 获取子元素内容
|
||||
String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent();
|
||||
String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent();
|
||||
String content = sendResult.getElementsByTagName("content").item(0).getTextContent();
|
||||
|
||||
System.out.println("bdocid: " + bdocid);
|
||||
System.out.println("resultcode: " + resultcode);
|
||||
System.out.println("content: " + content);
|
||||
if(resultcode.equals("1")){
|
||||
reconciliation.setSkSynchronousStatus(1);
|
||||
}else{
|
||||
reconciliation.setSkSynchronousStatus(2);
|
||||
}
|
||||
}
|
||||
ncLogMapper.updateById(ncLog);
|
||||
reconciliationMapper.updateById(reconciliation);
|
||||
response.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,21 +20,21 @@ spring:
|
||||
discovery:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
# server-addr: 10.33.0.129:6010
|
||||
server-addr: 10.102.192.5:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
server-addr: 10.33.0.129:6010
|
||||
# server-addr: 10.102.192.5:6848
|
||||
# username: nacos
|
||||
# password: manhuoda@2023
|
||||
config:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
# server-addr: 10.33.0.129:6010
|
||||
server-addr: 10.102.192.5:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
server-addr: 10.33.0.129:6010
|
||||
# server-addr: 10.102.192.5:6848
|
||||
# username: nacos
|
||||
# password: manhuoda@2023
|
||||
#线上正式环境
|
||||
# server-addr: 10.102.192.105:6848
|
||||
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
||||
file-extension: yml #默认properties
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
||||
Reference in New Issue
Block a user