diff --git a/ant-design-vue-jeecg/src/views/system/compare/CompareWcsLocation.vue b/ant-design-vue-jeecg/src/views/system/compare/CompareWcsLocation.vue index 3541c9f..5d7fe77 100644 --- a/ant-design-vue-jeecg/src/views/system/compare/CompareWcsLocation.vue +++ b/ant-design-vue-jeecg/src/views/system/compare/CompareWcsLocation.vue @@ -5,15 +5,29 @@ <a-form layout="inline" @keyup.enter.native="searchQuery"> <a-row :gutter="24"> <a-col :xl="6" :lg="7" :md="8" :sm="24"> + <a-form-item label="库区"> + <a-select + show-search + placeholder="请选择库区" + option-filter-prop="children" + v-model="queryParam.zoneCode" + > + <a-select-option v-for="item in zoneList" :key="item.name" :value="item.code"> + {{ item.name }} + </a-select-option> + </a-select> + </a-form-item> + </a-col> + <a-col :xl="6" :lg="7" :md="8" :sm="24"> <a-form-item label="库位编码"> <a-input placeholder="请输入库位编码" v-model="queryParam.locationCode"></a-input> </a-form-item> </a-col> - <a-col :xl="6" :lg="7" :md="8" :sm="24"> + <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24"> <a-form-item label="库位表容器编码"> <a-input placeholder="请输入库位表容器编码" v-model="queryParam.containerCode"></a-input> </a-form-item> - </a-col> + </a-col> --> <a-col :xl="6" :lg="7" :md="8" :sm="24"> <a-form-item label="数据状态"> <j-dict-select-tag @@ -90,7 +104,7 @@ import { JeecgListMixin } from '@/mixins/JeecgListMixin' import { getAction } from '@/api/manage' import CompareWcsLocationTask from './CompareWcsLocationTask' import { initDictOptions, filterMultiDictText } from '@/components/dict/JDictSelectUtil' -import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api' +import { getZoneList, ajaxGetDictItems, getDictItemsFromCache } from '@/api/api' export default { name: 'CompareWcsLocation', @@ -106,6 +120,7 @@ export default { containerStatusList: [], wcsLocationStatusList: [], consistencyStatusList: [], + zoneList:[], // 表头 columns: [ { @@ -182,6 +197,7 @@ export default { } }, created() { + this.loadFrom() this.initDictData() }, methods: { @@ -280,6 +296,13 @@ export default { return color }, initDictConfig() {}, + loadFrom() { + getZoneList().then(res => { + if (res.success) { + this.zoneList = res.result + } + }) + }, clickThenSelect(record) { return { on: { diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/address/service/impl/AddressServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/address/service/impl/AddressServiceImpl.java index 3307ba1..8ab0738 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/address/service/impl/AddressServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/address/service/impl/AddressServiceImpl.java @@ -1,14 +1,14 @@ package org.jeecg.modules.wms.config.address.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import org.apache.commons.math3.analysis.function.Add; import org.jeecg.modules.wms.config.address.entity.Address; import org.jeecg.modules.wms.config.address.mapper.AddressMapper; import org.jeecg.modules.wms.config.address.service.IAddressService; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; +import com.aliyuncs.utils.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; /** @@ -21,30 +21,28 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements IAddressService { @Override - @Cacheable(cacheNames = "getAddressByUrl#300", key = "#root.methodName") + @Cacheable(cacheNames = "getAddressByUrl#1", key = "#root.methodName + '_' + #url", unless = "#result == null ") public Address getAddressByUrl(String url) { LambdaQueryWrapper<Address> addressLambdaQueryWrapper = Wrappers.lambdaQuery(); - addressLambdaQueryWrapper.eq(Address::getUrl, url).last(" limit 1"); - Address address = getOne(addressLambdaQueryWrapper); - return address; + addressLambdaQueryWrapper.eq(Address::getUrl, url); + return getOne(addressLambdaQueryWrapper); } @Override - @Cacheable(cacheNames = "getUrlByParam#300", key = "#root.methodName + '_' + #param + '_' + #warehouseCode + '_' + #zoneCode") + @Cacheable(cacheNames = "getUrlByParam#1", key = "#root.methodName + '_' + #param + '_' + #warehouseCode + '_' + #zoneCode", unless = "#result == null ") public String getUrlByParam(String param, String warehouseCode, String zoneCode) { LambdaQueryWrapper<Address> addressLambdaQueryWrapper = Wrappers.lambdaQuery(); - addressLambdaQueryWrapper.eq(Address::getParam, param).eq(Address::getWarehouseCode, warehouseCode).eq(Address::getZoneCode, zoneCode); + addressLambdaQueryWrapper.eq(Address::getParam, param).eq(!StringUtils.isEmpty(warehouseCode), Address::getWarehouseCode, warehouseCode) + .eq(!StringUtils.isEmpty(zoneCode), Address::getZoneCode, zoneCode); Address address = getOne(addressLambdaQueryWrapper); if (address == null) { return null; } - String url = address.getUrl(); - return url; + return address.getUrl(); } - /** #300 缓存300秒 */ @Override - @Cacheable(cacheNames = "getUrlByParam#300", key = "#root.methodName + '_' + #param") + @Cacheable(cacheNames = "getUrlByParam#1", key = "#root.methodName + '_' + #param", unless = "#result == null ") public String getUrlByParam(String param) { LambdaQueryWrapper<Address> addressLambdaQueryWrapper = Wrappers.lambdaQuery(); addressLambdaQueryWrapper.eq(Address::getParam, param); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/dto/CompareLocationDto.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/dto/CompareLocationDto.java index 6691ed5..acf90b2 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/dto/CompareLocationDto.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/dto/CompareLocationDto.java @@ -17,28 +17,28 @@ public class CompareLocationDto { private String locationCode; /** 库位表容器编码 */ - private String locationContainerCode; + private String locationContainerCode = ""; /** 库位表状态 */ - private String locationStatus; + private String locationStatus = ""; /** 托盘表容器编码 */ - private String containerContainerCode; + private String containerContainerCode = ""; /** 托盘表状态 */ - private String containerStatus; + private String containerStatus = ""; /** 库存表容器编码 */ - private String inventoryContainerCode; + private String inventoryContainerCode = ""; /** 库存表状态 */ - private String inventoryStatus; + private String inventoryStatus = ""; /** WCS库位容器编码 */ - private String wcsContainerCode; + private String wcsContainerCode = ""; /** WCS库位表状态 */ - private String wcsLocationStatus; + private String wcsLocationStatus = ""; /** 数据状态 */ private Integer consistencyStatus = 1; diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/dto/QueryCompareLocationDto.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/dto/QueryCompareLocationDto.java index 4fd1aab..49b9ccc 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/dto/QueryCompareLocationDto.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/dto/QueryCompareLocationDto.java @@ -5,6 +5,9 @@ import lombok.Data; @Data public class QueryCompareLocationDto { + /** 库区编码 */ + private String zoneCode; + /** 仓库编码 */ private String warehouseCode; diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java index 86007f8..b69e076 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java @@ -4,6 +4,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -14,6 +15,7 @@ import java.util.stream.Collectors; import javax.annotation.Resource; +import org.apache.commons.collections4.ListUtils; import org.apache.shiro.util.CollectionUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.exception.JeecgBootException; @@ -446,47 +448,53 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i @Override public PageUtil<CompareLocationDto> compareWcsLocation(QueryCompareLocationDto queryCompareLocationDto) { + List<CompareLocationDto> compareLocationDtoList = new ArrayList<CompareLocationDto>(); + if (StringUtils.isEmpty(queryCompareLocationDto.getZoneCode())) { + return PageUtil.create(compareLocationDtoList, queryCompareLocationDto.getPageNo(), queryCompareLocationDto.getPageSize()); + } // 初始化数据 - Set<String> locationCodes = new HashSet<String>(); + List<String> locationCodes = new ArrayList<String>(); Map<String, Location> locationMap = new HashMap<String, Location>(); Map<String, List<Container>> containerMap = new HashMap<String, List<Container>>(); Map<String, List<InventoryDetail>> inventoryDetailMap = new HashMap<String, List<InventoryDetail>>(); Map<String, List<WcsLocationDto>> wcsLocationMap = new HashMap<String, List<WcsLocationDto>>(); - // 1.获取WMS库位表库位信息 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); locationLambdaQueryWrapper.select(Location::getWarehouseCode, Location::getCode, Location::getContainerCode, Location::getStatus) .eq(Location::getWarehouseCode, queryCompareLocationDto.getWarehouseCode()) + .eq(StringUtils.isNotEmpty(queryCompareLocationDto.getZoneCode()), Location::getZoneCode, queryCompareLocationDto.getZoneCode()) .eq(StringUtils.isNotEmpty(queryCompareLocationDto.getLocationCode()), Location::getCode, queryCompareLocationDto.getLocationCode()) .eq(StringUtils.isNotEmpty(queryCompareLocationDto.getContainerCode()), Location::getContainerCode, queryCompareLocationDto.getContainerCode()); List<Location> locationList = list(locationLambdaQueryWrapper); if (!CollectionUtils.isEmpty(locationList)) { locationMap.putAll(locationList.stream().collect(Collectors.toMap(Location::getCode, Function.identity(), (key1, key2) -> key2))); - locationCodes.addAll(locationList.stream().map(t -> t.getCode()).collect(Collectors.toSet())); + locationCodes.addAll(locationList.stream().map(t -> t.getCode()).distinct().collect(Collectors.toSet())); } - if (!CollectionUtils.isEmpty(locationCodes)) { - // 2.获取WMS托盘表库位信息 - LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery(); - containerLambdaQueryWrapper.select(Container::getWarehouseCode, Container::getLocationCode, Container::getCode, Container::getStatus) - .eq(Container::getWarehouseCode, queryCompareLocationDto.getWarehouseCode()).in(Container::getLocationCode, locationCodes); - List<Container> containerList = containerService.list(containerLambdaQueryWrapper); - if (!CollectionUtils.isEmpty(containerList)) { - containerMap.putAll(containerList.stream().collect(Collectors.groupingBy(Container::getLocationCode))); - } - - // 3.获取WMS库存表库位信息 - LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); - inventoryDetailLambdaQueryWrapper - .select(InventoryDetail::getWarehouseCode, InventoryDetail::getLocationCode, InventoryDetail::getContainerCode, InventoryDetail::getInventoryStatus) - .eq(InventoryDetail::getWarehouseCode, queryCompareLocationDto.getWarehouseCode()).in(InventoryDetail::getLocationCode, locationCodes); - List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper); - if (!CollectionUtils.isEmpty(inventoryDetailList)) { - inventoryDetailMap.putAll(inventoryDetailList.stream().collect(Collectors.groupingBy(InventoryDetail::getLocationCode))); + List<List<String>> partitionList = ListUtils.partition(locationCodes, 200); + for (List<String> list : partitionList) { + // 2.获取WMS托盘表库位信息 + LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery(); + containerLambdaQueryWrapper.select(Container::getWarehouseCode, Container::getLocationCode, Container::getCode, Container::getStatus) + .eq(Container::getWarehouseCode, queryCompareLocationDto.getWarehouseCode()).in(Container::getLocationCode, list); + List<Container> containerList = containerService.list(containerLambdaQueryWrapper); + if (!CollectionUtils.isEmpty(containerList)) { + containerMap.putAll(containerList.stream().collect(Collectors.groupingBy(Container::getLocationCode))); + } + // 3.获取WMS库存表库位信息 + LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); + inventoryDetailLambdaQueryWrapper + .select(InventoryDetail::getWarehouseCode, InventoryDetail::getLocationCode, InventoryDetail::getContainerCode, + InventoryDetail::getInventoryStatus) + .eq(InventoryDetail::getWarehouseCode, queryCompareLocationDto.getWarehouseCode()).in(InventoryDetail::getLocationCode, list); + List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper); + if (!CollectionUtils.isEmpty(inventoryDetailList)) { + inventoryDetailMap.putAll(inventoryDetailList.stream().collect(Collectors.groupingBy(InventoryDetail::getLocationCode))); + } } - // 4.获取WCS库位信息 - String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_WCS_LOCATION_INFO); + String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_WCS_LOCATION_INFO, queryCompareLocationDto.getWarehouseCode(), + queryCompareLocationDto.getZoneCode()); Map<String, Object> queryParamMap = new HashMap<String, Object>(); if (StringUtils.isNotEmpty(queryCompareLocationDto.getWarehouseCode())) { queryParamMap.put("warehouseCode", queryCompareLocationDto.getWarehouseCode()); @@ -504,9 +512,7 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i } } } - // 对返回数据进行组装 - List<CompareLocationDto> compareLocationDtoList = new ArrayList<CompareLocationDto>(); if (!CollectionUtils.isEmpty(locationCodes)) { for (String locationCode : locationCodes) { if (StringUtils.isEmpty(locationCode)) { @@ -524,7 +530,6 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i if (!CollectionUtils.isEmpty(containerGroupList)) { Set<String> containerCodes = containerGroupList.stream().map(t -> t.getCode()).collect(Collectors.toSet()); Set<String> containerStatus = containerGroupList.stream().map(t -> t.getStatus()).collect(Collectors.toSet()); - compareLocationDto.setContainerContainerCode(StringUtils.join(containerCodes, ",")); compareLocationDto.setContainerStatus(StringUtils.join(containerStatus, ",")); } @@ -545,10 +550,13 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i if (ObjectUtil.compare(compareLocationDto.getLocationContainerCode(), compareLocationDto.getContainerContainerCode()) != 0 || ObjectUtil.compare(compareLocationDto.getLocationContainerCode(), compareLocationDto.getInventoryContainerCode()) != 0 || ObjectUtil.compare(compareLocationDto.getLocationContainerCode(), compareLocationDto.getWcsContainerCode()) != 0 - || ObjectUtil.compare(compareLocationDto.getLocationStatus(), compareLocationDto.getContainerStatus()) != 0 || ObjectUtil.compare(compareLocationDto.getLocationStatus(), compareLocationDto.getWcsLocationStatus()) != 0) { compareLocationDto.setConsistencyStatus(0); } + if (!StringUtils.isEmpty(location.getContainerCode()) + && ObjectUtil.compare(compareLocationDto.getLocationStatus(), compareLocationDto.getContainerStatus()) != 0) { + compareLocationDto.setConsistencyStatus(0); + } compareLocationDtoList.add(compareLocationDto); } if (queryCompareLocationDto.getConsistencyStatus() != null) { @@ -563,11 +571,11 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i @Override public PageUtil<CompareLocationTaskDto> compareWcsLocationTask(QueryCompareLocationTaskDto queryCompareLocationTaskDto) { List<CompareLocationTaskDto> finalCompareLocationTaskList = new ArrayList<CompareLocationTaskDto>(); -// if (queryCompareLocationTaskDto.getLocationCode() == null) { -// return PageUtil.create(finalCompareLocationTaskList, queryCompareLocationTaskDto.getPageNo(), queryCompareLocationTaskDto.getPageSize()); -// } - // 只查询近90天的数据 -// String queryCreateTime = DateUtil.format(DateUtil.offsetDay(new Date(), -90), DatePattern.NORM_DATE_PATTERN); + if (StringUtils.isEmpty(queryCompareLocationTaskDto.getLocationCode())) { + return PageUtil.create(finalCompareLocationTaskList, queryCompareLocationTaskDto.getPageNo(), queryCompareLocationTaskDto.getPageSize()); + } + // 只查询近180天的数据 + String queryCreateTime = DateUtil.format(DateUtil.offsetDay(new Date(), -180), DatePattern.NORM_DATE_PATTERN); // 1.获取WMS任务信息 LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); taskHeaderLambdaQueryWrapper @@ -577,15 +585,20 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i .gt(StringUtils.isNotEmpty(queryCompareLocationTaskDto.getTaskCreateTimeBegin()), TaskHeader::getCreateTime, queryCompareLocationTaskDto.getTaskCreateTimeBegin()) .lt(StringUtils.isNotEmpty(queryCompareLocationTaskDto.getTaskCreateTimeEnd()), TaskHeader::getCreateTime, - queryCompareLocationTaskDto.getTaskCreateTimeEnd()); -// .ge(TaskHeader::getCreateTime, queryCreateTime) + queryCompareLocationTaskDto.getTaskCreateTimeEnd()) + .ge(TaskHeader::getCreateTime, queryCreateTime); if (StringUtils.isNotEmpty(queryCompareLocationTaskDto.getLocationCode())) { taskHeaderLambdaQueryWrapper.and(t -> t.eq(TaskHeader::getFromLocationCode, queryCompareLocationTaskDto.getLocationCode()).or() .eq(TaskHeader::getToLocationCode, queryCompareLocationTaskDto.getLocationCode())); } List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper); + if (CollectionUtils.isEmpty(taskHeaderList)) { + return PageUtil.create(finalCompareLocationTaskList, queryCompareLocationTaskDto.getPageNo(), queryCompareLocationTaskDto.getPageSize()); + } // 2.获取WCS任务信息 - String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_WCS_TAKS_INFOS); + Map<Integer, List<WcsTaskDto>> wcsTaskMap = new HashMap<Integer, List<WcsTaskDto>>(); + String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_WCS_TAKS_INFOS, queryCompareLocationTaskDto.getWarehouseCode(), + taskHeaderList.get(0).getZoneCode()); Map<String, Object> queryParamMap = new HashMap<String, Object>(); if (StringUtils.isNotEmpty(queryCompareLocationTaskDto.getWarehouseCode())) { queryParamMap.put("warehouseCode", queryCompareLocationTaskDto.getWarehouseCode()); @@ -599,18 +612,15 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i if (StringUtils.isNotEmpty(queryCompareLocationTaskDto.getTaskCreateTimeEnd())) { queryParamMap.put("end", queryCompareLocationTaskDto.getTaskCreateTimeEnd()); } -// queryParamMap.put("begin", queryCreateTime); + queryParamMap.put("begin", queryCreateTime); String jsonStringResult = OkHttpUtils.sendPostByJsonStr(url, JSON.toJSONString(queryParamMap)); WcsResultDto<List<WcsTaskDto>> wcsResult = JSON.parseObject(jsonStringResult, new TypeReference<WcsResultDto<List<WcsTaskDto>>>() {}); - - Map<Integer, List<WcsTaskDto>> wcsTaskMap = new HashMap<Integer, List<WcsTaskDto>>(); if (wcsResult.getCode() != null && wcsResult.getCode().equals(200)) { List<WcsTaskDto> wcsTaskList = wcsResult.getData(); if (wcsTaskList != null && wcsTaskList.size() > 0) { wcsTaskMap.putAll(wcsTaskList.stream().collect(Collectors.groupingBy(WcsTaskDto::getTaskNo))); } } - // 对返回数据进行组装 List<CompareLocationTaskDto> wcsCompareLocationTaskList = new ArrayList<CompareLocationTaskDto>(); if (!CollectionUtils.isEmpty(taskHeaderList)) {