add:erp同步
This commit is contained in:
@@ -7,6 +7,7 @@ import org.nl.common.websocket.heartSocket.clientSocket.HeartClientServer;
|
|||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
@@ -25,8 +26,7 @@ import java.net.InetSocketAddress;
|
|||||||
* @author ldjun
|
* @author ldjun
|
||||||
* @date 2021/2/22 9:20:19
|
* @date 2021/2/22 9:20:19
|
||||||
*/
|
*/
|
||||||
@EnableAsync
|
@RestController
|
||||||
@RestController
|
|
||||||
@SpringBootApplication(exclude = {
|
@SpringBootApplication(exclude = {
|
||||||
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
|
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
|
||||||
})
|
})
|
||||||
@@ -42,7 +42,7 @@ public class AppRun implements CommandLineRunner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) {
|
public void run(String... args) {
|
||||||
// HeartClientServer heartServer = new HeartClientServer(new InetSocketAddress("192.168.8.218", 20889));
|
HeartClientServer heartServer = new HeartClientServer(new InetSocketAddress("192.168.8.218", 20889));
|
||||||
System.out.println("--------项目启动完成--------");
|
System.out.println("--------项目启动完成--------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package org.nl.wms.external_system.erp;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.kingdee.bos.webapi.entity.*;
|
||||||
|
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nl.common.TableDataInfo;
|
||||||
|
import org.nl.common.anno.Log;
|
||||||
|
import org.nl.common.domain.entity.PageQuery;
|
||||||
|
import org.nl.common.domain.exception.BadRequestException;
|
||||||
|
import org.nl.wms.external_system.erp.dto.ErpQuery;
|
||||||
|
import org.nl.wms.external_system.erp.dto.ErpSec;
|
||||||
|
import org.nl.wms.pm_manage.form_data.service.IPmFormDataService;
|
||||||
|
import org.nl.wms.pm_manage.form_data.service.dao.PmFormData;
|
||||||
|
import org.nl.wms.sync_manage.service.form_mapping.ISyncFormMappingService;
|
||||||
|
import org.nl.wms.sync_manage.service.form_mapping.dao.SyncFormMapping;
|
||||||
|
import org.nl.wms.sync_manage.service.form_mapping.dto.FormMappingQuery;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.expression.Expression;
|
||||||
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 表单同步配置表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author generator
|
||||||
|
* @since 2024-04-11
|
||||||
|
* 表单同步规则:从erp拉取数据
|
||||||
|
* |
|
||||||
|
* 单据结构表获取单据需要的字段<---->单据配置的映射关系获取到需要字段的值
|
||||||
|
* |
|
||||||
|
* 结构表has_child:单据明细的单据结构表字段<---->单据配置的映射关系获取到需要字段的值
|
||||||
|
* |
|
||||||
|
* 保存明细跟主单据
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class SyncErpService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ErpSec erpSec;
|
||||||
|
|
||||||
|
|
||||||
|
public List<Object> syncData(SyncFormMapping syncFormMapping){
|
||||||
|
List<Object> result = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
log.info("开始同步ERP"+ syncFormMapping.getForm_name());
|
||||||
|
IdentifyInfo identifyInfo = new IdentifyInfo();
|
||||||
|
BeanUtils.copyProperties(erpSec,identifyInfo);
|
||||||
|
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||||
|
ErpQuery query = new ErpQuery();
|
||||||
|
//todo:查询当天信息
|
||||||
|
query.setFormId(syncFormMapping.getForm_type());
|
||||||
|
List<List<Object>> lists = cloudApi.executeBillQuery(query.toString());
|
||||||
|
log.info("同步ERP结果"+lists.size());
|
||||||
|
Set<String> ids = new HashSet<>();
|
||||||
|
for (List<Object> list : lists) {
|
||||||
|
for (Object o : list) {
|
||||||
|
JSONObject json = (JSONObject) JSON.toJSON(o);
|
||||||
|
String fid = json.getString("FID");
|
||||||
|
if (StringUtils.isEmpty(fid)){
|
||||||
|
throw new RuntimeException("单据同步失败,没有找到FID");
|
||||||
|
}
|
||||||
|
ids.add(fid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OperateParam param = new OperateParam();
|
||||||
|
Map<String, String> error = new HashMap<>();
|
||||||
|
for (String id : ids) {
|
||||||
|
param.setId(id);
|
||||||
|
OperatorResult view = cloudApi.view(syncFormMapping.getForm_type(), 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(error)){
|
||||||
|
log.info("ERP单据同步同步失败:{}", error);
|
||||||
|
}
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
throw new RuntimeException("同步失败:"+ex.getMessage());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package org.nl.wms.external_system.erp.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ErpQuery {
|
||||||
|
/**
|
||||||
|
* 业务对象表单Id(必录)
|
||||||
|
*/
|
||||||
|
private String FormId;
|
||||||
|
/**
|
||||||
|
* 需查询的字段key集合,字符串类型,格式:"key1,key2,..."(必录) 注(查询单据体内码,需加单据体Key和下划线,如:FEntryKey_FEntryId)
|
||||||
|
*/
|
||||||
|
private String FieldKeys;
|
||||||
|
/**
|
||||||
|
* 过滤条件,数组类型,如:[{"Left":"(","FieldName":"Field1","Compare":"67","Value":"111","Right":")","Logic":"0"},{"Left":"(","FieldName":"Field2","Compare":"67","Value":"222","Right":")","Logic":"0"}]
|
||||||
|
*/
|
||||||
|
private String FilterString;
|
||||||
|
/**
|
||||||
|
* 排序字段,字符串类型(非必录)
|
||||||
|
*/
|
||||||
|
private String OrderString;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 返回总行数,整型(非必录)
|
||||||
|
*/
|
||||||
|
private Integer TopRowCount;
|
||||||
|
/**
|
||||||
|
* 开始行索引,整型(非必录)
|
||||||
|
*/
|
||||||
|
private Integer StartRow = 0;
|
||||||
|
/**
|
||||||
|
* 行数
|
||||||
|
*/
|
||||||
|
private Integer Limit = 20;
|
||||||
|
/**
|
||||||
|
* 表单所在的子系统内码,字符串类型(非必录)
|
||||||
|
*/
|
||||||
|
private Integer SubSystemId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.nl.wms.external_system.erp.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "kdapi")
|
||||||
|
@Data
|
||||||
|
public class ErpSec {
|
||||||
|
private String AcctID;
|
||||||
|
private String AppSec;
|
||||||
|
private String UserName;
|
||||||
|
private String pwd;
|
||||||
|
private String serverUrl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package org.nl.wms.pda_manage.iostorage;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nl.common.TableDataInfo;
|
||||||
|
import org.nl.common.anno.Log;
|
||||||
|
import org.nl.common.domain.entity.PageQuery;
|
||||||
|
import org.nl.common.domain.exception.BadRequestException;
|
||||||
|
import org.nl.common.enums.StatusEnum;
|
||||||
|
import org.nl.common.utils.SecurityUtils;
|
||||||
|
import org.nl.wms.config_manage.form_struc.service.IBmFormStrucService;
|
||||||
|
import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
|
||||||
|
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.md_manage.vehicleMater.service.IMdPbVehicleMaterService;
|
||||||
|
import org.nl.wms.md_manage.vehicleMater.service.dao.MdPbVehicleMater;
|
||||||
|
import org.nl.wms.pda_manage.iostorage.server.dto.PdaFormOutStorageDto;
|
||||||
|
import org.nl.wms.pda_manage.palletio.service.dto.LabelValueVo;
|
||||||
|
import org.nl.wms.pm_manage.form_data.service.IPmFormDataService;
|
||||||
|
import org.nl.wms.pm_manage.form_data.service.dto.FormDataQuery;
|
||||||
|
import org.nl.wms.pm_manage.form_data.service.dto.PmFormDataDto;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 手持单据出库
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author generator
|
||||||
|
* @since 2024-03-28
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api/outStorage")
|
||||||
|
public class OutStorageController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMdPbVehicleMaterService iMdPbVehicleMaterService;
|
||||||
|
@Autowired
|
||||||
|
private IActRuExecutionService iActRuExecutionService;
|
||||||
|
@Autowired
|
||||||
|
private IBmFormStrucService iBmFormStrucService;
|
||||||
|
@Autowired
|
||||||
|
private IPmFormDataService iPmFormDataService;
|
||||||
|
|
||||||
|
@GetMapping("order/{type}")
|
||||||
|
@Log("出库单据列表")
|
||||||
|
public ResponseEntity<List<LabelValueVo>> orderType(@PathVariable String type) {
|
||||||
|
List<LabelValueVo> result = new ArrayList<>();
|
||||||
|
List<BmFormStruc> list = iBmFormStrucService.list(new QueryWrapper<BmFormStruc>()
|
||||||
|
.eq("form_desc", type)
|
||||||
|
.select("form_type","form_name"));
|
||||||
|
for (BmFormStruc formStruc : list) {
|
||||||
|
result.add(new LabelValueVo(formStruc.getForm_name(), formStruc.getForm_type()));
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(result,HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("orderList")
|
||||||
|
@Log("查询数据")
|
||||||
|
public ResponseEntity<TableDataInfo<PmFormDataDto>> orderList(FormDataQuery query, PageQuery page) {
|
||||||
|
return new ResponseEntity<>(TableDataInfo.build(iPmFormDataService.queryTree(query,page)), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
@PostMapping("confirm")
|
||||||
|
@Log("查询数据")
|
||||||
|
public ResponseEntity<TableDataInfo> confirm(@RequestBody PdaFormOutStorageDto pdaFormOutStorageDto) {
|
||||||
|
return new ResponseEntity<>(TableDataInfo.build(), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package org.nl.wms.pda_manage.iostorage.server.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.nl.wms.pm_manage.form_data.service.dto.PmFormDataDto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数组参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PdaFormOutStorageDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据明细
|
||||||
|
*/
|
||||||
|
private PmFormDataDto pmFormDataDto;
|
||||||
|
/**
|
||||||
|
* 车间
|
||||||
|
*/
|
||||||
|
private String product_area;
|
||||||
|
/**
|
||||||
|
* 仓库编码
|
||||||
|
*/
|
||||||
|
private String stor_code;
|
||||||
|
/**
|
||||||
|
* 是否齐套出库
|
||||||
|
*/
|
||||||
|
private Boolean need_intact;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.nl.wms.sync_manage.controller.form_mapping;
|
package org.nl.wms.sync_manage.controller.form_mapping;
|
||||||
|
|
||||||
|
|
||||||
|
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 org.nl.common.TableDataInfo;
|
import org.nl.common.TableDataInfo;
|
||||||
@@ -8,6 +9,7 @@ import org.nl.common.anno.Log;
|
|||||||
import org.nl.common.domain.entity.PageQuery;
|
import org.nl.common.domain.entity.PageQuery;
|
||||||
import org.nl.common.domain.exception.BadRequestException;
|
import org.nl.common.domain.exception.BadRequestException;
|
||||||
import org.nl.common.utils.FileUtil;
|
import org.nl.common.utils.FileUtil;
|
||||||
|
import org.nl.wms.external_system.erp.SyncErpService;
|
||||||
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.nl.wms.pm_manage.form_data.service.dao.PmFormData;
|
||||||
import org.nl.wms.sync_manage.service.field_mapping.dto.MappingQuery;
|
import org.nl.wms.sync_manage.service.field_mapping.dto.MappingQuery;
|
||||||
@@ -51,6 +53,8 @@ public class SyncFormMappingController {
|
|||||||
private ISyncFormMappingService iSyncFormMappingService;
|
private ISyncFormMappingService iSyncFormMappingService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPmFormDataService formDataService;
|
private IPmFormDataService formDataService;
|
||||||
|
@Autowired
|
||||||
|
private SyncErpService syncErpService;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
@@ -104,6 +108,16 @@ public class SyncFormMappingController {
|
|||||||
}
|
}
|
||||||
return new ResponseEntity<>(TableDataInfo.build(pmFormDatas),HttpStatus.OK);
|
return new ResponseEntity<>(TableDataInfo.build(pmFormDatas),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
@PostMapping("/syncData")
|
||||||
|
@Log("表同步测试")
|
||||||
|
public ResponseEntity<Object> syncData(@RequestBody JSONObject form){
|
||||||
|
//参数判读,参数解析,调用参数入库
|
||||||
|
SyncFormMapping syncFormMapping = form.toJavaObject(SyncFormMapping.class);
|
||||||
|
List<Object> objects = syncErpService.syncData(syncFormMapping);
|
||||||
|
List<PmFormData> pmFormDatas = formDataService.syncAnalyse(syncFormMapping, JSON.toJSONString(objects));
|
||||||
|
formDataService.saveBatch(pmFormDatas);
|
||||||
|
return new ResponseEntity<>(TableDataInfo.build(),HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,3 +155,9 @@ schedulerFile: /Users/mima0000/Desktop/scheduler.xml
|
|||||||
lucene:
|
lucene:
|
||||||
index:
|
index:
|
||||||
path: D:\lms\lucene\index
|
path: D:\lms\lucene\index
|
||||||
|
kdapi:
|
||||||
|
AcctID: 6304ba61219bf5
|
||||||
|
AppSec: 6304ba61219bf5
|
||||||
|
UserName: 6304ba61219bf5
|
||||||
|
pwd: 6304ba61219bf5
|
||||||
|
serverUrl: http://192.168.16.249/k3cloud/
|
||||||
|
|||||||
@@ -155,3 +155,9 @@ schedulerFile: /Users/mima0000/Desktop/scheduler.xml
|
|||||||
lucene:
|
lucene:
|
||||||
index:
|
index:
|
||||||
path: D:\lms\lucene\index
|
path: D:\lms\lucene\index
|
||||||
|
kdapi:
|
||||||
|
AcctID: 6304ba61219bf5
|
||||||
|
AppSec: 6304ba61219bf5
|
||||||
|
UserName: 6304ba61219bf5
|
||||||
|
pwd: 6304ba61219bf5
|
||||||
|
serverUrl: http://192.168.16.249/k3cloud/
|
||||||
|
|||||||
Reference in New Issue
Block a user