opt:增加单据根据创建时间进行过滤
This commit is contained in:
@@ -1,36 +1,20 @@
|
|||||||
package org.nl.wms.external_system.erp;
|
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.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.kingdee.bos.webapi.entity.*;
|
import com.kingdee.bos.webapi.entity.*;
|
||||||
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
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.ErpQuery;
|
||||||
import org.nl.wms.external_system.erp.dto.ErpSec;
|
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.dao.SyncFormMapping;
|
||||||
import org.nl.wms.sync_manage.service.form_mapping.dto.FormMappingQuery;
|
|
||||||
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.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.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -57,24 +41,29 @@ public class SyncErpService {
|
|||||||
ErpSec erpSec;
|
ErpSec erpSec;
|
||||||
|
|
||||||
|
|
||||||
public List<Object> syncData(SyncFormMapping syncFormMapping){
|
public List<Object> syncData(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());
|
||||||
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 filterString = "FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
|
||||||
ErpQuery query = new ErpQuery();
|
ErpQuery query = new ErpQuery();
|
||||||
//todo:查询当天信息
|
query.setFilterString(filterString);
|
||||||
query.setFormId(syncFormMapping.getForm_type());
|
//query.setFormId(syncFormMapping.getForm_type());
|
||||||
List<List<Object>> lists = cloudApi.executeBillQuery(query.toString());
|
query.setFormId("PRD_INSTOCK");
|
||||||
log.info("同步ERP结果"+lists.size());
|
query.setFieldKeys("FID");
|
||||||
|
query.setLimit(2000);
|
||||||
|
String jsonString = JSON.toJSONString(query);
|
||||||
|
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
|
||||||
|
log.info("同步ERP结果" + lists.size());
|
||||||
Set<String> ids = new HashSet<>();
|
Set<String> ids = new HashSet<>();
|
||||||
for (List<Object> list : lists) {
|
for (List<Object> list : lists) {
|
||||||
for (Object o : list) {
|
for (Object r : list) {
|
||||||
JSONObject json = (JSONObject) JSON.toJSON(o);
|
String fid = r.toString();
|
||||||
String fid = json.getString("FID");
|
if (StringUtils.isEmpty(fid)) {
|
||||||
if (StringUtils.isEmpty(fid)){
|
|
||||||
throw new RuntimeException("单据同步失败,没有找到FID");
|
throw new RuntimeException("单据同步失败,没有找到FID");
|
||||||
}
|
}
|
||||||
ids.add(fid);
|
ids.add(fid);
|
||||||
@@ -84,14 +73,14 @@ public class SyncErpService {
|
|||||||
Map<String, String> error = new HashMap<>();
|
Map<String, String> error = new HashMap<>();
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
param.setId(id);
|
param.setId(id);
|
||||||
OperatorResult view = cloudApi.view(syncFormMapping.getForm_type(), param);
|
OperatorResult view = cloudApi.view("PRD_INSTOCK", param);
|
||||||
RepoStatus status = view.getResult().getResponseStatus();
|
RepoStatus status = view.getResult().getResponseStatus();
|
||||||
if (!status.isIsSuccess()){
|
if (status.isIsSuccess()) {
|
||||||
result.add(view.getResult().getResult());
|
result.add(view.getResult().getResult());
|
||||||
}else {
|
} else {
|
||||||
ArrayList<RepoError> errors = status.getErrors();
|
ArrayList<RepoError> errors = status.getErrors();
|
||||||
String errorMsg = errors.stream().map(RepoError::getMessage).collect(Collectors.joining(","));
|
String errorMsg = errors.stream().map(RepoError::getMessage).collect(Collectors.joining(","));
|
||||||
error.put(id,errorMsg);
|
error.put(id, errorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(error)){
|
if (!CollectionUtils.isEmpty(error)){
|
||||||
@@ -101,8 +90,10 @@ public class SyncErpService {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
throw new RuntimeException("同步失败:"+ex.getMessage());
|
throw new RuntimeException("同步失败:"+ex.getMessage());
|
||||||
}
|
}
|
||||||
|
log.info(result.toString());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@ConfigurationProperties(prefix = "kdapi")
|
@ConfigurationProperties(prefix = "kdapi")
|
||||||
@Data
|
@Data
|
||||||
public class ErpSec {
|
public class ErpSec {
|
||||||
private String AcctID;
|
private String appId;
|
||||||
private String AppSec;
|
private String appSecret;
|
||||||
private String UserName;
|
private String userName;
|
||||||
private String pwd;
|
private String pwd;
|
||||||
private String serverUrl;
|
private String serverUrl;
|
||||||
|
private String dCID;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
|
|
||||||
|
|
||||||
private void getWeekWorkStatistics(List<TaskInfo> real_qty, List<Map<String, Object>> real_qty_default, Integer days) {
|
private void getWeekWorkStatistics(List<TaskInfo> real_qty, List<Map<String, Object>> real_qty_default, Integer days) {
|
||||||
for (int i = 0; i < days; i++) {
|
for (int i = days - 1; i >= 0; i--) {
|
||||||
Map<String, Object> item = new HashMap<>();
|
Map<String, Object> item = new HashMap<>();
|
||||||
item.put("total_qty", "0");
|
item.put("total_qty", "0");
|
||||||
item.put("date", today.minusDays(i).format(formatter));
|
item.put("date", today.minusDays(i).format(formatter));
|
||||||
|
|||||||
@@ -0,0 +1,163 @@
|
|||||||
|
server:
|
||||||
|
port: 8099
|
||||||
|
max-http-header-size: 65536
|
||||||
|
#配置数据源
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
druid:
|
||||||
|
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
|
# url: jdbc:mysql://${DB_HOST:192.168.8.218}:${DB_PORT:3306}/${DB_NAME:wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||||
|
url: jdbc:mysql://${DB_HOST:192.168.18.250}:${DB_PORT:3306}/${DB_NAME:wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||||
|
username: ${DB_USER:root}
|
||||||
|
password: ${DB_PWD:123456}
|
||||||
|
# 初始连接数
|
||||||
|
initial-size: 15
|
||||||
|
# 最小连接数
|
||||||
|
min-idle: 25
|
||||||
|
# 最大连接数
|
||||||
|
max-active: 40
|
||||||
|
# 是否自动回收超时连接
|
||||||
|
remove-abandoned: true
|
||||||
|
# 超时时间(以秒数为单位)
|
||||||
|
remove-abandoned-timeout: 20
|
||||||
|
# 获取连接超时时间
|
||||||
|
max-wait: 9000
|
||||||
|
# 连接有效性检测时间
|
||||||
|
time-between-eviction-runs-millis: 60000
|
||||||
|
# 连接在池中最小生存的时间
|
||||||
|
min-evictable-idle-time-millis: 300000
|
||||||
|
# 连接在池中最大生存的时间
|
||||||
|
max-evictable-idle-time-millis: 900000
|
||||||
|
# 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
|
||||||
|
test-while-idle: true
|
||||||
|
# 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
|
||||||
|
test-on-borrow: true
|
||||||
|
# 是否在归还到池中前进行检验
|
||||||
|
test-on-return: false
|
||||||
|
# 检测连接是否有效
|
||||||
|
validation-query: select 1
|
||||||
|
# 配置监控统计
|
||||||
|
webStatFilter:
|
||||||
|
enabled: true
|
||||||
|
stat-view-servlet:
|
||||||
|
enabled: true
|
||||||
|
url-pattern: /druid/*
|
||||||
|
reset-enable: false
|
||||||
|
filters:
|
||||||
|
DruidFilter,stat
|
||||||
|
|
||||||
|
redis:
|
||||||
|
#数据库索引
|
||||||
|
database: ${REDIS_DB:1}
|
||||||
|
#host: ${REDIS_HOST:127.0.0.1}
|
||||||
|
host: ${REDIS_HOST:localhost}
|
||||||
|
port: ${REDIS_PORT:6379}
|
||||||
|
password: ${REDIS_PWD:}
|
||||||
|
#连接超时时间
|
||||||
|
timeout: 5000
|
||||||
|
redisson:
|
||||||
|
config: |
|
||||||
|
threads: 4
|
||||||
|
nettyThreads: 4
|
||||||
|
singleServerConfig:
|
||||||
|
connectionMinimumIdleSize: 8
|
||||||
|
connectionPoolSize: 8
|
||||||
|
address: redis://127.0.0.1:6379
|
||||||
|
idleConnectionTimeout: 10000
|
||||||
|
timeout: 3000
|
||||||
|
# 登录相关配置
|
||||||
|
login:
|
||||||
|
# 登录缓存
|
||||||
|
cache-enable: true
|
||||||
|
# 是否限制单用户登录
|
||||||
|
single-login: false
|
||||||
|
# 验证码
|
||||||
|
login-code:
|
||||||
|
# 验证码类型配置 查看 LoginProperties 类
|
||||||
|
code-type: arithmetic
|
||||||
|
# 登录图形验证码有效时间/分钟
|
||||||
|
expiration: 2
|
||||||
|
# 验证码高度
|
||||||
|
width: 111
|
||||||
|
# 验证码宽度
|
||||||
|
heigth: 36
|
||||||
|
# 内容长度
|
||||||
|
length: 2
|
||||||
|
# 字体名称,为空则使用默认字体
|
||||||
|
font-name:
|
||||||
|
# 字体大小
|
||||||
|
font-size: 25
|
||||||
|
|
||||||
|
#jwt
|
||||||
|
jwt:
|
||||||
|
header: Authorization
|
||||||
|
# 令牌前缀
|
||||||
|
token-start-with: Bearer
|
||||||
|
# 必须使用最少88位的Base64对该令牌进行编码
|
||||||
|
base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI=
|
||||||
|
# 令牌过期时间 此处单位/毫秒 ,默认4小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html
|
||||||
|
token-validity-in-seconds: 14400000
|
||||||
|
# 在线用户key
|
||||||
|
online-key: online-token-
|
||||||
|
# 验证码
|
||||||
|
code-key: code-key-
|
||||||
|
# token 续期检查时间范围(默认30分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
|
||||||
|
detect: 1800000
|
||||||
|
# 续期时间范围,默认1小时,单位毫秒
|
||||||
|
renew: 3600000
|
||||||
|
|
||||||
|
#是否允许生成代码,生产环境设置为false
|
||||||
|
generator:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# IP 本地解析
|
||||||
|
ip:
|
||||||
|
local-parsing: true
|
||||||
|
|
||||||
|
# 文件存储路径
|
||||||
|
file:
|
||||||
|
mac:
|
||||||
|
path: ~/file/
|
||||||
|
avatar: ~/avatar/
|
||||||
|
linux:
|
||||||
|
path: /home/eladmin/file/
|
||||||
|
avatar: /home/eladmin/avatar/
|
||||||
|
windows:
|
||||||
|
path: C:\eladmin\file\
|
||||||
|
avatar: C:\eladmin\avatar\
|
||||||
|
# 文件大小 /M
|
||||||
|
maxSize: 100
|
||||||
|
avatarMaxSize: 5
|
||||||
|
|
||||||
|
sa-token:
|
||||||
|
# token 名称 (同时也是cookie名称)
|
||||||
|
token-name: Authorization
|
||||||
|
# token 有效期,单位s 默认30天, -1代表永不过期
|
||||||
|
timeout: 2592000
|
||||||
|
# token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
|
||||||
|
activity-timeout: -1
|
||||||
|
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
|
||||||
|
is-concurrent: true
|
||||||
|
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
||||||
|
is-share: false
|
||||||
|
# token风格
|
||||||
|
token-style: random-128
|
||||||
|
# 是否输出操作日志
|
||||||
|
is-log: false
|
||||||
|
jwt-secret-key: opsjajisdnnca0sdkksdfaaasdfwwq
|
||||||
|
# token 前缀
|
||||||
|
token-prefix:
|
||||||
|
is-read-cookie: false
|
||||||
|
is-print: false
|
||||||
|
schedulerFile: /Users/mima0000/Desktop/scheduler.xml
|
||||||
|
lucene:
|
||||||
|
index:
|
||||||
|
path: D:\lms\lucene\index
|
||||||
|
kdapi:
|
||||||
|
appId: 295539_RY4pS/CH0vl8TfUo652sR+1KULwdQNOG
|
||||||
|
appSecret: 0d47d08ee5014643b91a764e121e0bcb
|
||||||
|
userName: 管理员
|
||||||
|
pwd: ty.87016362
|
||||||
|
serverUrl: http://192.168.16.249/k3cloud/
|
||||||
|
dCID: 65b078e7ea0ce6
|
||||||
Reference in New Issue
Block a user