功能调整

This commit is contained in:
lj 2025-03-27 16:21:39 +08:00
parent 44a1ed41f7
commit e0732a29e5
8 changed files with 522 additions and 326 deletions

View File

@ -5,6 +5,22 @@
package nc.bs.arap.actions;
import nc.bs.arap.bill.ArapBillPubUtil;
import nc.bs.arap.util.ArapBillVOUtils;
import nc.bs.arap.util.ArapVOUtils;
import nc.bs.arap.util.BillAccountCalendarUtils;
import nc.bs.arap.validator.CrossRuleCheckValidator;
import nc.bs.dao.BaseDAO;
import nc.jdbc.framework.processor.MapProcessor;
import nc.vo.arap.basebill.BaseBillVO;
import nc.vo.arap.utils.StringUtil;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.lang.UFDouble;
import java.util.Map;
public class GatheringbillEditSaveBatchBSAction extends BillUpdateBatchBSAction {
public GatheringbillEditSaveBatchBSAction() {
this.validatorCode.add(5);
@ -12,6 +28,79 @@ public class GatheringbillEditSaveBatchBSAction extends BillUpdateBatchBSAction
this.validatorCode.add(57);
this.validatorCode.add(59);
this.validatorCode.add(62);
this.validatorCode.remove(44);
}
protected void doBeforeUpdate(AggregatedValueObject[] bills, AggregatedValueObject[] orginBills) throws BusinessException {
ArapBillPubUtil.fillTradeTypeInfo(bills);
for(AggregatedValueObject bill : bills) {
ArapBillPubUtil.processMoneyOnlySum(bill);
}
/**
* 收款单保存校验关联的销售订单实际收款金额是否超过价税合计
*/
int i = 0;
for(AggregatedValueObject bill : bills) {
AggregatedValueObject oriBill = orginBills[i++];
BaseBillVO billVO = (BaseBillVO) bill.getParentVO(); //修改的收款单
BaseBillVO billOriVO = (BaseBillVO) oriBill.getParentVO(); //之前的收款单
UFDouble money = billVO.getMoney(); //修改后的金额
UFDouble oriMoney = billOriVO.getMoney(); //修改前的金额
String pk_tradetype = billVO.getPk_tradetype();
if(!"F2-Cxx-02".equals(pk_tradetype)){
continue;
}
String def3 = billVO.getDef3(); //收款单对应的销售订单id
if(StringUtil.isEmpty(def3) || "N".equals(def3) || "~".equals(def3)){
//无绑定的销售订单则下一次循环
continue;
}
//计算收款单金额差值
UFDouble changeMoney = money.sub(oriMoney);
//根据销售订单id去查询销售订单
BaseDAO dao = new BaseDAO();
String sql = "select nreceivedmny,ntotalorigmny from so_saleorder where dr = 0 and csaleorderid = '" +def3+"'";
Map saleMap = (Map)dao.executeQuery(sql, new MapProcessor());
//销售订单价税合计
UFDouble ntotalorigmny = UFDouble.ZERO_DBL;
//销售订单实际收款金额
UFDouble nreceivedmny = UFDouble.ZERO_DBL;
if(saleMap != null) {
nreceivedmny = new UFDouble(saleMap.get("nreceivedmny") == null ? "0" : saleMap.get("nreceivedmny").toString());
ntotalorigmny = new UFDouble(saleMap.get("ntotalorigmny") == null ? "0" : saleMap.get("ntotalorigmny").toString());
}
UFDouble moreMoney = nreceivedmny.add(changeMoney).sub(ntotalorigmny);
if(nreceivedmny.add(changeMoney).compareTo(ntotalorigmny) > 0){
throw new BusinessException("【该笔收款已超销售订单"+ moreMoney +"元,无法传输!请检查订单累计收款金额!】");
}
}
ArapBillVOUtils.prepareDefaultInfo(bills, true);
int updateType = this.getUpdateType(bills, orginBills);
for(AggregatedValueObject bill : bills) {
bill.getParentVO().setStatus(1);
}
if (updateType == TEMP_2_SAVE || updateType == SAVE_2_SAVE) {
for(AggregatedValueObject bill : bills) {
for(CircularlyAccessibleValueObject item : bill.getChildrenVO()) {
if (item.getStatus() != 2 && item.getStatus() != 3) {
item.setStatus(1);
}
}
}
}
if (updateType == TEMP_2_SAVE || updateType == SAVE_2_SAVE) {
BillAccountCalendarUtils.setAccperiodYearMonth(bills);
}
this.checkIsCorrdBillMoneyControl(bills, orginBills);
this.checkOtherSystemBill(bills, orginBills);
(new CrossRuleCheckValidator()).validate(bills);
ArapVOUtils.resetMoneyBal(bills, orginBills);
}
}

View File

@ -5,6 +5,19 @@
package nc.bs.arap.actions;
import nc.bs.arap.bill.ArapBillPubUtil;
import nc.bs.arap.util.*;
import nc.bs.arap.validator.CrossRuleCheckValidator;
import nc.bs.dao.BaseDAO;
import nc.jdbc.framework.processor.MapProcessor;
import nc.vo.arap.basebill.BaseBillVO;
import nc.vo.arap.utils.StringUtil;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
import java.util.Map;
public class GatheringbillSaveBatchBSAction extends BillInsertBatchBSAction {
public GatheringbillSaveBatchBSAction() {
this.validatorCode.add(5);
@ -26,4 +39,52 @@ public class GatheringbillSaveBatchBSAction extends BillInsertBatchBSAction {
this.validatorCode.add(62);
this.validatorCode.add(76);
}
protected void doBeforeInsert(AggregatedValueObject[] bills) throws BusinessException {
ArapBillPubUtil.fillTradeTypeInfo(bills);
BillBankUtils.fillSettleBankrelated_code(bills);
BillDateUtils.setBillDateByNow(bills);
ArapBillPubUtil.resetBasedocVid(bills);
BillAccountCalendarUtils.setAccperiodYearMonth(bills);
ArapBillVOUtils.prepareDefaultInfo(bills);
BillMoneyVUtils.sumAllVoBodyToHead(bills);
(new CrossRuleCheckValidator()).validate(bills);
ArapBillPubUtil.resetDestVODoc(bills);
ArapBillVOUtils.setMaterialInfo(bills);
ArapBillVOUtils.setDefaultSagaFrozen(bills);
/**
* 收款单保存校验关联的销售订单实际收款金额是否超过价税合计
*/
for(AggregatedValueObject bill : bills) {
BaseBillVO billVO = (BaseBillVO) bill.getParentVO(); //修改的收款单
UFDouble money = billVO.getMoney(); //金额
String pk_tradetype = billVO.getPk_tradetype();
if(!"F2-Cxx-02".equals(pk_tradetype)){
continue;
}
String def3 = billVO.getDef3(); //收款单对应的销售订单id
if(StringUtil.isEmpty(def3) || "N".equals(def3) || "~".equals(def3)){
//无绑定的销售订单则下一次循环
continue;
}
//根据销售订单id去查询销售订单
BaseDAO dao = new BaseDAO();
String sql = "select nreceivedmny,ntotalorigmny from so_saleorder where dr = 0 and csaleorderid = '" +def3+"'";
Map saleMap = (Map)dao.executeQuery(sql, new MapProcessor());
//销售订单价税合计
UFDouble ntotalorigmny = UFDouble.ZERO_DBL;
//销售订单实际收款金额
UFDouble nreceivedmny = UFDouble.ZERO_DBL;
if(saleMap != null) {
nreceivedmny = new UFDouble(saleMap.get("nreceivedmny") == null ? "0" : saleMap.get("nreceivedmny").toString());
ntotalorigmny = new UFDouble(saleMap.get("ntotalorigmny") == null ? "0" : saleMap.get("ntotalorigmny").toString());
}
UFDouble moreMoney = nreceivedmny.add(money).sub(ntotalorigmny);
if(nreceivedmny.add(money).compareTo(ntotalorigmny) > 0){
throw new BusinessException("【该笔收款已超销售订单"+ moreMoney +"元,无法传输!请检查订单累计收款金额!】");
}
}
}
}

View File

@ -1,31 +1,10 @@
package nc.bs.arap.busireg;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.yonyou.cloud.utils.StringUtils;
import nc.bs.businessevent.BdUpdateEvent;
import nc.bs.businessevent.BusinessEvent;
import nc.bs.businessevent.IBusinessEvent;
import nc.bs.businessevent.IBusinessListener;
import nc.bs.dao.BaseDAO;
import nc.bs.trade.business.HYSuperDMO;
import nc.bs.uapbd.util.IgnoreSslUtil;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.vo.arap.basebill.BaseAggVO;
import nc.vo.arap.utils.ArrayUtil;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.lang.UFDouble;
import nc.vo.so.m30.entity.SaleOrderHVO;
import nccloud.bs.arap.sagas.util.SagasUtils;
import nccloud.commons.lang.ArrayUtils;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@ -34,228 +13,257 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.HttpsURLConnection;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.yonyou.cloud.utils.StringUtils;
import nc.bs.businessevent.BdUpdateEvent;
import nc.bs.businessevent.BusinessEvent;
import nc.bs.businessevent.IBusinessEvent;
import nc.bs.businessevent.IBusinessListener;
import nc.bs.dao.BaseDAO;
import nc.bs.trade.business.HYPubBO;
import nc.bs.trade.business.HYSuperDMO;
import nc.bs.uapbd.util.IgnoreSslUtil;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.vo.arap.basebill.BaseAggVO;
import nc.vo.arap.utils.ArrayUtil;
import nc.vo.cmp.settlement.SettlementAggVO;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.lang.UFDouble;
import nc.vo.so.m30.entity.SaleOrderHVO;
import nccloud.bs.arap.sagas.util.SagasUtils;
import nccloud.commons.lang.ArrayUtils;
public class BusiregForSyncSaleorderAndToBIP implements IBusinessListener{
@Override
public void doAction(IBusinessEvent event) throws BusinessException {
// TODO Auto-generated method stub
BaseAggVO[] bills = getBills(event);
if (ArrayUtils.isEmpty(bills) || SagasUtils.isCompensateStage()) {
return;
}
// 更新 销售订单
try {
BaseDAO dao = new BaseDAO();
for(BaseAggVO aggvo : bills) {
CircularlyAccessibleValueObject headvo = aggvo.getParentVO();
// 本次收款金额
Object money = headvo.getAttributeValue("money");
// 收款单主键
Object pk_busibill = headvo.getAttributeValue("pk_gatherbill");
// 销售订单主键
Object csaleorderid = headvo.getAttributeValue("def3");
// 根据销售订单主键查询比较字段
String sql = "select vdef17, vdef15, vdef14, vdef11, vdef9 from so_saleorder where csaleorderid = '" + csaleorderid + "' and dr = 0 ";
HashMap hm = (HashMap)dao.executeQuery(sql, new MapProcessor());
Object vdef17 = hm.get("vdef17");
Object vdef15 = hm.get("vdef15");
Object vdef14 = hm.get("vdef14");
Object vdef11 = hm.get("vdef11");
Object vdef9 = hm.get("vdef9");
// 合同号
Object ctpk = aggvo.getChildrenVO()[0].getAttributeValue("def6");
// 查询合同号下
String sql1 = " select sum(ar_gatheritem.money_cr) sk_effect_money " +
" from ar_gatheritem " +
" left join ar_gatherbill on ar_gatherbill.pk_gatherbill = ar_gatheritem.pk_gatherbill " +
" where ar_gatherbill.dr = 0 and ar_gatheritem.dr = 0 and ar_gatherbill.EFFECTSTATUS = 10 " +
" and ar_gatheritem.def6 = '" + ctpk + "'";
Object obj = dao.executeQuery(sql1, new ColumnProcessor());
// 收款单累计金额
UFDouble sk_effect_money = UFDouble.ZERO_DBL;
if(obj != null) {
sk_effect_money = new UFDouble(obj.toString());
}
// 表头合同金额
UFDouble ctmoney = UFDouble.ZERO_DBL;
if(vdef17 != null) {
ctmoney = new UFDouble(vdef17.toString());
}
// 预收比例
UFDouble preratio = UFDouble.ZERO_DBL;
if(vdef15 != null) {
preratio = new UFDouble(vdef15.toString());
}
// 收款大于预收
if (sk_effect_money.compareTo(UFDouble.ZERO_DBL) > 0 && sk_effect_money.sub(ctmoney.multiply(preratio)).compareTo(UFDouble.ZERO_DBL) >= 0) {
String updateSQL = "update so_saleorder set vdef11 = (select pk_defdoc from bd_defdoc where code = 'fhk01') where csaleorderid = '" + csaleorderid + "'";
dao.executeUpdate(updateSQL);
} else if (sk_effect_money.compareTo(UFDouble.ZERO_DBL) > 0 && sk_effect_money.sub(ctmoney.multiply(preratio)).compareTo(UFDouble.ZERO_DBL) < 0) {
String updateSQL = "update so_saleorder set vdef11 = (select pk_defdoc from bd_defdoc where code = 'fhk02') where csaleorderid = '" + csaleorderid + "'";
dao.executeUpdate(updateSQL);
}
JSONObject HTXSDD = new JSONObject();
HTXSDD.put("id", vdef9);
HYSuperDMO dmo= new HYSuperDMO();
SaleOrderHVO[] hvo = (SaleOrderHVO[])dmo.queryByWhereClause(SaleOrderHVO.class, "csaleorderid='"+csaleorderid+"'");
// 实际预收款 npreceivemny
UFDouble npreceivemny = hvo[0].getNpreceivemny();
JSONObject p = new JSONObject();
HTXSDD.put("actPreRecvAmt", npreceivemny.getDouble());
// 实际收款金额 nreceivedmny
UFDouble nreceivedmny = hvo[0].getNreceivedmny();
HTXSDD.put("actRecvAmt", nreceivedmny.getDouble());
// 是否收到预收款
Object vdef14Code = dao.executeQuery("select code from bd_defdoc where pk_defdoc = '" + vdef14 + "'", new ColumnProcessor());
HTXSDD.put("isPreRecv", vdef14Code);
// 是否收到发货款
Object vdef11Code = dao.executeQuery("select code from bd_defdoc where pk_defdoc = '" + vdef11 + "'", new ColumnProcessor());
HTXSDD.put("isShipRecdAmt", vdef11Code);
p.put("HTXSDD", HTXSDD);
System.out.println(p.toJSONString());
// 获取旗舰版的token
Map<String, String> params = new HashMap<>();
String appKey = "a3c57e0d871240e9b9bf56b35001a324";
String appSecret = "a959f7786db8dbb9a2c0493b5855a46bea68ad75";
String tokenUrl="https://www.tkkfbip.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";
String toBipUrl="https://www.tkkfbip.com/iuap-api-gateway/oxp4h3x6/current_yonbip_default_sys/KKAPI/contractSaleOrder/update?access_token=";
// 除签名外的其他参数
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 (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");
doPost(toBipUrl+ access_token, p);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private BaseAggVO[] getBills(IBusinessEvent event) {
Object value = null;
if (event instanceof BusinessEvent) {
value = ((BusinessEvent)event).getObject();
} else if (event instanceof BdUpdateEvent) {
value = ((BdUpdateEvent)event).getNewObject();
}
BaseAggVO[] bills = null;
if (null != value) {
if (value.getClass().isArray()) {
Object[] objs = (Object[])value;
bills = (objs instanceof BaseAggVO[]) ? (BaseAggVO[])objs : (BaseAggVO[])ArrayUtil.convertSupers2Subs((AggregatedValueObject[])objs, BaseAggVO.class);
} else {
bills = new BaseAggVO[1];
bills[0] = (BaseAggVO)value;
}
}
return bills;
}
private String doGet(String requestUrl, Map<String, String> paramMap) throws IOException {
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;
URL u = new URL(url);
try {
if("https".equalsIgnoreCase(u.getProtocol())){//判定网址是否信任不信任则调用忽略信任工具类SslUtil
IgnoreSslUtil.ignoreSsl();
}
HttpsURLConnection connection = (HttpsURLConnection)u.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
connection.connect();
StringBuilder response =new StringBuilder();
int responsecode = connection.getResponseCode();
if(responsecode == HttpsURLConnection.HTTP_OK) {
InputStream inputstream =connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream));
String line;
while((line =reader.readLine()) != null) {
response.append(line);
}
reader.close();
}
connection.disconnect();
return response.toString();
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public void doAction(IBusinessEvent event) throws BusinessException {
// TODO Auto-generated method stub
BaseAggVO[] bills = getBills(event);
if (ArrayUtils.isEmpty(bills) || SagasUtils.isCompensateStage()) {
return;
}
// 更新 销售订单
try {
BaseDAO dao = new BaseDAO();
for(BaseAggVO aggvo : bills) {
CircularlyAccessibleValueObject headvo = aggvo.getParentVO();
// 本次收款金额
Object money = headvo.getAttributeValue("money");
// 收款单主键
Object pk_busibill = headvo.getAttributeValue("pk_gatherbill");
// 销售订单主键
Object csaleorderid = headvo.getAttributeValue("def3");
// 根据销售订单主键查询比较字段
String sql = "select vdef17, vdef15, vdef14, vdef11, vdef9 from so_saleorder where csaleorderid = '" + csaleorderid + "' and dr = 0 ";
HashMap hm = (HashMap)dao.executeQuery(sql, new MapProcessor());
Object vdef17 = hm.get("vdef17");
Object vdef15 = hm.get("vdef15");
Object vdef14 = hm.get("vdef14");
Object vdef11 = hm.get("vdef11");
Object vdef9 = hm.get("vdef9");
// 合同号
Object ctpk = aggvo.getChildrenVO()[0].getAttributeValue("def6");
// 查询合同号下
String sql1 = " select sum(ar_gatheritem.money_cr) sk_effect_money " +
" from ar_gatheritem " +
" left join ar_gatherbill on ar_gatherbill.pk_gatherbill = ar_gatheritem.pk_gatherbill " +
" where ar_gatherbill.dr = 0 and ar_gatheritem.dr = 0 and ar_gatherbill.EFFECTSTATUS = 10 " +
" and ar_gatheritem.def6 = '" + ctpk + "'";
Object obj = dao.executeQuery(sql1, new ColumnProcessor());
// 收款单累计金额
UFDouble sk_effect_money = UFDouble.ZERO_DBL;
if(obj != null) {
sk_effect_money = new UFDouble(obj.toString());
}
// 表头合同金额
UFDouble ctmoney = UFDouble.ZERO_DBL;
if(vdef17 != null) {
ctmoney = new UFDouble(vdef17.toString());
}
// 预收比例
UFDouble preratio = UFDouble.ZERO_DBL;
if(vdef15 != null) {
preratio = new UFDouble(vdef15.toString());
}
// 收款大于预收
if (sk_effect_money.compareTo(UFDouble.ZERO_DBL) > 0 && sk_effect_money.sub(ctmoney.multiply(preratio)).compareTo(UFDouble.ZERO_DBL) >= 0) {
String updateSQL = "update so_saleorder set vdef11 = (select pk_defdoc from bd_defdoc where code = 'fhk01') where csaleorderid = '" + csaleorderid + "'";
dao.executeUpdate(updateSQL);
} else if (sk_effect_money.compareTo(UFDouble.ZERO_DBL) > 0 && sk_effect_money.sub(ctmoney.multiply(preratio)).compareTo(UFDouble.ZERO_DBL) < 0) {
String updateSQL = "update so_saleorder set vdef11 = (select pk_defdoc from bd_defdoc where code = 'fhk02') where csaleorderid = '" + csaleorderid + "'";
dao.executeUpdate(updateSQL);
}
JSONObject HTXSDD = new JSONObject();
HTXSDD.put("id", vdef9);
HYSuperDMO dmo= new HYSuperDMO();
SaleOrderHVO[] hvo = (SaleOrderHVO[])dmo.queryByWhereClause(SaleOrderHVO.class, "csaleorderid='"+csaleorderid+"'");
private String doPost(String requestUrl, JSONObject json) throws IOException {
URL u = new URL(requestUrl);
try {
if("https".equalsIgnoreCase(u.getProtocol())){//判定网址是否信任不信任则调用忽略信任工具类SslUtil
IgnoreSslUtil.ignoreSsl();
}
HttpsURLConnection connection = (HttpsURLConnection)u.openConnection();
// 设置请求方法
connection.setRequestMethod("POST");
// 设置请求属性
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
// 发送POST请求必须设置如下两行
connection.setDoOutput(true);
connection.setDoInput(true);
byte[] outputInBytes = json.toJSONString().getBytes(StandardCharsets.UTF_8);
// 写入数据到请求体
OutputStream os = connection.getOutputStream();
os.write(outputInBytes);
// 获取响应码
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// 读取响应
String response = "";
try(BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
br.readLine();
System.out.println("Response: " + response);
}
// 关闭连接
connection.disconnect();
return response;
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
// 实际收款金额 npreceivemny
UFDouble npreceivemny = hvo[0].getNpreceivemny();
JSONObject p = new JSONObject();
HTXSDD.put("actRecvAmt", npreceivemny.getDouble());
// 实际预收款 nreceivedmny
UFDouble nreceivedmny = hvo[0].getNreceivedmny();
HTXSDD.put("actPreRecvAmt", nreceivedmny.getDouble());
// 是否收到预收款
Object vdef14Code = dao.executeQuery("select code from bd_defdoc where pk_defdoc = '" + vdef14 + "'", new ColumnProcessor());
HTXSDD.put("isPreRecv", vdef14Code);
// 是否收到发货款
Object vdef11Code = dao.executeQuery("select code from bd_defdoc where pk_defdoc = '" + vdef11 + "'", new ColumnProcessor());
HTXSDD.put("isShipRecdAmt", vdef11Code);
p.put("HTXSDD", HTXSDD);
System.out.println(p.toJSONString());
// 获取旗舰版的token
Map<String, String> params = new HashMap<>();
String appKey = "a3c57e0d871240e9b9bf56b35001a324";
String appSecret = "a959f7786db8dbb9a2c0493b5855a46bea68ad75";
String tokenUrl="https://www.tkkfbip.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";
String toBipUrl="https://www.tkkfbip.com/iuap-api-gateway/oxp4h3x6/current_yonbip_default_sys/KKAPI/contractSaleOrder/update?access_token=";
// 除签名外的其他参数
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 (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");
doPost(toBipUrl+ access_token, p);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private BaseAggVO[] getBills(IBusinessEvent event) {
Object value = null;
if (event instanceof BusinessEvent) {
value = ((BusinessEvent)event).getObject();
} else if (event instanceof BdUpdateEvent) {
value = ((BdUpdateEvent)event).getNewObject();
}
BaseAggVO[] bills = null;
if (null != value) {
if (value.getClass().isArray()) {
Object[] objs = (Object[])value;
bills = (objs instanceof BaseAggVO[]) ? (BaseAggVO[])objs : (BaseAggVO[])ArrayUtil.convertSupers2Subs((AggregatedValueObject[])objs, BaseAggVO.class);
} else {
bills = new BaseAggVO[1];
bills[0] = (BaseAggVO)value;
}
}
return bills;
}
private String doGet(String requestUrl, Map<String, String> paramMap) throws IOException {
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;
URL u = new URL(url);
try {
if("https".equalsIgnoreCase(u.getProtocol())){//判定网址是否信任不信任则调用忽略信任工具类SslUtil
IgnoreSslUtil.ignoreSsl();
}
HttpsURLConnection connection = (HttpsURLConnection)u.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
connection.connect();
StringBuilder response =new StringBuilder();
int responsecode = connection.getResponseCode();
if(responsecode == HttpsURLConnection.HTTP_OK) {
InputStream inputstream =connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream));
String line;
while((line =reader.readLine()) != null) {
response.append(line);
}
reader.close();
}
connection.disconnect();
return response.toString();
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
private String doPost(String requestUrl, JSONObject json) throws IOException {
URL u = new URL(requestUrl);
try {
if("https".equalsIgnoreCase(u.getProtocol())){//判定网址是否信任不信任则调用忽略信任工具类SslUtil
IgnoreSslUtil.ignoreSsl();
}
HttpsURLConnection connection = (HttpsURLConnection)u.openConnection();
// 设置请求方法
connection.setRequestMethod("POST");
// 设置请求属性
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
// 发送POST请求必须设置如下两行
connection.setDoOutput(true);
connection.setDoInput(true);
byte[] outputInBytes = json.toJSONString().getBytes(StandardCharsets.UTF_8);
// 写入数据到请求体
OutputStream os = connection.getOutputStream();
os.write(outputInBytes);
// 获取响应码
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// 读取响应
String response = "";
try(BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
br.readLine();
System.out.println("Response: " + response);
}
// 关闭连接
connection.disconnect();
return response;
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -10,6 +10,7 @@ import nc.impl.pubapp.pattern.rule.IRule;
import nc.md.persist.framework.IMDPersistenceQueryService;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.mmpac.pickm.entity.AggPickmVO;
import nc.vo.mmpac.pickm.entity.PickmHeadVO;
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFBillstatusEnum;
@ -55,13 +56,22 @@ public void process(PMOAggVO[] vos) {
}
//Êý×éת»»
AggPickmVO[] aggVOsArr = new AggPickmVO[aggVOs.size()];
boolean flag = false;
for(int z=0; z<aggVOs.size(); z++) {
aggVOsArr[z] =aggVOs.get(z);
AggPickmVO aggPickmVO = aggVOs.get(z);
PickmHeadVO pickmHeadVO = aggPickmVO.getParentVO();
Integer fbillstatus = pickmHeadVO.getFbillstatus();
//已经位完工态的备料计划不修改
if(fbillstatus != 2){
aggVOsArr[z] =aggVOs.get(z);
flag = true;
}
}
if(flag) {
//备料计划完工
PickmMaintainServiceImpl ipickmMaintainService = new PickmMaintainServiceImpl();
ipickmMaintainService.finishPickm(aggVOsArr);
}
//备料计划完工
PickmMaintainServiceImpl ipickmMaintainService = new PickmMaintainServiceImpl();
ipickmMaintainService.finishPickm(aggVOsArr);
}catch(BusinessException e) {
// TODO Auto-generated catch block
e.printStackTrace();

View File

@ -242,8 +242,21 @@ public class IVApplicationServiceImpl implements IVApplicationService {
//如果来源单据为销售发票,根据来源单据编号src_billno和来源单据类型billtype = 32查询销售发票价税合计ntotalorigmny与开票申请中价税合计jshj比较须满足 jshj<ntotalorigmny
String src_billtype = ivApplicationVO.getParentVO().getSrc_billtype(); //来源单据类型
String src_billno = ivApplicationVO.getParentVO().getSrc_billno(); //来源单据号
if("32".equals(src_billtype) && !StringUtil.isNullStringOrNull(src_billno)){
BaseDAO dao = new BaseDAO();
String def23 = ivApplicationVO.getParentVO().getDef23(); //bip开票类型 3出口发票
//根据开票申请自定义项23查询自定义档案编码
BaseDAO dao = new BaseDAO();
String sqlDefdoc = "select code from bd_defdoc where dr = 0 and pk_defdoc = '" +def23+"'";
Object objDefdoc = dao.executeQuery(sqlDefdoc, new ColumnProcessor());
String def23Code = "";
if(objDefdoc != null) {
def23Code = objDefdoc.toString();
}
/**
* 2025-03-12新增
* 开票申请自定义项 23bip开票类型 不等于 3def23Code = 3
* 再做金额校验
*/
if("32".equals(src_billtype) && !StringUtil.isNullStringOrNull(src_billno) && !"3".equals(def23Code)){
String sql = "select ntotalorigmny from so_saleinvoice where dr = 0 and vbillcode = '" +src_billno+"'";
Object obj = dao.executeQuery(sql, new ColumnProcessor());
//销售发票价税合计

View File

@ -1,8 +1,11 @@
package nccloud.web.ssctp.sscbd.ssctask.action;
import com.alibaba.fastjson.JSONObject;
import antlr.collections.List;
import itf.approvecenter.util.DataExchangeBean;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Map;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.logging.Logger;
@ -26,73 +29,81 @@ implements ICommonAction
public Object doAction(IRequest request) {
IJson json = JsonFactory.create();
String read = request.read();
Map<String, Object> map = (Map)json.fromJson(read, Map.class);
String billType = (String)map.get("billtype");
String billno = (String)map.get("billno");
String pk_group = (String)map.get("pk_group");
String pk_task = (String)map.get("pk_task");
String pk_currenttask = (String)map.get("pk_currenttask");
String mod = (String)map.get("mod");
AggregatedValueObject billvo = null;
Map<String, Object> requestMap = (Map)json.fromJson(read, Map.class);
//?????????????????
ArrayList<Map<String, Object>> dataList = (ArrayList)requestMap.get("batchDataList");
ArrayList<JSONObject> resultList = new ArrayList<>();
JSONObject jo = new JSONObject();
//?????????
for(Map<String, Object> map: dataList) {
String billType = (String)map.get("billtype");
String billno = (String)map.get("billno");
String pk_group = (String)map.get("pk_group");
String pk_task = (String)map.get("pk_task");
String pk_currenttask = (String)map.get("pk_currenttask");
String mod = (String)map.get("mod");
AggregatedValueObject billvo = null;
try {
checkSagaStatus(pk_currenttask, SSCCurrentTaskVO.getDefaultTableName(), "pk_currenttask");
((ISSCTaskDriveWorkflowService)ServiceLocator.find(ISSCTaskDriveWorkflowService.class)).sscApproveDriveWorkflow(map);
String ts = TaskQryUtil.getLatestTs(pk_task, mod);
jo.put("ts", (ts == null) ? (String)map.get("ts") : ts);
resultList.add(jo);
} catch (Exception e) {
Throwable ex = ExceptionUtils.unmarsh(e);
if (e.getCause() instanceof InvocationTargetException)
{
if ((ex.getCause() != null && isInterface(ex.getCause().getClass(), "nc.itf.pubapp.pub.exception.IResumeException")) || (ex.getCause() == null && isInterface(ex.getClass(), "nc.itf.pubapp.pub.exception.IResumeException"))) {
// JSONObject retJson = new JSONObject();
String skipcodes = "";
String billtype2RegistClass = ((Billtype2VO)PfDataCache.getBillType2InfoByGroup(billType, 25, pk_group).get(0)).getClassname();
if (billtype2RegistClass != null && !"".equals(billtype2RegistClass)) {
try {
Class clazz = Class.forName(billtype2RegistClass);
IApproveBusiHandler busiHandler = (IApproveBusiHandler)clazz.newInstance();
DataExchangeBean bean = busiHandler.handleApproveBusiException(billType, billno, billvo, e);
if (bean.skipCodes != null && bean.skipCodes.length > 0) {
for (int i = 0; i < bean.skipCodes.length - 1; i++) {
skipcodes = skipcodes + bean.skipCodes[i] + ",";
}
skipcodes = skipcodes + bean.skipCodes[bean.skipCodes.length - 1];
}
} catch (Exception e1) {
Logger.error(e.getMessage(), e);
ExceptionUtils.wrapException(e1);
}
}
String lastcodes = InvocationInfoProxy.getInstance().getProperty("skipcodes");
if (lastcodes != null && !"".equals(lastcodes)) {
skipcodes = skipcodes + "," + lastcodes;
}
jo.put("skipcodes", skipcodes);
jo.put("bugetAlarm", ((InvocationTargetException)e.getCause()).getTargetException().getMessage());
resultList.add(jo);
}
}
Logger.error(e.getMessage(), e);
ExceptionUtils.wrapException(e);
}
}
try {
checkSagaStatus(pk_currenttask, SSCCurrentTaskVO.getDefaultTableName(), "pk_currenttask");
((ISSCTaskDriveWorkflowService)ServiceLocator.find(ISSCTaskDriveWorkflowService.class)).sscApproveDriveWorkflow(map);
String ts = TaskQryUtil.getLatestTs(pk_task, mod);
jo.put("ts", (ts == null) ? (String)map.get("ts") : ts);
} catch (Exception e) {
Throwable ex = ExceptionUtils.unmarsh(e);
if (e.getCause() instanceof InvocationTargetException)
{
if ((ex.getCause() != null && isInterface(ex.getCause().getClass(), "nc.itf.pubapp.pub.exception.IResumeException")) || (ex.getCause() == null && isInterface(ex.getClass(), "nc.itf.pubapp.pub.exception.IResumeException"))) {
JSONObject retJson = new JSONObject();
String skipcodes = "";
String billtype2RegistClass = ((Billtype2VO)PfDataCache.getBillType2InfoByGroup(billType, 25, pk_group).get(0)).getClassname();
if (billtype2RegistClass != null && !"".equals(billtype2RegistClass)) {
try {
Class clazz = Class.forName(billtype2RegistClass);
IApproveBusiHandler busiHandler = (IApproveBusiHandler)clazz.newInstance();
DataExchangeBean bean = busiHandler.handleApproveBusiException(billType, billno, billvo, e);
if (bean.skipCodes != null && bean.skipCodes.length > 0) {
for (int i = 0; i < bean.skipCodes.length - 1; i++) {
skipcodes = skipcodes + bean.skipCodes[i] + ",";
}
skipcodes = skipcodes + bean.skipCodes[bean.skipCodes.length - 1];
}
} catch (Exception e1) {
Logger.error(e.getMessage(), e);
ExceptionUtils.wrapException(e1);
}
}
String lastcodes = InvocationInfoProxy.getInstance().getProperty("skipcodes");
if (lastcodes != null && !"".equals(lastcodes)) {
skipcodes = skipcodes + "," + lastcodes;
}
retJson.put("skipcodes", skipcodes);
retJson.put("bugetAlarm", ((InvocationTargetException)e.getCause()).getTargetException().getMessage());
return retJson;
}
}
Logger.error(e.getMessage(), e);
ExceptionUtils.wrapException(e);
}
return jo;
return resultList.toString();
}

View File

@ -100,12 +100,16 @@ public class InvoiceTaskPlugin implements IBackgroundWorkPlugin{
*/
//手动开启事务
TransactionFactory.getTMProxy().begin(3,0);
//修改发票信息单据号
String sscivmSql = "UPDATE sscivm_invoice set billno = '" + fphm +"' where pk_invoice = '"+ pk_invoice +"'";
dao.executeUpdate(sscivmSql);
Logger.error("---sscivmSqlExecute------"+sscivmSql);
//修改发票关联关系单据编码
String sirSql = "UPDATE sscivm_invoice_relation set billno = '" + billno +"' where pk_invoice = '"+ pk_invoice +"' and billid = '"+ csaleinvoiceid +"'";
String sirSql = "UPDATE sscivm_invoice_relation set billno = '" + fphm +"' where pk_invoice = '"+ pk_invoice +"' and billid = '"+ csaleinvoiceid +"'";
dao.executeUpdate(sirSql);
Logger.error("---sirSqlExecute------"+sirSql);
//ERP销售发票回传根据销售发票id回写发票号和单据编号
String sSaleSql = "UPDATE so_saleinvoice set vdef20 = 'Y' , vdef13 = '" + fphm + "', vbillcode = '" + billno +"' where csaleinvoiceid = '" + csaleinvoiceid + "'";
String sSaleSql = "UPDATE so_saleinvoice set vdef20 = 'Y' , vdef13 = '" + fphm + "', vbillcode = '" + fphm +"' where csaleinvoiceid = '" + csaleinvoiceid + "'";
dao.executeUpdate(sSaleSql);
Logger.error("---sSaleSqlExecute------"+sSaleSql);
//根据销售发票id 回写下游应收单表头发票号
@ -125,7 +129,7 @@ public class InvoiceTaskPlugin implements IBackgroundWorkPlugin{
Logger.error("---recItemSqlExecute------"+recItemSql);
//查询销售发票下游单据如果有将下游单据表体字段来源单据号更新成新的发票号
String saleOutSql = "UPDATE ic_saleout_b \n" +
"SET vsourcebillcode = '"+ billno +"' \n" +
"SET vsourcebillcode = '"+ fphm +"' \n" +
"WHERE\n" +
"csourcetype = '32' \n" +
"AND csourcebillhid = '" + csaleinvoiceid +"'";

View File

@ -92,7 +92,7 @@ public class MaterialDefaultRefModel extends AbstractRefGridTreeBigDataModel imp
this.setClassDataPower(true);
this.setClassWherePart("1 = 1");
this.setFieldCode(new String[]{"pk_org", "code", "name", "materialspec", "materialtype", "materialshortname",
"materialmnecode", "graphid", "pk_measdoc", "memo"});
"materialmnecode", "memo", "graphid", "pk_measdoc"});
String[] fieldNames = new String[]{NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "2UC000-000360"),
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "UC000-0002911"),
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "UC000-0002908"),
@ -100,14 +100,14 @@ public class MaterialDefaultRefModel extends AbstractRefGridTreeBigDataModel imp
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "UC000-0001240"),
NCLangRes4VoTransl.getNCLangRes().getStrByID("10140mag", "2materia-000017"),
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "UC000-0000703"),
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "2UC000-000258"),
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "UC000-0001223"),
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "2UC000-000031"),
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "2UC000-000258")};
NCLangRes4VoTransl.getNCLangRes().getStrByID("common", "2UC000-000031")};
this.setFieldName(fieldNames);
String orgFomula = "getMLCValue(\"" + OrgVO.getDefaultTableName() + "\",\"" + "name" + "\",\"" + "pk_org" + "\"," + "pk_org" + ")";
String mesFomula = "getMLCValue(\"" + MeasdocVO.getDefaultTableName() + "\",\"" + "name" + "\",\"" + "pk_measdoc" + "\"," + "pk_measdoc" + ")";
this.setFormulas(new String[][]{{"pk_org", orgFomula}, {"pk_measdoc", mesFomula}});
this.setDefaultFieldCount(7);
this.setDefaultFieldCount(8);
this.setHiddenFieldCode(new String[]{"pk_material", "pk_source", "pk_marbasclass"});
this.setTableName(MaterialVersionVO.getDefaultTableName());
this.setPkFieldCode("pk_source");