Merge remote-tracking branch 'origin/master'

# Conflicts:
#	wms_pro/hd/nladmin-system/src/main/java/org/nl/wms/dispatch_manage/task/handler/impl/PalletInStorageTask.java
This commit is contained in:
zhangzq
2024-12-06 23:10:58 +08:00
9 changed files with 239 additions and 132 deletions

View File

@@ -45,7 +45,7 @@ public class InterationUtil {
if (execute.getStatus() != 200){
throw new BadRequestException("acs申请失败"+response.getString("message"));
}
if (!response.getString("code").equals("200")){
if (!"200".equals(response.getString("code"))){
String error = "";
if (response.get("data")!=null){
JSONArray data = response.getJSONArray("data");

View File

@@ -11,7 +11,6 @@ import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -77,10 +76,20 @@ public class SpelUtil {
}
//如果表达式为null,空则返回''
private static Map<String, String> Product_Area_Mapping = MapOf.of(
"827083", "A1", "827082", "A1", "827081", "A1", "827080", "A1", "1028689", "A1", "1028688", "A1", "827077", "A1", "827076", "A1"
, "827075", "A1", "827074", "A1", "827073"
, "827078", "A2", "827079", "A2"
, "", "A3");
"827083", "A1",
"827082", "A1",
"827081", "A1",
"827080", "A1",
"1028689", "A1",
"1028688", "A1",
"827077", "A1",
"827076", "A1",
"827075", "A1",
"827074", "A1",
"827073", "A1",
"827078", "A2",
"827079", "A2"
);
/**
*
*/
@@ -97,7 +106,7 @@ public class SpelUtil {
if (field.equals("product_area")){
String product_area = Product_Area_Mapping.get(value);
if (StringUtils.isEmpty(product_area)){
throw new BadRequestException("当前业务数据product_area"+value+" 对应的车间数据");
product_area = "A1";
}
value = product_area;
}

View File

@@ -78,7 +78,7 @@ public class HeartClientServer extends AbstraceServer {
@Override
public void doConnect() {
System.out.println("-------尝试连接服务器-------");
// System.out.println("-------尝试连接服务器-------");
try {
ChannelFuture connect = ((Bootstrap) server).connect(address);
connect.addListener((ChannelFutureListener) channelFuture -> {

View File

@@ -17,8 +17,6 @@ import org.nl.wms.dispatch_manage.task.handler.AbstractTask;
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
import org.nl.wms.flow_manage.flow.service.execution.IActRuExecutionService;
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
import org.nl.wms.flow_manage.monitor.event.FlowContinueEvent;
import org.nl.wms.flow_manage.monitor.event.FlowStartEvent;
import org.nl.wms.md_manage.group_dick.service.IMdGruopDickService;
import org.nl.wms.md_manage.group_dick.service.dao.MdGruopDick;
@@ -105,17 +103,17 @@ public class PalletInStorageTask extends AbstractTask {
}else {
String groupId = vehicleMaterVo.getGroup_id();
MdGruopDick mst = iMdGruopDickService.getById(groupId);
if (mst==null){
throw new BadRequestException("申请任务失败:"+vehicle_code+"载具没有组盘信息");
if (mst == null) {
throw new BadRequestException("申请任务失败载具没有组盘信息");
}
SchBaseTask schBaseTask = iSchBaseTaskService.getOne(new QueryWrapper<SchBaseTask>()
.eq("vehicle_code", vehicle_code).select("task_code")
.lt("status",StatusEnum.FORM_STATUS.code("完成")));
if (schBaseTask!=null){
throw new BadRequestException("申请任务失败:载具"+vehicle_code+"已经存任务"+schBaseTask.getTask_code());
.lt("status", StatusEnum.FORM_STATUS.code("完成")));
if (schBaseTask != null) {
throw new BadRequestException("申请任务失败:载具" + vehicle_code + "已经存任务" + schBaseTask.getTask_code());
}
iBmVehicleInfoService.update(new UpdateWrapper<BmVehicleInfo>()
.set("h",Integer.valueOf(h))
.set("h", Integer.valueOf(h))
.set("update_time", DateUtil.now())
.set("update_name", "ACS托盘入库申请")
.eq("vehicle_code",vehicle_code));

View File

@@ -320,14 +320,14 @@ public class SyncErpService {
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
//String filterString = "FUseOrgId='750572'";
//String filterString = "FBillNo ='PPBOM240800244'";
String filterString = "FBillNo ='XSDD241200129'";
//String filterString = "FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
ErpQuery query = new ErpQuery();
//query.setFilterString(filterString);
//query.setFormId(syncFormMapping.getForm_type());
query.setFormId(syncFormMapping.getForm_type());
query.setFieldKeys("FMATERIALID");
query.setLimit(1);
query.setFieldKeys("FID");
query.setLimit(0);
String jsonString = JSON.toJSONString(query);
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
log.info("同步ERP结果" + lists.size());

View File

@@ -316,22 +316,34 @@ public class CockpitServiceImpl implements CockpitService {
r.setProduct_area(pointInfo.getProduct_area());
}
}
InteracteDto<Object> dto = InteracteDto.builder().service("wmsToAcsService")
BigDecimal theoryQty = BigDecimal.ZERO;
BigDecimal actual_weight = BigDecimal.ZERO;
try {
InteracteDto<Object> dto = InteracteDto.builder()
.service("wmsToAcsService")
.trace_id(MDC.get("trace_id"))
.type("getWeight")
.data(new JSONObject().put("device_code", code))
.data(new JSONObject().fluentPut("device_code", code))
.build();
//查询称重重量
TableDataInfo result = InterationUtil.notifyExt("/api/wmsToAcs/apply", (JSONObject) JSON.toJSON(dto));
String weight;
//tofix
if (result.getCode().equals("200")) {
Object sd = result.getData();
JSONObject data = JSONObject.parseObject(sd.toString());
if (ObjectUtil.isNotEmpty(data)) {
weight = data.getString("weight");
if ("200".equals(result.getCode())) {
Object dataObj = result.getData();
if (dataObj != null) {
JSONObject data = JSONObject.parseObject(dataObj.toString());
if (data != null && data.containsKey("weight")) {
String weightStr = data.getString("weight");
if (ObjectUtil.isNotEmpty(weightStr)) {
// 转换为 BigDecimal
actual_weight = new BigDecimal(weightStr.trim());
}
}
BigDecimal theoryQty = BigDecimal.ZERO;
}
}
} catch (Exception ex) {
log.error(ex.getMessage());
}
r.setActual_weight(actual_weight);
//根据称重信息计算理论数量
if (r.getActual_weight().compareTo(BigDecimal.ZERO) > 0) {
//计算理论重量

View File

@@ -52,6 +52,7 @@ public class PdaOutController {
@GetMapping("order")
@Log("出库单据列表")
@SaIgnore
public ResponseEntity<List<Map>> orderType() {
List<Map> result = new ArrayList<>();
List<BmFormStruc> list = iBmFormStrucService.list(new QueryWrapper<BmFormStruc>()

View File

@@ -146,9 +146,10 @@ public class PmFormDataServiceImpl extends ServiceImpl<PmFormDataMapper, PmFormD
}
return result;
} catch (Exception ex) {
ex.printStackTrace();
log.error("ERP单据解析异常" + ex.getMessage());
throw new BadRequestException(ex.getMessage());
// ex.printStackTrace();
// log.error("ERP单据解析异常" + ex.getMessage());
// throw new BadRequestException(ex.getMessage());
return null;
}
}

View File

@@ -59,9 +59,9 @@ public class SyncErpBillsScheduleService {
private static Map<String, String> BillOrg_Mapping = MapOf.of(
"PRD_PPBOM", "FPrdOrgId",
"PRD_MO", "FPrdOrgId",
"SAL_SaleOrder", "StockOrgId",
"PUR_ReceiveBill", "StockOrgId"
, "ka7c19edf9d4b4b39b8cc4a06802163b0", "F_PMSY_StockOrgId_Id");
"SAL_SaleOrder", "FStockOrgId",
"PUR_ReceiveBill", "FStockOrgId"
, "ka7c19edf9d4b4b39b8cc4a06802163b0", "F_PMSY_PrdOrgId");
public void run() {
try {
@@ -69,22 +69,176 @@ public class SyncErpBillsScheduleService {
MDC.put("requestIp", "127.0.0.1");
MDC.put("requestTime", DateUtil.now());
LuceneAppender.traceIdTL.set(BaseCode.intToChars(IdUtil.getLongId()));
List<SyncFormMapping> list = syncFormMappingServiceImpl.list(new LambdaQueryWrapper<SyncFormMapping>().in(SyncFormMapping::getForm_type, "BD_MATERIAL"));
//List<SyncFormMapping> list = syncFormMappingServiceImpl.list(new LambdaQueryWrapper<SyncFormMapping>().in(SyncFormMapping::getForm_type, "BD_MATERIAL"));
List<SyncFormMapping> list = syncFormMappingServiceImpl.list(new LambdaQueryWrapper<SyncFormMapping>().in(SyncFormMapping::getForm_type, "ka7c19edf9d4b4b39b8cc4a06802163b0", "PRD_MO", "PUR_ReceiveBill", "PRD_PPBOM"));
for (SyncFormMapping m : list) {
JSONArray mappingJson = m.getMapping_json();
String mappingString = JSON.toJSONString(mappingJson);
syncData(mappingString, m.getForm_type(), m.getDtl_split());
}
// list.forEach(this::syncData);
} finally {
LuceneAppender.traceIdTL.remove();
}
}
/**
*
*/
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 = BillOrg_Mapping.get(formType) + " ='750572' AND FDocumentStatus='C' ";
if ("ka7c19edf9d4b4b39b8cc4a06802163b0".equals(formType)) {
filterString += " AND F_PMSY_BillStatus ='A' AND F_PMSY_CreateDate >= '" + today + " 00:00:00' and F_PMSY_CreateDate <= '" + today + " 23:59:59' ";
} else {
filterString += " AND FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59' ";
}
// if ("ka7c19edf9d4b4b39b8cc4a06802163b0".equals(formType)) {
// filterString += " AND F_PMSY_StockOrgId='750572' AND F_PMSY_BillStatus ='A' AND F_PMSY_CreateDate >= '2024-11-01 00:00:00' and F_PMSY_CreateDate <= '2024-12-04 23:59:59' ";
// }else{
// filterString += " AND FCreateDate >= '2024-11-01 00:00:00' and FCreateDate <= '2024-12-04 23:59:59' ";
// }
//String filterString = "FUseOrgId='750572'";
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 {
jsonString = JSON.toJSONString(r);
JSONArray mappingJsonArray = JSONArray.parseArray(mappingJson);
List<PmFormData> formDataList = formDataService.syncAnalyse(mappingJsonArray, formType, dtlSplit, JSON.toJSONString(r));
Set<String> materials = formDataList.stream().filter(rd -> StringUtils.isBlank(rd.getCode())).map(PmFormData::getMaterial_id).collect(Collectors.toSet());
int materialCount = iMdMeMaterialbaseService.count(new QueryWrapper<MdMeMaterialbase>().in("material_id", materials));
if (materialCount != materials.size()) {
log.error("保存数据 [{}] 时出现异常: {}", JSON.toJSONString(formDataList), "物料信息不存在" + materials.toString());
}
for (String id : formDataList.stream().map(PmFormData::getId).collect(Collectors.toList())) {
if (exitFormDataList.contains(id)) {
continue 外部;
}
}
for (PmFormData formData : formDataList) {
formDataService.save(formData);
}
} catch (Exception e) {
//log.error("解析数据 [{}] 时出现异常: {}", JSON.toJSONString(r), e.getMessage());
}
}
}
} catch (Exception ex) {
log.error("同步数据时出现异常: {}", ex.getMessage());
} finally {
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
public void syncData1(String mappingJson, String formType, Boolean dtlSplit) {
boolean islock = lock.tryLock();
try {
if (islock) {
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 = "FUseOrgId='750572'";
//String filterString = BillOrg + "='750572' AND FDocumentStatus='C' AND FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
//构建查询条件
// String BillOrg = BillOrg_Mapping.get(formType);
// String filterString = BillOrg + "='750572' AND FDocumentStatus='C' ";
// if ("ka7c19edf9d4b4b39b8cc4a06802163b0".equals(formType)) {
// filterString += " AND F_PMSY_StockOrgId='750572' AND F_PMSY_BillStatus ='A' AND F_PMSY_CreateDate >= '2024-11-01 00:00:00' and F_PMSY_CreateDate <= '2024-12-04 23:59:59' ";
// }else{
// filterString += " AND FCreateDate >= '2024-11-01 00:00:00' and FCreateDate <= '2024-12-04 23:59:59' ";
// }
ErpQuery query = new ErpQuery();
query.setFilterString(filterString);
query.setFormId(formType);
query.setFieldKeys("FMATERIALID");
query.setLimit(0);
String jsonString = JSON.toJSONString(query);
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
// Set<String> exitFormDataList = pmFormDataMapper.existFormDataList();
for (List<Object> list : lists) {
for (Object r : list) {
String fid = r.toString();
if (StringUtils.isEmpty(fid)) {
log.error("单据同步失败,没有找到FID");
continue;
}
try {
OperateParam param = new OperateParam();
param.setId(fid);
OperatorResult view = cloudApi.view(formType, param);
RepoStatus status = view.getResult().getResponseStatus();
if (status.isIsSuccess()) {
List<Object> result = new ArrayList<>();
result.add(view.getResult().getResult());
getData(mappingJson, formType, dtlSplit, result);
} else {
ArrayList<RepoError> errors = status.getErrors();
String errorMsg = errors.stream().map(RepoError::getMessage).collect(Collectors.joining(","));
}
} catch (Exception e) {
log.error("处理ID [{}] 时出现异常: {}", fid, e.getMessage());
}
}
}
}
} catch (Exception ex) {
log.error("同步数据时出现异常: {}", ex.getMessage());
} finally {
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
public void syncDataTest(String mappingJson, String formType, Boolean dtlSplit) {
boolean islock = lock.tryLock();
try {
if (islock) {
@@ -159,96 +313,28 @@ public class SyncErpBillsScheduleService {
}
}
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 = "FBillNo ='PPBOM240800244'";
//String filterString = BillOrg + "='750572' AND FDocumentStatus='C' AND FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
//构建查询条件
// String BillOrg = BillOrg_Mapping.get(formType);
// String filterString = BillOrg + "='750572' AND FDocumentStatus='C' ";
// if ("ka7c19edf9d4b4b39b8cc4a06802163b0".equals(formType)) {
// filterString += " AND F_PMSY_StockOrgId='750572' AND F_PMSY_BillStatus ='A' AND F_PMSY_CreateDate >= '2024-11-01 00:00:00' and F_PMSY_CreateDate <= '2024-12-04 23:59:59' ";
// }else{
// filterString += " AND FCreateDate >= '2024-11-01 00:00:00' and FCreateDate <= '2024-12-04 23:59:59' ";
// }
//String filterString = "FUseOrgId='750572'";
ErpQuery query = new ErpQuery();
query.setFilterString(filterString);
query.setFormId(formType);
query.setFieldKeys("FMATERIALID");
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();
private void getData(String mappingJson, String formType, Boolean dtlSplit, List<Object> result) {
String jsonString;
外部:
for (Object r : result) {
try {
jsonString = JSON.toJSONString(r);
JSONArray mappingJsonArray = JSONArray.parseArray(mappingJson);
List<PmFormData> formDataList = formDataService.syncAnalyse(mappingJsonArray, formType, dtlSplit, JSON.toJSONString(r));
Set<String> materials = formDataList.stream().map(PmFormData::getMaterial_id).collect(Collectors.toSet());
int materialCount = iMdMeMaterialbaseService.count(new QueryWrapper<MdMeMaterialbase>().in("material_id", materials));
if (materialCount!=materials.size()){
log.error("保存数据 [{}] 时出现异常: {}", JSON.toJSONString(formDataList), "物料信息不存在"+materials.toString());
}
for (String id : formDataList.stream().map(PmFormData::getId).collect(Collectors.toList())) {
if (exitFormDataList.contains(id)) {
continue 外部;
}
}
for (PmFormData formData : formDataList) {
// for (String id : formDataList.stream().map(PmFormData::getId).collect(Collectors.toList())) {
// if (exitFormDataList.contains(id)) {
// continue 外部;
// }
// }
if (formDataList != null) {
List<PmFormData> formDataFilterList = formDataList.stream().filter(rs1 -> "BD_MATERIAL_1".equals(rs1.getForm_type())).collect(Collectors.toList());
for (PmFormData formData : formDataFilterList) {
formDataService.save(formData);
}
}
} catch (Exception e) {
log.error("解析数据 [{}] 时出现异常: {}", JSON.toJSONString(r), e.getMessage());
}
}
}
} catch (Exception ex) {
log.error("同步数据时出现异常: {}", ex.getMessage());
} finally {
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
}