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

dev
黄泽腾 2 years ago
commit 7cd0d1c06d

@ -1214,7 +1214,6 @@ public class IoCodeTempController extends BaseController {
if (StrUtil.isNotEmpty(codeTempEntity.getBatchNo()) && codeTempEntity.getBatchNo().length() > 20) {
return ResultVOUtils.error(500, "无效条码!批次号超出最大范围");
}
if (StrUtil.isBlank(codeTempEntity.getSerialNo()) && StrUtil.isBlank(codeTempEntity.getBatchNo())) {
return ResultVOUtils.error(500, "批次号不能为空!");
}

@ -22,10 +22,14 @@ import com.glxp.api.req.sync.OrderStatusFilterRequest;
import com.glxp.api.req.sync.SyncUpLoadRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.RefreshInoiceResponse;
import com.glxp.api.res.inv.InvPreProductResponse;
import com.glxp.api.res.inv.InvPreinProductResponse;
import com.glxp.api.res.inv.InvProductResponse;
import com.glxp.api.res.sync.*;
import com.glxp.api.res.system.SyncDataSetResponse;
import com.glxp.api.service.sync.SyncDataSetService;
import com.glxp.api.util.OkHttpCli;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -438,12 +442,58 @@ public class SpGetHttpClient {
public BaseResponse<String> postTemplateFile(List<String> fileNameList) {
return fileService.upload(fileNameList);
}
// String json = JSONUtil.toJsonStr(fileNameList);
// String result = okHttpCli.doPostJson(getIpUrl() + "/spssync/file/download", json, buildHeader());
// BaseResponse<String> response =
// JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
// });
// return response;
//下载普通库存
public BaseResponse<PageSimpleResponse<InvProductResponse>> getInvData(Integer page, Integer limit) {
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("page", page + "");
paramMap.put("limit", limit + "");
String response = okHttpCli.doGet(getIpUrl() + "/syncToSpms" + "/spms/inv/product/vail", paramMap, buildHeader());
try {
BaseResponse<PageSimpleResponse<InvProductResponse>> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<InvProductResponse>>>() {
});
return data;
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error(500, "下载失败!");
}
}
//下载寄售库存
public BaseResponse<PageSimpleResponse<InvPreProductResponse>> getInvPreData(Integer page, Integer limit) {
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("page", page + "");
paramMap.put("limit", limit + "");
String response = okHttpCli.doGet(getIpUrl() + "/syncToSpms" + "/spms/inv/pre/product/vail", paramMap, buildHeader());
try {
BaseResponse<PageSimpleResponse<InvPreProductResponse>> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<InvPreProductResponse>>>() {
});
return data;
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error(500, "下载失败!");
}
}
//下载预验收库存
public BaseResponse<PageSimpleResponse<InvPreinProductResponse>> getInvPreInData(Integer page, Integer limit) {
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("page", page + "");
paramMap.put("limit", limit + "");
String response = okHttpCli.doGet(getIpUrl() + "/syncToSpms" + "/spms/inv/preIn/product/vail", paramMap, buildHeader());
try {
BaseResponse<PageSimpleResponse<InvPreinProductResponse>> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<InvPreinProductResponse>>>() {
});
return data;
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error(500, "下载失败!");
}
}
}

@ -0,0 +1,173 @@
package com.glxp.api.task;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.entity.inv.InvPreProductEntity;
import com.glxp.api.entity.inv.InvPreinProductEntity;
import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.req.system.ScheduledRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inv.InvProductResponse;
import com.glxp.api.service.inv.InvPreProductService;
import com.glxp.api.service.inv.InvPreinProductService;
import com.glxp.api.service.inv.InvProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@Component
@Transactional(rollbackFor = Exception.class)
public class VailInvTask implements SchedulingConfigurer {
@Resource
private ScheduledDao scheduledDao;
@Resource
SpGetHttpClient spGetHttpClient;
@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()) {
log.error("cron is null");
}
return new CronTrigger(cron).nextExecutionTime(triggerContext);
} else
return null;
});
}
private void process() {
StringBuffer stringBuffer = new StringBuffer();
String invStr = downloadInv();
String invPreStr = downloadPreInv();
String invPreInStr = downloadPreInInv();
stringBuffer.append("------------普通库存-----------------------\n");
stringBuffer.append(invStr);
stringBuffer.append("------------寄售库存-----------------------\n");
stringBuffer.append(invPreStr);
stringBuffer.append("------------预验收库存-----------------------\n");
stringBuffer.append(invPreInStr);
}
@Resource
InvProductService invProductService;
@Resource
InvPreinProductService invPreinProductService;
@Resource
InvPreProductService invPreProductService;
public String downloadInv() {
int page = 1;
int limit = 100;
StringBuffer buffer = new StringBuffer();
while (true) {
BaseResponse<PageSimpleResponse<InvProductResponse>> baseResponse = spGetHttpClient.getInvData(page, limit);
if (baseResponse.getCode() == 20000) {
List<InvProductResponse> list = baseResponse.getData().getList();
list.forEach(invProductResponse -> {
InvProductEntity invProductEntity = invProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode());
if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) {
buffer.append(invProductResponse.getCpmctymc() + ","
+ invProductResponse.getNameCode() + ","
+ invProductResponse.getBatchNo() + ","
+ invProductResponse.getSupName() + ","
+ invProductResponse.getDeptName() + ","
+ invProductResponse.getInvCode() + "\n");
}
});
if (list.size() >= limit) {
page++;
} else {
break;
}
} else {
return buffer.toString();
}
}
return buffer.toString();
}
public String downloadPreInv() {
int page = 1;
int limit = 100;
StringBuffer buffer = new StringBuffer();
while (true) {
BaseResponse<PageSimpleResponse<InvProductResponse>> baseResponse = spGetHttpClient.getInvData(page, limit);
if (baseResponse.getCode() == 20000) {
List<InvProductResponse> list = baseResponse.getData().getList();
list.forEach(invProductResponse -> {
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode());
if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) {
buffer.append(invProductResponse.getCpmctymc() + ","
+ invProductResponse.getNameCode() + ","
+ invProductResponse.getBatchNo() + ","
+ invProductResponse.getSupName() + ","
+ invProductResponse.getDeptName() + ","
+ invProductResponse.getInvCode() + "\n");
}
});
if (list.size() >= limit) {
page++;
} else {
break;
}
} else {
return buffer.toString();
}
}
return buffer.toString();
}
public String downloadPreInInv() {
int page = 1;
int limit = 100;
StringBuffer buffer = new StringBuffer();
while (true) {
BaseResponse<PageSimpleResponse<InvProductResponse>> baseResponse = spGetHttpClient.getInvData(page, limit);
if (baseResponse.getCode() == 20000) {
List<InvProductResponse> list = baseResponse.getData().getList();
list.forEach(invProductResponse -> {
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode());
if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) {
buffer.append(invProductResponse.getCpmctymc() + ","
+ invProductResponse.getNameCode() + ","
+ invProductResponse.getBatchNo() + ","
+ invProductResponse.getSupName() + ","
+ invProductResponse.getDeptName() + ","
+ invProductResponse.getInvCode() + "\n");
}
});
if (list.size() >= limit) {
page++;
} else {
break;
}
} else {
return buffer.toString();
}
}
return buffer.toString();
}
}
Loading…
Cancel
Save