Files
WorkNote/SanPinPLM/接口配置/金蝶云星空企业版.md

140 lines
5.9 KiB
Markdown
Raw Normal View History

2025-04-25 09:53:56 +08:00
# 金蝶云星空·企业版字段映射配置
## 1、字段映射
### 1.1、基础信息
| 名称 | 说明 | 示例 |
| ---------- | ------------------------------ | ------------------------------------------------------------- |
| 同步顺序 | 按此设置的顺序进行同步,不能有重复的顺序 | |
| from语句 | pdmitem是物料表、cfobjkind是对象分类表 | pdmitem a left JOIN cfobjkind b on a.itemkindid = b.objkindid |
| where条件 | | viewid = 1 and a.stat = 4 and a.itemid > 0 |
| order by排序 | | itemcode |
| erp接口 | BD_MATERIAL物料接口ENG_BOMbom接口 | |
### 1.2、字段映射
#### 1.2.1、接口位置
[金蝶云星空企业版API文档](https://openapi.open.kingdee.com/ApiDoc)
![image-20250407154239474](assets/image-20250407154239474.png)
![image-20250407154447450](assets/image-20250407154447450.png)
#### 1.2.2、新增字段映射
![image-20250407155223180](assets/image-20250407155223180.png)
| 名称 | 说明 | 示例 |
| -------- | ------------------------------------------------------------ | -------------------------- |
| 父字段 | 填写Model下的类型为Object且子字段不为FNumber的字段如果不是则不用填 | 物料接口中的FSubHeadEntity |
| erp字段 | 字段名称 | FNumber |
| 扩展字段 | ![image-20250407155738744](assets/image-20250407155738744.png)有些字段展开后有FNumber等字段的需要填写 | |
| 字段类型 | 对应接口文档中的类型,注意:如果有扩展字段则填扩展字段的字段类型 | |
| 处理方式 | | |
| 赋值 | 赋PLM字段值时建议加上别名以防字段重名 | a.itemcode |
| 仅新增 | 只在新增时添加字段数据,修改时不进行修改 | |
1.2.3、发布
![image-20250407160315724](assets/image-20250407160315724.png)
在左侧输入框内查询条件,然后点测试发布,会在右侧中显示同步结果
## 2、日志
### 2.1、同步日志
用于查看同步日志,默认查看当天的日志
![image-20250407160541605](assets/image-20250407160541605.png)
### 2.2、操作日志
记录字段映射的操作日志
![image-20250407160643916](assets/image-20250407160643916.png)
## 3、注意事项
### 3.1、版本规则
将字母改成数字
![微信图片_20250407172907_32](assets/微信图片_20250407172907_32.png)
## 4、按钮脚本
#### 4.1、物料同步按钮
```
uses MyClass,Variables,BaseUtil,CommonFunc,DataConst,CFFrm,CFSimplePropFrm,Forms,StdCtrls,Variants,SysUtils,Classes,Controls,Dialogs,
CHostIntf,ProductClas,DocClas,LoginClas,VirtualTrees,CEntClas,PathClas,JsonHttpClient,JSON;
var
jsonObject: TJSONObject; //请求对象
request: string; //请求对象转成的json字符串
response : String;//返回json字符串
begin
if Application.MessageBox( '确定同步吗', '同步确认', 1) = 1 then begin
btncxtsCusPage_1.Enabled := False; //禁用按钮,防止重复点
try
jsonObject := TJSONObject.Create;
jsonObject.AddPair('sql', 'a.viewid = 1 and a.itemcode = ''' + fedtItemCode.Text + '''');
jsonObject.AddPair('syncId', '1904456130482036739');
request := jsonObject.ToString; //举例中转字符串后为:{“itemid”:”11111”}
response := TJsonHttpClient.post7TS1('http://192.168.254.20:8005/erp/sync/manual',request,'application/json',''); //发起请求读取返回值
finally
jsonObject.Free;
btncxtsCusPage_1.Enabled := True; //不管是否失败,释放资源,启用按钮
end;
//showmessage(inttostr(length(response)));
if(length(response) = 0) then exit;
//response := StringReplace(response,'\n',#10,[rfReplaceAll]);
//response := StringReplace(response,'\t',#9,[rfReplaceAll]);
showmessage(response);
end;
end.
```
#### 4.2、BOM同步按钮
```
uses MyClass,Variables,BaseUtil,CommonFunc,DataConst,CFFrm,CFSimplePropFrm,Forms,StdCtrls,Variants,SysUtils,Classes,Controls,Dialogs,
CHostIntf,ProductClas,DocClas,LoginClas,VirtualTrees,CEntClas,PathClas,JsonHttpClient,JSON;
var
jsonObject: TJSONObject; //请求对象
request: string; //请求对象转成的json字符串
response : String;//返回json字符串
begin
if Application.MessageBox( '确定同步吗', '同步确认', 1) = 1 then begin
btncxtsCusPage_2.Enabled := False; //禁用按钮,防止重复点
try
jsonObject := TJSONObject.Create;
jsonObject.AddPair('sql', 'a.viewid = 1 and a.itemcode = ''' + fedtItemCode.Text + '''');
jsonObject.AddPair('syncId', '1904456130482036737');
request := jsonObject.ToString; //举例中转字符串后为:{“itemid”:”11111”}
response := TJsonHttpClient.post7TS1('http://192.168.254.20:8005/erp/sync/manual',request,'application/json',''); //发起请求读取返回值
finally
jsonObject.Free;
btncxtsCusPage_2.Enabled := True; //不管是否失败,释放资源,启用按钮
end;
//showmessage(inttostr(length(response)));
if(length(response) = 0) then exit;
//response := StringReplace(response,'\n',#10,[rfReplaceAll]);
//response := StringReplace(response,'\t',#9,[rfReplaceAll]);
showmessage(response);
end;
end.
```
需修改脚本ip并开放端口