附件,客商准入
This commit is contained in:
parent
111651caeb
commit
4622337d13
@ -22,6 +22,8 @@ include(
|
||||
':yem-wmzh-csm',
|
||||
|
||||
':yem-wm-bd',
|
||||
|
||||
':yem-wmzh-ii',
|
||||
)
|
||||
|
||||
// -------------- 引入苍穹调试工程模块 --------------
|
||||
@ -51,3 +53,6 @@ project(':yem-wmzh-csm').projectDir = new File('yem-wmzh/yem-wmzh-csm')
|
||||
|
||||
// -------------- 引入wm云-bd应用模块 --------------
|
||||
project(':yem-wm-bd').projectDir = new File('yem-wm/yem-wm-bd')
|
||||
|
||||
// -------------- 引入wmzh云-ii应用模块 --------------
|
||||
project(':yem-wmzh-ii').projectDir = new File('yem-wmzh/yem-wmzh-ii')
|
||||
|
@ -0,0 +1,356 @@
|
||||
package yem.base.common.module.attach.form;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.bill.OperationStatus;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.EntityMetadataCache;
|
||||
import kd.bos.entity.MainEntityType;
|
||||
import kd.bos.entity.datamodel.IDataModel;
|
||||
import kd.bos.form.FormShowParameter;
|
||||
import kd.bos.form.IFormView;
|
||||
import kd.bos.form.control.AttachmentPanel;
|
||||
import kd.bos.form.control.events.BeforeAttachmentRemoveEvent;
|
||||
import kd.bos.form.control.events.BeforeAttachmentRemoveListener;
|
||||
import kd.bos.form.control.events.UploadEvent;
|
||||
import kd.bos.form.control.events.UploadListener;
|
||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||
import kd.bos.metadata.dao.MetaCategory;
|
||||
import kd.bos.metadata.dao.MetadataDao;
|
||||
import kd.bos.metadata.form.ControlAp;
|
||||
import kd.bos.metadata.form.FormMetadata;
|
||||
import kd.bos.metadata.form.control.AttachmentPanelAp;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.bos.servicehelper.user.UserServiceHelper;
|
||||
import yem.base.common.utils.DynamicObjectUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 附件表单功能
|
||||
* @Author: LiuHB
|
||||
* @CreateTime: 2025-02-17 10:42
|
||||
*/
|
||||
public class AccessoryToolsBillPlugin extends AbstractBillPlugIn implements UploadListener ,BeforeAttachmentRemoveListener{
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 注册监听器,定义了在注册监听器时的操作。
|
||||
* @param e 事件对象,表示要注册监听的事件。
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
AttachmentPanel attachmentPanel = this.getView().getControl("attachmentpanel");
|
||||
attachmentPanel.addUploadListener(this);
|
||||
attachmentPanel.addBeforeRemoveListener(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 根据操作结果控制界面
|
||||
* @function 1.点击保存或提交后为附件分录的【单据id】字段赋值
|
||||
* @purposes 用户点击按钮、菜单,执行完绑定的操作后,不论成功与否,均会触发此事件
|
||||
* @param e
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
||||
super.afterDoOperation(e);
|
||||
IFormView view = this.getView();
|
||||
IDataModel model = view.getModel();
|
||||
String operateKey = e.getOperateKey();
|
||||
switch (operateKey) {
|
||||
case "save":
|
||||
case "submit":
|
||||
String formName = this.getView().getModel().getDataEntity(true).getDynamicObjectType().getName();
|
||||
Set<String> attachmentkey = getAttachControl(formName).keySet();
|
||||
//增加/更新附件
|
||||
attachmentForm("yem_attachmentinfo_e", attachmentkey);
|
||||
DynamicObjectCollection attachmentinfo_e = this.getView().getModel().getDataEntity(true).getDynamicObjectCollection("yem_attachmentinfo_e");
|
||||
for (int i = 0; i < attachmentinfo_e.size(); i++) {
|
||||
model.setValue("yem_billid", model.getValue("id"), i);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 用户在前端附件面板,上传文件后,系统自动调用
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void afterUpload(UploadEvent evt) {
|
||||
UploadListener.super.afterUpload(evt);
|
||||
String formName = this.getView().getModel().getDataEntity(true).getDynamicObjectType().getName();
|
||||
Set<String> attachmentkey = getAttachControl(formName).keySet();
|
||||
//增加/更新附件
|
||||
attachmentForm("yem_attachmentinfo_e", attachmentkey);
|
||||
}
|
||||
/**
|
||||
* @Description: 用户在前端附件面板,删除文件前,系统自动调用
|
||||
* @function 校验:当前登陆人不能删除其他人上传的附件
|
||||
* @param e
|
||||
* @return void
|
||||
*/
|
||||
@Override
|
||||
public void beforeAttachmentRemove(BeforeAttachmentRemoveEvent e) {
|
||||
FormShowParameter showParameter = this.getView().getFormShowParameter();
|
||||
String status = showParameter.getStatus().toString();
|
||||
if (!status.equals("ADDNEW")) {
|
||||
long userId = UserServiceHelper.getCurrentUserId();
|
||||
DynamicObject bos_user = BusinessDataServiceHelper.loadSingleFromCache(userId, "bos_user");
|
||||
Map<String, Object> map = e.getAttachemnt();
|
||||
AttachmentPanel attachmentPanel = (AttachmentPanel) e.getSource();
|
||||
String uid = (String) map.get("uid");
|
||||
List<Map<String, Object>> attachmentData = attachmentPanel.getAttachmentData();
|
||||
for (Map<String, Object> data : attachmentData) {
|
||||
String uidAttachment = (String) data.get("uid");
|
||||
if (!StringUtils.isEmpty(uidAttachment)) {
|
||||
if (uidAttachment.equals(uid)) {
|
||||
String creator = data.get("creator").toString();
|
||||
if (!creator.contains(bos_user.getString("name"))) {
|
||||
e.setMsg("不能删除别人上传的附件!!!");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 用户在前端附件面板,删除文件后,系统自动调用
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void afterRemove(UploadEvent evt) {
|
||||
UploadListener.super.afterRemove(evt);
|
||||
String formName = this.getView().getModel().getDataEntity(true).getDynamicObjectType().getName();
|
||||
Map<String, String> attachControl = getAttachControl(formName);
|
||||
Set<String> attachControlkey = attachControl.keySet();
|
||||
removeAttachmentContext(attachControlkey,formName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description 附件表格赋值
|
||||
* @function 1.根据传入的附件面板标识,获取到各个附件面板的数据,调用buildAttachmentMap()方法,返回附件数据集合
|
||||
* key: 附件uid value:附件信息
|
||||
* 2.将现有的附件uid存入set
|
||||
* 3.判断调整后的附件面板的附件uid和附件分录的是否包含
|
||||
* 包含:根据获取到的附件信息更新分录数据
|
||||
* 不包含:新增附件分录数据
|
||||
* @param yemAttachmentdetail 附件分录标识
|
||||
* @param attachmentkey 附件面板标识集合
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private void attachmentForm(String yemAttachmentdetail, Set<String> attachmentkey) {
|
||||
Map<String, Map<String, Object>> attachmentMap = buildAttachmentMap(attachmentkey);
|
||||
DynamicObjectCollection attachmentDetail = this.getView().getModel().getDataEntity(true).getDynamicObjectCollection(yemAttachmentdetail);
|
||||
// 获取现有的 UID 列表
|
||||
Set<String> existingUids = attachmentDetail.stream()
|
||||
.map(detail -> detail.getString("yem_attachedid"))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 处理每个附件
|
||||
attachmentMap.forEach((uid, value) -> {
|
||||
if (existingUids.contains(uid)) {
|
||||
//更新
|
||||
updateExistingAttachment( attachmentDetail, uid, value,(String) value.get("attachmentpanelKey"));
|
||||
} else {
|
||||
//新增
|
||||
createNewAttachment( yemAttachmentdetail, uid, value, (String) value.get("attachmentpanelKey"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description 更新附件行
|
||||
* @param attachmentDetail 附件分录
|
||||
* @param uid 附件uid
|
||||
* @param data 附件信息
|
||||
* @param attachmentpanelKey 附件面板标识
|
||||
*/
|
||||
private void updateExistingAttachment(DynamicObjectCollection attachmentDetail,
|
||||
String uid, Map<String, Object> data,
|
||||
String attachmentpanelKey) {
|
||||
for (DynamicObject attachment : attachmentDetail) {
|
||||
if (uid.equals(attachment.getString("yem_attachedid"))) {
|
||||
int rowIndex = attachmentDetail.indexOf(attachment);
|
||||
setAttachmentValues(this, rowIndex, uid, data, attachmentpanelKey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 增加新附件行
|
||||
* @param entityName 附件分录标识
|
||||
* @param uid 附件uid
|
||||
* @param data 附件信息
|
||||
* @param attachmentpanelKey 附件面板标识
|
||||
*/
|
||||
private void createNewAttachment(String entityName, String uid, Map<String, Object> data,
|
||||
String attachmentpanelKey) {
|
||||
int newRow = this.getView().getModel().createNewEntryRow(entityName);
|
||||
setAttachmentValues(this,newRow, uid, data, attachmentpanelKey);
|
||||
}
|
||||
/**
|
||||
* @Description 附件分录赋值
|
||||
*/
|
||||
private static void setAttachmentValues(AbstractBillPlugIn form, int row, String uid,
|
||||
Map<String, Object> data,
|
||||
String attachmentpanelKey) {
|
||||
//单据标识
|
||||
String billName = form.getView().getModel().getDataEntity(true).getDataEntityType().getName();
|
||||
form.getView().getModel().setValue("yem_attachmentname", data.get("name"), row);//附件名称
|
||||
form.getView().getModel().setValue("yem_atturl", data.get("url"), row);//url
|
||||
form.getView().getModel().setValue("yem_panel", attachmentpanelKey, row);//附件面板
|
||||
form.getView().getModel().setValue("yem_billno",form.getView().getModel().getValue("billno"), row);//单据编号
|
||||
form.getView().getModel().setValue("yem_docid",billName, row);//单据标识
|
||||
form.getView().getModel().setValue("yem_billid",form.getView().getModel().getValue("id"), row);//单据id
|
||||
form.getView().getModel().setValue("yem_attachedid", uid, row);//uid
|
||||
form.getView().getModel().setValue("yem_uploaddate", data.get("createTime"), row);//上传时间
|
||||
Long currentUserId = UserServiceHelper.getCurrentUserId();
|
||||
form.getView().getModel().setValue("yem_attacheduser", currentUserId, row);//上传人
|
||||
QFilter qFilter = new QFilter("yem_bill.number", QCP.equals, billName);
|
||||
qFilter.and("yem_isdefault",QCP.equals,true);
|
||||
DynamicObject attachmenttype = BusinessDataServiceHelper.loadSingle("yem_bd_attachmenttype", qFilter.toArray());
|
||||
form.getView().getModel().setValue("yem_attachmenttype", attachmenttype, row);//上传时间
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description 构建附件map
|
||||
* @function 功能
|
||||
* @purposes 准备附件分录需要的数据
|
||||
* @param attachmentkey
|
||||
* @return java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>
|
||||
* key:附件uid value:附件信息
|
||||
*/
|
||||
|
||||
private Map<String, Map<String, Object>> buildAttachmentMap(Set<String> attachmentkey) {
|
||||
Map<String, Map<String, Object>> attachmentMap = new HashMap<>();
|
||||
for (String sattachmentinfo : attachmentkey) {
|
||||
AttachmentPanel attachmentPanel = this.getView().getControl(sattachmentinfo);
|
||||
List<Map<String, Object>> attachmentDatas = attachmentPanel.getAttachmentData();
|
||||
|
||||
for (Map<String, Object> attachmentData : attachmentDatas) {
|
||||
String uid = (String) attachmentData.get("uid");
|
||||
String name = (String) attachmentData.get("name");
|
||||
String url = (String) attachmentData.get("url");
|
||||
Long createTime = (Long) attachmentData.get("createdate");
|
||||
// 格式化时间
|
||||
String formattedTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(createTime));
|
||||
// 获取创建人
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> creator = (Map<String, Object>) attachmentData.get("creator");
|
||||
String creatorName = creator != null ? (String) creator.get("zh_CN") : null;
|
||||
|
||||
// 存储数据
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("name", name);
|
||||
dataMap.put("url", url);
|
||||
dataMap.put("createTime", formattedTime);
|
||||
dataMap.put("creator", creatorName);
|
||||
dataMap.put("attachmentpanelKey",sattachmentinfo);
|
||||
attachmentMap.put(uid, dataMap);
|
||||
}
|
||||
}
|
||||
return attachmentMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 删除附件
|
||||
* @function 1.获取当前页面所有附件面板的附件id
|
||||
* 2.遍历附件分录,判断分录id是否包含在附件面板id集合中,包含则记录行号,遍历完成删行处理
|
||||
* @purposes 用途
|
||||
* @param attachmentpanelKey 附件面板标识集合
|
||||
* @param formName 单据标识
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private void removeAttachmentContext(Set<String> attachmentpanelKey, String formName) {
|
||||
|
||||
Set<String> urlSet = new HashSet<>();
|
||||
for (String attachmentpanel : attachmentpanelKey) {
|
||||
AttachmentPanel attachment = this.getView().getControl(attachmentpanel);
|
||||
List<Map<String, Object>> attachmentDatas = attachment.getAttachmentData();
|
||||
for (Map<String, Object> attachmentData : attachmentDatas) {
|
||||
urlSet.add((String) attachmentData.get("uid"));
|
||||
}
|
||||
}
|
||||
//附件分录
|
||||
DynamicObjectCollection attachmentDetail = this.getView().getModel()
|
||||
.getDataEntity(true).
|
||||
getDynamicObjectCollection("yem_attachmentinfo_e");
|
||||
// 找出需要删除的记录(在urld中有但在urls中没有的记录)
|
||||
List<Integer> toDelete = new ArrayList<>();
|
||||
for (int i = 0; i < attachmentDetail.size(); i++) {
|
||||
DynamicObject attachment = attachmentDetail.get(i);
|
||||
if (!urlSet.contains(attachment.getString("yem_attachedid"))) {
|
||||
toDelete.add(i);
|
||||
}
|
||||
}
|
||||
if (!toDelete.isEmpty()) {
|
||||
int[] array = toDelete.stream().mapToInt(Integer::intValue).toArray();
|
||||
this.getView().getModel().deleteEntryRows("yem_attachmentinfo_e", array);
|
||||
}
|
||||
FormShowParameter showParameter = this.getView().getFormShowParameter();
|
||||
if (!showParameter.getStatus().equals(OperationStatus.ADDNEW)) {
|
||||
OperationServiceHelper.executeOperate("save", formName, new DynamicObject[]{this.getView().getModel().getDataEntity(true)}, OperateOption.create());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 获取源单实体所有附件面板的key\name
|
||||
* @param formName 源单标识
|
||||
* @return java.util.Map<java.lang.String,java.lang.String>
|
||||
* key:附件面板标识
|
||||
* value:附件面板名称
|
||||
*/
|
||||
|
||||
private Map<String, String> getAttachControl(String formName) {
|
||||
MainEntityType entityType = EntityMetadataCache.getDataEntityType(formName);
|
||||
FormMetadata taskMeta = (FormMetadata) MetadataDao.readRuntimeMeta(MetadataDao.getIdByNumber(
|
||||
entityType.getName(), MetaCategory.Form), MetaCategory.Form);
|
||||
List<ControlAp<?>> items = taskMeta.getItems();
|
||||
// 附件面板标识集合。
|
||||
Map<String, String> attachmentPanelAp = new HashMap<>();
|
||||
items.forEach(item -> {
|
||||
if (item instanceof AttachmentPanelAp) {
|
||||
AttachmentPanelAp attachmentPanel = (AttachmentPanelAp) item;
|
||||
attachmentPanelAp.put(attachmentPanel.getKey(), String.valueOf(attachmentPanel.getName()));
|
||||
}
|
||||
});
|
||||
return attachmentPanelAp;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,4 +33,7 @@ dependencies {
|
||||
// 引入wm云 bd应用模块
|
||||
implementation project(':yem-wm-bd')
|
||||
|
||||
// 引入wmzh云 ii应用模块
|
||||
implementation project(':yem-wmzh-ii')
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package yem.wm.bd.attachmenttype.opplugin.op;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import yem.base.common.utils.DynamicObjectUtil;
|
||||
|
||||
/**
|
||||
* @Description 附件类型
|
||||
* @Author: LiuHB
|
||||
* @CreateTime: 2025-02-19 10:23
|
||||
*/
|
||||
public class OnlyoneIsdefaultOpPlugin extends AbstractOperationServicePlugIn {
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
DynamicObject[] attachmenttypes = e.getDataEntities();
|
||||
for (DynamicObject attachmenttype : attachmenttypes) {
|
||||
boolean yemIsdefault = attachmenttype.getBoolean("yem_isdefault");
|
||||
if(yemIsdefault){
|
||||
long id = attachmenttype.getLong("id");
|
||||
DynamicObject yemBill = attachmenttype.getDynamicObject("yem_bill");
|
||||
String selectfields = DynamicObjectUtil.getSelectfields("yem_bd_attachmenttype", false);
|
||||
QFilter qFilter = new QFilter("id", QCP.not_equals, id);
|
||||
qFilter.and("yem_bill.number",QCP.equals,yemBill.getString("number"));
|
||||
DynamicObject[] bdAttachmenttypes = BusinessDataServiceHelper.load("yem_bd_attachmenttype", selectfields, qFilter.toArray());
|
||||
for (DynamicObject bdAttachmenttype : bdAttachmenttypes) {
|
||||
bdAttachmenttype.set("yem_isdefault",false);
|
||||
}
|
||||
SaveServiceHelper.save(bdAttachmenttypes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import kd.bos.form.CloseCallBack;
|
||||
import kd.bos.form.FormShowParameter;
|
||||
import kd.bos.form.IFormView;
|
||||
import kd.bos.form.ShowType;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.control.EntryGrid;
|
||||
import kd.bos.form.events.ClosedCallBackEvent;
|
||||
import kd.bos.orm.query.QCP;
|
||||
@ -21,6 +22,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.user.UserServiceHelper;
|
||||
import yem.base.common.utils.YEM;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -73,9 +75,11 @@ public class CustomeraccessBillPlugin extends AbstractBillPlugIn {
|
||||
Long dptid = 0L;
|
||||
if (entryentity.size() > 0) {
|
||||
for (DynamicObject userow : entryentity) {
|
||||
DynamicObject dpt = (DynamicObject) userow.get("dpt");
|
||||
dptid = null != dpt ? dpt.getLong("id") : null;
|
||||
break;
|
||||
boolean ispartjob = userow.getBoolean("ispartjob");
|
||||
if(!ispartjob){
|
||||
DynamicObject dpt = (DynamicObject) userow.get("dpt");
|
||||
dptid = null != dpt ? dpt.getLong("id") : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dptid;
|
||||
@ -102,8 +106,9 @@ public class CustomeraccessBillPlugin extends AbstractBillPlugIn {
|
||||
ILocaleString yemMerchantstnamed = (ILocaleString) this.getModel().getValue("yem_merchantstname");
|
||||
String yemMerchantstnames = yemMerchantstnamed.getLocaleValue();
|
||||
Boolean yemInternal = (Boolean) model.getValue("yem_internal");//内部业务单元
|
||||
String domesticoroverseas = (String)model.getValue("yem_domesticoroverseas");
|
||||
//去除客商名称中的空格
|
||||
String merchantstnames = nameprocessing(yemMerchantstnames);
|
||||
String merchantstnames = nameprocessing(yemMerchantstnames,domesticoroverseas);
|
||||
//校验必须有与客商名称匹配的组织
|
||||
matchOrganizations(yemInternal, merchantstnames);
|
||||
break;
|
||||
@ -116,6 +121,8 @@ public class CustomeraccessBillPlugin extends AbstractBillPlugIn {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 插件可以在此相应点击事件,如弹出单独的编辑界面。
|
||||
* @function 1.弹出{客商地址}动态表单,回填联系人分录
|
||||
@ -125,14 +132,24 @@ public class CustomeraccessBillPlugin extends AbstractBillPlugIn {
|
||||
@Override
|
||||
public void click(EventObject evt) {
|
||||
super.click(evt);
|
||||
addresspasswd("yem_wmzh_cusadress", "yem_associatedaddress");
|
||||
Control c = (Control) evt.getSource();
|
||||
String key = c.getKey();
|
||||
switch (key){
|
||||
case "yem_associatedaddress":
|
||||
addressPasswd("yem_wmzh_cusadress", "yem_associatedaddress");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 弹出{客商地址}动态表单
|
||||
*/
|
||||
private void addresspasswd(String dynamicform, String button) {
|
||||
private void addressPasswd(String dynamicform, String button) {
|
||||
FormShowParameter showParameter = new FormShowParameter();
|
||||
showParameter.setStatus(OperationStatus.ADDNEW);
|
||||
showParameter.getOpenStyle().setShowType(ShowType.Modal);
|
||||
@ -207,30 +224,52 @@ public class CustomeraccessBillPlugin extends AbstractBillPlugIn {
|
||||
* @Description: 去除客商名称中的空格
|
||||
* @function 去除客商名称中的空格, 如果都是中文字符去除所有空格,包含其他字符则去除前后空格
|
||||
*/
|
||||
private String nameprocessing(String yemMerchantstnames) {
|
||||
private String nameprocessing(String yemMerchantstnames, String domesticoroverseas) {
|
||||
String merchantstnames = "";
|
||||
boolean containsValidChars = false;
|
||||
boolean containsChinese = false;
|
||||
// if("A".equals(domesticoroverseas)) {
|
||||
// 检查是否包含中文字符
|
||||
boolean containsChinese = yemMerchantstnames.codePoints()
|
||||
.anyMatch(codePoint -> (codePoint >= 0x4e00 && codePoint <= 0x9fa5) || // 基本汉字
|
||||
(codePoint >= 0x3400 && codePoint <= 0x4dbf) || // 扩展A
|
||||
(codePoint >= 0xf900 && codePoint <= 0xfaff) || // 兼容汉字
|
||||
(codePoint >= 0x20000 && codePoint <= 0x2a6df) || // 扩展B
|
||||
(codePoint >= 0x2a700 && codePoint <= 0x2b73f) || // 扩展C
|
||||
(codePoint >= 0x2b740 && codePoint <= 0x2b81f) || // 扩展D
|
||||
(codePoint >= 0x2b820 && codePoint <= 0x2ceaf)); // 扩展E
|
||||
// 检查是否包含空格
|
||||
boolean containsSpace = yemMerchantstnames.contains(" ");
|
||||
// 判断是否同时包含中文字符和空格
|
||||
boolean isAllChinese = containsChinese && containsSpace;
|
||||
if (isAllChinese) {
|
||||
//字符串全部由中文字符组成
|
||||
//去除客商名称空格
|
||||
merchantstnames = removeSpacesFromString(yemMerchantstnames);
|
||||
this.getModel().setValue("yem_merchantstname", merchantstnames);
|
||||
} else {
|
||||
//字符串包含非中文字符
|
||||
merchantstnames = yemMerchantstnames.trim();
|
||||
this.getModel().setValue("yem_merchantstname", merchantstnames);
|
||||
if(null!=yemMerchantstnames) {
|
||||
if("A".equals(domesticoroverseas)) {
|
||||
yemMerchantstnames = yemMerchantstnames.replace("(", "(").replace(")", ")");
|
||||
containsValidChars = yemMerchantstnames.codePoints()
|
||||
.allMatch(codePoint ->
|
||||
(codePoint >= 0x4e00 && codePoint <= 0x9fa5) || // 基本汉字
|
||||
(codePoint >= 0x3400 && codePoint <= 0x4dbf) || // 扩展A
|
||||
(codePoint >= 0xf900 && codePoint <= 0xfaff) || // 兼容汉字
|
||||
(codePoint >= 0x20000 && codePoint <= 0x2a6df) || // 扩展B
|
||||
(codePoint >= 0x2a700 && codePoint <= 0x2b73f) || // 扩展C
|
||||
(codePoint >= 0x2b740 && codePoint <= 0x2b81f) || // 扩展D
|
||||
(codePoint >= 0x2b820 && codePoint <= 0x2ceaf) || // 扩展E
|
||||
(codePoint == 0xFF08 || codePoint == 0xFF09) || // 中文括号 ()
|
||||
(codePoint == 0x0020) // 空格
|
||||
);
|
||||
|
||||
// 检查字符串中是否包含至少一个中文字符
|
||||
containsChinese = yemMerchantstnames.codePoints()
|
||||
.anyMatch(codePoint ->
|
||||
(codePoint >= 0x4e00 && codePoint <= 0x9fa5) || // 基本汉字
|
||||
(codePoint >= 0x3400 && codePoint <= 0x4dbf) || // 扩展A
|
||||
(codePoint >= 0xf900 && codePoint <= 0xfaff) || // 兼容汉字
|
||||
(codePoint >= 0x20000 && codePoint <= 0x2a6df) || // 扩展B
|
||||
(codePoint >= 0x2a700 && codePoint <= 0x2b73f) || // 扩展C
|
||||
(codePoint >= 0x2b740 && codePoint <= 0x2b81f) || // 扩展D
|
||||
(codePoint >= 0x2b820 && codePoint <= 0x2ceaf) // 扩展E
|
||||
);
|
||||
}
|
||||
boolean isValid = containsValidChars && containsChinese;
|
||||
if (isValid) {
|
||||
//字符串全部由中文字符组成
|
||||
//去除客商名称空格
|
||||
merchantstnames = removeSpacesFromString(yemMerchantstnames);
|
||||
this.getModel().setValue("yem_merchantstname", merchantstnames);
|
||||
|
||||
} else {
|
||||
//字符串包含非中文字符
|
||||
merchantstnames = yemMerchantstnames.trim();
|
||||
this.getModel().setValue("yem_merchantstname", merchantstnames);
|
||||
}
|
||||
}
|
||||
return merchantstnames;
|
||||
}
|
||||
@ -267,14 +306,14 @@ public class CustomeraccessBillPlugin extends AbstractBillPlugIn {
|
||||
// 加载行政组织信息
|
||||
List<String> adminOrgNames = loadAdminOrgNames();
|
||||
// 1.检查 客商名称 是否在行政组织列表中
|
||||
//2.检查客商名称 是否和准入组织相同
|
||||
if (!adminOrgNames.contains(yemMerchantstnames)) {
|
||||
model.setValue("yem_merchantstname","");
|
||||
model.setValue("yem_merchantstname",null);
|
||||
this.getView().showErrorNotification("未找到与之匹配的组织,请重新检查相关信息。");
|
||||
}if(!name.equals(yemMerchantstnames)){
|
||||
model.setValue("yem_merchantstname","");
|
||||
model.setValue("yem_merchantstname",null);
|
||||
this.getView().showErrorNotification("该内部业务单元客商:"+yemMerchantstnames+"与准入组织不符,请检查!");
|
||||
}
|
||||
this.getView().updateView();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -282,7 +321,7 @@ public class CustomeraccessBillPlugin extends AbstractBillPlugIn {
|
||||
* @function 查询行政组织
|
||||
* @purposes 辅助方法:加载行政组织名称列表
|
||||
*/
|
||||
private List<String> loadAdminOrgNames() {
|
||||
public static List<String> loadAdminOrgNames() {
|
||||
String adminOrgFields = "number,name"; // 查询字段:编码和名称
|
||||
DynamicObject[] adminOrgs = BusinessDataServiceHelper.load("bos_adminorg", adminOrgFields, null);
|
||||
|
||||
|
@ -33,6 +33,16 @@ import java.util.*;
|
||||
*/
|
||||
public class CreatMerchantRepositorOpPlugin extends AbstractOperationServicePlugIn {
|
||||
|
||||
/**
|
||||
* @Description: 自定义校验器
|
||||
* @function 1.【客户分类】【供应商分类】为空且【客户】【供应商】不为空
|
||||
* 2.【客户分类】为空且 客户不为空
|
||||
* 3.【供应商分类】为空且 供应商不为空
|
||||
* @purposes 重写系统validate方法在生成基础资料时增加控制
|
||||
* @param e
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
@ -166,75 +176,61 @@ public class CreatMerchantRepositorOpPlugin extends AbstractOperationServicePlug
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 更新仓库
|
||||
* @function 1.删除客商准入单不存在但是在仓库基础资料中存在的仓库
|
||||
* 2.判断客户的【仓库主数据】是否为空
|
||||
* 为空新增仓库
|
||||
* 不为空获取仓库实体更新数据
|
||||
* @param merchantApply 客商准入单
|
||||
* @param warehouse 客商准入对应的仓库集合
|
||||
* @param warehouseinfo 客商准入仓库信息分录
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private void updateWarehouse(DynamicObject merchantApply,DynamicObject[] warehouse, DynamicObjectCollection warehouseinfo) {
|
||||
deleteWarehouse(warehouse,warehouseinfo);
|
||||
List<DynamicObject> warehouseentry = new ArrayList<>();
|
||||
for (DynamicObject warehouserowid : warehouseinfo) {
|
||||
DynamicObject yemWarehouse = warehouserowid.getDynamicObject("yem_warehouse");
|
||||
if (null != yemWarehouse) {
|
||||
yemWarehouse.set("name", warehouserowid.get("yem_warehousename"));
|
||||
yemWarehouse.set("group", warehouserowid.get("yem_warehousegroup"));
|
||||
if (!YEM.isEmpty(warehouserowid.get("yem_citycounty"))) {
|
||||
yemWarehouse.set("address", warehouserowid.get("yem_citycounty"));
|
||||
} else {
|
||||
yemWarehouse.set("address", null);
|
||||
}
|
||||
yemWarehouse.set("detailaddress", warehouserowid.get("yem_address"));
|
||||
yemWarehouse.set("principal", warehouserowid.get("yem_contact"));
|
||||
yemWarehouse.set("telephone", warehouserowid.get("yem_warehousetel"));
|
||||
warehouseentry.add(yemWarehouse);
|
||||
}else {
|
||||
//新增仓库
|
||||
creatwarehouse(merchantApply,warehouseinfo);
|
||||
}
|
||||
|
||||
}
|
||||
SaveServiceHelper.save(new DynamicObject[]{merchantApply});
|
||||
SaveServiceHelper.save(warehouseentry.toArray(new DynamicObject[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 删除仓库
|
||||
* @function 功能
|
||||
* @purposes 用途
|
||||
* @param warehouse 客商准入生成仓库集合
|
||||
* @param warehouseinfo 客商准入仓库分录
|
||||
* @Description: 生成/更新供应商基础资料
|
||||
* @function 1.存在客商准入id与客商准入单相同的客户则更新不存在新增
|
||||
* @param supplier 供应商基础资料
|
||||
* @param merchantApply 客商准入单
|
||||
* @param supplierstatus 供应商状态
|
||||
* @param userId 当前登录人id
|
||||
* @param linkmanMap 联系人分录默认行信息
|
||||
* @param linkmanentryMap 联系人分录信息(以准入单行id为key)
|
||||
* @param bankCurrency 银行信息默认行币别
|
||||
* @param bankentryMap 银行分录信息(以准入单行id为key)
|
||||
* @return void
|
||||
*/
|
||||
private void deleteWarehouse(DynamicObject[] warehouse, DynamicObjectCollection warehouseinfo) {
|
||||
Map<Long,DynamicObject> warehouseMap = new HashMap<>();//仓库id集合
|
||||
List<Long> merchantWarehouserowid = new ArrayList();//客商准入仓库id集合
|
||||
for (DynamicObject depot : warehouse) {
|
||||
warehouseMap.put((Long)depot.get("id"),depot);
|
||||
|
||||
private void creatOrUpdateSupplier(DynamicObject supplier, DynamicObject merchantApply,DynamicObject supplierstatus,long userId,Map<Object, Object> linkmanMap, Map<Object,
|
||||
Map<String, Object>> linkmanentryMap,DynamicObject bankCurrency, Map<Object, Map<String, Object>> bankentryMap) {
|
||||
if(null!=supplier){
|
||||
//更新供应商
|
||||
updatesupplier(supplier,linkmanentryMap,merchantApply,bankCurrency,supplierstatus,linkmanMap,bankentryMap);
|
||||
}
|
||||
for (DynamicObject warehouserowid : warehouseinfo) {
|
||||
DynamicObject yemWarehouse = warehouserowid.getDynamicObject("yem_warehouse");
|
||||
long id = null != yemWarehouse ? yemWarehouse.getLong("id") : 0L;
|
||||
merchantWarehouserowid.add(id);
|
||||
else{
|
||||
//新建供应商
|
||||
createsupplier(userId,merchantApply,bankCurrency,supplierstatus,linkmanMap,linkmanentryMap,bankentryMap);
|
||||
}
|
||||
//warehouselist存在 bdaddressnumberList 不存在的值
|
||||
List<DynamicObject> result = new ArrayList<>();//
|
||||
for (Long number : warehouseMap.keySet()) {
|
||||
if (!merchantWarehouserowid.contains(number)) { // 检查是否不存在
|
||||
result.add(warehouseMap.get(number));
|
||||
}
|
||||
}
|
||||
OperationServiceHelper.executeOperate("delete", "bd_warehouse", result.toArray(new DynamicObject[0]), OperateOption.create());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 生成/更新客户基础资料
|
||||
* @function 1.存在客商准入id与客商准入单相同的客户则更新不存在新增
|
||||
* @param customer 客户基础资料
|
||||
* @param merchantApply 客商准入单
|
||||
* @param customerstatus 客户状态
|
||||
* @param userId 当前登录人id
|
||||
* @param linkmanMap 联系人分录默认行信息
|
||||
* @param linkmanentryMap 联系人分录信息(以准入单行id为key)
|
||||
* @param bankCurrency 银行信息默认行币别
|
||||
* @param bankentryMap 银行分录信息(以准入单行id为key)
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private void creatOrUpdateCustomer(DynamicObject customer, DynamicObject merchantApply, DynamicObject customerstatus, long userId, Map<Object, Object> linkmanMap, Map<Object,
|
||||
Map<String, Object>> linkmanentryMap, DynamicObject bankCurrency, Map<Object, Map<String, Object>> bankentryMap) {
|
||||
if (null != customer) {
|
||||
//更新客户
|
||||
updateCustomer(customer,linkmanentryMap,merchantApply,bankCurrency,customerstatus,linkmanMap,bankentryMap);
|
||||
}
|
||||
else {
|
||||
//新建客户
|
||||
createCustomer(userId,merchantApply,bankCurrency,customerstatus,linkmanMap,linkmanentryMap,bankentryMap);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @Description: 新建仓库
|
||||
* @param merchantApply 客商准入单
|
||||
@ -314,61 +310,6 @@ public class CreatMerchantRepositorOpPlugin extends AbstractOperationServicePlug
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 生成/更新供应商基础资料
|
||||
* @function 1.存在客商准入id与客商准入单相同的客户则更新不存在新增
|
||||
* @param supplier 供应商基础资料
|
||||
* @param merchantApply 客商准入单
|
||||
* @param supplierstatus 供应商状态
|
||||
* @param userId 当前登录人id
|
||||
* @param linkmanMap 联系人分录默认行信息
|
||||
* @param linkmanentryMap 联系人分录信息(以准入单行id为key)
|
||||
* @param bankCurrency 银行信息默认行币别
|
||||
* @param bankentryMap 银行分录信息(以准入单行id为key)
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private void creatOrUpdateSupplier(DynamicObject supplier, DynamicObject merchantApply,DynamicObject supplierstatus,long userId,Map<Object, Object> linkmanMap, Map<Object,
|
||||
Map<String, Object>> linkmanentryMap,DynamicObject bankCurrency, Map<Object, Map<String, Object>> bankentryMap) {
|
||||
if(null!=supplier){
|
||||
//更新供应商
|
||||
updatesupplier(supplier,linkmanentryMap,merchantApply,bankCurrency,supplierstatus,linkmanMap,bankentryMap);
|
||||
}
|
||||
else{
|
||||
//新建供应商
|
||||
createsupplier(userId,merchantApply,bankCurrency,supplierstatus,linkmanMap,linkmanentryMap,bankentryMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 生成/更新客户基础资料
|
||||
* @function 1.存在客商准入id与客商准入单相同的客户则更新不存在新增
|
||||
* @param customer 客户基础资料
|
||||
* @param merchantApply 客商准入单
|
||||
* @param customerstatus 客户状态
|
||||
* @param userId 当前登录人id
|
||||
* @param linkmanMap 联系人分录默认行信息
|
||||
* @param linkmanentryMap 联系人分录信息(以准入单行id为key)
|
||||
* @param bankCurrency 银行信息默认行币别
|
||||
* @param bankentryMap 银行分录信息(以准入单行id为key)
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private void creatOrUpdateCustomer(DynamicObject customer, DynamicObject merchantApply, DynamicObject customerstatus, long userId, Map<Object, Object> linkmanMap, Map<Object,
|
||||
Map<String, Object>> linkmanentryMap, DynamicObject bankCurrency, Map<Object, Map<String, Object>> bankentryMap) {
|
||||
if (null != customer) {
|
||||
//更新客户
|
||||
updateCustomer(customer,linkmanentryMap,merchantApply,bankCurrency,customerstatus,linkmanMap,bankentryMap);
|
||||
}
|
||||
else {
|
||||
//新建客户
|
||||
createCustomer(userId,merchantApply,bankCurrency,customerstatus,linkmanMap,linkmanentryMap,bankentryMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 新增供应商基础资料
|
||||
* @param userId 当前登录人id
|
||||
@ -413,6 +354,77 @@ public class CreatMerchantRepositorOpPlugin extends AbstractOperationServicePlug
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 更新仓库
|
||||
* @function 1.删除客商准入单不存在但是在仓库基础资料中存在的仓库
|
||||
* 2.判断客户的【仓库主数据】是否为空
|
||||
* 为空新增仓库
|
||||
* 不为空获取仓库实体更新数据
|
||||
* @param merchantApply 客商准入单
|
||||
* @param warehouse 客商准入对应的仓库集合
|
||||
* @param warehouseinfo 客商准入仓库信息分录
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private void updateWarehouse(DynamicObject merchantApply,DynamicObject[] warehouse, DynamicObjectCollection warehouseinfo) {
|
||||
deleteWarehouse(warehouse,warehouseinfo);
|
||||
List<DynamicObject> warehouseentry = new ArrayList<>();
|
||||
for (DynamicObject warehouserowid : warehouseinfo) {
|
||||
DynamicObject yemWarehouse = warehouserowid.getDynamicObject("yem_warehouse");
|
||||
if (null != yemWarehouse) {
|
||||
yemWarehouse.set("name", warehouserowid.get("yem_warehousename"));
|
||||
yemWarehouse.set("group", warehouserowid.get("yem_warehousegroup"));
|
||||
if (!YEM.isEmpty(warehouserowid.get("yem_citycounty"))) {
|
||||
yemWarehouse.set("address", warehouserowid.get("yem_citycounty"));
|
||||
} else {
|
||||
yemWarehouse.set("address", null);
|
||||
}
|
||||
yemWarehouse.set("detailaddress", warehouserowid.get("yem_address"));
|
||||
yemWarehouse.set("principal", warehouserowid.get("yem_contact"));
|
||||
yemWarehouse.set("telephone", warehouserowid.get("yem_warehousetel"));
|
||||
warehouseentry.add(yemWarehouse);
|
||||
}else {
|
||||
//新增仓库
|
||||
creatwarehouse(merchantApply,warehouseinfo);
|
||||
}
|
||||
|
||||
}
|
||||
SaveServiceHelper.save(new DynamicObject[]{merchantApply});
|
||||
SaveServiceHelper.save(warehouseentry.toArray(new DynamicObject[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 删除仓库
|
||||
* @function 功能
|
||||
* @purposes 用途
|
||||
* @param warehouse 客商准入生成仓库集合
|
||||
* @param warehouseinfo 客商准入仓库分录
|
||||
* @return void
|
||||
*/
|
||||
private void deleteWarehouse(DynamicObject[] warehouse, DynamicObjectCollection warehouseinfo) {
|
||||
Map<Long,DynamicObject> warehouseMap = new HashMap<>();//仓库id集合
|
||||
List<Long> merchantWarehouserowid = new ArrayList();//客商准入仓库id集合
|
||||
for (DynamicObject depot : warehouse) {
|
||||
warehouseMap.put((Long)depot.get("id"),depot);
|
||||
}
|
||||
for (DynamicObject warehouserowid : warehouseinfo) {
|
||||
DynamicObject yemWarehouse = warehouserowid.getDynamicObject("yem_warehouse");
|
||||
long id = null != yemWarehouse ? yemWarehouse.getLong("id") : 0L;
|
||||
merchantWarehouserowid.add(id);
|
||||
}
|
||||
//warehouselist存在 bdaddressnumberList 不存在的值
|
||||
List<DynamicObject> result = new ArrayList<>();//
|
||||
for (Long number : warehouseMap.keySet()) {
|
||||
if (!merchantWarehouserowid.contains(number)) { // 检查是否不存在
|
||||
result.add(warehouseMap.get(number));
|
||||
}
|
||||
}
|
||||
OperationServiceHelper.executeOperate("delete", "bd_warehouse", result.toArray(new DynamicObject[0]), OperateOption.create());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 新增客户基础资料
|
||||
* @param userId 当前登录人id
|
||||
|
@ -1,10 +1,15 @@
|
||||
package yem.wmzh.csm.customeraccess.opplugin.validator;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.ILocaleString;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import yem.base.common.utils.YEM;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static yem.wmzh.csm.customeraccess.from.CustomeraccessBillPlugin.loadAdminOrgNames;
|
||||
|
||||
/**
|
||||
* @Description 客商准入单提交校验
|
||||
* @Author: LiuHB
|
||||
@ -14,6 +19,8 @@ public class CustomeraccessSubmitValidator extends AbstractValidator {
|
||||
/**
|
||||
* @Description: 自定义校验器
|
||||
* @function 1.【内部业务单元】=true,且字段【境内/境外】=境内时,统一社会信用代码必填
|
||||
* 2.检查 客商名称 是否在行政组织列表中
|
||||
* 3.检查客商名称 是否和准入组织相同
|
||||
* @purposes 重写系统validate方法在提交节点增加控制
|
||||
*/
|
||||
@Override
|
||||
@ -25,8 +32,41 @@ public class CustomeraccessSubmitValidator extends AbstractValidator {
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
// 遍历每个数据实体并进行校验
|
||||
for (ExtendedDataEntity entity : dataEntities) {
|
||||
DynamicObject customerAccess = entity.getDataEntity();
|
||||
validateCustomerInternalInfo(customerAccess, entity);
|
||||
//【内部业务单元】=true,且字段【境内/境外】=境内时,统一社会信用代码必填
|
||||
validateCustomerInternalInfo(entity.getDataEntity(), entity);
|
||||
//客商名称校验
|
||||
Calibratecustomername(entity.getDataEntity(), entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void Calibratecustomername(DynamicObject dataEntity, ExtendedDataEntity entity) {
|
||||
String yemMerchantstnamed = dataEntity.getLocaleString("yem_merchantstname").getLocaleValue();
|
||||
Boolean yemInternal = (Boolean) dataEntity.getBoolean("yem_internal");//内部业务单元
|
||||
//校验必须有与客商名称匹配的组织
|
||||
matchOrganizations(yemInternal, dataEntity,yemMerchantstnamed,entity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void matchOrganizations(Boolean yemInternal, DynamicObject dataEntity,String yemMerchantstnamed, ExtendedDataEntity entity) {
|
||||
// 如果 内部业务单元 为 false 或 客商中文名称 为空,直接返回
|
||||
if (!yemInternal || YEM.isEmpty(yemMerchantstnamed)) {
|
||||
return;
|
||||
}
|
||||
//获取当前单据准入组织
|
||||
DynamicObject org = (DynamicObject)dataEntity.getDynamicObject("org");
|
||||
String name = null != org ? org.getString("name") : "";
|
||||
// 加载行政组织信息
|
||||
List<String> adminOrgNames = loadAdminOrgNames();
|
||||
// 1.检查 客商名称 是否在行政组织列表中
|
||||
//2.检查客商名称 是否和准入组织相同
|
||||
if (!adminOrgNames.contains(yemMerchantstnamed)) {
|
||||
|
||||
this.addMessage(entity,"未找到与之匹配的组织,请重新检查相关信息。");
|
||||
}if(!name.equals(yemMerchantstnamed)){
|
||||
|
||||
this.addMessage(entity,"该内部业务单元客商:"+yemMerchantstnamed+"与准入组织不符,请检查!");
|
||||
}
|
||||
}
|
||||
|
||||
|
14
yem-wmzh/yem-wmzh-ii/build.gradle
Normal file
14
yem-wmzh/yem-wmzh-ii/build.gradle
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* This is a kingdee cosmic template project that is automatically generated by the Kingdee cosmic development assistant plugin.
|
||||
* If there are any issues during the use process, you can provide feedback to the kingdee developer community website.
|
||||
* Website: https://developer.kingdee.com/developer?productLineId=29
|
||||
* Author: liebin.zheng
|
||||
* Generate Date: 2025-02-18 17:19:05
|
||||
*/
|
||||
|
||||
dependencies {
|
||||
api project(':yem-base-common')
|
||||
// api project(':yem-base-helper')
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,231 @@
|
||||
package yem.wmzh.ii.utils;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description Http连接
|
||||
* @Author: LiuHB
|
||||
* @CreateTime: 2025-02-18 17:28
|
||||
*/
|
||||
public class InterfaceCallspublicMethods {
|
||||
/**
|
||||
* @Description: 访问接口GET
|
||||
* @param url 接口地址(带请求参数)
|
||||
* @param info 入参信息
|
||||
* @param accessToken 密钥
|
||||
* @return java.lang.String 返回结果json
|
||||
*/
|
||||
|
||||
public static String sendGetRequest(String url, Map<String,Object> info,String accessToken) {
|
||||
|
||||
|
||||
// // 构建请求参数
|
||||
// StringBuilder params = new StringBuilder();
|
||||
// params.append("key=").append(URLEncoder.encode(key, "UTF-8"));
|
||||
// params.append("&address=").append(URLEncoder.encode(address, "UTF-8"));
|
||||
// if (city != null && !city.isEmpty()) {
|
||||
// params.append("&city=").append(URLEncoder.encode(city, "UTF-8"));
|
||||
// }
|
||||
// params.append("&output=json"); // 请求返回类型为JSON
|
||||
//
|
||||
// // 创建URL对象
|
||||
// URL url = new URL(API_URL + "?" + params.toString());
|
||||
|
||||
|
||||
try {
|
||||
URL urlObj = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
|
||||
|
||||
// 设置请求方法为 GET
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
connection.setRequestProperty("Authorization", "Bearer " + accessToken); // 添加 accessToken 到 Authorization 头部
|
||||
|
||||
// 获取响应状态码
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) { // 成功
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
String line;
|
||||
StringBuilder response = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
reader.close();
|
||||
return response.toString();
|
||||
} else {
|
||||
// 处理非 200 的状态码
|
||||
return "GET请求失败,响应码: " + responseCode;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 访问接口PUT
|
||||
* @param url 接口地址
|
||||
* @param parameters 请求体
|
||||
* @param accessToken 密钥
|
||||
* @return java.lang.String 返回结果json
|
||||
*/
|
||||
|
||||
public static String sendPutRequest(String url, String parameters, String accessToken) {
|
||||
try {
|
||||
URL urlObj = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
|
||||
|
||||
// 设置请求方法为 PUT
|
||||
connection.setRequestMethod("PUT");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
connection.setRequestProperty("Authorization", "Bearer " + accessToken); // 添加 accessToken 到 Authorization 头部
|
||||
connection.setDoOutput(true);
|
||||
|
||||
// 写入请求体
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.write(parameters.getBytes("UTF-8"));
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
// 读取响应
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
String line;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
return response.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 访问接口post
|
||||
* @param url 接口地址
|
||||
* @param requestBody 请求体
|
||||
* @param accessToken 密钥
|
||||
* @return java.lang.String 返回结果json
|
||||
*/
|
||||
public static String sendPostRequests(String url, String requestBody, String accessToken) throws Exception {
|
||||
URL obj = new URL(url);
|
||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Authorization", "Bearer " + accessToken); // 添加 accessToken 到 Authorization 头部
|
||||
con.setDoOutput(true);
|
||||
OutputStream os = con.getOutputStream();
|
||||
os.write(requestBody.getBytes());
|
||||
os.flush();
|
||||
os.close();
|
||||
|
||||
BufferedReader in;
|
||||
if (con.getResponseCode() >= 400) {
|
||||
in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
|
||||
} else {
|
||||
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
}
|
||||
String inputLine;
|
||||
StringBuilder response = new StringBuilder();
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
|
||||
return response.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 访问接口DELETE
|
||||
* @param url 接口地址
|
||||
* @param accessToken 密钥
|
||||
* @return java.lang.String 返回结果json * @return java.lang.String 返回结果json
|
||||
*/
|
||||
|
||||
|
||||
public static String sendDeleteRequest(String url, String accessToken) {
|
||||
try {
|
||||
URL urlObj = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
|
||||
|
||||
// 设置请求方法为 DELETE
|
||||
connection.setRequestMethod("DELETE");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
connection.setRequestProperty("Authorization", "Bearer " + accessToken); // 添加 accessToken 到 Authorization 头部
|
||||
|
||||
// 获取响应状态码
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_NO_CONTENT) { // 成功删除
|
||||
return "DELETE请求成功,响应码: " + responseCode;
|
||||
} else {
|
||||
// 处理非 204 的状态码
|
||||
return "DELETE请求失败,响应码: " + responseCode;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取accessToken
|
||||
* @param username
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public static String loginAndGetAccessToken(String username, String password) {
|
||||
try {
|
||||
String url = "http://10.64.111.165/admin-api/system/auth/login";
|
||||
String requestBody = "{\"username\": \"" + username + "\", \"password\": \"" + password + "\"}";
|
||||
|
||||
URL endpoint = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) endpoint.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setDoOutput(true);
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
byte[] input = requestBody.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream(), "utf-8"))) {
|
||||
StringBuilder response = new StringBuilder();
|
||||
String responseLine = null;
|
||||
while ((responseLine = br.readLine()) != null) {
|
||||
response.append(responseLine.trim());
|
||||
}
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject jsonResponse = (JSONObject) parser.parse(response.toString());
|
||||
JSONObject data = (JSONObject) jsonResponse.get("data");
|
||||
String accessToken = (String) data.get("accessToken");
|
||||
return accessToken;
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user