Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -12,11 +12,11 @@ import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nl.wms.base_manage.bsrealstorattr.service.dao.StIvtBsrealstorattr;
|
||||||
import org.nl.wms.base_manage.bsrealstorattr.service.impl.StIvtBsrealstorattrServiceImpl;
|
import org.nl.wms.base_manage.bsrealstorattr.service.impl.StIvtBsrealstorattrServiceImpl;
|
||||||
import org.nl.wms.base_manage.customer.service.impl.BmCustomerServiceImpl;
|
import org.nl.wms.base_manage.customer.service.impl.BmCustomerServiceImpl;
|
||||||
import org.nl.wms.base_manage.material.service.dao.MdMeMaterialbase;
|
import org.nl.wms.base_manage.material.service.dao.MdMeMaterialbase;
|
||||||
import org.nl.wms.base_manage.material.service.impl.MdMeMaterialbaseServiceImpl;
|
import org.nl.wms.base_manage.material.service.impl.MdMeMaterialbaseServiceImpl;
|
||||||
import org.nl.wms.base_manage.measure.service.dao.BmMeasureUnit;
|
|
||||||
import org.nl.wms.base_manage.measure.service.impl.BmMeasureUnitServiceImpl;
|
import org.nl.wms.base_manage.measure.service.impl.BmMeasureUnitServiceImpl;
|
||||||
import org.nl.wms.base_manage.supplier.service.IBmSupplierService;
|
import org.nl.wms.base_manage.supplier.service.IBmSupplierService;
|
||||||
import org.nl.wms.external_system.erp.dto.ErpQuery;
|
import org.nl.wms.external_system.erp.dto.ErpQuery;
|
||||||
@@ -64,10 +64,10 @@ public class SyncErpService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BmMeasureUnitServiceImpl bmMeasureUnitServiceImpl;
|
private BmMeasureUnitServiceImpl bmMeasureUnitServiceImpl;
|
||||||
|
|
||||||
public List<Object> syncUnitData(SyncFormMapping syncFormMapping) {
|
public List<Object> syncData(SyncFormMapping syncFormMapping) {
|
||||||
List<BmMeasureUnit> list = bmMeasureUnitServiceImpl.list();
|
List<StIvtBsrealstorattr> list = stIvtBsrealstorattrServiceImpl.list();
|
||||||
list.forEach(r -> {
|
list.forEach(r -> {
|
||||||
syncUnit(r.getUnit_code());
|
syncUnit(r.getStor_code());
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -75,16 +75,16 @@ public class SyncErpService {
|
|||||||
public List<Object> syncUnit(String fNumber) {
|
public List<Object> syncUnit(String fNumber) {
|
||||||
List<Object> result = new ArrayList<>();
|
List<Object> result = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
String filterString = "FNumber = '" + fNumber + "'";
|
// String filterString = "FNumber = '" + fNumber + "'";
|
||||||
// String filterString = "FCreateOrgId ='750572' AND FNumber = '" + fNumber + "'";
|
String filterString = "FCreateOrgId ='750572' AND FNumber = '" + fNumber + "'";
|
||||||
IdentifyInfo identifyInfo = new IdentifyInfo();
|
IdentifyInfo identifyInfo = new IdentifyInfo();
|
||||||
BeanUtils.copyProperties(erpSec, identifyInfo);
|
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||||
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||||
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
ErpQuery query = new ErpQuery();
|
ErpQuery query = new ErpQuery();
|
||||||
query.setFilterString(filterString);
|
query.setFilterString(filterString);
|
||||||
query.setFormId("BD_UNIT");
|
query.setFormId("BD_STOCK");
|
||||||
query.setFieldKeys("FUNITID,FNumber");
|
query.setFieldKeys("FStockId,FNumber");
|
||||||
//query.setLimit(10);
|
//query.setLimit(10);
|
||||||
String jsonString = JSON.toJSONString(query);
|
String jsonString = JSON.toJSONString(query);
|
||||||
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
|
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
|
||||||
@@ -99,15 +99,15 @@ public class SyncErpService {
|
|||||||
ids.add(fid);
|
ids.add(fid);
|
||||||
}
|
}
|
||||||
if (ids.size() > 1) {
|
if (ids.size() > 1) {
|
||||||
List<BmMeasureUnit> sds = bmMeasureUnitServiceImpl.list(new LambdaQueryWrapper<BmMeasureUnit>().eq(BmMeasureUnit::getUnit_code, ids.get(1)));
|
List<StIvtBsrealstorattr> sds = stIvtBsrealstorattrServiceImpl.list(new LambdaQueryWrapper<StIvtBsrealstorattr>().eq(StIvtBsrealstorattr::getStor_code, ids.get(1)));
|
||||||
if (ObjectUtils.isNotEmpty(sds)) {
|
if (ObjectUtils.isNotEmpty(sds)) {
|
||||||
if (StringUtils.isNotBlank(ids.get(0)) && StringUtils.isNotBlank(ids.get(1))) {
|
if (StringUtils.isNotBlank(ids.get(0)) && StringUtils.isNotBlank(ids.get(1))) {
|
||||||
String id = ids.get(0);
|
String id = ids.get(0);
|
||||||
String code = ids.get(1);
|
String code = ids.get(1);
|
||||||
LambdaUpdateWrapper<BmMeasureUnit> data = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<StIvtBsrealstorattr> data = new LambdaUpdateWrapper<>();
|
||||||
data.eq(BmMeasureUnit::getUnit_code, code);
|
data.eq(StIvtBsrealstorattr::getStor_code, code);
|
||||||
data.set(BmMeasureUnit::getUnit_id, id);
|
data.set(StIvtBsrealstorattr::getId, id);
|
||||||
bmMeasureUnitServiceImpl.update(data);
|
stIvtBsrealstorattrServiceImpl.update(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,30 +178,38 @@ public class SyncErpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 回传测试
|
* 回传测试
|
||||||
*/
|
*/
|
||||||
public JSONObject process2(JSONObject from) {
|
|
||||||
JSONObject result = new JSONObject();
|
|
||||||
try {
|
|
||||||
//todo 需要封装
|
|
||||||
IdentifyInfo identifyInfo = new IdentifyInfo();
|
|
||||||
BeanUtils.copyProperties(erpSec, identifyInfo);
|
|
||||||
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
|
||||||
String results = cloudApi.push("PRD_INSTOCK", from.toJSONString());
|
|
||||||
result.put("results", results);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Log.error(ex.getMessage());
|
|
||||||
result.put("error", ex.getMessage());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 回传测试
|
* 回传测试
|
||||||
*/
|
*/
|
||||||
public JSONObject process(JSONObject from) {
|
public JSONObject process(JSONObject from) {
|
||||||
|
String result = "";
|
||||||
|
//执行回传
|
||||||
|
String formType = from.getString("formid");
|
||||||
|
try {
|
||||||
|
//要回传的json数据
|
||||||
|
JSONObject formData = from.getJSONObject("data");
|
||||||
|
//todo 需要封装
|
||||||
|
IdentifyInfo identifyInfo = new IdentifyInfo();
|
||||||
|
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||||
|
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||||
|
String json =formData.toJSONString();
|
||||||
|
result = cloudApi.save(formType, formData.toJSONString());
|
||||||
|
Integer sd = 0;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.error(ex.getMessage());
|
||||||
|
String sd = result;
|
||||||
|
}
|
||||||
|
return from;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回传测试
|
||||||
|
*/
|
||||||
|
public JSONObject process1(JSONObject from) {
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
//执行回传
|
//执行回传
|
||||||
String formType = from.getString("formid");
|
String formType = from.getString("formid");
|
||||||
@@ -282,7 +290,7 @@ public class SyncErpService {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Object> syncData(SyncFormMapping syncFormMapping) {
|
public List<Object> syncData1(SyncFormMapping syncFormMapping) {
|
||||||
List<Object> result = new ArrayList<>();
|
List<Object> result = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
log.info("开始同步ERP" + syncFormMapping.getForm_name());
|
log.info("开始同步ERP" + syncFormMapping.getForm_name());
|
||||||
|
|||||||
@@ -4,14 +4,17 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.github.javaparser.utils.Log;
|
import com.github.javaparser.utils.Log;
|
||||||
import com.kingdee.bos.webapi.entity.IdentifyInfo;
|
import com.kingdee.bos.webapi.entity.IdentifyInfo;
|
||||||
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.nl.common.domain.exception.BadRequestException;
|
import org.nl.common.domain.exception.BadRequestException;
|
||||||
import org.nl.wms.external_system.erp.dto.ErpSec;
|
import org.nl.wms.external_system.erp.dto.ErpSec;
|
||||||
import org.nl.wms.flow_manage.flow.framework.process.nodeType.excess.impl.process.classprocess.ClassProcess;
|
import org.nl.wms.flow_manage.flow.framework.process.nodeType.excess.impl.process.classprocess.ClassProcess;
|
||||||
import org.nl.wms.pm_manage.form_data.service.IPmFormDataService;
|
import org.nl.wms.pm_manage.form_data.service.IPmFormDataService;
|
||||||
|
import org.nl.wms.pm_manage.form_data.service.dao.PmFormData;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -20,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author ZZQ
|
* @author ZZQ
|
||||||
@@ -41,13 +45,14 @@ public class SyncReceiptProcessHandler implements ClassProcess {
|
|||||||
public JSONObject process(JSONObject from, JSONObject param) {
|
public JSONObject process(JSONObject from, JSONObject param) {
|
||||||
//执行回传单
|
//执行回传单
|
||||||
String formType = from.getString("form_type");
|
String formType = from.getString("form_type");
|
||||||
|
String id = from.getString("id");
|
||||||
|
PmFormData pmFormData = iPmFormDataService.getById(id);
|
||||||
try {
|
try {
|
||||||
String code = from.getString("code");
|
|
||||||
if (!formType.contains("RECEIPT")) {
|
if (!formType.contains("RECEIPT")) {
|
||||||
throw new BadRequestException("回传失败:单据类型不是回传类型单据");
|
throw new BadRequestException("回传失败:单据类型不是回传类型单据");
|
||||||
}
|
}
|
||||||
//要回传的json数据
|
//要回传的json数据
|
||||||
JSONObject formData = from.getJSONObject("form_data");
|
JSONObject formData = pmFormData.getForm_data();
|
||||||
String formid = formData.getString("formid");
|
String formid = formData.getString("formid");
|
||||||
if (StringUtils.isEmpty(formid)) {
|
if (StringUtils.isEmpty(formid)) {
|
||||||
throw new BadRequestException("回传失败:回传数据form_data中数据格式不是formid,data类型");
|
throw new BadRequestException("回传失败:回传数据form_data中数据格式不是formid,data类型");
|
||||||
@@ -56,10 +61,34 @@ public class SyncReceiptProcessHandler implements ClassProcess {
|
|||||||
IdentifyInfo identifyInfo = new IdentifyInfo();
|
IdentifyInfo identifyInfo = new IdentifyInfo();
|
||||||
BeanUtils.copyProperties(erpSec, identifyInfo);
|
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||||
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||||
String jsonData = formData.toJSONString();
|
String json = formData.toJSONString();
|
||||||
String result = cloudApi.save(formid, formData.toJSONString());
|
String result = cloudApi.save(formid, formData.toJSONString());
|
||||||
String ex = result;
|
JSONObject res = JSONObject.parseObject(result);
|
||||||
|
JSONObject responseStatus = res.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||||
|
boolean isSuccess = responseStatus.getBooleanValue("IsSuccess");
|
||||||
|
JSONArray errors = responseStatus.getJSONArray("Errors");
|
||||||
|
String errorMessages = "";
|
||||||
|
if (ObjectUtils.isNotEmpty(errors)) {
|
||||||
|
errorMessages = errors.stream()
|
||||||
|
.map(error -> ((JSONObject) error).getString("Message"))
|
||||||
|
.collect(Collectors.joining("; "));
|
||||||
|
}
|
||||||
|
if (isSuccess) {
|
||||||
|
LambdaUpdateWrapper<PmFormData> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(PmFormData::getId, pmFormData.getId());
|
||||||
|
updateWrapper.set(PmFormData::getRemark, "回执单创建成功");
|
||||||
|
iPmFormDataService.update(updateWrapper);
|
||||||
|
} else {
|
||||||
|
LambdaUpdateWrapper<PmFormData> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(PmFormData::getId, pmFormData.getId());
|
||||||
|
updateWrapper.set(PmFormData::getRemark, errorMessages);
|
||||||
|
iPmFormDataService.update(updateWrapper);
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
LambdaUpdateWrapper<PmFormData> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(PmFormData::getId, pmFormData.getId());
|
||||||
|
updateWrapper.set(PmFormData::getRemark, ex.getMessage());
|
||||||
|
iPmFormDataService.update(updateWrapper);
|
||||||
Log.error(ex.getMessage());
|
Log.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
return from;
|
return from;
|
||||||
|
|||||||
@@ -182,10 +182,12 @@ public class PdaIOService {
|
|||||||
if (ObjectUtils.isNotEmpty(dFormJson) && ObjectUtils.isNotEmpty(pFormJson)) {
|
if (ObjectUtils.isNotEmpty(dFormJson) && ObjectUtils.isNotEmpty(pFormJson)) {
|
||||||
result.setBillNo(receiveBillData.getPCode());
|
result.setBillNo(receiveBillData.getPCode());
|
||||||
result.setBusinessType(StringUtils.isBlank(pFormJson.getString("businessType")) ? "CG" : dFormJson.getString("businessType"));
|
result.setBusinessType(StringUtils.isBlank(pFormJson.getString("businessType")) ? "CG" : dFormJson.getString("businessType"));
|
||||||
result.setSupplierId(pFormJson.getString("SupplierId_Id"));
|
result.setPrdOrgId(pFormJson.getString("DemandOrgId"));
|
||||||
|
result.setStockOrgId(pFormJson.getString("StockOrgId"));
|
||||||
|
result.setSupplierId(pFormJson.getString("SupplierId"));
|
||||||
result.setMaterial_id(receiveBillData.getMaterial_id());
|
result.setMaterial_id(receiveBillData.getMaterial_id());
|
||||||
result.setPcsn(receiveBillData.getPCode());
|
result.setPcsn(receiveBillData.getPCode());
|
||||||
result.setPurchaserId(dFormJson.getString("PurchaserId"));
|
result.setPurchaserId(pFormJson.getString("PurchaserId"));
|
||||||
result.setUnit_id(receiveBillData.getUnit_id());
|
result.setUnit_id(receiveBillData.getUnit_id());
|
||||||
result.setQty(new BigDecimal(dFormJson.getString("ActReceiveQty")));
|
result.setQty(new BigDecimal(dFormJson.getString("ActReceiveQty")));
|
||||||
result.setTaxPrice(dFormJson.getString("taxPrice"));
|
result.setTaxPrice(dFormJson.getString("taxPrice"));
|
||||||
@@ -274,8 +276,7 @@ public class PdaIOService {
|
|||||||
result.setOwnerTypeId(StringUtils.isBlank(dataList.get(13).toString()) ? "BD_OwnerOrg" : dataList.get(13).toString());
|
result.setOwnerTypeId(StringUtils.isBlank(dataList.get(13).toString()) ? "BD_OwnerOrg" : dataList.get(13).toString());
|
||||||
result.setOwnerId_Id(dFormJson.getString("InStockOwnerId"));
|
result.setOwnerId_Id(dFormJson.getString("InStockOwnerId"));
|
||||||
result.setStockStatusId("10000");
|
result.setStockStatusId("10000");
|
||||||
// result.setStockId(dFormJson.getString("stockId"));
|
result.setStockId(dFormJson.getString("stockId"));
|
||||||
result.setStockId("04.01");
|
|
||||||
result.setKeeperId((dFormJson.getString("StockOrgId")));
|
result.setKeeperId((dFormJson.getString("StockOrgId")));
|
||||||
result.setKeeperTypeId("BD_KeeperOrg");
|
result.setKeeperTypeId("BD_KeeperOrg");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class PdaInIOService {
|
|||||||
String materialId = mst.getMaterial_id();
|
String materialId = mst.getMaterial_id();
|
||||||
String vehicleCode = mst.getVehicle_code();
|
String vehicleCode = mst.getVehicle_code();
|
||||||
String unitId = mst.getUnit_id();
|
String unitId = mst.getUnit_id();
|
||||||
Assert.noNullElements(new Object[]{mst.getStor_code(),mst.getQty(),mst.getMaterial_code(),mst.getBar_code(), materialId,mst.getQty(),mst.getSingle_weight(),mst.getOwnerId_Id(),mst.getStockId(),mst.getStockOrgId()},"入库失败:请求参数不全");
|
Assert.noNullElements(new Object[]{mst.getStor_code(),mst.getQty(),mst.getMaterial_code(),mst.getBar_code(), materialId,mst.getQty(),mst.getSingle_weight(),mst.getStockOrgId()},"入库失败:请求参数不全");
|
||||||
MaterGroupDto groupDto = new MaterGroupDto();
|
MaterGroupDto groupDto = new MaterGroupDto();
|
||||||
groupDto.setStor_code(mst.getStor_code());
|
groupDto.setStor_code(mst.getStor_code());
|
||||||
String form_type;
|
String form_type;
|
||||||
|
|||||||
@@ -146,14 +146,14 @@ public class PmFormData implements Serializable {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生产组织
|
* 对应表头:生产入库单-生产组织prdOrgId/采购入库单-采购组织FPurchaseOrgId
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String prdOrgId;
|
private String prdOrgId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入库组织
|
* 对应表头:生产入库单-入库组织FStockOrgId/采购入库单-收料组织FStockOrgId
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String stockOrgId;
|
private String stockOrgId;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class SyncErpBillsScheduleService {
|
|||||||
MDC.put("requestIp", "127.0.0.1");
|
MDC.put("requestIp", "127.0.0.1");
|
||||||
MDC.put("requestTime", DateUtil.now());
|
MDC.put("requestTime", DateUtil.now());
|
||||||
LuceneAppender.traceIdTL.set(BaseCode.intToChars(IdUtil.getLongId()));
|
LuceneAppender.traceIdTL.set(BaseCode.intToChars(IdUtil.getLongId()));
|
||||||
List<SyncFormMapping> list = syncFormMappingServiceImpl.list(new LambdaQueryWrapper<SyncFormMapping>().in(SyncFormMapping::getForm_type, "PRD_MO"));
|
List<SyncFormMapping> list = syncFormMappingServiceImpl.list(new LambdaQueryWrapper<SyncFormMapping>().in(SyncFormMapping::getForm_type, "PRD_MO","PUR_ReceiveBill","PRD_PPBOM","SP_PickMtrl"));
|
||||||
for (SyncFormMapping m : list) {
|
for (SyncFormMapping m : list) {
|
||||||
JSONArray mappingJson = m.getMapping_json();
|
JSONArray mappingJson = m.getMapping_json();
|
||||||
String mappingString = JSON.toJSONString(mappingJson);
|
String mappingString = JSON.toJSONString(mappingJson);
|
||||||
@@ -73,7 +73,7 @@ public class SyncErpBillsScheduleService {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void syncData(String mappingJson, String formType, Boolean dtlSplit) {
|
public void syncData1(String mappingJson, String formType, Boolean dtlSplit) {
|
||||||
boolean islock = lock.tryLock();
|
boolean islock = lock.tryLock();
|
||||||
try {
|
try {
|
||||||
if (islock) {
|
if (islock) {
|
||||||
@@ -82,8 +82,8 @@ public class SyncErpBillsScheduleService {
|
|||||||
BeanUtils.copyProperties(erpSec, identifyInfo);
|
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||||
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||||
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
//String filterString = "FCreateDate >= '" + "2024-11-01" + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
|
String filterString = "FDocumentStatus='C' AND FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
|
||||||
String filterString = "FCreateDate >= '2024-11-20 00:00:00' and FCreateDate <= '2024-11-23 23:59:59'";
|
//String filterString = " FDocumentStatus='C' AND FCreateDate >= '2024-11-30 00:00:00' and FCreateDate <= '2024-11-30 23:59:59'";
|
||||||
ErpQuery query = new ErpQuery();
|
ErpQuery query = new ErpQuery();
|
||||||
query.setFilterString(filterString);
|
query.setFilterString(filterString);
|
||||||
query.setFormId(formType);
|
query.setFormId(formType);
|
||||||
@@ -98,7 +98,7 @@ public class SyncErpBillsScheduleService {
|
|||||||
String fid = r.toString();
|
String fid = r.toString();
|
||||||
if (StringUtils.isEmpty(fid)) {
|
if (StringUtils.isEmpty(fid)) {
|
||||||
log.error("单据同步失败,没有找到FID");
|
log.error("单据同步失败,没有找到FID");
|
||||||
throw new RuntimeException("单据同步失败,没有找到FID");
|
continue;
|
||||||
}
|
}
|
||||||
ids.add(fid);
|
ids.add(fid);
|
||||||
}
|
}
|
||||||
@@ -120,12 +120,12 @@ public class SyncErpBillsScheduleService {
|
|||||||
if (!CollectionUtils.isEmpty(error)) {
|
if (!CollectionUtils.isEmpty(error)) {
|
||||||
log.error("ERP单据同步同步失败:{}", error);
|
log.error("ERP单据同步同步失败:{}", error);
|
||||||
}
|
}
|
||||||
//外部同步过来的需要插入数据库的数据
|
|
||||||
List<PmFormData> pmFormDataAll = new ArrayList<>();
|
List<PmFormData> pmFormDataAll = new ArrayList<>();
|
||||||
for (Object r : result) {
|
for (Object r : result) {
|
||||||
log.info(JSON.toJSONString(r));
|
//log.info(JSON.toJSONString(r));
|
||||||
JSONArray mappingJsonArray = JSONArray.parseArray(mappingJson);
|
JSONArray mappingJsonArray = JSONArray.parseArray(mappingJson);
|
||||||
List<PmFormData> formDataList = formDataService.syncAnalyse(mappingJsonArray, formType, dtlSplit, JSON.toJSONString(r));
|
List<PmFormData> formDataList = formDataService.syncAnalyse(mappingJsonArray, formType, dtlSplit, JSON.toJSONString(r));
|
||||||
|
formDataService.saveBatch(formDataList);
|
||||||
if (ObjectUtils.isNotEmpty(formDataList)) {
|
if (ObjectUtils.isNotEmpty(formDataList)) {
|
||||||
pmFormDataAll.addAll(formDataList);
|
pmFormDataAll.addAll(formDataList);
|
||||||
}
|
}
|
||||||
@@ -140,8 +140,86 @@ public class SyncErpBillsScheduleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("定时任务执行异常:" + ex.getMessage());
|
log.error("同步数据时出现异常: {}", ex.getMessage());
|
||||||
ex.printStackTrace();
|
} finally {
|
||||||
|
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void syncData(String mappingJson, String formType, Boolean dtlSplit) {
|
||||||
|
boolean islock = lock.tryLock();
|
||||||
|
try {
|
||||||
|
if (islock) {
|
||||||
|
List<Object> result = new ArrayList<>();
|
||||||
|
IdentifyInfo identifyInfo = new IdentifyInfo();
|
||||||
|
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||||
|
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||||
|
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
|
//String filterString = " FDocumentStatus='C' AND FCreateDate >= '2024-11-22 00:00:00' and FCreateDate <= '2024-11-30 23:59:59'";
|
||||||
|
String filterString = "FDocumentStatus='C' AND FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
|
||||||
|
ErpQuery query = new ErpQuery();
|
||||||
|
query.setFilterString(filterString);
|
||||||
|
query.setFormId(formType);
|
||||||
|
query.setFieldKeys("FID");
|
||||||
|
query.setLimit(0);
|
||||||
|
String jsonString = JSON.toJSONString(query);
|
||||||
|
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
|
||||||
|
Set<String> ids = new HashSet<>();
|
||||||
|
for (List<Object> list : lists) {
|
||||||
|
for (Object r : list) {
|
||||||
|
String fid = r.toString();
|
||||||
|
if (StringUtils.isEmpty(fid)) {
|
||||||
|
log.error("单据同步失败,没有找到FID");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ids.add(fid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OperateParam param = new OperateParam();
|
||||||
|
Map<String, String> error = new HashMap<>();
|
||||||
|
for (String id : ids) {
|
||||||
|
try {
|
||||||
|
param.setId(id);
|
||||||
|
OperatorResult view = cloudApi.view(formType, param);
|
||||||
|
RepoStatus status = view.getResult().getResponseStatus();
|
||||||
|
if (status.isIsSuccess()) {
|
||||||
|
result.add(view.getResult().getResult());
|
||||||
|
} else {
|
||||||
|
ArrayList<RepoError> errors = status.getErrors();
|
||||||
|
String errorMsg = errors.stream().map(RepoError::getMessage).collect(Collectors.joining(","));
|
||||||
|
error.put(id, errorMsg);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("处理ID [{}] 时出现异常: {}", id, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(error)) {
|
||||||
|
log.error("ERP单据同步失败:{}", error);
|
||||||
|
}
|
||||||
|
Set<String> exitFormDataList = pmFormDataMapper.existFormDataList();
|
||||||
|
for (Object r : result) {
|
||||||
|
try {
|
||||||
|
JSONArray mappingJsonArray = JSONArray.parseArray(mappingJson);
|
||||||
|
List<PmFormData> formDataList = formDataService.syncAnalyse(mappingJsonArray, formType, dtlSplit, JSON.toJSONString(r));
|
||||||
|
for (PmFormData formData : formDataList) {
|
||||||
|
try {
|
||||||
|
//log.error(JSON.toJSONString(r));
|
||||||
|
if (!exitFormDataList.contains(formData.getId())) {
|
||||||
|
formDataService.save(formData);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("保存数据 [{}] 时出现异常: {}", JSON.toJSONString(formData), e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("解析数据 [{}] 时出现异常: {}", JSON.toJSONString(r), e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("同步数据时出现异常: {}", ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -150,5 +228,4 @@ public class SyncErpBillsScheduleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user