提交内容:计划编制调整自定义API接口/计划编制自定义API接口/上存金额扩展/推送星空收付款单电子回单附件代码

时间:2025-05-15 16:48
提交人:邹江涛
This commit is contained in:
zoujiangtao 2025-05-15 16:49:07 +08:00
parent ab1165feb6
commit 2f1863908e
4 changed files with 153 additions and 43 deletions

View File

@ -0,0 +1,32 @@
package shkd.sys.sys.plugin.Exp;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.tmc.bei.extpoint.balance.IFillBankBalance;
import java.math.BigDecimal;
/**
* @Description
* @Author Tao
* @Date 2025/5/14
*/
public class BalanceExpansion implements IFillBankBalance {
private static final Log logger = LogFactory.getLog(BalanceExpansion.class);
@Override
public void fillExtBankBalance(DynamicObject bankBalance, String balanceString) {
JSONObject jsonObject = JSON.parseObject(balanceString);
logger.info("bankBalance数据{}balanceString数据{}", bankBalance, jsonObject);
Object balance = jsonObject.get("depositBalance");
if (balance != null) {
bankBalance.set("shkd_depositbalance", new BigDecimal(String.valueOf(balance)));
} else {
bankBalance.set("shkd_depositbalance", BigDecimal.ZERO);
}
SaveServiceHelper.save(new DynamicObject[]{bankBalance});
}
}

View File

@ -0,0 +1,105 @@
package shkd.sys.sys.plugin.api;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.openapi.common.custom.annotation.*;
import kd.bos.openapi.common.result.CustomApiResult;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.tmc.fpm.business.dataproc.save.domain.FpmResponse;
import kd.tmc.fpm.business.dataproc.save.domain.ReportAdjustBillBatchSaveResDTO;
import shade.javax.validation.Valid;
import shkd.sys.sys.mservice.PlanningService;
import javax.validation.constraints.Min;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static shkd.sys.sys.mservice.PlanningService.planAdjustment;
import static shkd.sys.sys.mservice.PlanningService.planningWrite;
@ApiController(value = "open", desc = "用户example")
@ApiMapping("/example")
//请求头
@ApiHeaders({
@ApiHeader(name = "a", desc = "aa", example = "aaa"),
@ApiHeader(name = "b", desc = "bb", example = "bbb")
})
//错误码
@ApiErrorCodes({
@ApiErrorCode(code = "001", desc = "0001"),
@ApiErrorCode(code = "002", desc = "0002")
})
public class InterfacePracticePlug extends AbstractListPlugin implements Serializable {
private static final long serialVersionUID = 5265058589290098717L;
private static final Log logger = LogFactory.getLog(InterfacePracticePlug.class);
/**
* 计划编制写入
* @param arrHashMap
* @return
*/
@ApiPostMapping(value = "planning_save", desc = "计划编制写入")
public CustomApiResult<@ApiResponseBody("返回参数") String> planning_save(@ApiParam(value = "查询字段值") ArrayList<HashMap<String, Object>> arrHashMap) {
StringBuilder stringBuffer = new StringBuilder();
for (int i = 0; i < arrHashMap.size(); i++) {
HashMap<String, Object> hashMap = arrHashMap.get(i);
JSONObject jsonObject = new JSONObject(hashMap);
jsonObject.getString("periodCode");// 编报期间
jsonObject.getString("orgCode");// 编报主体
jsonObject.getString("subjectCode");// 计划科目
jsonObject.getString("entryPeriodCode");// 主维度数据分录期间code
jsonObject.getString("amount");//金额
FpmResponse<Void> voidFpmResponse = planningWrite(jsonObject.getString("periodCode"), jsonObject.getString("orgCode"), jsonObject.getString("subjectCode"), jsonObject.getString("entryPeriodCode"), Integer.parseInt(jsonObject.getString("amount")));
stringBuffer.append("").append(i + 1).append("条数据写入").append(voidFpmResponse.isSuccess() ? "成功" : "失败")
.append(",返回信息:").append(voidFpmResponse.getMessage()).append("\n");
}
return CustomApiResult.success(stringBuffer.toString());
}
/**
* 计划编制调整
*
* @param arrHashMap
* @return
*/
@ApiPostMapping(value = "planAdjustment_save", desc = "计划编制写入")
public CustomApiResult<@ApiResponseBody("返回参数") String> planAdjustment_save(@ApiParam(value = "查询字段值") ArrayList<HashMap<String, Object>> arrHashMap) {
logger.info("planAdjustment_save请求参数{}", arrHashMap.get(0));
StringBuilder stringBuffer = new StringBuilder();
for (int i = 0; i < arrHashMap.size(); i++) {
HashMap<String, Object> hashMap = arrHashMap.get(i);
JSONObject jsonObject = new JSONObject(hashMap);
jsonObject.getString("adjustReason");// 调整原因
jsonObject.getString("orgCode");// 编报主体
jsonObject.getString("periodCode");// 编报期间
jsonObject.getString("subjectCode");// 计划科目
jsonObject.getString("entryPeriodCode");// 主维度数据分录期间code
jsonObject.getString("amount");//金额
ReportAdjustBillBatchSaveResDTO resDTO = planAdjustment(
jsonObject.getString("adjustReason"),
jsonObject.getString("orgCode"),
jsonObject.getString("periodCode"),
jsonObject.getString("subjectCode"),
jsonObject.getString("entryPeriodCode"),
Integer.parseInt(jsonObject.getString("amount"))
);
List<String> adjustBillNoList = resDTO.getAdjustBillNoList();// 调整单据编号列表
if (adjustBillNoList.isEmpty()) {
stringBuffer.append("").append(i + 1).append("条数据写入").append("失败").append("\n");
}else {
stringBuffer.append("").append(i + 1).append("条数据写入").append("成功,").append("单据编号:").append(adjustBillNoList).append("\n");
}
}
return CustomApiResult.success(stringBuffer.toString());
}
}

View File

@ -23,6 +23,9 @@ import shkd.sys.sys.mservice.ApiService;
import java.util.*;
import static shkd.sys.sys.mservice.ApiService.getBillObject;
import static shkd.sys.sys.mservice.ApiService.pushBillAttachment;
/**
* 动态表单插件
*/
@ -114,46 +117,19 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
// 查询星空单据
if ("shkd_queryxk".equals(itemKey)) {
// 获取想要推送单据类型
String billMark = dataEntity.getDynamicObject("shkd_sourcebill").getString("number");
// 获取想要推送单据编码
String billNumber = dataEntity.getString("shkd_sourcenumber");
logger.info("获取推送单据编码 → billNumber{}", billNumber);
// 获取想要推送单据类型
String billMark = dataEntity.getDynamicObject("shkd_sourcebill").getString("number");
logger.info("获取推送单据类型 → billMark{}", billMark);
String xkBillType = null;
if ("cas_paybill".equals(billMark)) {
xkBillType = "AP_PAYBILL";
} else if ("cas_recbill".equals(billMark)) {
xkBillType = "AR_RECEIVEBILL";
}
IdentifyInfo iden = new IdentifyInfo();
iden.setUserName(dataEntity.getString("shkd_xkusername"));// properties.getProperty("X-KDApi-UserName")
iden.setAppId(dataEntity.getString("shkd_xkappid"));// properties.getProperty("X-KDApi-AppID")
iden.setdCID(dataEntity.getString("shkd_xkacctid"));// properties.getProperty("X-KDApi-AcctID")
iden.setAppSecret(dataEntity.getString("shkd_xkappsec"));// properties.getProperty("X-KDApi-AppSec")
iden.setlCID(2052);
iden.setServerUrl(dataEntity.getString("shkd_xkserverurl"));// properties.getProperty("X-KDApi-ServerUrl")
K3CloudApi k3CloudApi = new K3CloudApi(iden);
JSONObject jsonObject = new JSONObject();
jsonObject.put("OrderString", "");
jsonObject.put("TopRowCount", 0);
jsonObject.put("SubSystemId", "");
jsonObject.put("FieldKeys", "FBillNo,FID");
jsonObject.put("FormId", xkBillType);
jsonObject.put("Limit", 2000);
jsonObject.put("FilterString", "F_keed_SKDJBH='" + billNumber + "'");
jsonObject.put("StartRow", 0);
try {
List<List<Object>> lists = k3CloudApi.executeBillQuery(jsonObject.toString());
if (lists.isEmpty()) {
this.getView().showTipNotification("未查找到单据");
} else {
List<Object> objects = lists.get(0);
this.getView().showSuccessNotification("查找到单据 → 星空单据编码:" + objects.get(0) + "星空单据ID" + objects.get(1));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
HashMap<String, Object> map = getBillObject(dataEntity, billMark, billNumber);
this.getView().showTipNotification("查找到单据 → 星空单据编码:" + map.get("billNumber") + "星空单据ID" + map.get("billId"));
}
// 推送星空单据附件
if ("shkd_pushxk".equals(itemKey)) {
String result = pushBillAttachment(dataEntity);
this.getView().showTipNotification("返回结果:" + result);
}
}

View File

@ -23,18 +23,15 @@ public class AccountClosureMobBillPlugin extends AbstractMobBillPlugIn implement
if (afterDoOperationEventArgs.getOperateKey().equals("donothing")) {
boolean success = afterDoOperationEventArgs.getOperationResult().isSuccess();//是否成功
if (success) {
this.getPageCache().put("xhsuccess", String.valueOf(true));
String xhsuccess = this.getPageCache().get("xhsuccess");
logger.info("xhsuccess"+xhsuccess);
logger.info("进入donothing");
// 插件代码
HashMap<String, Object> map = new HashMap<>();
map.put("method", "setLocalStorage");
HashMap<String, Object> args = new HashMap<>();
args.put("key", "123");
args.put("value", "456");
args.put("key", "frontKey");
args.put("value", "frontValue");
map.put("args", args);
this.getView().executeClientCommand("callAPPApi", map);
logger.info("进入销户申请 → 执行完前端触发代码");
}
}
}