|
|
@@ -9,13 +9,11 @@ import com.malk.jinlun.service.CpClient;
|
|
|
import com.malk.jinlun.service.JinlunTaskService;
|
|
|
import com.malk.utils.UtilMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -254,7 +252,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
Map map1 = UtilMap.getMap(content, "data");
|
|
|
List<Map> list1 = UtilMap.getList(map1, "Sheet1760153734916");
|
|
|
|
|
|
- for (int i = 0; i < items.size(); i++) {
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
items.get(i).put("rowStatus", "Modified");
|
|
|
items.get(i).put("id", (UtilMap.getString(list1.get(i),"id")));//子表实例id
|
|
|
}
|
|
|
@@ -393,7 +391,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
Map map1 = UtilMap.getMap(content, "data");
|
|
|
List<Map> list1 = UtilMap.getList(map1, "Sheet1760585205663");
|
|
|
|
|
|
- for (int i = 0; i < items.size(); i++) {
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
items.get(i).put("rowStatus", "Modified");
|
|
|
items.get(i).put("id", (UtilMap.getString(list1.get(i),"id")));//子表实例id
|
|
|
}
|
|
|
@@ -789,7 +787,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","FBillNo","67","S304-260410001","","","0"));//单据编号等于XX
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FBillNo","67","S305-251031001","","","0"));//单据编号等于XX
|
|
|
|
|
|
billQuery.setFilterString(filterString);
|
|
|
billQuery.setLimit(limit);
|
|
|
@@ -848,7 +846,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
// data.put("",UtilMap.getString(saleOut,""));//客户
|
|
|
data.put("ShortText1775637878744",UtilMap.getString(saleOut,"FCustId.FName"));//客户名称
|
|
|
data.put("Text1775637885319",UtilMap.getString(saleOut,"FCustId.FNumber"));//客户编号
|
|
|
- data.put("StaffSingle1775629353797",UtilMap.getString(saleOut, "FSalerId.FName"));//销售员
|
|
|
+ data.put("ShortText1776926946903",UtilMap.getString(saleOut, "FSalerId.FName"));//销售员
|
|
|
String fWgrComboRe5 = UtilMap.getString(saleOut, "F_WGR_Combo_re5");
|
|
|
String fWgrComboRe5Value = "";
|
|
|
switch (fWgrComboRe5){
|
|
|
@@ -859,7 +857,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
}
|
|
|
data.put("Dropdown1775629436727",fWgrComboRe5Value);//订单要求
|
|
|
data.put("Date1775629061650",UtilMap.getString(saleOut, "FDate").split("\\.")[0].replace("T"," "));//日期
|
|
|
- data.put("StaffSelector1775629377100",UtilMap.getString(saleOut, "F_Sl_gendanyuan.FName"));//跟单员
|
|
|
+ data.put("ShortText1776926951569",UtilMap.getString(saleOut, "F_Sl_gendanyuan.FName"));//跟单员
|
|
|
|
|
|
|
|
|
|
|
|
@@ -920,7 +918,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
//处理特殊字段格式
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
//成员
|
|
|
- String salerName = UtilMap.getString(stringObjectMap,"StaffSingle1775629353797");
|
|
|
+ String salerName = UtilMap.getString(stringObjectMap,"ShortText1776926946903");
|
|
|
if(cpUserMap.containsKey(salerName)){
|
|
|
Map cpUserInfo = cpUserMap.get(salerName);
|
|
|
stringObjectMap.put("StaffSingle1775629353797",cpUserInfo);//销售员
|
|
|
@@ -936,10 +934,10 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- String gendanName = UtilMap.getString(stringObjectMap, "StaffSelector1775629377100");
|
|
|
+ String gendanName = UtilMap.getString(stringObjectMap, "ShortText1776926951569");
|
|
|
if(cpUserMap.containsKey(gendanName)){
|
|
|
- Map cpUserInfo = cpUserMap.get(gendanName);
|
|
|
- stringObjectMap.put("StaffSingle1775629353797",cpUserInfo);//跟单员
|
|
|
+ Map cpUserInfo = new HashMap(cpUserMap.get(gendanName));
|
|
|
+ stringObjectMap.put("StaffSelector1775629377100",cpUserInfo);//跟单员
|
|
|
}else {
|
|
|
List<Map> cpUserInfoList = cpClient.getCpUserInfo(null, null, null, null, gendanName, 0, 1);
|
|
|
if (cpUserInfoList.size() == 1){
|
|
|
@@ -992,7 +990,7 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
List<Map> list1 = UtilMap.getList(map1, "Sheet1775629877034");
|
|
|
|
|
|
if (!list1.isEmpty()){
|
|
|
- for (int i = 0; i < items.size(); i++) {
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
items.get(i).put("rowStatus", "Modified");
|
|
|
items.get(i).put("id", (UtilMap.getString(list1.get(i),"id")));//子表实例id
|
|
|
}
|
|
|
@@ -1013,6 +1011,147 @@ public class JinlunTaskServiceImpl implements JinlunTaskService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncReceiptVerification() {
|
|
|
+ log.info("开始同步应收收款核销明细");
|
|
|
+ K3CloudApi client = new K3CloudApi(initIden());
|
|
|
+
|
|
|
+ List<Map> result = new ArrayList<>();
|
|
|
+ List<Map> list = new ArrayList<>();
|
|
|
+
|
|
|
+ int startRow = 0;
|
|
|
+ int limit = 2000;
|
|
|
+
|
|
|
+ BillQuery billQuery = new BillQuery();
|
|
|
+ billQuery.setFormId("AR_MatchRecord");
|
|
|
+ billQuery.setFieldKeys("FBILLNO,FCURWRITTENOFFAMOUNTFOR,FCURWRITTENOFFAMOUNT,FCURRENCYID.FName,FSOURCETYPE.FName,FSRCBILLNO,FVERIFYDATE,FCONTACTUNITTYPE,FCONTACTUNIT.FNumber,FCONTACTUNIT.FName,FBILLNUMBER");
|
|
|
+ List<Map> filterString = new ArrayList<>();
|
|
|
+
|
|
|
+ filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FVERIFYDATE","265",1,"","","0"));//核销日期在今天之前N天以后
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FVERIFYDATE","39","2026-01-01 00:00:00","","","0"));//核销日期>=XX
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FVERIFYDATE","16","2026-03-31 00:00:00","","","0"));//核销日期<=XX
|
|
|
+ filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FCURWRITTENOFFAMOUNTFOR","21",0,"","","0"));//本次核销金额>0
|
|
|
+
|
|
|
+ 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);
|
|
|
+ list.addAll(result);
|
|
|
+
|
|
|
+ startRow += limit;
|
|
|
+ }while (result.size() == limit);
|
|
|
+
|
|
|
+ System.out.println("1111");
|
|
|
+
|
|
|
+ for (Map map : list) {
|
|
|
+ Map body = new HashMap();
|
|
|
+ body.put("ShortText1776845631494",UtilMap.getString(map, "FBILLNO"));//核销单号
|
|
|
+ body.put("Number1776845666515",UtilMap.getDouble(map, "FCURWRITTENOFFAMOUNTFOR"));//本次核销金额
|
|
|
+ body.put("Number1776845698524",UtilMap.getDouble(map, "FCURWRITTENOFFAMOUNT"));//本次核销金额本位币
|
|
|
+ body.put("ShortText1776845718075",UtilMap.getString(map, "FCURRENCYID.FName"));//结算币别
|
|
|
+ body.put("ShortText1776845730884",UtilMap.getString(map, "FSOURCETYPE.FName"));//单据类型
|
|
|
+ String fsrcbillno = UtilMap.getString(map, "FSRCBILLNO");
|
|
|
+ body.put("ShortText1776845842726", fsrcbillno);//应收单编号
|
|
|
+ body.put("Date1776845858285",UtilMap.getString(map, "FVERIFYDATE").split("\\.")[0].replace("T"," "));//核销日期
|
|
|
+ String fcontactunittype = UtilMap.getString(map, "FCONTACTUNITTYPE");
|
|
|
+ String fcontactunittypeValue = "";
|
|
|
+ switch (fcontactunittype){
|
|
|
+ case "BD_Supplier":fcontactunittypeValue="供应商";break;
|
|
|
+ case "BD_Customer":fcontactunittypeValue="客户";break;
|
|
|
+ case "BD_Empinfo":fcontactunittypeValue="员工";break;
|
|
|
+ case "FIN_OTHERS":fcontactunittypeValue="其他往来单位";break;
|
|
|
+ default:break;
|
|
|
+ }
|
|
|
+ body.put("ShortText1776845885255",fcontactunittypeValue);//往来单位类型
|
|
|
+ body.put("ShortText1776845907662",UtilMap.getString(map, "FCONTACTUNIT.FNumber"));//往来单位编码
|
|
|
+ body.put("Text1776845928307",UtilMap.getString(map, "FCONTACTUNIT.FName"));//往来单位名称
|
|
|
+
|
|
|
+ String saleOrderNumber = UtilMap.getString(map, "FBILLNUMBER");//销售订单号
|
|
|
+
|
|
|
+ if (Strings.isBlank(saleOrderNumber)){
|
|
|
+ //查询应收单
|
|
|
+ BillQuery billQuery2 = new BillQuery();
|
|
|
+ billQuery2.setFormId("AR_receivable");
|
|
|
+ billQuery2.setFieldKeys("FBillNo,FSourceBillNo");
|
|
|
+ List<Map> filterString2 = new ArrayList<>();
|
|
|
+ filterString2.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FBillNo","17",fsrcbillno,"","","0"));//单据编号包含XX
|
|
|
+ billQuery2.setFilterString(filterString2);
|
|
|
+ billQuery2.setLimit(1);
|
|
|
+ billQuery2.setStartRow(0);
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<Map> ysdList = (List<Map>) JSONObject.parse(client.billQuery(JSONObject.toJSONString(billQuery2)));
|
|
|
+ if (!ysdList.isEmpty()){
|
|
|
+ Map ysd = ysdList.get(0);
|
|
|
+ String fSourceBillNo = UtilMap.getString(ysd, "FSourceBillNo");//销售出库单单号
|
|
|
+
|
|
|
+ if (Strings.isNotBlank(fSourceBillNo)){
|
|
|
+ //查询销售出库单
|
|
|
+ BillQuery billQuery3 = new BillQuery();
|
|
|
+ billQuery3.setFormId("SAL_OUTSTOCK");
|
|
|
+ billQuery3.setFieldKeys("FBillNo,FSrcBillNo");
|
|
|
+ List<Map> filterString3 = new ArrayList<>();
|
|
|
+ filterString3.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FBillNo","17",fSourceBillNo,"","","0"));//单据编号包含XX
|
|
|
+ billQuery3.setFilterString(filterString3);
|
|
|
+ billQuery3.setLimit(1);
|
|
|
+ billQuery3.setStartRow(0);
|
|
|
+
|
|
|
+ List<Map> ckdList = (List<Map>) JSONObject.parse(client.billQuery(JSONObject.toJSONString(billQuery3)));
|
|
|
+ if (!ckdList.isEmpty()){
|
|
|
+ Map ckd = ckdList.get(0);
|
|
|
+
|
|
|
+ saleOrderNumber = UtilMap.getString(ckd, "FSrcBillNo");//销售订单号
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ body.put("ShortText1776845949665",saleOrderNumber);
|
|
|
+
|
|
|
+ String schemaCode = "YSSKHXJL";
|
|
|
+
|
|
|
+ //查询是否存在
|
|
|
+ Map queryCondition = new HashMap();
|
|
|
+ queryCondition.put("op", "and");
|
|
|
+ queryCondition.put("items", Arrays.asList(
|
|
|
+ UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1776845631494", UtilMap.getString(body, "ShortText1776845631494")),
|
|
|
+ UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1776845842726", UtilMap.getString(body, "ShortText1776845842726"))));
|
|
|
+ Map result2 = cpClient.getCpBoList(schemaCode,queryCondition,null, 0, 1, null);
|
|
|
+
|
|
|
+ Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
|
|
|
+
|
|
|
+ int totalElements = UtilMap.getInt(bizObjectPage, "totalElements");
|
|
|
+
|
|
|
+ if (totalElements > 0) {
|
|
|
+ //更新
|
|
|
+ Map content = ((List<Map>) UtilMap.getList(bizObjectPage, "content")).get(0);
|
|
|
+
|
|
|
+ String bizObjectId = UtilMap.getString(content,"bizObjectId");//主表实例id
|
|
|
+
|
|
|
+ body.put("id",bizObjectId);
|
|
|
+
|
|
|
+ Map result3 = cpClient.updateCpBo(schemaCode, body,null);
|
|
|
+ }else {
|
|
|
+ //云枢新增销售出库单
|
|
|
+ Map result3 = cpClient.createCpBo(schemaCode, body,null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private IdentifyInfo initIden(){
|
|
|
//注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
|
|
|
//注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
|