This commit is contained in:
zhangxinah@yonyou.com 2025-04-08 18:53:01 +08:00
commit 029debdf8a
15 changed files with 4710 additions and 997 deletions

5
cmp/component.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding='gb2312'?>
<module displayname="cmp" name="cmp">
<dependencies>
</dependencies>
</module>

View File

@ -0,0 +1,443 @@
package nccloud.web.cmp.informer.informer.action;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import nc.bs.logging.Logger;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.JdbcSession;
import nc.jdbc.framework.PersistenceManager;
import nc.jdbc.framework.exception.DbException;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.web.cmp.informer.action.InformerAction;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
/**
* 2005适配2312
*
* @author mzr
* @date 2025/04/02
*/
public class myBtnClickAction extends InformerAction implements ICommonAction {
@Override
public Object doAction(IRequest request) {
// 初始化结果映射用于存储处理结果
HashMap<String, String> resultMap = new HashMap<String, String>();
// 读取请求中的JSON数据
String json = request.read();
Map<String, Object> maps = JSON.parseObject(json, Map.class);
if (maps.get("pks") == null) {
resultMap.put("result", "请选择行");
return resultMap;
}
JSONArray jsonArray = (JSONArray) maps.get("pks");
ArrayList<Object> pks = new ArrayList<>(Arrays.asList(jsonArray.toArray()));
// 使用 String.join 进行字符串拼接
String result = "";
StringBuilder sb = new StringBuilder();
if (pks.size() > 1) {
for (int i = 0; i < pks.size(); i++) {
sb.append("'").append(pks.get(i)).append("'");
if (i < pks.size() - 1) {
sb.append(",");
}
}
result = sb.toString();
} else {
result = "'" + (String) pks.get(0) + "'";
}
System.out.println(result);
// 解析JSON数据为JSONObject对象
// 从JSON对象中提取账单编号
System.out.println(json);
String urlpath;
String appKey;
String appSecret;
String tenant;
// 如果账单编号为空则返回失败结果
try {
String urlsql = "select code,name from bd_defdoc where code='baseUrl'";
String appksql = "select code,name from bd_defdoc where code='appKey'";
String uappssql = "select code,name from bd_defdoc where code='appSecret'";
String tenantsql = "select code,name from bd_defdoc where code='tenant'";
Map<String, Object> urls = (Map<String, Object>) getQueryService().executeQuery(urlsql, new MapProcessor());
Map<String, Object> appks = (Map<String, Object>) getQueryService().executeQuery(appksql, new MapProcessor());
Map<String, Object> appses = (Map<String, Object>) getQueryService().executeQuery(uappssql, new MapProcessor());
Map<String, Object> tenants = (Map<String, Object>) getQueryService().executeQuery(tenantsql, new MapProcessor());
if (urls.get("code") != null) {
urlpath = (String) urls.get("name");
} else {
resultMap.put("result", "未配置url");
return resultMap;
}
if (appks.get("code") != null) {
appKey = (String) appks.get("name");
} else {
resultMap.put("result", "未配置appKey");
return resultMap;
}
if (appses.get("code") != null) {
appSecret = (String) appses.get("name");
} else {
resultMap.put("result", "未配置appSecret");
return resultMap;
}
if (tenants.get("code") != null) {
tenant = (String) tenants.get("name");
} else {
resultMap.put("result", "未配置tenant");
return resultMap;
}
long timestampMillis = System.currentTimeMillis();
System.out.println("当前时间戳(毫秒):" + timestampMillis);
String dai = "appKey" + appKey + "timestamp" + timestampMillis;
String signature = calculateHmacSHA256(dai, appSecret);
SSLUtilities sas = new SSLUtilities();
sas.disableCertificateValidation();
String urlstr = "appKey=" + appKey + "&timestamp=" + timestampMillis + "&signature=" + signature;
URL url = new URL(urlpath + "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken?" + urlstr);
// 打开连接
HttpURLConnection con = (HttpURLConnection) url.openConnection();
// 设置请求方法为 GET
con.setRequestMethod("GET");
// 获取响应代码
BufferedReader ins = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = ins.readLine()) != null) {
response.append(inputLine);
}
System.out.println(response);
System.out.println(response);
String jsonString = response.toString();
Map<String, Object> map = JSON.parseObject(jsonString, Map.class);
System.out.println(map);
System.out.println(url);
// 获取当前年份
String sql = " select jstype.code as pk_balatype,ban.code bancode,ban.name as banname,bankname,bank.accnum as accnum,infodate,CASE direction " +
"WHEN 'paymoney' THEN '付款' " +
"WHEN 'receivemoney' THEN '收款' " +
"ELSE '不存在' " +
"END as direction, 'CNY' as currencyCode,moneyy , bant.code as dfcode,bant.name as dfname,oppbankaccount,bankt.accnum dfaccnum " +
",pk_oppunit,org.code as orgcode,org.name as orgname,cmp.pk_informer " +
",cmp.memo,cmp.transerial,df.name as ksmc,df.code as ksbm,cmp.note_no,def01,cmp.oppunitname " +
"from cmp_informer cmp " +
"left join bd_bankaccbas bank on cmp.pk_bankacc=bank.pk_bankaccbas " +
"left join bd_bankdoc ban on cmp.pk_bank=ban.pk_bankdoc " +
"left join bd_bankdoc bant on cmp.pk_oppbank=bant.pk_bankdoc " +
"left join bd_bankaccbas bankt on cmp.pk_oppacc=bankt.pk_bankaccbas " +
"left join bd_cust_supplier df on cmp.pk_oppunit=df.pk_cust_sup " +
"left join org_financeorg org on cmp.pk_org = org.pk_financeorg " +
"left join bd_balatype jstype on jstype.pk_balatype =cmp.pk_balatype " +
" where cmp.pk_informer in(" + result + ") ";
List<Map<String, String>> results = (List<Map<String, String>>) getQueryService().executeQuery(sql, new MapListProcessor());
ArrayList lists = new ArrayList();
for (int i = 0; i < results.size(); i++) {
Map vmao = new HashMap();
Map<String, String> row = results.get(i);
String def01 = (String) row.get("def01");
if ("已推送".equals(def01)) {
resultMap.put("flag", "false");
resultMap.put("message", "已推送无法再次推送");
return resultMap;
}
if ("撤回".equals(def01)) {
vmao.put("publishStatus", "再次发布");
} else {
vmao.put("publishStatus", "");
}
String pjlsh;
if (row.get("transerial") != null) {
pjlsh = row.get("transerial").toString();
} else if (row.get("note_no") != null) {
pjlsh = row.get("note_no").toString();
} else {
resultMap.put("flag", "false");
resultMap.put("message", "票据与流水号不可同时为空");
return resultMap;
}
vmao.put("accountName", row.get("bancode"));
vmao.put("bankNum", row.get("accnum"));
vmao.put("transactionDate", row.get("infodate"));
vmao.put("paymentReceiptStatus", row.get("direction"));
vmao.put("currencyCode", "CNY");
vmao.put("transactionAmount", row.get("moneyy"));
vmao.put("pendingClaimAmount", 0);
vmao.put("oppAccount", row.get("oppbankaccount"));
vmao.put("oppAccountName", row.get("oppunitname"));
vmao.put("oppBank", row.get("dfcode"));
vmao.put("oppBankName", row.get("dfname"));
vmao.put("description", row.get("memo"));
vmao.put("bankTransactionNumber", pjlsh);
vmao.put("accountType", "默认类型");
vmao.put("orgCode", row.get("orgcode"));
vmao.put("billNumber", row.get("note_no"));
if (row.get("pk_balatype") != null && row.get("pk_balatype") != "" && row.get("pk_balatype") != "~") {
vmao.put("paymentMethod", row.get("pk_balatype"));
} else {
vmao.put("paymentMethod", "10");
}
vmao.put("sourceId", row.get("pk_informer"));
lists.add(vmao);
}
// lists转json
String jsonString1 = JSON.toJSONString(lists);
Map access_token = (Map) map.get("data");
String urls2 = urlpath + "/iuap-api-gateway/" + tenant + "/current_yonbip_default_sys/KKAPI/paymentNotice/addBatch?access_token=" + access_token.get("access_token");
Map mapjson = httpFW(urls2, jsonString1);
Map datas = (Map) mapjson.get("data");
JSONArray faijsonist = (JSONArray) datas.get("failData");
String message1 = (String) mapjson.get("message");
JSONArray jsonist = (JSONArray) datas.get("successData");
// 将JSONArray转换为List<String>
ArrayList<String> successData = null;
ArrayList<String> failData = null;
if (jsonist != null) {
successData = (ArrayList<String>) jsonist.toJavaList(String.class);
}
if (faijsonist != null) {
failData = (ArrayList<String>) faijsonist.toJavaList(String.class);
}
ArrayList sqlStr = new ArrayList<>();
for (int i = 0; i < pks.size(); i++) {
String pk_s = (String) pks.get(i);
String sql1;
if (successData != null && successData.contains(pk_s)) {
sql1 = "update cmp_informer set def01='已推送' where pk_informer='" + pk_s + "'";
sqlStr.add(sql1);
} else {
sql1 = "update cmp_informer set def01='推送失败' where pk_informer='" + pk_s + "'";
}
sqlStr.add(sql1);
}
int succState = executeUpdate(sqlStr);
String message = datas.get("successData") + "成功" + message1 + ",失败:" + failData;
resultMap.put("flag", "true");
resultMap.put("message", message);
// 调用服务工具类的deletePrcplInterest方法尝试删除利息计划
System.out.println("year" + mapjson);
ins.close();
} catch (Exception ex) {
// 捕获异常并记录错误日志
Logger.error("123" + ex.getMessage(), ex);
resultMap.put("flag", "0");
resultMap.put("message", ex.getMessage());
}
// 返回结果映射
return resultMap;
}
public IUAPQueryBS getQueryService() {
return ServiceLocator.find(IUAPQueryBS.class);
}
public static String calculateHmacSHA256(String data, String key) throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException {
String algorithm = "HmacSHA256";
Mac hmacSHA256 = Mac.getInstance(algorithm);
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), algorithm);
hmacSHA256.init(secretKey);
byte[] hashBytes = hmacSHA256.doFinal(data.getBytes());
String base64Hash = Base64.encodeBase64String(hashBytes);
return URLEncoder.encode(base64Hash, StandardCharsets.UTF_8.toString());
}
public static Map httpFW(String urlString, String jsonInputString) {
// String jsonInputString = "{\"key\": \"中文\"}"; // 你的 JSON 数据
// String urlString = "http://example.com/api"; // 替换为你的 URL
System.out.println("请求值");
System.out.println(jsonInputString);
try {
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
connection.setDoOutput(true);
// 发送请求
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
// 获取响应码
int responseCode = connection.getResponseCode();
System.out.println("响应码: " + responseCode);
// 根据响应码读取响应
InputStream is = (responseCode >= 200 && responseCode < 300) ? connection.getInputStream() : connection.getErrorStream();
StringBuilder response = new StringBuilder();
try (BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
String responseLine;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
}
// 输出响应
System.out.println("返回值:");
System.out.println(response.toString());
// 返回map
Map result = JSON.parseObject(response.toString(), HashMap.class);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public class SSLUtilities {
public void disableCertificateValidation() throws Exception {
TrustManager[] trustAllCertificates = new TrustManager[]{
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}
};
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCertificates, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
}
public int executeUpdate(List<String> updateSqls) throws DbException {
if (updateSqls == null) {
return 0;
}
int ret = 0;
PersistenceManager manager = null;
JdbcSession session = null;
Connection connection = null;
try {
manager = PersistenceManager.getInstance();
session = manager.getJdbcSession();
connection = session.getConnection(); // 获取实际的数据库连接
// connection = ConnectionFactory.getConnection();
// 开始事务
connection.setAutoCommit(false); // 禁用自动提交手动管理事务
// 执行批量操作
for (String sql : updateSqls) {
session.addBatch(sql);
}
// 执行批处理
ret = session.executeBatch();
// 提交事务
connection.commit(); // 批处理成功后提交事务
} catch (DbException e) {
if (connection != null) {
try {
// 如果发生异常回滚事务
connection.rollback();
} catch (SQLException rollbackEx) {
// 记录回滚异常的详细信息
throw new DbException("Error during transaction rollback", rollbackEx) {
@Override
public boolean isDataIntegrityViolation() {
return false;
}
@Override
public boolean isBadSQLGrammar() {
return false;
}
};
}
}
throw e; // 将原始异常抛出
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
// 恢复自动提交模式确保不会影响其他操作
connection.setAutoCommit(true);
} catch (SQLException e) {
// 忽略恢复自动提交时的异常
}
}
if (manager != null) {
manager.release();
}
}
return ret;
}
}

View File

@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<actions>
<action>
<name>cmp.informer.myBtnClickAction</name>
<label>推送测试</label>
<clazz>nccloud.web.cmp.informer.informer.action.myBtnClickAction</clazz>
</action>
<action>
<name>cmp.informer.go2cardcheck</name>
<label>列表跳转检查</label>
<clazz>nccloud.web.cmp.informer.informer.action.CmpInformerGo2CardCheckAction</clazz>
</action>
<action>
<name>cmp.informer.informerquery</name>
<label>列表查询</label>
<clazz>nccloud.web.cmp.informer.informer.action.ListQueryAction</clazz>
</action>
<action>
<name>cmp.informer.informerqueryone</name>
<label>到账通知查询</label>
<clazz>nccloud.web.cmp.informer.informer.action.InformerQueryAction</clazz>
</action>
<action>
<name>cmp.informer.informerpagequery</name>
<label>列表分页查询</label>
<clazz>nccloud.web.cmp.informer.informer.action.ListPageQueryAction</clazz>
</action>
<action>
<name>cmp.informer.informerpublish</name>
<label>列表发布</label>
<btncode>commitpublish,Compublish</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.ListPublishAction</clazz>
</action>
<action>
<name>cmp.informer.informerunpublish</name>
<label>列表取消发布</label>
<btncode>Cancelpublish</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.ListUnPublishAction</clazz>
</action>
<action>
<name>cmp.informer.informergenerate</name>
<label>列表生单</label>
<btncode>Generate,Confirmgenerate</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.ListGenerateAction</clazz>
</action>
<action>
<name>cmp.informer.informerungenerate</name>
<label>列表不生单</label>
<btncode>Nopublish,Unpublish</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.ListUnGenerateAction</clazz>
</action>
<action>
<name>cmp.informer.informerrecgenerate</name>
<label>列表恢复生单</label>
<btncode>Recgenerate</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.ListRecGenerateAction</clazz>
</action>
<action>
<name>cmp.informer.informercombine</name>
<label>列表合并生单</label>
<btncode>combine</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.ListCombineAction</clazz>
</action>
<action>
<name>cmp.informer.informercancelgenerate</name>
<label>列表取消生单</label>
<btncode>Cancelgenerate,ungenerate,Lungenerate</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.ListCancelGenerateAction</clazz>
</action>
<action>
<name>cmp.informer.listdialogdefaultvalue</name>
<label>付/收款款结算单补录框设置默认值</label>
<clazz>nccloud.web.cmp.informer.informer.action.ListDialogDefaultValue</clazz>
</action>
<action>
<name>cmp.informer.informercardquery</name>
<label>卡片查询</label>
<clazz>nccloud.web.cmp.informer.informer.action.CardQueryAction</clazz>
</action>
<action>
<name>cmp.informer.cardpublish</name>
<label>卡片发布</label>
<clazz>nccloud.web.cmp.informer.informer.action.CardPublishAction</clazz>
</action>
<action>
<name>cmp.informer.cardunpublish</name>
<label>卡片取消发布</label>
<btncode>Lcancelpublish,Cancelpublish</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.CardUnPublishAction</clazz>
</action>
<action>
<name>cmp.informer.appoint</name>
<label>卡片指派</label>
<clazz>nccloud.web.cmp.informer.informer.action.AppointAction</clazz>
</action>
<action>
<name>cmp.informer.cardunclaim</name>
<label>卡片取消认领</label>
<btncode>Cancelclaim,Lunclaim</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.CardUnClaimAction</clazz>
</action>
<action>
<name>cmp.informer.cardcancelgenerate</name>
<label>卡片取消生成</label>
<btncode>Cancelgenerate,Lcancelgenerate</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.CardUnMakeBillAction</clazz>
</action>
<action>
<name>cmp.informer.cardgenerate</name>
<label>卡片生单</label>
<btncode>confirmgenerate,generate</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.CardGenerateAction</clazz>
</action>
<action>
<name>cmp.informer.carddialogdefaultvalue</name>
<label>付/收款款结算单补录框设置默认值</label>
<clazz>nccloud.web.cmp.informer.informer.action.CardDialogDefaultValue</clazz>
</action>
<action>
<name>cmp.informer.cardcombine</name>
<label>卡片生单</label>
<clazz>nccloud.web.cmp.informer.informer.action.CardCombineAction</clazz>
</action>
<action>
<name>cmp.informer.afterevent</name>
<label>弹框编辑后事件</label>
<clazz>nccloud.web.cmp.informer.informer.handler.InformerAfterEditHandler</clazz>
</action>
<action>
<name>cmp.informer.linkbill</name>
<label>联查单据</label>
<clazz>nccloud.web.cmp.informer.informer.action.InformerLinkBill</clazz>
</action>
<action>
<name>cmp.informer.defaultorg</name>
<label>默认组织</label>
<clazz>nccloud.web.cmp.informer.informer.action.InformerDefaultOrg</clazz>
</action>
<action>
<name>cmp.informer.refund</name>
<label>退款</label>
<btncode>refundBill,refund</btncode>
<clazz>nccloud.web.cmp.informer.informer.action.RefundAction</clazz>
</action>
<action>
<name>cmp.informer.sscinformerquery</name>
<label>共享中心列表查询</label>
<clazz>nccloud.web.cmp.informer.informer.action.SSCListQueryAction</clazz>
</action>
<action>
<name>cmp.informer.custsupafteredit</name>
<label>补录框版本编辑后</label>
<clazz>nccloud.web.cmp.informer.informer.action.CustSupAtferEditAction</clazz>
</action>
<action>
<name>cmp.informer.billdateafteredit</name>
<label>补录框单据日期编辑后</label>
<clazz>nccloud.web.cmp.informer.informer.action.BillDateAfterEditAction</clazz>
</action>
<action>
<name>cmp.informer.checkispaymentreturn</name>
<label>补录框单据日期编辑后</label>
<clazz>nccloud.web.cmp.informer.informer.action.CheckIsPaymentreturnAction</clazz>
</action>
</actions>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<authorizes>
<authorize>
<!--到账通知鉴权-->
<appcode>36070AISC,36070AISCC,36070AIPSSC</appcode>
<actions>
<action>cmp.informer.go2cardcheck</action>
<action>cmp.informer.informerquery</action>
<action>cmp.informer.informerpagequery</action>
<action>cmp.informer.informerpublish</action>
<action>cmp.informer.informerunpublish</action>
<action>cmp.informer.informergenerate</action>
<action>cmp.informer.informerungenerate</action>
<action>cmp.informer.informerrecgenerate</action>
<action>cmp.informer.informercombine</action>
<action>cmp.informer.informercancelgenerate</action>
<action>cmp.informer.informercardquery</action>
<action>cmp.informer.cardpublish</action>
<action>cmp.informer.cardunpublish</action>
<action>cmp.informer.cardunclaim</action>
<action>cmp.informer.cardcancelgenerate</action>
<action>cmp.informer.cardgenerate</action>
<action>cmp.informer.carddialogdefaultvalue</action>
<action>cmp.informer.cardcombine</action>
<action>cmp.informer.afterevent</action>
<action>cmp.informer.linkbill</action>
<action>cmp.informer.listdialogdefaultvalue</action>
<action>cmp.informer.defaultorg</action>
<action>cmp.informer.informerqueryone</action>
<action>cmp.informer.appoint</action>
<action>cmp.informer.refund</action>
<action>cmp.informer.sscinformerquery</action>
<action>cmp.informer.custsupafteredit</action>
<action>cmp.informer.billdateafteredit</action>
<action>cmp.informer.checkispaymentreturn</action>
<action>cmp.informer.myBtnClickAction</action>
</actions>
</authorize>
</authorizes>

View File

@ -1,3 +1,5 @@
<component name="fbm" displayname="fbm">
<dependencies/>
</component>
<?xml version="1.0" encoding='gb2312'?>
<module displayname="fbm" name="fbm">
<dependencies>
</dependencies>
</module>

View File

@ -0,0 +1,331 @@
package nccloud.web.fbm.fbm.gather.action;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.JdbcSession;
import nc.jdbc.framework.PersistenceManager;
import nc.jdbc.framework.exception.DbException;
import nc.jdbc.framework.processor.MapListProcessor;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import java.sql.Connection;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* 2005适配2312
*
* @author mzr
* @date 2025/04/03
*/
public class DzButton implements ICommonAction {
@Override
public Object doAction(IRequest request) {
// 初始化结果映射用于存储处理结果
HashMap<String, String> resultMap = new HashMap<String, String>();
// 读取请求中的JSON数据
String json = request.read();
Map<String, Object> maps = JSON.parseObject(json, Map.class);
if (maps.get("pks") == null) {
resultMap.put("result", "请选择行");
return resultMap;
}
int yg = 0;
int cg = 0;
int sbl = 0;
JSONArray jsonArray = (JSONArray) maps.get("pks");
ArrayList<Object> pks = new ArrayList<>(Arrays.asList(jsonArray.toArray()));
// 使用 String.join 进行字符串拼接
String result = "";
StringBuilder sb = new StringBuilder();
if (pks.size() > 1) {
for (int i = 0; i < pks.size(); i++) {
sb.append("'").append(pks.get(i)).append("'");
if (i < pks.size() - 1) {
sb.append(",");
}
}
result = sb.toString();
} else {
result = "'" + (String) pks.get(0) + "'";
}
// 如果账单编号为空则返回失败结果
try {
// 获取当前年份
String sql = "select fbm.gatherdate,bank1.pk_bankdoc as fkyh,bank2.pk_bankdoc as skyh,fbm.acceptorbank,fbm.hidereceivebankacc ,holdunit,org.name as orgname , reg.name as pjname,xxb_bon.bdcode,btype.pk_balatype,reg.code,xxe.exsystemcode,\n" +
"xxb_bon.exsysval\n" +
",invoiceunit,fbmbilltype,fbm.fbmbillno,fbm.pk_register, paybankacc as bankaccount,fbm.payunit,cust.name as bankname,fbm.billmaker,fbm.creator,fbm.note,fbm.money,cust.custsupprop ,cust.custsuptype,fbm.pk_banktype ,fbm.pk_org ,fbm.pk_org_v,fbm.hidereceiveunit, fbm.hidepayunit,fbm.hidepaybankacc ,fbm.hidepaybank ,fbm.paybankacc ,fbm.paybank ,fbm.receiveunit,fbm.receivebankacc ,fbm.receivebank ,hidereceivebank, bankdoc.pk_bankaccbas ,fbm.pk_group \n" +
"from fbm_register fbm \n" +
"left join bd_cust_supplier cust on fbm.hidepayunit=cust.pk_cust_sup \n" +
"left join bd_bankaccbas bankdoc on fbm.receivebankacc = bankdoc.code\n" +
"left join bd_notetype reg on fbm.fbmbilltype=reg.pk_notetype\n" +
"join xx_bdcontra_b xxb_bon on xxb_bon.exsysval=reg.code\n" +
"join xx_bdcontra xxb on xxb.pk_contra=xxb_bon.pk_contra\n" +
"join xx_exsystem xxe on xxe.pk_exsystem =xxb.exsystem and xxe.exsystemcode='pkinformer'\n" +
"left join org_financeorg org on org.pk_financeorg=fbm.holdunit\n" +
"left join bd_bankdoc bank1 on fbm.paybank =bank1.name\n" +
"left join bd_bankdoc bank2 on fbm.receivebank =bank2.name\n" +
"left join bd_balatype btype on btype.code=xxb_bon.bdcode " +
" where fbm.pk_register in(" + result + ") ";
List<Map<String, Object>> results = (List<Map<String, Object>>) getQueryService().executeQuery(sql, new MapListProcessor());
List sqlStr = new ArrayList();
LocalDateTime creationTime = LocalDateTime.now();
// 格式化年月日
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = creationTime.format(dateFormatter);
// 格式化时分秒
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
String formattedTime = creationTime.format(timeFormatter);
// 格式化时间
DateTimeFormatter datatimes = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formatteddatatime = creationTime.format(datatimes);
yg = results.size();
for (int i = 0; i < results.size(); i++) {
Map<String, Object> row = results.get(i);
String bankAccount = (String) row.get("receivebankacc");
String gatherdate = (String) row.get("gatherdate");
// 本方开户银行名称
String bankName = (String) row.get("receiveunit");
// 制单人
String billMaker = (String) row.get("billmaker");
// 托收协议号
String consignAgreement = "~";
// 记录创建时间
String sj = formatteddatatime;
// 创建人
String creator = (String) row.get("creator");
// 收付性质
String direction = "receivemoney";
// 未明确用途可根据实际情况使用
String domain = "~";
// 制单日期
String doOperateDate = formatteddatatime;
// 制单时间
String doOperateTime = formattedTime;
// 标记通常用于逻辑删除0 表示未删除
int dr = 0;
// 未明确用途可根据实际情况使用
String family = "~";
// 未生成标志
String generateFlag = "hasnogenerate";
// 到账日期
String infoDate = gatherdate;
// 到账时间
String infoDateTime = formattedTime;
// 备注
String memo = (String) row.get("note");
// 修改时间
String modifiedTime = formatteddatatime;
// 修改人
String modifier = (String) row.get("creator");
// 金额
double money = Double.parseDouble(row.get("money").toString());
// 对方账户
String oppBankAccount = (String) row.get("paybankacc");
// 对方单位内外部标识 custsupprop 0=外部单位;
// 1=内部单位;
String oppInOut;
if (row.get("custsupprop") != null && row.get("custsupprop").toString().equals("0")) {
oppInOut = "outer";
} else {
oppInOut = "inner";
}
// 对方名称
String oppUnitName = (String) row.get("payunit");
// 对方单位类别
Object custsuptype = row.get("custsuptype");
String oppUnitType = "cust"; // 默认值
if (custsuptype != null && custsuptype.toString().equals("2")) {
oppUnitType = "supp";
}
// 本方账户对应子户
String pkAccSub = (String) row.get("hidereceivebankacc");
// 未明确用途可根据实际情况使用
String pk_balatype = (String) row.get("pk_balatype");
// 本方开户银行主键
String pkBank = (String) row.get("skyh");
// 本方银行账号主键
String pkBankAcc = (String) row.get("pk_bankaccbas");// 1
// 记账人
String pkBankAccer = "~";
// 本方银行类别主键
String pkBankType = (String) row.get("pk_banktype");
// 对方单位
String pk_oppunit = (String) row.get("hidepayunit");
// 对方开户银行账号主键
String pk_oppbank = (String) row.get("fkyh");
// 对方账户PK
String pk_oppacc = (String) row.get("hidepaybankacc");
// 单据类型
String pkBillTypeCode = "36S3";
// 单据类型主键
String pkBillTypeId = "1001Z61000000001SOPF";
// 未明确用途可根据实际情况使用
String pkClaimer = "~";
// 币种
String pkCurrType = "1002Z0100000000001K1";
// 未明确用途可根据实际情况使用
String pkFundType = "~";
// 所属集团
String pkGroup = (String) row.get("pk_group");
// 未明确用途可根据实际情况使用主键
String pkInformer = (String) row.get("pk_register");
// 未明确用途可根据实际情况使用
String pkOrg = (String) row.get("pk_org");
// 财务组织版本
String pkOrgV = (String) row.get("pk_org_v");
// 来源单据主键
String pkSrc = null;
// 制证人
String pkVouch = (String) row.get("billmaker");
// /付款资金组织
String recPayFundOrg = "~";
// /付款资金组织计划项目
String recPayFundPlansubj = "~";
// 未明确用途可根据实际情况使用
String recPayInnerAcc = "~";
// 未明确用途可根据实际情况使用
String recPayOrg = "~";
// 未明确用途可根据实际情况使用
String recPayOrgPlansubj = "~";
// 未明确用途可根据实际情况使用
String releaseOrg = "~";
// 风格标志A 可能表示某种风格类型
char styleFlag = 'A';
// 未明确用途可根据实际情况使用
String subFamily = "~";
// 系统代码
String sysCode = "sysnet";
// 时间戳
String ts = formatteddatatime;
// 单据号
long timestamp = System.currentTimeMillis();
Random random = new Random();
int randomNumber = random.nextInt(10000); // 生成0到9999之间的随机数
String vBillNo = "36S" + String.format("%d%04d", timestamp, randomNumber);
String note_no = (String) row.get("fbmbillno");
// String sqlp="insert into cmp_informer(bankaccount,bankname,billmaker,consignagreement,creationtime,creator,direction,domain,doperatedate,doperatetime,dr,family,generateflag,infodate,infodatetime,memo,modifiedtime,modifier,moneyy,oppbankaccount,oppinout,oppunitname,oppunittype,pk_acc_sub,pk_balatype,pk_bank,pk_bankacc,pk_bankaccer,pk_banktype,pk_billtypecode,pk_billtypeid,pk_claimer,pk_currtype,pk_fundtype,pk_group,pk_informer,pk_org,pk_org_v,pk_src,pk_vouch,recpay_fundorg,recpay_fundplansubj,recpay_inneracc,recpay_org,recpay_orgplansubj,release_org,styleflag,subfamily,syscode,ts,vbillno) values('"+num+"','济南热电有限公司','1001A110000000003Q0I','~','"+dam+"','1001A110000000003Q0I','"+pr+"','~','"+transactionDate+"','"+dam+"','0','~','hasnogenerate','"+transactionDate+"','"+timesub+"','"+zhaiYao+"','"+dam+"','1001A110000000003Q0I',"+money+",'"+oppositeAccountNumber+"','"+opp+"','"+oppositeUserName+"','"+opptype+"','"+select[2]+"','~','"+select[0]+"','"+select[1]+"','~','"+select3[0]+"','36S3','1001Z61000000001SOPF','~','1002Z0100000000001K1','~','0001N2100000000002ZE','"+vId+"','0001N710000000001FWC','0001N710000000001FWB','1001A110000000007IWJ','~','~','~','~','~','~','~','A','~','sysnet','"+dam+"','"+fId2+"')"
// 形成sql
String sqlp = "insert into cmp_informer(bankaccount,bankname,billmaker,consignagreement,creationtime,creator,direction,domain,doperatedate,doperatetime,dr,family,generateflag,infodate,infodatetime,memo,modifiedtime,modifier,moneyy,oppbankaccount,oppinout,oppunitname,oppunittype,pk_acc_sub,pk_balatype,pk_bank,pk_bankacc,pk_bankaccer,pk_banktype,pk_billtypecode,pk_billtypeid,pk_claimer,pk_currtype,pk_fundtype,pk_group,pk_informer,pk_org,pk_org_v,pk_src,pk_vouch,recpay_fundorg,recpay_fundplansubj,recpay_inneracc,recpay_org,recpay_orgplansubj,release_org,styleflag,subfamily,syscode,ts,vbillno,note_no,pk_oppunit,pk_oppbank,pk_oppacc) values('"
+ bankAccount + "','" + bankName + "','" + billMaker + "','" + consignAgreement + "','" + formatteddatatime + "','" + creator + "','" + direction + "','" + domain + "','" + doOperateDate + "','" + sj + "','" + dr + "','" + family + "','" + generateFlag + "','" + infoDate + "','" + infoDateTime + "','" + memo + "','" + modifiedTime + "','" + modifier + "','" + money + "','" + oppBankAccount + "','" + oppInOut + "','" + oppUnitName + "','" + oppUnitType + "','" + pkAccSub + "','" + pk_balatype + "','" + pkBank + "','" + pkBankAcc + "','" + pkBankAccer + "','" + pkBankType + "','" + pkBillTypeCode + "','" + pkBillTypeId + "','" + pkClaimer + "','" + pkCurrType + "','" + pkFundType + "','" + pkGroup + "','" + pkInformer + "','" + pkOrg + "','" + pkOrgV + "','" + pkSrc + "','" + pkVouch + "','" + recPayFundOrg + "','" + recPayFundPlansubj + "','" + recPayInnerAcc + "','" + recPayOrg + "','" + recPayOrgPlansubj + "','" + releaseOrg + "','" + styleFlag + "','" + subFamily + "','" + sysCode + "','" + ts + "','" + vBillNo + "','" + note_no + "','" + pk_oppunit + "','" + pk_oppbank + "','" + pk_oppacc + "')";
sqlStr.add(sqlp);
}
int succState = executeUpdate(sqlStr);
cg = succState;
sbl = yg - succState;
resultMap.put("flag", "1");
resultMap.put("message", "插入数据成功,已插入" + succState + "条数据");
resultMap.put("cg", String.valueOf(cg));
resultMap.put("sbl", String.valueOf(sbl));
resultMap.put("yg", String.valueOf(yg));
// lists转json
} catch (Exception ex) {
// 捕获异常并记录错误日志
resultMap.put("cg", String.valueOf(0));
resultMap.put("sbl", String.valueOf(yg));
resultMap.put("yg", String.valueOf(yg));
resultMap.put("flag", "0");
resultMap.put("message", ex.getMessage());
}
// 返回结果映射
return resultMap;
}
public IUAPQueryBS getQueryService() {
return ServiceLocator.find(IUAPQueryBS.class);
}
public int executeUpdate(List<String> updateSqls) throws DbException {
if (updateSqls == null) {
return 0;
}
int ret = 0;
PersistenceManager manager = null;
JdbcSession session = null;
Connection connection = null;
try {
manager = PersistenceManager.getInstance();
session = manager.getJdbcSession();
connection = session.getConnection(); // 获取实际的数据库连接
// 开始事务
connection.setAutoCommit(false); // 禁用自动提交手动管理事务
// 执行批量操作
for (String sql : updateSqls) {
session.addBatch(sql);
}
// 执行批处理
ret = session.executeBatch();
// 提交事务
connection.commit(); // 批处理成功后提交事务
} catch (DbException e) {
if (connection != null) {
try {
// 如果发生异常回滚事务
connection.rollback();
} catch (SQLException rollbackEx) {
// 记录回滚异常的详细信息
throw new DbException("Error during transaction rollback", rollbackEx) {
@Override
public boolean isDataIntegrityViolation() {
return false;
}
@Override
public boolean isBadSQLGrammar() {
return false;
}
};
}
}
throw e; // 将原始异常抛出
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
// 恢复自动提交模式确保不会影响其他操作
connection.setAutoCommit(true);
} catch (SQLException e) {
// 忽略恢复自动提交时的异常
}
}
if (manager != null) {
manager.release();
}
}
return ret;
}
}

View File

@ -0,0 +1,327 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<actions>
<action>
<name>fbm.gather.gatherSave</name>
<label>收票登记-保存</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCSaveAction</clazz>
</action>
<action>
<name>fbm.gather.DzButton</name>
<label>收票推送到账</label>
<clazz>nccloud.web.fbm.fbm.gather.action.DzButton</clazz>
</action>
<action>
<name>fbm.gather.gatherDelete</name>
<label>收票登记-删除</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCDeleteAction</clazz>
</action>
<action>
<name>fbm.gather.gatherQuery</name>
<label>收票登记-列表查询</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCQueryAction</clazz>
</action>
<action>
<name>fbm.gather.gatherPageQuery</name>
<label>收票登记-分页查询</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCPageQueryAction</clazz>
</action>
<action>
<name>fbm.gather.gatherPrint</name>
<label>收票登记-打印</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherPrint4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherAfterEvent</name>
<label>收票登记-编辑后事件</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCAfterEventAction</clazz>
</action>
<action>
<name>fbm.gather.gatherBeforeEvent</name>
<label>收票登记-编辑前事件</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCBeforeEventAction</clazz>
</action>
<action>
<name>fbm.gather.gatherCardQuery</name>
<label>收票登记-卡片查询</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherCardQuery4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherCommit</name>
<label>收票登记-提交</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherCommit4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherUnCommit</name>
<label>收票登记-收回</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherUnCommit4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherVoucher</name>
<label>收票登记-制证</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCMkVoucherAction</clazz>
</action>
<action>
<name>fbm.gather.gatherUnVoucher</name>
<label>收票登记-取消制证</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCUnVoucherAction</clazz>
</action>
<action>
<name>fbm.gather.linkquerysf</name>
<label>收票登记-联查收付款单</label>
<clazz>nccloud.web.fbm.fbm.gather.action.FbmLQuerySFBillAction4NCC</clazz>
</action>
<action>
<name>fbm.gather.gatherReceive</name>
<label>收票登记-签收</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherRecieve4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherReceiveCancel</name>
<label>收票登记-取消签收</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherRecieveCancel4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherReceiveReject</name>
<label>收票登记-拒签</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherRefuseSign4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherElcBillQuery</name>
<label>收票登记-待签收/已签收票据查询</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherReceivedElcBill4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherCopy</name>
<label>收票登记-复制</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCCopyAction</clazz>
</action>
<action>
<name>fbm.gather.gatherCollectionSettle</name>
<label>收票登记-关联收款结算单(弃用)</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherCollectionSettle4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherCreateGather</name>
<label>收票登记-生成收票登记</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherCreateGather4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.queryOther</name>
<label>收票登记-其他查询</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherOtherQueryAction</clazz>
</action>
<action>
<name>fbm.gather.voucherLink</name>
<label>收票登记-凭证反联查</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherNCCVoucherLinkAction</clazz>
</action>
<action>
<name>fbm.gather.palnLink</name>
<label>收票登记-预算反联查</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherNCCNtbLinkAction</clazz>
</action>
<action>
<name>fbm.gather.bankRegister</name>
<label>收票登记-银行登记</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherBankRegisterAction</clazz>
</action>
<action>
<name>fbm.gather.disabled</name>
<label>收票登记-作废</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherDisable4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.cancelDisabled</name>
<label>收票登记-取消作废</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherCancelDisable4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.quickservice</name>
<label>收票登记-快捷业务数据组装</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherQuickservice4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.quickdiscount</name>
<label>收票登记-快捷贴现</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherQuickDiscount4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.quickdiscountapp</name>
<label>收票登记-快捷贴现申请</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherQuickDiscountApply4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.quickendore</name>
<label>收票登记-快捷背书</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherQuickEndore4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.quickconsignbank</name>
<label>收票登记-快捷托收</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherQuickConsign4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.quickimpawn</name>
<label>收票登记-快捷质押</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherQuickImpawn4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.circulate</name>
<label>收票登记-联查票据流转信息</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherLinkCirculate4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.circulateprint</name>
<label>票据流转信息-打印</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillCirculatePrint4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.quickServiceAfterEvent</name>
<label>快捷业务-编辑后事件</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGatherQuick4NCCAfterEventAction</clazz>
</action>
<action>
<name>fbm.gather.gatheringBill</name>
<label>收票登记-关联收款单</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherBusiAR4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.recbill</name>
<label>收票登记-关联收款结算单</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherRecbill4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.commissionGathering</name>
<label>收票登记-关联委托收款单</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatheringConfig4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.pdfImport</name>
<label>收票登记-PDF导入</label>
<clazz>nccloud.web.fbm.fbm.gather.action.BillGather4NCCPDFImportAction</clazz>
</action>
<action>
<name>fbm.gather.bankkeeping</name>
<label>收票登记-关联银行托管</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherBankKeeping4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.bankbacking</name>
<label>收票登记-关联银行领用</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherBankBacking4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.endoring</name>
<label>收票登记-关联背书办理</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherEndoring4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.discountapplying</name>
<label>收票登记-关联贴现申请</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherDiscountApplying4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.discounting</name>
<label>收票登记-关联贴现办理</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherDiscounting4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.consignbanking</name>
<label>收票登记-关联银行托收</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherConsignBanking4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.consignbanking</name>
<label>收票登记-关联银行托收</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherConsignBanking4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.impawning</name>
<label>收票登记-关联票据质押</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherImpawning4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.rreturning</name>
<label>收票登记-关联应收票据退票</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherRreturning4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gathernontransablecancell</name>
<label>收票登记-不得转让撤销</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherNonTransableCancel4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.gatherrecallnontranstablecancell</name>
<label>收票登记-撤回不得转让撤销</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherRecallNonTransableCancel4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.printcirculate</name>
<label>收票登记-票据流转正反面打印(正序)</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherBatchPrintCirculate4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.printcirculatedesc</name>
<label>收票登记-票据流转正反面打印(倒序)</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherBatchPrintCirculateDESC4NCCAction</clazz>
</action>
<action>
<name>fbm.gather.batchdowncirculate</name>
<label>收票登记-批量下载票据流转信息</label>
<clazz>nccloud.web.fbm.fbm.gather.action.GatherBatchDownloadCirculate4NCCAction</clazz>
</action>
</actions>

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<authorizes>
<authorize>
<appcode>36180RBR,36180RBR_APPR,36180ET,36180ET_APPR,36180BCI,36180BBS</appcode>
<actions>
<action>fbm.gather.gatherSave</action>
<action>fbm.gather.gatherDelete</action>
<action>fbm.gather.gatherQuery</action>
<action>fbm.gather.gatherPageQuery</action>
<action>fbm.gather.gatherPrint</action>
<action>fbm.gather.gatherAfterEvent</action>
<action>fbm.gather.gatherBeforeEvent</action>
<action>fbm.gather.gatherCardQuery</action>
<action>fbm.gather.gatherCommit</action>
<action>fbm.gather.gatherUnCommit</action>
<action>fbm.gather.gatherVoucher</action>
<action>fbm.gather.gatherUnVoucher</action>
<action>fbm.gather.gatherReceive</action>
<action>fbm.gather.gatherReceiveCancel</action>
<action>fbm.gather.gatherReceiveReject</action>
<action>fbm.gather.gatherElcBillQuery</action>
<action>fbm.gather.gatherCopy</action>
<action>fbm.gather.gatherCollectionSettle</action>
<action>fbm.gather.gatherCreateGather</action>
<action>fbm.gather.linkquerysf</action>
<action>fbm.gather.queryOther</action>
<action>fbm.gather.voucherLink</action>
<action>fbm.gather.palnLink</action>
<action>fbm.gather.bankRegister</action>
<action>fbm.gather.disabled</action>
<action>fbm.gather.cancelDisabled</action>
<action>fbm.gather.quickservice</action>
<action>fbm.gather.quickdiscount</action>
<action>fbm.gather.quickdiscountapp</action>
<action>fbm.gather.quickendore</action>
<action>fbm.gather.quickconsignbank</action>
<action>fbm.gather.quickimpawn</action>
<action>fbm.gather.circulate</action>
<action>fbm.gather.circulateprint</action>
<action>fbm.gather.quickServiceAfterEvent</action>
<action>fbm.gather.gatheringBill</action>
<action>fbm.gather.recbill</action>
<action>fbm.gather.commissionGathering</action>
<action>fbm.gather.pdfImport</action>
<action>fbm.gather.bankkeeping</action>
<action>fbm.gather.bankbacking</action>
<action>fbm.gather.endoring</action>
<action>fbm.gather.discountapplying</action>
<action>fbm.gather.discounting</action>
<action>fbm.gather.consignbanking</action>
<action>fbm.gather.impawning</action>
<action>fbm.gather.rreturning</action>
<action>fbm.gather.gathernontransablecancell</action>
<action>fbm.gather.gatherrecallnontranstablecancell</action>
<action>fbm.gather.printcirculate</action>
<action>fbm.gather.printcirculatedesc</action>
<action>fbm.gather.batchdowncirculate</action>
<action>fbm.gather.DzButton</action>
</actions>
</authorize>
</authorizes>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding='gb2312'?>
<module>
<rest>
<resource classname="nccloud.api.mmpac.productreport.ProductReportResources" exinfo="生产报告新增、审核接口"/>
</rest>

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ import nc.vo.pu.m422x.entity.StoreReqAppVO;
import nc.vo.pub.BusinessException;
public interface IQuery422XFor4455 {
StoreReqAppVO[] queryStoreReqAppsFor4455(IQueryScheme var1) throws BusinessException;
StoreReqAppVO[] queryStoreReqAppsFor4455(IQueryScheme queryScheme) throws BusinessException;
AggPickmVO[] queryPickmAppsFor4455(IQueryScheme queryScheme) throws BusinessException;
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding='gb2312'?>
<module>
<rest>
<resource classname="nc.vo.so.m32.saleinvoice.operator.billSaveAction" exinfo="销售发票及其下游单据开票申请修改红冲逻辑"/>
</rest>
</module>

View File

@ -3,10 +3,13 @@ package nc.bs.so.m32.maintain.rule.delete;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.yonyou.cloud.utils.StringUtils;
import nc.bs.dao.DAOException;
import nc.bs.logging.Logger;
import nc.bs.trade.business.HYSuperDMO;
import nc.bs.uapbd.util.IgnoreSslUtil;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.bd.defdoc.DefdocVO;
import nc.vo.pub.BusinessException;
import nc.vo.so.m32.entity.SaleInvoiceBVO;
import nc.vo.so.m32.entity.SaleInvoiceHVO;
import nc.vo.so.m32.entity.SaleInvoiceVO;
@ -31,11 +34,12 @@ import java.util.*;
* @date 2025/3/20
*/
public class SyncBipBillRuleForDelete implements IRule<SaleInvoiceVO> {
private static String appKey = "a3c57e0d871240e9b9bf56b35001a324";
private static String appSecret = "a959f7786db8dbb9a2c0493b5855a46bea68ad75";
private static String tokenUrl = "https://www.tkkfbip.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";
private static String toBipUrl = "https://www.tkkfbip.com/iuap-api-gateway/oxp4h3x6/current_yonbip_default_sys/KKAPI/invoiceApplication/updateInvoice?access_token=";
private HYSuperDMO superDMO = null;
private String appKey = "";
private String appSecret = "";
private String baseUrl = "https://www.tkkfbip.com";
private String tokenUrl = "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";
private String toBipUrl = "/iuap-api-gateway/oxp4h3x6/current_yonbip_default_sys/KKAPI/invoiceApplication/updateInvoice?access_token=";
@Override
public void process(SaleInvoiceVO[] vos) {
@ -47,13 +51,23 @@ public class SyncBipBillRuleForDelete implements IRule<SaleInvoiceVO> {
if (!hasVdef38) {
return;
}
// 从自定义档案中获取
Map<String, String> bipParamMap = checkBipParam();
if (bipParamMap.isEmpty()) {
return;
}
baseUrl = bipParamMap.get("baseUrl");
appKey = bipParamMap.get("appKey");
appSecret = bipParamMap.get("appSecret");
NCCForUAPLogger.debug(String.format("SyncBipBillRuleForDelete-baseUrl = [%s],appKey1 = [%s],appSecret = [%s],",
baseUrl, appKey, appSecret));
String access_token = getAccessToken();
for (SaleInvoiceVO invoiceVO : vos) {
SaleInvoiceHVO hvo = invoiceVO.getParentVO();
SaleInvoiceBVO[] bvos = invoiceVO.getChildrenVO();
if (access_token.isEmpty()) {
Logger.error("SyncBipBillRuleForDelete-token获取失败");
ExceptionUtils.wrappBusinessException("token获取失败");
throw new BusinessException("token获取失败");
}
// bip旗舰版发票主键
String vdef38 = hvo.getVdef38();
@ -72,15 +86,22 @@ public class SyncBipBillRuleForDelete implements IRule<SaleInvoiceVO> {
updateJson.put("id", vdef38);
updateJson.put("saleInvoiceId", "");
updateJson.put("contractInvoiceApplicationDetailList", childrenList);
String bipRes = doPost(toBipUrl + access_token, updateJson);
String bipRes = doPost(baseUrl + toBipUrl + access_token, updateJson);
NCCForUAPLogger.debug("SyncBipBillRuleForDelete-bipRes = " + bipRes);
}
}
} catch (NoSuchAlgorithmException | InvalidKeyException | IOException e) {
} catch (Exception e) {
Logger.error("SyncBipBillRuleForDelete-exp:" + e.getMessage(), e);
}
}
public HYSuperDMO getSuperDMO() {
if (superDMO == null) {
superDMO = new HYSuperDMO();
}
return superDMO;
}
/**
* 获取旗舰版的token
*
@ -89,6 +110,7 @@ public class SyncBipBillRuleForDelete implements IRule<SaleInvoiceVO> {
* @date 2025/3/20
*/
private String getAccessToken() throws NoSuchAlgorithmException, InvalidKeyException, IOException {
String access_token = "";
// 获取旗舰版的token
Map<String, String> params = new HashMap<>();
// 除签名外的其他参数
@ -107,13 +129,12 @@ public class SyncBipBillRuleForDelete implements IRule<SaleInvoiceVO> {
String base64String = Base64.getEncoder().encodeToString(signData);
String signature = URLEncoder.encode(base64String, "UTF-8");
params.put("signature", signature);
String responseString = doGet(tokenUrl, params);
String responseString = doGet(baseUrl + tokenUrl, params);
Gson gson = new Gson();
Map result = gson.fromJson(responseString, Map.class);
String access_token = "";
if (StringUtils.equals("00000", result.get("code").toString())) {
if (StringUtils.equals("00000", result.getOrDefault("code", "") + "")) {
Map<String, Object> tokenInfo = (Map<String, Object>) result.get("data");
access_token = (String) tokenInfo.get("access_token");
access_token = (String) tokenInfo.getOrDefault("access_token", "");
}
Logger.error("SyncBipBillRuleForDelete-getAccessToken = " + access_token);
return access_token;
@ -200,4 +221,24 @@ public class SyncBipBillRuleForDelete implements IRule<SaleInvoiceVO> {
return null;
}
/**
* 检查bip参数是否完整
*/
private Map<String, String> checkBipParam() {
Map<String, String> map = new HashMap<String, String>();
String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='BIP-sq' and dr=0 ) and dr=0";
try {
DefdocVO[] defdocVOs = (DefdocVO[]) getSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
if (defdocVOs != null && defdocVOs.length > 0) {
for (DefdocVO defdocVO : defdocVOs) {
map.put(defdocVO.getCode().trim(), defdocVO.getName());
}
}
} catch (DAOException e) {
e.printStackTrace();
}
return map;
}
}

View File

@ -0,0 +1,344 @@
package nc.vo.so.m32.saleinvoice.operator;
import com.alibaba.fastjson.JSONObject;
import nc.bs.framework.common.NCLocator;
import nc.bs.framework.core.util.ObjectCreator;
import nc.bs.ia.audit.pub.CloneUtil;
import nc.bs.logging.Logger;
import nc.bs.trade.business.HYSuperDMO;
import nc.itf.uap.IUAPQueryBS;
import nc.pubitf.so.m32.api.ISaleinvoiceQueryAPI;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.scmpub.res.billtype.SOBillType;
import nc.vo.so.m32.entity.SaleInvoiceBVO;
import nc.vo.so.m32.entity.SaleInvoiceHVO;
import nc.vo.so.m32.entity.SaleInvoiceVO;
import nc.vo.sscivm.ivsale.IVApplicationAggVO;
import nc.vo.sscivm.ivsale.IVApplicationBodyVO;
import nc.vo.sscivm.ivsale.IVApplicationHeadVO;
import nccloud.api.baseapp.exchange.convert.IExchangeForService;
import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataObject;
import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataResult;
import nccloud.api.rest.utils.ResultMessageUtil;
import nccloud.itf.sscivm.ivsale.impl.IVApplicationServiceImpl;
import nccloud.pubitf.riart.pflow.CloudPFlowContext;
import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService;
import nccloud.ws.rest.resource.AbstractNCCRestResource;
import org.json.JSONString;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.List;
@Path("so/saleinvoice/operator")
public class billSaveAction extends AbstractNCCRestResource {
public static String fplxStr = "";// 开票申请发票类型
public billSaveAction() {
}
public OpenApiConvertDataResult changeToExchangeData(OpenApiConvertDataObject openApiConvertDataObject)
throws Exception {
return getPFxxEJBService().changeToExchangeData(openApiConvertDataObject);
}
public static IExchangeForService getPFxxEJBService() {
IExchangeForService exchangeForService = (IExchangeForService) ObjectCreator.newInstance("ufesbexpress",
"nccloud.pubimpl.pfxx.convert.ExchangeForServiceImpl");
return exchangeForService;
}
@Override
public String getModule() {
return "so";
}
@POST
@Path("/billSaveRp")
@Consumes({"application/json"})
@Produces({"application/json"})
public JSONString billSaveRp(JSONString json) throws Exception {
/**
* 销售发票红冲
* 1.根据bip传参中的销售发票主表id查询erp的销售发票VO
* 2.根据查询的销售发票VO生成红冲的销售发票
*/
JSONObject jobject = JSONObject.parseObject(json.toJSONString());
if (jobject == null) {
return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null"));
}
JSONObject bject = jobject.getJSONObject("billhead");
if (bject == null) {
return ResultMessageUtil.exceptionToJSON(new NullPointerException("billhead:null"));
}
String csaleinvoiceid = bject.getString("csaleinvoiceid"); // 销售发票id
// 根据销售发票主实体id查询销售发票
String[] ids = {csaleinvoiceid};
SaleInvoiceVO[] saleInvoiceVOs = NCLocator.getInstance().lookup(ISaleinvoiceQueryAPI.class)
.queryVOByIDs(ids);
if (saleInvoiceVOs.length <= 0) {
return ResultMessageUtil.exceptionToJSON(new NullPointerException("未查询到Erp对应的销售发票"));
}
try {
// 调用函数根据原销售发票组装新红冲发票
SaleInvoiceVO saleInvoiceRedRushVO = makeNewRedRushSaleInvoice(saleInvoiceVOs[0], bject);
// 生成红冲发票
ICloudScriptPFlowService flowService = NCLocator.getInstance().lookup(ICloudScriptPFlowService.class);
CloudPFlowContext context = new CloudPFlowContext();
context.setBillType("32");
context.setBillVos(new SaleInvoiceVO[]{saleInvoiceRedRushVO});
context.setActionName("WRITE");
SaleInvoiceVO[] returnSaveSaleInvoiceVOs = (SaleInvoiceVO[]) flowService.exeScriptPFlow(context);
// SaleInvoiceVO[] returnSaveSaleInvoiceVO = (SaleInvoiceVO[])PfServiceScmUtil.processBatch("WRITE", SOBillType.Invoice.getCode(), new SaleInvoiceVO[] { saleInvoiceRedRushVO }, null, null);
if (returnSaveSaleInvoiceVOs != null && returnSaveSaleInvoiceVOs.length > 0) {
// 生成红冲发票成功后执行销售发票审批动作
context.setBillType("32");
context.setBillVos(returnSaveSaleInvoiceVOs);
context.setActionName("APPROVE");
SaleInvoiceVO[] returnApproveSaleInvoiceVOs = (SaleInvoiceVO[]) flowService.exeScriptPFlow(context);
if (returnApproveSaleInvoiceVOs == null && returnApproveSaleInvoiceVOs.length <= 0) {
throw new BusinessException("生成销售发票审核失败");
}
/**
* 开票申请红冲逻辑
* 1.根据销售发票号查询下游开票申请
* 2.根据原开票申请生成新红冲
*/
String vBillcode = saleInvoiceVOs[0].getParentVO().getVbillcode();
HYSuperDMO dmo = new HYSuperDMO();
// 开票申请单主表
IVApplicationHeadVO[] iVApplicationHeadVO = (IVApplicationHeadVO[]) dmo.queryByWhereClause(IVApplicationHeadVO.class, "src_billno='" + vBillcode + "' and dr=0 ");
String pk_ivapplication = iVApplicationHeadVO[0].getPk_ivapplication(); // 开票申请id
// 开票申请单子表
IVApplicationBodyVO[] iVApplicationBodyVOs = (IVApplicationBodyVO[]) dmo.queryByWhereClause(IVApplicationBodyVO.class, "pk_ivapplication='" + pk_ivapplication + "' and dr=0 ");
// 调用函数封装开票申请红冲VO
IVApplicationAggVO iVApplicationAggVO = makeNewRedRushIVApplicationAggVO(iVApplicationHeadVO[0], iVApplicationBodyVOs, bject, returnApproveSaleInvoiceVOs);
// 生成红冲的开票申请
// context.setBillType("SSCIVA");
// context.setBillVos( new IVApplicationAggVO[] { iVApplicationAggVO });
// context.setActionName("SAVE");
// IVApplicationAggVO[] returnSaveIVApplicationAggVO = (IVApplicationAggVO[] )flowService.exeScriptPFlow(context);
IVApplicationServiceImpl serviceImpl = new IVApplicationServiceImpl();
IVApplicationAggVO returnSaveIVApplicationAggVO = serviceImpl.save(iVApplicationAggVO);
// Object returnIVApplicationAggVO = PfServiceScmUtil.processBatch("SAVE", "SSCIVA", new IVApplicationAggVO[] { iVApplicationAggVO }, null, null);
if (returnSaveIVApplicationAggVO != null) {
return ResultMessageUtil.toJSON(null, "接口调用成功");
} else {
Exception e = new Exception("接口调用失败");
return ResultMessageUtil.exceptionToJSON(e);
}
} else {
Exception e = new Exception("接口调用失败");
return ResultMessageUtil.exceptionToJSON(e);
}
} catch (BusinessException e) {
Logger.error("writeBack Error: ", e);
return ResultMessageUtil.exceptionToJSON(e);
}
}
/**
* 构造红冲发票VO
*
* @param originalSaleInvoiceVO
* @param bject
* @return
* @throws Exception
*/
public static SaleInvoiceVO makeNewRedRushSaleInvoice(SaleInvoiceVO originalSaleInvoiceVO, JSONObject bject) throws Exception {
try {
SaleInvoiceVO saleInvoiceVO = new SaleInvoiceVO();
SaleInvoiceHVO saleInvoiceHVO = originalSaleInvoiceVO.getParentVO(); // 主实体
SaleInvoiceBVO[] saleInvoiceBVOs = originalSaleInvoiceVO.getChildrenVO(); // 子实体
SaleInvoiceHVO newSaleInvoiceHVO = new SaleInvoiceHVO(); // 新主实体
// 子实体属性赋值
UFDouble sumNum = new UFDouble(); // 合计数量
UFDouble sumNtax = new UFDouble(); // 合计税额
UFDouble sumNcaltaxmny = new UFDouble(); // 合计计税金额
UFDouble sumNorigmny = new UFDouble(); // 合计无税金额
UFDouble sumNorigtaxmny = new UFDouble(); // 合计价税合计
int i = 0;
com.alibaba.fastjson.JSONArray paramsSaleInvoiceBVOsJSA = (com.alibaba.fastjson.JSONArray) bject.get("SaleInvoiceBVOs"); // 参数子实体数组
List<JSONObject> paramsSaleInvoiceBVOs = paramsSaleInvoiceBVOsJSA.toJavaList(JSONObject.class);
SaleInvoiceBVO[] newSaleInvoiceBVOs = new SaleInvoiceBVO[paramsSaleInvoiceBVOs.size()]; // 新子实体
for (SaleInvoiceBVO saleInvoiceBVO : saleInvoiceBVOs) {
String csaleinvoicebid = saleInvoiceBVO.getCsaleinvoicebid(); // 子表id
// 筛选参数红冲的子表集合
List<JSONObject> newParamsSaleInvoiceBVOs = paramsSaleInvoiceBVOs.stream().filter(item -> {
String parCsaleinvoicebid = item.getString("csaleinvoicebid") + "";
return csaleinvoicebid.equals(parCsaleinvoicebid);
}).toList();
if (newParamsSaleInvoiceBVOs.size() <= 0) {
continue;
}
JSONObject paramSaleInvoiceBVO = newParamsSaleInvoiceBVOs.get(0); // 参数子表
SaleInvoiceBVO newSaleInvoiceBVO = new SaleInvoiceBVO();
// BeanUtil.copyProperties(saleInvoiceBVO,newSaleInvoiceBVO);
// 克隆取值原子表销售发票
newSaleInvoiceBVO = (SaleInvoiceBVO) CloneUtil.depthClone(saleInvoiceBVO);
// 赋值之后修改子实体红冲时字段
newSaleInvoiceBVO.setCsaleinvoicebid(null); // 发票子实体id
newSaleInvoiceBVO.setDbilldate(newSaleInvoiceHVO.getDbilldate()); // 开票日期
newSaleInvoiceBVO.setNastnum(new UFDouble(paramSaleInvoiceBVO.getString("nastnum"))); // 数量
newSaleInvoiceBVO.setNnum(new UFDouble(paramSaleInvoiceBVO.getString("nnum"))); // 主数量
newSaleInvoiceBVO.setNtax(new UFDouble(paramSaleInvoiceBVO.getString("ntax"))); // 税额
newSaleInvoiceBVO.setNmny(new UFDouble(paramSaleInvoiceBVO.getString("nmny"))); // 本币无税金额
newSaleInvoiceBVO.setNtaxmny(new UFDouble(paramSaleInvoiceBVO.getString("ntaxmny"))); // 本币价税合计
newSaleInvoiceBVO.setNcaltaxmny(new UFDouble(paramSaleInvoiceBVO.getString("ncaltaxmny"))); // 计税金额
newSaleInvoiceBVO.setNorigmny(new UFDouble(paramSaleInvoiceBVO.getString("norigmny"))); // 无税金额
newSaleInvoiceBVO.setNorigtaxmny(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny"))); // 价税合计
newSaleInvoiceBVO.setCopposesrcbid(paramSaleInvoiceBVO.getString("csaleinvoicebid")); // 对冲来源子表id
newSaleInvoiceBVO.setNqtunitnum(null); // 报价数量
newSaleInvoiceBVO.setCsaleinvoiceid(null); // 发票关联主表id
newSaleInvoiceBVO.setNtotalcostnum(null); // 累计成本结算数量
newSaleInvoiceBVO.setNtotalincomemny(null); // 累计确认应收金额
newSaleInvoiceBVO.setNtotalincomenum(null); // 累计确认应收数量
newSaleInvoiceBVO.setVchangerate("1.00/1.00"); // 换算率
newSaleInvoiceBVOs[i++] = newSaleInvoiceBVO;
sumNum = sumNum.add(new UFDouble(paramSaleInvoiceBVO.getString("nnum")));
sumNtax = sumNtax.add(new UFDouble(paramSaleInvoiceBVO.getString("ntax")));
sumNcaltaxmny = sumNcaltaxmny.add(new UFDouble(paramSaleInvoiceBVO.getString("ncaltaxmny")));
sumNorigmny = sumNorigmny.add(new UFDouble(paramSaleInvoiceBVO.getString("norigmny")));
sumNorigtaxmny = sumNorigtaxmny.add(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny")));
}
// 克隆取值原子表销售发票
newSaleInvoiceHVO = (SaleInvoiceHVO) CloneUtil.depthClone(saleInvoiceHVO);
// 赋值之后修改主实体红冲时字段
newSaleInvoiceHVO.setCsaleinvoiceid(null); // 发票主实体id
newSaleInvoiceHVO.setVbillcode(null); // 发票号
newSaleInvoiceHVO.setDbilldate(new UFDate()); // 开票日期
newSaleInvoiceHVO.setDmakedate(new UFDate()); // 制单日期
newSaleInvoiceHVO.setBsubunitflag(UFBoolean.TRUE); // 冲抵标记
newSaleInvoiceHVO.setFopposeflag(2); // 对冲标记 2对冲生成
newSaleInvoiceHVO.setFstatusflag(1); // 单据状态 1自由态
newSaleInvoiceHVO.setNtotalastnum(null); // 总数量
newSaleInvoiceHVO.setNtotalorigsubmny(null); // 冲抵金额
newSaleInvoiceHVO.setNtotalorigmny(null); // 价税合计
newSaleInvoiceHVO.setVopposesrccode(saleInvoiceHVO.getVbillcode()); // 对冲来源发票号
newSaleInvoiceHVO.setCopposesrcid(saleInvoiceHVO.getCsaleinvoiceid()); // 对冲来源发票id
newSaleInvoiceHVO.setApprover(null); // 审批人
newSaleInvoiceHVO.setTaudittime(null); // 审批日期
// 组装VO
saleInvoiceVO.setParentVO(newSaleInvoiceHVO);
saleInvoiceVO.setChildrenVO(newSaleInvoiceBVOs);
return saleInvoiceVO;
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
}
/**
* 构造红冲开票申请VO
*
* @param ivApplicationHeadVO 原开票申请主实体
* @param ivApplicationBodyVOS 原开票申请子实体
* @param bject bip参数
* @param returnApproveSaleInvoiceVOs 新生成的红冲销售发票实体
* @return
* @throws Exception
*/
public static IVApplicationAggVO makeNewRedRushIVApplicationAggVO(IVApplicationHeadVO ivApplicationHeadVO, IVApplicationBodyVO[] ivApplicationBodyVOS, JSONObject bject, SaleInvoiceVO[] returnApproveSaleInvoiceVOs) throws Exception {
try {
IVApplicationAggVO ivApplicationAggVO = new IVApplicationAggVO();
IVApplicationHeadVO newivApplicationHeadVO = new IVApplicationHeadVO(); // 新主实体
// 取新生成红冲发票的主实体数据
String csaleinvoiceid = returnApproveSaleInvoiceVOs[0].getParentVO().getCsaleinvoiceid();
String[] ids = {csaleinvoiceid};
SaleInvoiceVO[] rpSaleInvoiceVOs = NCLocator.getInstance().lookup(ISaleinvoiceQueryAPI.class)
.queryVOByIDs(ids);
SaleInvoiceHVO rpSaleInvoiceHVO = rpSaleInvoiceVOs[0].getParentVO();
// 主实体属性赋值
// BeanUtil.copyProperties(ivApplicationHeadVO,newivApplicationHeadVO, CopyOptions.create().setIgnoreNullValue(true));
// 克隆取值原子表开票申请
newivApplicationHeadVO = (IVApplicationHeadVO) CloneUtil.depthClone(ivApplicationHeadVO);
// 根据参数判断是否为部分红冲
boolean isPartHCFlag = false;
UFDouble paramNtotalorigmny = new UFDouble(bject.getString("ntotalorigmny")); // 参数价税合计主表红冲金额
UFDouble ntotalorigmny = ivApplicationHeadVO.getJshj(); // 原开票申请主表价税合计
// 红冲金额与开票申请源价税合计比较如果和值大于零则为部分红冲
if (ntotalorigmny.add(paramNtotalorigmny).compareTo(UFDouble.ZERO_DBL) > 0) {
isPartHCFlag = true;
}
UFDouble sumXmsl = new UFDouble(); // 合计数量
UFDouble sumXmje = new UFDouble(); // 合计金额
UFDouble sumXmjshj = new UFDouble(); // 合计价税合计
UFDouble sumBchcje = new UFDouble(); // 合计本次红冲金额
UFDouble sumSe = new UFDouble(); // 合计税额
// 子实体属性赋值
int i = 0;
com.alibaba.fastjson.JSONArray paramsSaleInvoiceBVOsJSA = (com.alibaba.fastjson.JSONArray) bject.get("SaleInvoiceBVOs"); // 参数子实体数组
List<JSONObject> paramsSaleInvoiceBVOs = paramsSaleInvoiceBVOsJSA.toJavaList(JSONObject.class);
IVApplicationBodyVO[] newivApplicationBodyVOS = new IVApplicationBodyVO[paramsSaleInvoiceBVOs.size()]; // 新子实体
for (IVApplicationBodyVO ivApplicationBodyVO : ivApplicationBodyVOS) {
String src_pkdetail = ivApplicationBodyVO.getSrc_pkdetail(); // 来源单据行id
// 筛选参数红冲的子表集合
List<JSONObject> newParamsSaleInvoiceBVOs = paramsSaleInvoiceBVOs.stream().filter(item -> {
String parCsaleinvoicebid = item.getString("csaleinvoicebid") + "";
return src_pkdetail.equals(parCsaleinvoicebid);
}).toList();
if (newParamsSaleInvoiceBVOs.size() <= 0) {
continue;
}
JSONObject paramSaleInvoiceBVO = newParamsSaleInvoiceBVOs.get(0); // 参数子表
IVApplicationBodyVO newivApplicationBodyVO = new IVApplicationBodyVO();
// BeanUtil.copyProperties(ivApplicationBodyVO,newivApplicationBodyVO, CopyOptions.create().setIgnoreNullValue(true));
// 克隆取值原子表开票申请
newivApplicationBodyVO = (IVApplicationBodyVO) CloneUtil.depthClone(ivApplicationBodyVO);
// 赋值之后修改子实体红冲时字段
newivApplicationBodyVO.setPk_ivappdetail(null); // 开票申请子实体id
newivApplicationBodyVO.setBillno(null); // 开票申请子实体单据号
newivApplicationBodyVO.setSe(new UFDouble(paramSaleInvoiceBVO.getString("ntax"))); // 税额
newivApplicationBodyVO.setXmsl(new UFDouble(paramSaleInvoiceBVO.getString("nnum"))); // 数量
newivApplicationBodyVO.setXmje(new UFDouble(paramSaleInvoiceBVO.getString("norigmny"))); // 金额
newivApplicationBodyVO.setXmjshj(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny"))); // 价税合计
newivApplicationBodyVO.setBchcje(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny")).multiply(new UFDouble(-1))); // 本次红冲金额 = 本次参数红冲金额
newivApplicationBodyVOS[i++] = newivApplicationBodyVO;
sumSe = sumSe.add(new UFDouble(paramSaleInvoiceBVO.getString("ntax")));
sumXmsl = sumXmsl.add(new UFDouble(paramSaleInvoiceBVO.getString("nnum")));
sumXmje = sumXmje.add(new UFDouble(paramSaleInvoiceBVO.getString("norigmny")));
sumXmjshj = sumXmjshj.add(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny")));
sumBchcje = sumBchcje.add(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny")).multiply(new UFDouble(-1)));
}
// 赋值之后修改主实体红冲时字段
newivApplicationHeadVO.setPk_ivapplication(null); // 开票申请单主实体id
newivApplicationHeadVO.setBillno(null); // 单据号
newivApplicationHeadVO.setPreparedate(new UFDate()); // 单据日期
newivApplicationHeadVO.setJshj(sumXmjshj); // 价税合计
newivApplicationHeadVO.setHjje(sumXmje); // 合计金额
newivApplicationHeadVO.setHjse(sumSe); // 合计税额
newivApplicationHeadVO.setBchcje(sumBchcje); // 本次红冲金额
newivApplicationHeadVO.setHzfp(UFBoolean.TRUE); // 红字发票
newivApplicationHeadVO.setSrc_billtype(SOBillType.Invoice.getCode()); // 来源单据类型
newivApplicationHeadVO.setSrc_tradetype(rpSaleInvoiceHVO.getCtrantypeid()); // 来源交易类型
newivApplicationHeadVO.setTranstypecode(rpSaleInvoiceHVO.getVtrantypecode()); // 来源交易类型编码
newivApplicationHeadVO.setSrc_pkbusibill(rpSaleInvoiceHVO.getCsaleinvoiceid()); // 来源单据id
newivApplicationHeadVO.setSrc_billno(rpSaleInvoiceHVO.getVbillcode()); // 来源单据编号
newivApplicationHeadVO.setHcyy("2"); // 红冲原因2开票有误
// 组装VO
ivApplicationAggVO.setParentVO(newivApplicationHeadVO);
ivApplicationAggVO.setChildrenVO(newivApplicationBodyVOS);
return ivApplicationAggVO;
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
}
public IUAPQueryBS getQueryService() {
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
}
}