Merge remote-tracking branch 'origin/dev' into dev

pro
郑明梁 2 years ago
commit de32494a78

@ -1,5 +1,6 @@
package com.glxp.api.controller.thrsys;
import cn.hutool.core.thread.ThreadUtil;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.enums.ResultEnum;
@ -23,6 +24,7 @@ import com.glxp.api.service.thrsys.ThrCorpsDlService;
import com.glxp.api.service.thrsys.ThrSystemDetailService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
@ -32,6 +34,7 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@RestController
public class ThrCorpsController {
@Resource
@ -146,33 +149,19 @@ public class ThrCorpsController {
@AuthRuleAnnotation("")
@PostMapping("/udiwms/thrsys/corp/corpsDlAll")
public BaseResponse corpsDlAll(@RequestBody ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest) {
thrUnitMaintainFilterRequest.setThirdSysFk(thrUnitMaintainFilterRequest.getThirdSys());
String data = (String) redisUtil.get(Constant.dlThrProducts);
if (data != null && data.equals("true")) {
return ResultVOUtils.error(500, "当前任务正在下载更新产品信息,请稍后重试!");
} else {
redisUtil.set(Constant.dlThrCorps, "true", 30);
if (thrUnitMaintainFilterRequest.getThirdSysFk() == null) {
return ResultVOUtils.error(500, "未选择第三方系统!");
if (null == thrUnitMaintainFilterRequest) {
return ResultVOUtils.error(500, "参数不能为空");
}
ThrCorpImportLogEntity thrCorpImportLogEntity = new ThrCorpImportLogEntity();
String genKey = CustomUtil.getId();
thrCorpImportLogEntity.setGenKey(genKey);
thrCorpImportLogEntity.setFromType("第三方系统获取");
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
thrCorpImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogEntity.setThirdSysFk(thrUnitMaintainFilterRequest.getThirdSysFk());
thrCorpImportLogService.insertImportLog(thrCorpImportLogEntity);
if (thrUnitMaintainFilterRequest.getThrCorpEntities() != null && thrUnitMaintainFilterRequest.getThrCorpEntities().size() > 0) {//选中导出
thrCorpsDlService.importSelectCorps(genKey, thrUnitMaintainFilterRequest.getThrCorpEntities(), thrUnitMaintainFilterRequest.getThirdSysFk());
} else { //结果导出
thrCorpsDlService.importCorps(genKey,thrUnitMaintainFilterRequest, thrUnitMaintainFilterRequest.getThirdSysFk());
ThreadUtil.execAsync(() -> {
try {
thrCorpService.downloadByRequest(thrUnitMaintainFilterRequest);
} catch (Exception e) {
log.error("下载异常", e);
e.printStackTrace();
}
// thrCorpsDlService.importCorps(genKey, filterThrCorpRequest.getThirdSysFk());
return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看");
}
});
return ResultVOUtils.success("后台正在下载,请稍后刷新查看!");
}
//查询ERP往来单位

@ -1,6 +1,8 @@
package com.glxp.api.controller.thrsys;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.IdUtil;
@ -16,17 +18,20 @@ import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
import com.glxp.api.req.thrsys.PostThrProductsRequest;
import com.glxp.api.req.thrsys.ThrOnhandRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.thrsys.ThrProductsService;
import com.glxp.api.service.thrsys.ThrSystemDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
import java.util.List;
@ -38,6 +43,7 @@ import java.util.List;
* @author ${author}
* @since 2023-01-10
*/
@Slf4j
@RestController
public class ThrProductsController {
@ -71,35 +77,9 @@ public class ThrProductsController {
if (thrSystemDetailEntity.getEnabled()) {
if (thrSystemDetailEntity.getFromType() == 0 || (filterThrProductsRequest.getIsDownThrSys() != null && filterThrProductsRequest.getIsDownThrSys())) {
BaseResponse<PageSimpleResponse<ThrProductsResponse>> udiDlDeviceResponse = erpBasicClient.getErpProducts(filterThrProductsRequest);
if (udiDlDeviceResponse.getCode() == 20000) {
List<ThrProductsResponse> invmandocResponses = udiDlDeviceResponse.getData().getList();
//todo 耗材字典未确认数据库
// if (invmandocResponses != null) {
// for (ThrProductsResponse invmandocResponse : invmandocResponses) {
// UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(invmandocResponse.getCode(), filterErpGoodsRequest.getThirdSys());
// invmandocResponse.setThirdSys(thrProductsRequest.getThirdSys());
// if (udiRelevanceEntity != null) {
// invmandocResponse.setChecked(true);
// } else {
// invmandocResponse.setChecked(false);
// }
// }
// }
}
return udiDlDeviceResponse;
} else {
List<ThrProductsResponse> thrCorpEntities = thrProductsService.filterJoinThrProducts(filterThrProductsRequest);
//todo 耗材字典未确认数据库
// for (ThrProductsEntity thrProductsEntity : thrCorpEntities) {
// UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(thrProductsEntity.getCode(), thrProductsEntity.getThirdSysFk());
// if (udiRelevanceEntity != null) {
// thrProductsEntity.setChecked(true);
// } else {
// thrProductsEntity.setChecked(false);
// }
// }
PageInfo<ThrProductsResponse> pageInfo;
pageInfo = new PageInfo<>(thrCorpEntities);
PageSimpleResponse<ThrProductsResponse> pageSimpleResponse = new PageSimpleResponse<>();
@ -215,7 +195,11 @@ public class ThrProductsController {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "每次只能上传一个文件!");
}
ThreadUtil.execAsync(() -> {
thrProductsService.uploadPi(files, thirdSys);
try {
thrProductsService.uploadPi(files.get(0).getBytes(), files.get(0).getName(), thirdSys);
} catch (IOException e) {
e.printStackTrace();
}
});
return ResultVOUtils.success("正在导入中,稍后请刷新页面查看");
}
@ -237,4 +221,29 @@ public class ThrProductsController {
return ResultVOUtils.success();
}
/**
*
*
* @param filterThrProductsRequest
* @return
*/
@PostMapping("/udiwms/thrsys/products/productsDlAll")
public BaseResponse productsDlAll(@RequestBody FilterThrProductsRequest filterThrProductsRequest) {
if (null == filterThrProductsRequest) {
return ResultVOUtils.error(500, "参数不能为空");
}
ThreadUtil.execAsync(() -> {
try {
thrProductsService.downloadByRequest(filterThrProductsRequest);
} catch (Exception e) {
log.error("下载异常", e);
e.printStackTrace();
}
});
return ResultVOUtils.success("后台正在下载,请稍后刷新查看!");
}
}

@ -18,10 +18,7 @@ import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
/**
* Mapper ,
@ -242,8 +239,39 @@ public interface BaseMapperPlus<M, T, V> extends BaseMapper<T> {
* @param entityList
* @return
*/
default boolean insertIgnoreBatchs(List<T> entityList) {
return insertIgnoreBatchs(entityList, DEFAULT_BATCH_SIZE);
}
default boolean insertIgnoreBatchs(List<T> entityList, int batchSize) {
try {
int size = entityList.size();
int idxLimit = Math.min(DEFAULT_BATCH_SIZE, size);
int i = 1;
//保存单批提交的数据集合
List<T> oneBatchList = new ArrayList<>();
for (Iterator<T> var7 = entityList.iterator(); var7.hasNext(); ++i) {
T element = var7.next();
oneBatchList.add(element);
if (i == idxLimit) {
this.insertIgnoreBatch(oneBatchList);
//每次提交后需要清空集合数据
oneBatchList.clear();
idxLimit = Math.min(idxLimit + batchSize, size);
}
}
} catch (Exception e) {
log.error("insertIgnoreBatch fail", e);
return false;
}
return true;
}
int insertIgnoreBatch(List<T> entityList);
/**
*
* replace intoPrimaryKeyuniqueinsert into
@ -262,5 +290,36 @@ public interface BaseMapperPlus<M, T, V> extends BaseMapper<T> {
* @param entityList
* @return
*/
default boolean replaceBatchs(List<T> entityList) {
return this.replaceBatchs(entityList, DEFAULT_BATCH_SIZE);
}
default boolean replaceBatchs(List<T> entityList, int batchSize) {
try {
int size = entityList.size();
int idxLimit = Math.min(DEFAULT_BATCH_SIZE, size);
int i = 1;
//保存单批提交的数据集合
List<T> oneBatchList = new ArrayList<>();
for (Iterator<T> var7 = entityList.iterator(); var7.hasNext(); ++i) {
T element = var7.next();
oneBatchList.add(element);
if (i == idxLimit) {
this.replaceBatch(oneBatchList);
//每次提交后需要清空集合数据
oneBatchList.clear();
idxLimit = Math.min(idxLimit + batchSize, size);
}
}
} catch (Exception e) {
log.error("insertIgnoreBatch fail", e);
return false;
}
return true;
}
int replaceBatch(List<T> entityList);
}

@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.util.List;
/**
@ -43,8 +44,7 @@ public class ErpBasicClient {
UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest();
BeanUtils.copyProperties(thrUnitMaintainFilterRequest, udiwmsUnitRequest);
udiwmsUnitRequest.setUnitId(thrUnitMaintainFilterRequest.getErpId());
ThrSystemEntity thrSystemEntity = basicThirdSysService.selectByThirdId(thrUnitMaintainFilterRequest.getThirdSys());
ThrSystemEntity thrSystemEntity = basicThirdSysService.selectByThirdId(thrUnitMaintainFilterRequest.getThirdSysFk());
try {
String url = thrSystemEntity.getThridUrl() + "/udiwms/erp/getUnits";
String response = httpOkClient.uCloudPost(url, udiwmsUnitRequest, thrSystemEntity);
@ -64,9 +64,8 @@ public class ErpBasicClient {
//获取产品信息
public BaseResponse<PageSimpleResponse<ThrProductsResponse>> getErpProducts(FilterThrProductsRequest filterThrProductsRequest) {
ThrSystemEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(filterThrProductsRequest.getThirdSys());
ThrSystemEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(filterThrProductsRequest.getThirdSysFk());
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/getProducts";
try {
String response = httpOkClient.uCloudPost(url, filterThrProductsRequest, basicThirdSysEntity);
if (StrUtil.isBlank(response)) {
@ -159,16 +158,14 @@ public class ErpBasicClient {
* @param thirdSys
* @return
*/
public BaseResponse<PostThrProductsRequest> uploadPi(List<MultipartFile> files, String thirdSys) {
public BaseResponse<PostThrProductsRequest> uploadPi(byte[] bytes, String fileName, String thirdSys) {
ThrSystemEntity thrSystemEntity = basicThirdSysService.selectByThirdId(thirdSys);
String url = thrSystemEntity.getThridUrl() + "/udiwms/erp/pi/upload";
try {
MultipartBody.Builder builder = new MultipartBody.Builder()
.setType(MultipartBody.FORM);
for (MultipartFile file : files) {
builder.addFormDataPart("file", file.getOriginalFilename(), RequestBody.create(MediaType.parse("application/vnd.ms-excel"), file.getBytes()));
}
builder.addFormDataPart("file", fileName, RequestBody.create(MediaType.parse("application/vnd.ms-excel"), bytes));
builder.addFormDataPart("thirdSys", thirdSys);
MultipartBody multipartBody = builder.build();

@ -1,6 +1,7 @@
package com.glxp.api.req.thrsys;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.util.page.ListPageRequest;
import lombok.Data;
@ -34,5 +35,20 @@ public class FilterThrProductsRequest extends ListPageRequest {
private String uuid;
private Integer diType;
public List<ThrProductsEntity> getThrProductsEntities() {
return thrProductsEntities;
}
public String getThirdSys() {
if (StrUtil.isEmpty(thirdSys))
return thirdSysFk;
return thirdSys;
}
public String getThirdSysFk() {
if (StrUtil.isEmpty(thirdSysFk))
return thirdSys;
return thirdSysFk;
}
}

@ -1,6 +1,7 @@
package com.glxp.api.req.thrsys;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.util.page.ListPageRequest;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import lombok.Data;
@ -28,4 +29,18 @@ public class ThrUnitMaintainFilterRequest extends ListPageRequest {
private Boolean isDownThrSys;
private String lastUpdateTime;
List<ThrCorpsResponse> thrCorpEntities;
public String getThirdSys() {
if (StrUtil.isEmpty(thirdSys))
return thirdSysFk;
return thirdSys;
}
public String getThirdSysFk() {
if (StrUtil.isEmpty(thirdSysFk))
return thirdSys;
return thirdSysFk;
}
}

@ -6,7 +6,7 @@ import java.util.List;
public interface CustomService<T> extends IService<T> {
int insertIgnore(T entity);
int insertIgnoreBatch(List<T> entityList);
boolean insertIgnoreBatch(List<T> entityList);
int replace(T entity);
int replaceBatch(List<T> entityList);
boolean replaceBatch(List<T> entityList);
}

@ -13,8 +13,8 @@ public class CustomServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<B
}
@Override
public int insertIgnoreBatch(List<T> entityList) {
return baseMapper.insertIgnoreBatch(entityList);
public boolean insertIgnoreBatch(List<T> entityList) {
return baseMapper.insertIgnoreBatchs(entityList);
}
@Override
@ -23,7 +23,7 @@ public class CustomServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<B
}
@Override
public int replaceBatch(List<T> entityList) {
return baseMapper.replaceBatch(entityList);
public boolean replaceBatch(List<T> entityList) {
return baseMapper.replaceBatchs(entityList);
}
}

@ -31,6 +31,7 @@ import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.idc.service.FileService;
import com.glxp.api.idc.service.IdcService;
import com.glxp.api.req.sync.SpsSyncDataRequest;
import com.glxp.api.res.inv.InnerOrderPrintResponse;
import com.glxp.api.res.sync.*;
import com.glxp.api.service.auth.*;
import com.glxp.api.service.basic.EntrustReceService;
@ -1614,7 +1615,13 @@ public class HeartService {
supManufacturerDao.replaceBatch(supManufacturerList);
}
if (CollectionUtil.isNotEmpty(supProductList)) {
supProductDao.replaceBatch(supProductList);
List<List<SupProductEntity>> splits = CustomUtil.splitList(supProductList, 100);
if (CollUtil.isNotEmpty(splits)) {
for (List<SupProductEntity> items : splits) {
supProductDao.replaceBatch(items);
}
}
}
if (CollUtil.isNotEmpty(syncFiles)) {
// fileService.download(syncFiles);

@ -6,6 +6,7 @@ import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.entity.thrsys.ThrCorpEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
import com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import com.glxp.api.res.thrsys.ThrUnitMaintainResponse;
@ -42,4 +43,5 @@ public interface ThrCorpService extends IService<ThrCorpEntity> {
*/
BaseResponse downloadThrCorp(ThrSystemDetailEntity thrSystemDetailEntity);
public BaseResponse downloadByRequest(ThrUnitMaintainFilterRequest request);
}

@ -49,7 +49,7 @@ public interface ThrProductsService extends IService<ThrProductsEntity> {
* @param thirdSys
* @return
*/
BaseResponse uploadPi(List<MultipartFile> files, String thirdSys);
BaseResponse uploadPi(byte[] bytes, String fileName, String thirdSys);
/**
*
@ -66,4 +66,12 @@ public interface ThrProductsService extends IService<ThrProductsEntity> {
* @return
*/
BaseResponse downloadThrPi(ThrSystemDetailEntity thrSystemDetailEntity);
/**
*
*
* @param filterThrProductsRequest
* @return
*/
BaseResponse downloadByRequest(FilterThrProductsRequest filterThrProductsRequest);
}

@ -180,7 +180,7 @@ public class ThrBusTypeOriginServiceImpl extends ServiceImpl<ThrBusTypeOriginDao
if (baseResponse.getCode() == 20000) {
List<ThrSystemBusApiEntity> list = baseResponse.getData().getList();
list.forEach(item -> {
ThrBusTypeOriginEntity thrBusTypeOriginEntity = thrBusTypeOriginDao.selectOne(new QueryWrapper<ThrBusTypeOriginEntity>().eq("code", item.getCode()).eq("thirdSys", thrSystemDetailEntity.getThirdSysFk()));
ThrBusTypeOriginEntity thrBusTypeOriginEntity = thrBusTypeOriginDao.selectOne(new QueryWrapper<ThrBusTypeOriginEntity>().eq("action", item.getCode()).eq("thirdSys", thrSystemDetailEntity.getThirdSysFk()));
if (null == thrBusTypeOriginEntity) {
thrBusTypeOriginEntity = new ThrBusTypeOriginEntity();
BeanUtil.copyProperties(item, thrBusTypeOriginEntity);

@ -1,6 +1,7 @@
package com.glxp.api.service.thrsys.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.res.BaseResponse;
@ -47,11 +48,19 @@ public class ThrCorpServiceImpl extends ServiceImpl<ThrCorpDao, ThrCorpEntity> i
@Override
public boolean insertThrCorps(ThrCorpEntity thrCorpEntity) {
if (thrCorpEntity.getId() == null) {
thrCorpEntity.setId(IdUtil.getSnowflakeNextId());
}
return thrCorpDao.insertThrCorps(thrCorpEntity);
}
@Override
public boolean insertThrCorpss(List<ThrCorpEntity> thrCorpEntitys) {
for (ThrCorpEntity thrCorpEntity : thrCorpEntitys) {
if (thrCorpEntity.getId() == null) {
thrCorpEntity.setId(IdUtil.getSnowflakeNextId());
}
}
return thrCorpDao.insertThrCorpss(thrCorpEntitys);
}
@ -125,7 +134,51 @@ public class ThrCorpServiceImpl extends ServiceImpl<ThrCorpDao, ThrCorpEntity> i
BeanUtil.copyProperties(thrCorpsResponse, thrCorpEntity);
thrCorpEntity.setCreateTime(new Date());
thrCorpEntity.setUpdateTime(new Date());
thrCorpEntity.setId(null);
thrCorpEntity.setId(IdUtil.getSnowflakeNextId());
thrCorpEntity.setThirdSysFk(thrSystemDetailEntity.getThirdSysFk());
thrCorpDao.insertThrCorps(thrCorpEntity);
} else {
boolean isChange = verifyDataChange(thrCorpEntity, thrCorpsResponse);
if (isChange) {
thrCorpEntity.setUpdateTime(new Date());
thrCorpDao.updateThrCorps(thrCorpEntity);
}
}
});
if (list.size() >= limit) {
page++;
} else {
break;
}
} else {
return baseResponse;
}
}
return ResultVOUtils.success("下载完成");
}
@Override
public BaseResponse downloadByRequest(ThrUnitMaintainFilterRequest request) {
int page = 1;
int limit = 100;
while (true) {
request.setPage(page);
request.setLimit(limit);
request.setThirdSysFk(request.getThirdSys());
BaseResponse<PageSimpleResponse<ThrCorpsResponse>> baseResponse = erpBasicClient.getErpCrop(request);
if (baseResponse.getCode() == 20000) {
List<ThrCorpsResponse> list = baseResponse.getData().getList();
list.forEach(thrCorpsResponse -> {
ThrCorpEntity thrCorpEntity = thrCorpDao.selectByUnitIdAndThirdId(thrCorpsResponse.getUnitId(), request.getThirdSys());
if (null == thrCorpEntity) {
thrCorpEntity = new ThrCorpEntity();
BeanUtil.copyProperties(thrCorpsResponse, thrCorpEntity);
thrCorpEntity.setCreateTime(new Date());
thrCorpEntity.setUpdateTime(new Date());
thrCorpEntity.setThirdSysFk(request.getThirdSys());
thrCorpEntity.setId(IdUtil.getSnowflakeNextId());
thrCorpDao.insertThrCorps(thrCorpEntity);
} else {
boolean isChange = verifyDataChange(thrCorpEntity, thrCorpsResponse);

@ -130,8 +130,8 @@ public class ThrProductsServiceImpl extends ServiceImpl<ThrProductsDao, ThrProdu
}
@Override
public BaseResponse uploadPi(List<MultipartFile> files, String thirdSys) {
BaseResponse<PostThrProductsRequest> baseResponse = erpBasicClient.uploadPi(files, thirdSys);
public BaseResponse uploadPi(byte[] bytes, String fileName, String thirdSys) {
BaseResponse<PostThrProductsRequest> baseResponse = erpBasicClient.uploadPi(bytes, fileName, thirdSys);
if (baseResponse.getCode() == 20000) {
return ResultVOUtils.success("导入成功");
} else {
@ -153,10 +153,11 @@ public class ThrProductsServiceImpl extends ServiceImpl<ThrProductsDao, ThrProdu
thrProductsEntity.setThirdSysFk(postThrProductsRequest.getThirdSys());
thrProductsEntity.setCreateTime(DateUtil.date(new Date()));
thrProductsEntity.setUpdateTime(DateUtil.date(new Date()));
thrProductsEntity.setId(IdUtil.getSnowflakeNextId());
try {
mapper.insertThrProducts(thrProductsEntity);
} catch (Exception e) {
e.printStackTrace();
log.error("", e);
}
});
@ -176,7 +177,6 @@ public class ThrProductsServiceImpl extends ServiceImpl<ThrProductsDao, ThrProdu
request.setLimit(limit);
while (true) {
request.setPage(page);
BaseResponse<PageSimpleResponse<ThrProductsResponse>> baseResponse = erpBasicClient.getErpProducts(request);
if (baseResponse.getCode() == 20000) {
List<ThrProductsResponse> list = baseResponse.getData().getList();
@ -188,6 +188,7 @@ public class ThrProductsServiceImpl extends ServiceImpl<ThrProductsDao, ThrProdu
thrProductsEntity.setCreateTime(new Date());
thrProductsEntity.setUpdateTime(new Date());
thrProductsEntity.setId(IdUtil.getSnowflakeNextId());
thrProductsEntity.setThirdSysFk(thrSystemDetailEntity.getThirdSysFk());
thrProductsDao.insertThrProducts(thrProductsEntity);
} else {
boolean isChange = verifyDataChange(thrProductsEntity, item);
@ -212,6 +213,51 @@ public class ThrProductsServiceImpl extends ServiceImpl<ThrProductsDao, ThrProdu
return ResultVOUtils.success("下载成功");
}
@Override
public BaseResponse downloadByRequest(FilterThrProductsRequest filterThrProductsRequest) {
int page = 1;
int limit = 200;
filterThrProductsRequest.setThirdSysFk(filterThrProductsRequest.getThirdSys());
filterThrProductsRequest.setLimit(limit);
log.error("开始下载-------");
while (true) {
log.error("下载分页-------" + page);
filterThrProductsRequest.setPage(page);
BaseResponse<PageSimpleResponse<ThrProductsResponse>> baseResponse = erpBasicClient.getErpProducts(filterThrProductsRequest);
if (baseResponse.getCode() == 20000) {
List<ThrProductsResponse> list = baseResponse.getData().getList();
list.forEach(item -> {
ThrProductsEntity thrProductsEntity = thrProductsDao.selectByCodeAndThird(item.getCode(), item.getThirdSys());
if (null == thrProductsEntity) {
thrProductsEntity = new ThrProductsEntity();
BeanUtil.copyProperties(item, thrProductsEntity);
thrProductsEntity.setCreateTime(new Date());
thrProductsEntity.setUpdateTime(new Date());
thrProductsEntity.setId(IdUtil.getSnowflakeNextId());
thrProductsEntity.setThirdSysFk(filterThrProductsRequest.getThirdSys());
thrProductsDao.insertThrProducts(thrProductsEntity);
} else {
boolean isChange = verifyDataChange(thrProductsEntity, item);
if (isChange) {
BeanUtil.copyProperties(item, thrProductsEntity, new CopyOptions().setIgnoreNullValue(true));
thrProductsEntity.setUpdateTime(new Date());
thrProductsDao.updateEntityById(thrProductsEntity);
}
}
});
if (list.size() >= limit) {
page++;
} else {
break;
}
} else {
return ResultVOUtils.error(500, "下载第三方系统产品信息异常");
}
}
log.error("下载结束-------");
return ResultVOUtils.success("下载成功");
}
/**
*
*

@ -6,8 +6,12 @@ import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.glxp.api.constant.ThirdSysConstant;
import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.dao.system.SyncDataSetDao;
import com.glxp.api.dao.thrsys.ThrSystemDetailDao;
import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.req.system.ScheduledRequest;
import com.glxp.api.res.thrsys.ThirdSysInterfaceExecuteVo;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.service.thrsys.IThrBusTypeOriginService;
@ -16,7 +20,12 @@ import com.glxp.api.service.thrsys.ThrInvWarehouseService;
import com.glxp.api.service.thrsys.ThrProductsService;
import com.glxp.api.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@ -24,13 +33,10 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
/**
*
* 线
*/
@Slf4j
@Component
public class ThirdSysInterfaceTask {
@EnableScheduling
@Slf4j
public class SyncThirdSysTask implements SchedulingConfigurer {
/**
* redis key
@ -39,21 +45,6 @@ public class ThirdSysInterfaceTask {
private volatile ExecutorService executor;
/**
* 线
*
* @return
*/
private ExecutorService getExecutor() {
if (null == executor) {
synchronized (this) {
log.info("初始化第三方系统接口执行线程池");
executor = ThreadUtil.newExecutor(10, 100, Integer.MAX_VALUE);
}
}
return executor;
}
@Resource
private RedisUtil redisUtil;
@Resource
@ -69,8 +60,46 @@ public class ThirdSysInterfaceTask {
@Resource
private IoOrderService orderService;
@Scheduled(fixedRate = 20 * 1000, initialDelay = 60 * 1000)
public void scanInterface() {
final Logger logger = LoggerFactory.getLogger(SyncHeartTask.class);
@Resource
protected ScheduledDao scheduledDao;
@Resource
private SyncDataSetDao syncDataSetDao;
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.addTriggerTask(() -> process(),
triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("dlThrSysHeartTask");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
if (scheduledEntity != null) {
String cron = scheduledEntity.getCron();
if (cron.isEmpty()) {
logger.error("cron is null");
}
return new CronTrigger(cron).nextExecutionTime(triggerContext);
} else
return null;
});
}
private ExecutorService getExecutor() {
if (null == executor) {
synchronized (this) {
log.info("初始化第三方系统接口执行线程池");
executor = ThreadUtil.newExecutor(10, 100, Integer.MAX_VALUE);
}
}
return executor;
}
private void process() {
log.info("开始扫描自动执行的第三方接口列表");
List<ThrSystemDetailEntity> list = thrSystemDetailDao.selectAutoExecuteList();
if (CollUtil.isNotEmpty(list)) {
@ -107,6 +136,7 @@ public class ThirdSysInterfaceTask {
}
}
/**
*
*
@ -243,11 +273,20 @@ public class ThirdSysInterfaceTask {
return false;
}
long nextTime = DateUtil.offsetMonth(new Date(), thrSystemDetailEntity.getTime()).getTime();
if (vo != null) {
if (vo.getNextTime() - new Date().getTime() > thrSystemDetailEntity.getTime() * 1000 * 60) {
log.info("定时任务时间未到", taskKey);
return false;
} else {
return true;
}
} else {
vo = Optional.ofNullable(vo).orElse(new ThirdSysInterfaceExecuteVo());
vo.setKey(taskKey);
vo.setNextTime(nextTime);
vo.setFinished(false);
redisUtil.set(taskKey, vo);
}
return true;
}
@ -288,4 +327,5 @@ public class ThirdSysInterfaceTask {
return key;
}
}

@ -26,12 +26,12 @@
</select>
<insert id="insertThrCorps" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrCorpEntity">
<insert id="insertThrCorps" parameterType="com.glxp.api.entity.thrsys.ThrCorpEntity">
replace
INTO thr_corp
(unitId, name, spell, addr, creditNo,
(id, unitId, name, spell, addr, creditNo,
contact, mobile, thirdSysFk, updateTime, createUser, createTime, updateUser, remark)
values (#{unitId},
values (#{id}, #{unitId},
#{name},
#{spell},
#{addr},
@ -48,13 +48,13 @@
<insert id="insertThrCorpss" keyProperty="id" parameterType="java.util.List">
replace INTO thr_corp
(unitId, name, spell, addr, creditNo,
(id, unitId, name, spell, addr, creditNo,
contact, mobile, thirdSysFk, updateTime, createUser, createTime, updateUser, remark)
values
<foreach collection="thrCorpEntitys" item="item" index="index"
separator=",">
(#{item.unitId},
(#{item.id}, #{item.unitId},
#{item.name},
#{item.spell},
#{item.addr},

@ -41,10 +41,14 @@
<select id="selectByThrDeptCode" parameterType="com.glxp.api.req.thrsys.FilterThrSubInvWarehouseRequest"
resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
select * from thr_inv_warehouse
select *
from thr_inv_warehouse
<where>
parentId not in (SELECT code FROM thr_dept
where status=#{status} and thirdSysFk=#{thirdSysFk}) and thirdSysFk=#{thirdSysFk}
parentId not in (SELECT code
FROM thr_dept
where status = #{status}
and thirdSysFk = #{thirdSysFk})
and thirdSysFk = #{thirdSysFk}
<if test="name != '' and name != null">
and name like concat('%', #{name}, '%')
</if>
@ -53,13 +57,15 @@
<select id="countSubInvByParentInvId" resultType="java.lang.Integer">
select count(*) from thr_inv_warehouse where
parentId = (select code from thr_dept where id = #{parentInvId})
select count(*)
from thr_inv_warehouse
where parentId = (select code from thr_dept where id = #{parentInvId})
</select>
<select id="filterThrInvWarehouseResponse"
resultType="com.glxp.api.res.thrsys.ThrInvWarehouseResponse">
select t1.*, t2.name as parentName from thr_inv_warehouse t1
select t1.*, t2.name as parentName
from thr_inv_warehouse t1
left join thr_dept t2
on t2.code = t1.parentId
<where>
@ -86,15 +92,13 @@
replace
INTO thr_inv_warehouse
(id, code, `name`, parentId, remark, thirdSysFk, updateTime)
values (
#{id},
values (#{id},
#{code},
#{name},
#{parentId},
#{remark},
#{thirdSysFk},
#{updateTime}
)
#{updateTime})
</insert>
<insert id="insertThrInvWarehouses" parameterType="java.util.List">
@ -103,8 +107,7 @@
VALUES
<foreach collection="thrInvWarehouseEntitys" item="item" index="index"
separator=",">
(
#{item.id}, #{item.code},
(#{item.id}, #{item.code},
#{item.name}, #{item.parentId},
#{item.remark}, #{item.thirdSysFk}, #{item.updateTime})
</foreach>
@ -119,18 +122,32 @@
<update id="updateThrInvWarehouse" parameterType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
UPDATE thr_inv_warehouse
<trim prefix="set" suffixOverrides=",">
<if test="name != null">`name`=#{name},</if>
<if test="code != null">code=#{code},</if>
<if test="parentId != null">parentId=#{parentId},</if>
<if test="remark != null">remark=#{remark},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="name != null">
`name`=#{name},
</if>
<if test="code != null">
code=#{code},
</if>
<if test="parentId != null">
parentId=#{parentId},
</if>
<if test="remark != null">
remark=#{remark},
</if>
<if test="thirdSysFk != null">
thirdSysFk=#{thirdSysFk},
</if>
<if test="updateTime != null">
updateTime=#{updateTime},
</if>
</trim>
WHERE id = #{id}
</update>
<select id="selectByLastTime" resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
select * from thr_inv_warehouse where updateTime >= #{lastUpdateTime}
select *
from thr_inv_warehouse
where updateTime >= #{lastUpdateTime}
</select>
<select id="selectByCodeAndThirdId" resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
@ -144,5 +161,6 @@
AND thirdSysFk = #{thirdId}
</if>
</where>
limit 1
</select>
</mapper>

@ -444,9 +444,31 @@ CALL Pro_Temp_ColumnWork('io_code', 'preInSpaceCode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('pur_order_detail', 'price', 'decimal(10, 2)', 1);
INSERT ignore INTO `sys_pdf_template_relevance_label`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`, `localAction`, `remark1`, `remark2`, `remark3`, `printType`, `modelKey`) VALUES (1, 30, 110, 0, 9, '内部码打印', NULL, NULL, NULL, NULL, 'lable');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`, `localAction`, `remark1`, `remark2`, `remark3`, `printType`, `modelKey`) VALUES (1, 31, 110, 0, NULL, '配送企业资质打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`, `localAction`, `remark1`, `remark2`, `remark3`, `printType`, `modelKey`) VALUES (2, 32, 110, 0, NULL, '生产企业资质打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`, `localAction`, `remark1`, `remark2`, `remark3`, `printType`, `modelKey`) VALUES (3, 33, 110, 0, NULL, '配送产品资质打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`, `localAction`, `remark1`, `remark2`, `remark3`, `printType`, `modelKey`) VALUES (4, 33, 110, 0, NULL, '库存报表打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`, `localAction`, `remark1`, `remark2`, `remark3`, `printType`, `modelKey`) VALUES (5, 33, 110, 0, NULL, '内部码报表打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_label`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`,
`localAction`, `remark1`, `remark2`, `remark3`, `printType`,
`modelKey`)
VALUES (1, 30, 110, 0, 9, '内部码打印', NULL, NULL, NULL, NULL, 'lable');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`,
`localAction`, `remark1`, `remark2`, `remark3`, `printType`,
`modelKey`)
VALUES (1, 31, 110, 0, NULL, '配送企业资质打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`,
`localAction`, `remark1`, `remark2`, `remark3`, `printType`,
`modelKey`)
VALUES (2, 32, 110, 0, NULL, '生产企业资质打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`,
`localAction`, `remark1`, `remark2`, `remark3`, `printType`,
`modelKey`)
VALUES (3, 33, 110, 0, NULL, '配送产品资质打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`,
`localAction`, `remark1`, `remark2`, `remark3`, `printType`,
`modelKey`)
VALUES (4, 33, 110, 0, NULL, '库存报表打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_pdf_template_relevance_statemen`(`id`, `templateId`, `customerId`, `adminId`, `moduleId`,
`localAction`, `remark1`, `remark2`, `remark3`, `printType`,
`modelKey`)
VALUES (5, 33, 110, 0, NULL, '内部码报表打印', NULL, NULL, NULL, NULL, 'reportForms');
INSERT ignore INTO `sys_scheduled`(`id`, `cronName`, `cron`, `customerId`, `remark`)
VALUES (140, 'dlThrSysHeartTask', '0 0/1 * * * ?', NULL, '第三方接口同步心跳');

Loading…
Cancel
Save