|
|
@@ -8,6 +8,7 @@ import com.malk.jinlun.entity.BillQuery;
|
|
|
import com.malk.jinlun.service.CpClient;
|
|
|
import com.malk.jinlun.service.JinlunTaskService;
|
|
|
import com.malk.utils.UtilMap;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -16,6 +17,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
@Autowired
|
|
|
@@ -26,6 +28,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
@Override
|
|
|
public void syncMaterial() {
|
|
|
+ log.info("开始同步物料数据");
|
|
|
K3CloudApi client = new K3CloudApi(initIden());
|
|
|
|
|
|
List<Map> result = new ArrayList<>();
|
|
|
@@ -41,6 +44,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
//审核日期为昨天至今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","420","2024-10-20 00:00:00","","","0"));//审核日期年=XX
|
|
|
// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FNumber","67","35","","","0"));//物料编码等于XX
|
|
|
|
|
|
|
|
|
@@ -62,7 +66,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
startRow += limit;
|
|
|
}while (result.size() == limit);
|
|
|
|
|
|
- for (Map map : result) {
|
|
|
+ for (Map map : materialList) {
|
|
|
Map data = new HashMap();
|
|
|
data.put("ShortText1757932581400",UtilMap.getString(map,"FName"));//物料名称
|
|
|
data.put("ShortText1757932557449",UtilMap.getString(map,"FNumber"));//物料编码
|
|
|
@@ -135,10 +139,11 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
@Override
|
|
|
public void syncSaleOut() {
|
|
|
+ log.info("开始同步销售出库单数据");
|
|
|
K3CloudApi client = new K3CloudApi(initIden());
|
|
|
|
|
|
List<Map> result = new ArrayList<>();
|
|
|
- List<Map> materialList = new ArrayList<>();
|
|
|
+ List<Map> saleOutList = new ArrayList<>();
|
|
|
|
|
|
int startRow = 0;
|
|
|
int limit = 2000;
|
|
|
@@ -150,6 +155,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
//审核日期为昨天至今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","420","2025-10-20 00:00:00","","","0"));//审核日期年=XX
|
|
|
// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FNumber","67","35","","","0"));//物料编码等于XX
|
|
|
|
|
|
|
|
|
@@ -166,7 +172,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
result = (List<Map>)JSONObject.parse(s);
|
|
|
- materialList.addAll(result);
|
|
|
+ saleOutList.addAll(result);
|
|
|
|
|
|
startRow += limit;
|
|
|
}while (result.size() == limit);
|
|
|
@@ -174,34 +180,34 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
List<Map<String,Object>> dataList = new ArrayList<>();
|
|
|
|
|
|
- for (Map material : materialList) {
|
|
|
+ for (Map saleOut : saleOutList) {
|
|
|
Map data = new HashMap();
|
|
|
|
|
|
- data.put("ShortText1760153678207",UtilMap.getString(material,"FBillNo"));//单据编号
|
|
|
- data.put("ShortText1760153685839",UtilMap.getString(material,"FBillTypeID.FName"));//单据类型
|
|
|
- data.put("Date1760153694040",UtilMap.getString(material, "FDate").replace("T"," "));//日期
|
|
|
- data.put("ShortText1760153691233",UtilMap.getString(material,"FSettleCurrID.FName"));//结算币别
|
|
|
- data.put("ShortText1760153707273",UtilMap.getString(material,"FCustomerID.FName"));//客户名称
|
|
|
- data.put("ShortText1760153714871",UtilMap.getString(material,"FCustomerID.FShortName"));//客户简称
|
|
|
- data.put("ShortText1760153722192",UtilMap.getString(material,"FHeadLocationID.FName"));//交货地点
|
|
|
+ data.put("ShortText1760153678207",UtilMap.getString(saleOut,"FBillNo"));//单据编号
|
|
|
+ data.put("ShortText1760153685839",UtilMap.getString(saleOut,"FBillTypeID.FName"));//单据类型
|
|
|
+ data.put("Date1760153694040",UtilMap.getString(saleOut, "FDate").replace("T"," "));//日期
|
|
|
+ data.put("ShortText1760153691233",UtilMap.getString(saleOut,"FSettleCurrID.FName"));//结算币别
|
|
|
+ data.put("ShortText1760153707273",UtilMap.getString(saleOut,"FCustomerID.FName"));//客户名称
|
|
|
+ data.put("ShortText1760153714871",UtilMap.getString(saleOut,"FCustomerID.FShortName"));//客户简称
|
|
|
+ data.put("ShortText1760153722192",UtilMap.getString(saleOut,"FHeadLocationID.FName"));//交货地点
|
|
|
|
|
|
List<Map> entry = new ArrayList<>();
|
|
|
Map entryMap = new HashMap();
|
|
|
- entryMap.put("Number1760153738400",UtilMap.getString(material,"FMaterialID.FNumber"));//物料编码
|
|
|
- entryMap.put("ShortText1760153773163",UtilMap.getString(material,"FMaterialID.FNumber"));//物料编码
|
|
|
- entryMap.put("Text1760153778635",UtilMap.getString(material,"FMaterialID.FName"));//物料名称
|
|
|
- entryMap.put("Text1760153786986",UtilMap.getString(material,"FMaterialID.FSpecification"));//规格型号
|
|
|
- entryMap.put("Number1760153811668",UtilMap.getDouble(material,"FPriceUnitQty"));//计价数量
|
|
|
- entryMap.put("Number1760153958907",UtilMap.getDouble(material,"FRealQty"));//实发数量
|
|
|
- entryMap.put("Text1760153793403",UtilMap.getString(material,"FPriceUnitId.FName"));//计价单位
|
|
|
- entryMap.put("Text1760153804514",UtilMap.getString(material,"FBaseUnitID.FName"));//基本单位
|
|
|
- entryMap.put("Logic1760171983887",UtilMap.getBoolean(material,"FIsFree"));//是否赠品
|
|
|
- entryMap.put("Number1760153991898",UtilMap.getDouble(material,"FPrice"));//单价
|
|
|
- entryMap.put("Number1760154006703",UtilMap.getDouble(material,"FTaxPrice"));//计价单价
|
|
|
- entryMap.put("Number1760154034052",UtilMap.getDouble(material,"FAmount"));//金额
|
|
|
- entryMap.put("Number1760154039959",UtilMap.getDouble(material,"FAllAmount"));//价税合计
|
|
|
- entryMap.put("Number1760154058940",UtilMap.getDouble(material,"FDiscount"));//折扣额
|
|
|
- entryMap.put("ShortText1760154066042",UtilMap.getString(material,"FEntrynote"));//备注
|
|
|
+ entryMap.put("Number1760153738400",UtilMap.getString(saleOut,"FMaterialID.FNumber"));//物料编码
|
|
|
+ entryMap.put("ShortText1760153773163",UtilMap.getString(saleOut,"FMaterialID.FNumber"));//物料编码
|
|
|
+ entryMap.put("Text1760153778635",UtilMap.getString(saleOut,"FMaterialID.FName"));//物料名称
|
|
|
+ entryMap.put("Text1760153786986",UtilMap.getString(saleOut,"FMaterialID.FSpecification"));//规格型号
|
|
|
+ entryMap.put("Number1760153811668",UtilMap.getDouble(saleOut,"FPriceUnitQty"));//计价数量
|
|
|
+ entryMap.put("Number1760153958907",UtilMap.getDouble(saleOut,"FRealQty"));//实发数量
|
|
|
+ entryMap.put("Text1760153793403",UtilMap.getString(saleOut,"FPriceUnitId.FName"));//计价单位
|
|
|
+ entryMap.put("Text1760153804514",UtilMap.getString(saleOut,"FBaseUnitID.FName"));//基本单位
|
|
|
+ entryMap.put("Logic1760171983887",UtilMap.getBoolean(saleOut,"FIsFree"));//是否赠品
|
|
|
+ entryMap.put("Number1760153991898",UtilMap.getDouble(saleOut,"FPrice"));//单价
|
|
|
+ entryMap.put("Number1760154006703",UtilMap.getDouble(saleOut,"FTaxPrice"));//计价单价
|
|
|
+ entryMap.put("Number1760154034052",UtilMap.getDouble(saleOut,"FAmount"));//金额
|
|
|
+ entryMap.put("Number1760154039959",UtilMap.getDouble(saleOut,"FAllAmount"));//价税合计
|
|
|
+ entryMap.put("Number1760154058940",UtilMap.getDouble(saleOut,"FDiscount"));//折扣额
|
|
|
+ entryMap.put("ShortText1760154066042",UtilMap.getString(saleOut,"FEntrynote"));//备注
|
|
|
|
|
|
entry.add(entryMap);
|
|
|
|
|
|
@@ -252,6 +258,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
@Override
|
|
|
public void syncReceipt() {
|
|
|
+ log.info("开始同步收款单数据");
|
|
|
K3CloudApi client = new K3CloudApi(initIden());
|
|
|
|
|
|
List<Map> result = new ArrayList<>();
|
|
|
@@ -267,6 +274,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
//审核日期为昨天至今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","420","2025-10-20 00:00:00","","","0"));//审核日期年=XX
|
|
|
// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FNumber","67","35","","","0"));//物料编码等于XX
|
|
|
|
|
|
|
|
|
@@ -389,6 +397,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
@Override
|
|
|
public void syncReceivable() {
|
|
|
+ log.info("开始同步应收单数据");
|
|
|
K3CloudApi client = new K3CloudApi(initIden());
|
|
|
|
|
|
List<Map> result = new ArrayList<>();
|
|
|
@@ -404,9 +413,13 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
|
|
|
//审核日期为昨天至今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
|
|
|
-// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FNumber","67","35","","","0"));//物料编码等于XX
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","39","2025-10-14 00:00:00","","","0"));//审核日期大于等于XX
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","16","2025-10-16 00:00:00","","","0"));//审核日期小于等于XX
|
|
|
|
|
|
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FAPPROVEDATE","420","2025-10-21 00:00:00","","","0"));//审核日期年=XX
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FDATE","420","2025-10-21 00:00:00","","","0"));//业务日期年=XX
|
|
|
+
|
|
|
billQuery.setFilterString(filterString);
|
|
|
billQuery.setLimit(limit);
|
|
|
|
|
|
@@ -487,7 +500,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
for (Map<String, Object> map : list) {
|
|
|
String schemaCode = "YSD";
|
|
|
//查询是否存在
|
|
|
- Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1760602123650", UtilMap.getString(map, "Sheet1760602277185")), 0, 1, null);
|
|
|
+ Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1760602123650", UtilMap.getString(map, "ShortText1760602123650")), 0, 1, null);
|
|
|
|
|
|
Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
|
|
|
|
|
|
@@ -521,6 +534,129 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncSaleReturn() {
|
|
|
+ log.info("开始同步销售退货单数据");
|
|
|
+ K3CloudApi client = new K3CloudApi(initIden());
|
|
|
+
|
|
|
+ List<Map> result = new ArrayList<>();
|
|
|
+ List<Map> saleReturnList = new ArrayList<>();
|
|
|
+
|
|
|
+ int startRow = 0;
|
|
|
+ int limit = 2000;
|
|
|
+
|
|
|
+ BillQuery billQuery = new BillQuery();
|
|
|
+ billQuery.setFormId("SAL_RETURNSTOCK");
|
|
|
+ billQuery.setFieldKeys("FBillTypeID.FName,FBillNo,FDate,FRetcustId.FName,FSettleCurrId.FName,FHeadNote,FEntity_FEntryID,FMaterialId.FNumber,FMaterialId.FName,FMaterialId.FSpecification,FMaterialId.F_Sl_xingnengid,FMustqty,FRealQty,FPriceUnitId.FName,FPriceUnitQty,FPrice,FTaxPrice,FIsFree,FEntryTaxRate,FAmount,FEntryTaxAmount,FAllAmount,FReturnType.FDataValue,FStockId.FName,FDeliveryDate,FNote,FLot.FName");
|
|
|
+ List<Map> filterString = new ArrayList<>();
|
|
|
+
|
|
|
+ //审核日期为昨天至今天
|
|
|
+ filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FAPPROVEDATE","420","2025-10-21 00:00:00","","","0"));//审核日期年=XX
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FDATE","420","2025-10-21 00:00:00","","","0"));//业务日期年=XX
|
|
|
+
|
|
|
+ billQuery.setFilterString(filterString);
|
|
|
+ billQuery.setLimit(limit);
|
|
|
+
|
|
|
+ do {
|
|
|
+ billQuery.setStartRow(startRow);
|
|
|
+ String s = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ s = client.billQuery(JSONObject.toJSONString(billQuery));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ result = (List<Map>)JSONObject.parse(s);
|
|
|
+ saleReturnList.addAll(result);
|
|
|
+
|
|
|
+ startRow += limit;
|
|
|
+ }while (result.size() == limit);
|
|
|
+
|
|
|
+
|
|
|
+ List<Map<String,Object>> dataList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map receipt : saleReturnList) {
|
|
|
+ Map data = new HashMap();
|
|
|
+
|
|
|
+ data.put("ShortText1761032880442",UtilMap.getString(receipt,"FBillNo"));//单据编号
|
|
|
+ data.put("ShortText1761032890399",UtilMap.getString(receipt,"FBillTypeID.FName"));//单据类型
|
|
|
+ data.put("Date1761032895713",UtilMap.getString(receipt, "FDate").replace("T"," "));//日期
|
|
|
+ data.put("ShortText1761032899575",UtilMap.getString(receipt,"FRetcustId.FName"));//退货客户
|
|
|
+ data.put("ShortText1761032904895",UtilMap.getString(receipt,"FSettleCurrId.FName"));//结算币别
|
|
|
+ data.put("ShortText1761032937812",UtilMap.getString(receipt,"FHeadNote"));//退货备注
|
|
|
+
|
|
|
+ List<Map> entry = new ArrayList<>();
|
|
|
+ Map entryMap = new HashMap();
|
|
|
+ entryMap.put("ShortText1761033279692",UtilMap.getString(receipt,"FEntity_FEntryID"));//分录ID
|
|
|
+ entryMap.put("ShortText1761032968041",UtilMap.getString(receipt,"FMaterialId.FNumber"));//物料编码
|
|
|
+ entryMap.put("Text1761032973000",UtilMap.getString(receipt,"FMaterialId.FName"));//物料名称
|
|
|
+ entryMap.put("ShortText1761033477673",UtilMap.getString(receipt,"FMaterialId.F_Sl_xingnengid"));//性能
|
|
|
+ entryMap.put("ShortText1761032979494",UtilMap.getString(receipt,"FMaterialId.FSpecification"));//规格型号
|
|
|
+ entryMap.put("Number1761032987168",UtilMap.getDouble(receipt,"FMustqty"));//应退数量
|
|
|
+ entryMap.put("Number1761032997394",UtilMap.getDouble(receipt,"FRealQty"));//实退数量
|
|
|
+ entryMap.put("ShortText1761033008702",UtilMap.getString(receipt,"FPriceUnitId.FName"));//计价单位
|
|
|
+ entryMap.put("Number1761033960104",UtilMap.getDouble(receipt,"FPriceUnitQty"));//计价数量
|
|
|
+ entryMap.put("Number1761033026518",UtilMap.getDouble(receipt,"FTaxPrice"));//含税单价
|
|
|
+ entryMap.put("Number1761033015285",UtilMap.getDouble(receipt,"FPrice"));//单价
|
|
|
+ entryMap.put("Number1761033046672",UtilMap.getDouble(receipt,"FEntryTaxRate"));//税率
|
|
|
+ entryMap.put("Number1761033064064",UtilMap.getDouble(receipt,"FAmount"));//金额
|
|
|
+ entryMap.put("Number1761033076151",UtilMap.getDouble(receipt,"FEntryTaxAmount"));//税额
|
|
|
+ entryMap.put("Number1761033079296",UtilMap.getDouble(receipt,"FAllAmount"));//价税合计
|
|
|
+ entryMap.put("Logic1761033036005",UtilMap.getBoolean(receipt,"FIsFree"));//是否赠品
|
|
|
+ entryMap.put("ShortText1761033090318",UtilMap.getString(receipt,"FReturnType.FDataValue"));//退货类型
|
|
|
+ entryMap.put("ShortText1761033099990",UtilMap.getString(receipt,"FStockId.FName"));//仓库
|
|
|
+ entryMap.put("Date1761033104411",UtilMap.getString(receipt,"FDeliveryDate").replace("T"," "));//退货日期
|
|
|
+ entryMap.put("Text1761033119394",UtilMap.getString(receipt,"FLot.FName"));//批号
|
|
|
+ entryMap.put("ShortText1761033111040",UtilMap.getString(receipt,"FNote"));//备注
|
|
|
+
|
|
|
+ entry.add(entryMap);
|
|
|
+
|
|
|
+ data.put("Sheet1761032958852",entry);
|
|
|
+
|
|
|
+ dataList.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理同一收款单多个明细
|
|
|
+ List<Map<String, Object>> list = mergeListMap(dataList, "ShortText1761032880442", "Sheet1761032958852");
|
|
|
+
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ String schemaCode = "XSTHD";
|
|
|
+ //查询是否存在
|
|
|
+ Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1761032880442", UtilMap.getString(map, "ShortText1761032880442")), 0, 1, null);
|
|
|
+
|
|
|
+ Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
|
|
|
+
|
|
|
+ int totalElements = UtilMap.getInt(bizObjectPage, "totalElements");
|
|
|
+
|
|
|
+ List<Map> items = (List<Map>) map.get("Sheet1761032958852");
|
|
|
+ if (totalElements > 0) {
|
|
|
+ //云枢更新销售出库单
|
|
|
+ Map content = ((List<Map>) UtilMap.getList(bizObjectPage, "content")).get(0);
|
|
|
+
|
|
|
+ Map map1 = UtilMap.getMap(content, "data");
|
|
|
+ List<Map> list1 = UtilMap.getList(map1, "Sheet1761032958852");
|
|
|
+
|
|
|
+ for (int i = 0; i < items.size(); i++) {
|
|
|
+ items.get(i).put("rowStatus", "Modified");
|
|
|
+ items.get(i).put("id", (UtilMap.getString(list1.get(i),"id")));//子表实例id
|
|
|
+ }
|
|
|
+
|
|
|
+ items.forEach(item -> item.put("rowStatus", "Modified"));
|
|
|
+
|
|
|
+ String bizObjectId = UtilMap.getString(content,"bizObjectId");//主表实例id
|
|
|
+
|
|
|
+ map.put("id",bizObjectId);
|
|
|
+
|
|
|
+ Map result3 = cpClient.updateCpBo(schemaCode, map,null);
|
|
|
+ }else {
|
|
|
+ //云枢新增销售出库单
|
|
|
+ items.forEach(item -> item.put("rowStatus", "added"));
|
|
|
+ Map result3 = cpClient.createCpBo(schemaCode, map,null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private IdentifyInfo initIden(){
|
|
|
//注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
|
|
|
//注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
|