feat: 同步所有客户到下单平台
This commit is contained in:
parent
9971b563c8
commit
7a5944c413
@ -19,6 +19,7 @@ import kd.bos.entity.datamodel.ListSelectedRow;
|
||||
import kd.bos.entity.operate.OperateOptionConst;
|
||||
import kd.bos.entity.operate.result.IOperateInfo;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.exception.KDBizException;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.ORM;
|
||||
@ -472,11 +473,10 @@ public class OrderApiUtils {
|
||||
JSONObject jsonObject = JSONObject.parseObject(res);
|
||||
int code = jsonObject.getIntValue("code");
|
||||
if (code == 0) {
|
||||
Object data = jsonObject.get("data");
|
||||
if (data instanceof Long) {
|
||||
String ids = data.toString();
|
||||
resStatus.put("id", ids);
|
||||
}
|
||||
Integer data = jsonObject.getInteger("data");
|
||||
resStatus.put("id", String.valueOf(data));
|
||||
} else {
|
||||
throw new KDBizException("失败:" + res);
|
||||
}
|
||||
return resStatus;
|
||||
} else {
|
||||
|
@ -4,7 +4,6 @@ import com.yem.or.utils.OrderApiUtils;
|
||||
import com.yem.wm.utils.YEM;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
@ -25,15 +24,15 @@ public class CustomerValidator extends AbstractValidator {
|
||||
for (ExtendedDataEntity dataEntitie : dataEntities) {
|
||||
DynamicObject mechanical = dataEntitie.getDataEntity();
|
||||
boolean isSynced = mechanical.getBoolean("yem_checkboxfield");
|
||||
DynamicObject group = mechanical.getDynamicObject("group");
|
||||
if (group != null) {
|
||||
long groupid = group.getLong("id");
|
||||
QFilter qFilter = new QFilter("parent.number", QCP.equals, "11602");
|
||||
QFilter qFilter1 = new QFilter("id", QCP.equals, groupid);
|
||||
qFilter1.and(new QFilter("enable", QCP.equals, "1"));
|
||||
DynamicObject[] dynamicObjects = BusinessDataServiceHelper.load("bd_customergroup", "id,number,parent"
|
||||
, new QFilter[]{qFilter, qFilter1});
|
||||
if (dynamicObjects.length > 0) {
|
||||
// DynamicObject group = mechanical.getDynamicObject("group");
|
||||
// if (group != null) {
|
||||
// long groupid = group.getLong("id");
|
||||
// QFilter qFilter = new QFilter("parent.number", QCP.equals, "11602");
|
||||
// QFilter qFilter1 = new QFilter("id", QCP.equals, groupid);
|
||||
// qFilter1.and(new QFilter("enable", QCP.equals, "1"));
|
||||
// DynamicObject[] dynamicObjects = BusinessDataServiceHelper.load("bd_customergroup", "id,number,parent"
|
||||
// , new QFilter[]{qFilter, qFilter1});
|
||||
// if (dynamicObjects.length > 0) {
|
||||
String number = mechanical.getString("number");
|
||||
String name = mechanical.getString("name");
|
||||
DynamicObject groupcustomers = mechanical.getDynamicObject("yem_groupcustomers");
|
||||
@ -51,31 +50,29 @@ public class CustomerValidator extends AbstractValidator {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isSynced) {
|
||||
String torderid = mechanical.getString("yem_torderid");
|
||||
Long existId = Long.valueOf(torderid);
|
||||
if (isSynced) {
|
||||
demands = OrderApiUtils.demands(name, number, groupcustomers, false, existId);
|
||||
} else {
|
||||
demands = OrderApiUtils.demands(name, number, groupcustomers, true, null);
|
||||
}
|
||||
String msg = demands.get("msg");
|
||||
if (msg == null) {
|
||||
if (demands.containsKey("id")) {
|
||||
String id = demands.get("id");
|
||||
if (YEM.isNotEmpty(id)) {
|
||||
mechanical.set("yem_torderid", id);
|
||||
mechanical.set("yem_checkboxfield", true);
|
||||
SaveServiceHelper.update(mechanical);
|
||||
SaveServiceHelper.save(new DynamicObject[]{mechanical});
|
||||
}
|
||||
} else {
|
||||
this.addErrorMessage(dataEntitie, msg);
|
||||
}
|
||||
} else {
|
||||
this.addErrorMessage(dataEntitie, "当前客户不满足同步条件,禁止同步至下单平台!!!");
|
||||
}
|
||||
} else {
|
||||
this.addErrorMessage(dataEntitie, "当前客户分组为空!!");
|
||||
}
|
||||
// } else {
|
||||
// this.addErrorMessage(dataEntitie, "当前客户不满足同步条件,禁止同步至下单平台!!!");
|
||||
// }
|
||||
// } else {
|
||||
// this.addErrorMessage(dataEntitie, "当前客户分组为空!!");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user