Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
6a1bc211dd
|
|
@ -0,0 +1,103 @@
|
|||
package tqq9.lc123.cloud.app.plugin.form.conm;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bes.gson.Gson;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.datamodel.ListSelectedRow;
|
||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.list.BillList;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import tqq9.lc123.cloud.app.eip.iscb.LCLogService;
|
||||
import tqq9.lc123.cloud.app.eip.iscb.impl.LCLogServiceImpl;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 标准单据列表插件
|
||||
*/
|
||||
public class ConmChangePlugin extends AbstractListPlugin implements Plugin {
|
||||
final static String KEY_OPKEY = "bizchange";
|
||||
private static String Change_URL;
|
||||
private static String FLXT_TOKEN;
|
||||
|
||||
static {
|
||||
DynamicObject url = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
||||
new QFilter[]{new QFilter("number", QCP.equals, "FLXT_Change_Url")});
|
||||
Change_URL = url != null ? url.getString("name") : null;
|
||||
DynamicObject token = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
||||
new QFilter[]{new QFilter("number", QCP.equals, "FLXT_TOKEN")});
|
||||
FLXT_TOKEN = token != null ? token.getString("name") : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
FormOperate formOperate = (FormOperate) args.getSource();
|
||||
if (StringUtils.equals(KEY_OPKEY, formOperate.getOperateKey())) {
|
||||
LCLogService lcLogService = new LCLogServiceImpl();
|
||||
BillList billlistap = this.getControl("billlistap");
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", FLXT_TOKEN);
|
||||
ListSelectedRowCollection selectedRows = billlistap.getSelectedRows();
|
||||
if (selectedRows != null && selectedRows.size() > 0) {
|
||||
for (ListSelectedRow listSelectedRow : selectedRows) {
|
||||
Object primaryKeyValue = listSelectedRow.getPrimaryKeyValue(); //获取单据pkid
|
||||
DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("conm_purcontract",
|
||||
new QFilter[]{new QFilter("id", QCP.equals, primaryKeyValue)});
|
||||
DynamicObjectCollection tqq9Entryentity = dataEntity.getDynamicObjectCollection("tqq9_entryentity");
|
||||
for (DynamicObject dynamicObject : tqq9Entryentity) {//
|
||||
DynamicObject tqq9_pur_rebate = dynamicObject.getDynamicObject("tqq9_pur_rebate");
|
||||
DynamicObject tqq9_pur_rebate1 = BusinessDataServiceHelper.loadSingle("tqq9_pur_rebate", new QFilter[]{new QFilter("id", QCP.equals, tqq9_pur_rebate.getLong("id"))});
|
||||
String id = tqq9_pur_rebate1.getString("id");//获取返利单据id
|
||||
String tqq9_rebateruleid = tqq9_pur_rebate1.getString("tqq9_rebateruleid");//获取返利规则id
|
||||
if (tqq9_rebateruleid != null && id != null) {
|
||||
params.put("id", tqq9_rebateruleid);
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
String bodyString = HttpRequestUtils.doGet(Change_URL, params, headers);
|
||||
JSONObject map = gson.fromJson(bodyString, JSONObject.class);
|
||||
Integer code = map.getInteger("code");
|
||||
if (code == 0) {
|
||||
lcLogService.savelog("FL-查看规则状态", Change_URL, false, true, params.toString(), bodyString);
|
||||
Map<String, Object> data = (Map<String, Object>) map.get("data");
|
||||
if (data != null) {
|
||||
Number statusNum = (Number) data.get("status");
|
||||
if (statusNum != null) {
|
||||
int status = statusNum.intValue();
|
||||
if (status == -1 || status == 1 || status == 4) {
|
||||
//终止流程
|
||||
this.getView().showErrorNotification("该状态下不允许变更!");
|
||||
args.setCancel(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lcLogService.savelog("FL-查看规则状态", Change_URL, false, true, params.toString(), bodyString);
|
||||
args.setCancel(true);
|
||||
return;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
lcLogService.savelog("FL-查看规则状态", Change_URL, false, false, params.toString(), "接口调用报错,errormessage:" + e.getMessage());
|
||||
throw new RuntimeException(e + ",请求返利规则状态查询失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package tqq9.lc123.cloud.app.plugin.form.result;
|
||||
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.CloneUtils;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.botp.runtime.BFRow;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 单据操作插件
|
||||
*/
|
||||
public class WarehouseReceiptClone extends AbstractOperationServicePlugIn implements Plugin {
|
||||
private final static Log logger = LogFactory.getLog(WarehouseReceiptClone.class);
|
||||
|
||||
@Override
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
super.beforeExecuteOperationTransaction(e);
|
||||
|
||||
DynamicObject[] dataEntities1 = e.getDataEntities();//获取数据实体
|
||||
for (DynamicObject dynamicObject : dataEntities1) {
|
||||
StringBuilder billnoSet = new StringBuilder();
|
||||
//查找上游单据
|
||||
Map<Long, List<BFRow>> sourceBillsMap = BFTrackerServiceHelper.findDirtSourceBills(dynamicObject.getDataEntityType().getName(), new Long[]{dynamicObject.getLong("id")});
|
||||
if (sourceBillsMap.size() > 0 && sourceBillsMap != null) {
|
||||
List<BFRow> bfRows = sourceBillsMap.get(dynamicObject.getLong("id"));
|
||||
if (bfRows != null) {
|
||||
for (BFRow bfRow : bfRows) {
|
||||
Long billId = bfRow.getSId().getBillId();//获取上游订单ID
|
||||
DynamicObject[] im_otheroutbill = BusinessDataServiceHelper.load("im_otheroutbill",
|
||||
"billno", new QFilter[]{new QFilter("id", QCP.equals, billId)});
|
||||
if (im_otheroutbill != null) {
|
||||
for (int i = 0; i < im_otheroutbill.length; i++) {
|
||||
DynamicObject doj = im_otheroutbill[i];
|
||||
billnoSet.append(doj.get("billno"));
|
||||
if (i < im_otheroutbill.length - 1) {
|
||||
billnoSet.append("、");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//查找再克隆
|
||||
QFilter qf1 = new QFilter("id", QCP.equals, dynamicObject.getLong("id"));
|
||||
dynamicObject = BusinessDataServiceHelper.loadSingle(dynamicObject.getDataEntityType().getName(), new QFilter[]{qf1});
|
||||
DynamicObject newData = (DynamicObject) new CloneUtils(false, true).clone(dynamicObject);
|
||||
newData.set("billno", dynamicObject.getString("billno"));
|
||||
newData.set("billstatus", "C");
|
||||
newData.set("tqq9_sourcebillno", billnoSet);
|
||||
//保存
|
||||
SaveServiceHelper.save(new DynamicObject[]{newData});
|
||||
//反审核
|
||||
OperateOption option = OperateOption.create();
|
||||
StringBuilder message = new StringBuilder();
|
||||
OperationResult unauditResult = OperationServiceHelper.executeOperate("unaudit", dynamicObject.getDataEntityType().getName(), new DynamicObject[]{dynamicObject}, OperateOption.create());
|
||||
if (unauditResult.isSuccess()) {
|
||||
OperationResult deleteResult = OperationServiceHelper.executeOperate("delete", dynamicObject.getDataEntityType().getName(), new DynamicObject[]{dynamicObject}, OperateOption.create());
|
||||
|
||||
deleteResult.getAllErrorOrValidateInfo().forEach((error) -> {
|
||||
message.append(error.getMessage());
|
||||
});
|
||||
} else {
|
||||
unauditResult.getAllErrorOrValidateInfo().forEach((error) -> {
|
||||
message.append(error.getMessage());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue