diff --git a/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java b/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java index 2687a3cf9..1494dcf37 100644 --- a/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java +++ b/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java @@ -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 postTemplateFile(List fileNameList) { return fileService.upload(fileNameList); + } -// String json = JSONUtil.toJsonStr(fileNameList); -// String result = okHttpCli.doPostJson(getIpUrl() + "/spssync/file/download", json, buildHeader()); -// BaseResponse response = -// JSONObject.parseObject(result, new TypeReference>() { -// }); -// return response; + //下载普通库存 + public BaseResponse> getInvData(Integer page, Integer limit) { + Map 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> data = + JSONObject.parseObject(response, new TypeReference>>() { + }); + return data; + } catch (Exception e) { + e.printStackTrace(); + return ResultVOUtils.error(500, "下载失败!"); + } } + + //下载寄售库存 + public BaseResponse> getInvPreData(Integer page, Integer limit) { + Map 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> data = + JSONObject.parseObject(response, new TypeReference>>() { + }); + return data; + } catch (Exception e) { + e.printStackTrace(); + return ResultVOUtils.error(500, "下载失败!"); + } + } + + //下载预验收库存 + public BaseResponse> getInvPreInData(Integer page, Integer limit) { + Map 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> data = + JSONObject.parseObject(response, new TypeReference>>() { + }); + return data; + } catch (Exception e) { + e.printStackTrace(); + return ResultVOUtils.error(500, "下载失败!"); + } + } + + } diff --git a/src/main/java/com/glxp/api/service/basic/impl/BasicBusTypePreServiceImpl.java b/src/main/java/com/glxp/api/service/basic/impl/BasicBusTypePreServiceImpl.java index 7f96a9acc..a3843d8ff 100644 --- a/src/main/java/com/glxp/api/service/basic/impl/BasicBusTypePreServiceImpl.java +++ b/src/main/java/com/glxp/api/service/basic/impl/BasicBusTypePreServiceImpl.java @@ -89,7 +89,9 @@ public class BasicBusTypePreServiceImpl extends ServiceImpl list = basicBusTypePreDao.selectList(wrapper); if (CollUtil.isNotEmpty(list)) { diff --git a/src/main/java/com/glxp/api/service/purchase/impl/PurApplyDetailImplService.java b/src/main/java/com/glxp/api/service/purchase/impl/PurApplyDetailImplService.java index 42d076398..326005595 100644 --- a/src/main/java/com/glxp/api/service/purchase/impl/PurApplyDetailImplService.java +++ b/src/main/java/com/glxp/api/service/purchase/impl/PurApplyDetailImplService.java @@ -90,17 +90,26 @@ public class PurApplyDetailImplService implements PurApplyDetailService { @Override public List getDetailList(PurApplyDetailRequest purApplyDetailRequest) { - if (null == purApplyDetailRequest) { +// if (null == purApplyDetailRequest) { +// return Collections.emptyList(); +// } +// if (purApplyDetailRequest.getPage() == null) +// purApplyDetailRequest.setPage(1); +// if (purApplyDetailRequest.getLimit() == null) { +// purApplyDetailRequest.setLimit(10); +// } +// PageHelper.offsetPage((purApplyDetailRequest.getPage() - 1) * purApplyDetailRequest.getLimit(), purApplyDetailRequest.getLimit()); + if (purApplyDetailRequest == null) { return Collections.emptyList(); } - if (purApplyDetailRequest.getPage() == null) - purApplyDetailRequest.setPage(1); - if (purApplyDetailRequest.getLimit() == null) { - purApplyDetailRequest.setLimit(10); + if (purApplyDetailRequest.getPage() != null) { + int offset = (purApplyDetailRequest.getPage() - 1) * purApplyDetailRequest.getLimit(); + PageHelper.offsetPage(offset, purApplyDetailRequest.getLimit()); } - PageHelper.offsetPage((purApplyDetailRequest.getPage() - 1) * purApplyDetailRequest.getLimit(), purApplyDetailRequest.getLimit()); return purApplyDetailDao.selectPurApplyDetailList(purApplyDetailRequest); + } + } diff --git a/src/main/java/com/glxp/api/task/VailInvTask.java b/src/main/java/com/glxp/api/task/VailInvTask.java new file mode 100644 index 000000000..058d362e1 --- /dev/null +++ b/src/main/java/com/glxp/api/task/VailInvTask.java @@ -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> baseResponse = spGetHttpClient.getInvData(page, limit); + if (baseResponse.getCode() == 20000) { + List 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> baseResponse = spGetHttpClient.getInvData(page, limit); + if (baseResponse.getCode() == 20000) { + List 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> baseResponse = spGetHttpClient.getInvData(page, limit); + if (baseResponse.getCode() == 20000) { + List 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(); + } + +} diff --git a/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml b/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml index 912ed505d..482789d11 100644 --- a/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml +++ b/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml @@ -765,7 +765,7 @@ basic_products.sfwblztlcp, basic_products.cgzmraqxgxx, basic_products.sfbjwycxsy, - basic_products.zdcfsycs, +-- basic_products.zdcfsycs, basic_products.sfwwjbz, basic_products.syqsfxyjxmj, basic_products.mjfs,