diff --git a/ant-design-vue-jeecg/src/components/tools/HeaderNotice.vue b/ant-design-vue-jeecg/src/components/tools/HeaderNotice.vue index 0dd05fa..584f4c2 100644 --- a/ant-design-vue-jeecg/src/components/tools/HeaderNotice.vue +++ b/ant-design-vue-jeecg/src/components/tools/HeaderNotice.vue @@ -228,6 +228,7 @@ export default { websocketOnmessage: function (e) { console.log("-----接收消息-------", e.data); var data = eval("(" + e.data + ")"); //解析对象 + this.openNotification(data) if (data.cmd == "topic") { //系统通知 this.loadData(); 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..0a5d48b 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: [ { @@ -114,6 +129,20 @@ export default { dataIndex: 'locationCode' }, { + title: '库位表状态', + align: 'center', + dataIndex: 'locationStatus', + key: 'locationStatus', + scopedSlots: { customRender: 'locationStatus' } + }, + { + title: 'WCS库位表状态', + align: 'center', + dataIndex: 'wcsLocationStatus', + key: 'wcsLocationStatus', + scopedSlots: { customRender: 'wcsLocationStatus' } + }, + { title: '库位表容器编码', align: 'center', dataIndex: 'locationContainerCode' @@ -134,13 +163,6 @@ export default { dataIndex: 'wcsContainerCode' }, { - title: '库位表状态', - align: 'center', - dataIndex: 'locationStatus', - key: 'locationStatus', - scopedSlots: { customRender: 'locationStatus' } - }, - { title: '托盘表状态', align: 'center', dataIndex: 'containerStatus', @@ -148,13 +170,6 @@ export default { scopedSlots: { customRender: 'containerStatus' } }, { - title: 'WCS库位表状态', - align: 'center', - dataIndex: 'wcsLocationStatus', - key: 'wcsLocationStatus', - scopedSlots: { customRender: 'wcsLocationStatus' } - }, - { title: '数据状态', align: 'center', dataIndex: 'consistencyStatus', @@ -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/ant-design-vue-jeecg/src/views/system/config/ContainerList.vue b/ant-design-vue-jeecg/src/views/system/config/ContainerList.vue index c7a21ec..c247fbc 100644 --- a/ant-design-vue-jeecg/src/views/system/config/ContainerList.vue +++ b/ant-design-vue-jeecg/src/views/system/config/ContainerList.vue @@ -14,22 +14,22 @@ <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-form-item label="容器类型"> + <a-select + show-search + placeholder="请选择容器类型" + option-filter-prop="children" + v-model="queryParam.containerTypeCode" + > + <a-select-option v-for="item in containerTypeList" :key="item.name" :value="item.code" + >{{ item.name }} + </a-select-option> + </a-select> + </a-form-item> + </a-col> <template v-if="toggleSearchStatus"> <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.containerTypeCode" - > - <a-select-option v-for="item in containerTypeList" :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="容器状态"> <j-dict-select-tag placeholder="请选择容器状态" diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java index 91f73fe..5b36c0f 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java @@ -262,7 +262,7 @@ public class WcsServiceImpl implements WcsService { if (!taskHeaderService.updateById(taskHeader)) { throw new JeecgBootException("更新任务头表目标库位失败"); } - + WcsTask wcsTask = new WcsTask(); wcsTask.setToLocationCode(locationCode); wcsTask.setPreTaskNo(String.valueOf(preTaskNo)); @@ -350,7 +350,7 @@ public class WcsServiceImpl implements WcsService { } Result<TaskHeader> result = taskHeaderService.createTransferTask(insideLocation.getCode(), destinationLocation.getCode(), warehouseCode); if (!result.isSuccess()) { - throw new JeecgBootException("创建移库任务失败"); + throw new JeecgBootException(result.getMessage()); } preTaskNo = result.getResult().getId(); taskHeader.setPreTaskNo(preTaskNo); @@ -634,6 +634,8 @@ public class WcsServiceImpl implements WcsService { originLocationCode = originLocationCode + "," + taskLocationCode; } + taskHeader = new TaskHeader(); + taskHeader.setId(Integer.parseInt(taskNo)); taskHeader.setToLocationCode(locationCode); taskHeader.setExceptionName("重入处理"); taskHeader.setIsDoubleIn(QuantityConstant.DOUBLE_IN); 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..e6e2aef 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,8 +4,8 @@ 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; import java.util.Map; import java.util.Set; @@ -14,6 +14,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; @@ -92,7 +93,7 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i @Resource private IInventoryDetailService inventoryDetailService; - + @Autowired private ILocationService locationService; @@ -446,47 +447,52 @@ 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, 1000); + 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) + .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 +510,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,16 +528,13 @@ 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, ",")); } List<InventoryDetail> inventoryGroupList = inventoryDetailMap.get(locationCode); if (!CollectionUtils.isEmpty(inventoryGroupList)) { Set<String> inventoryContainerCodes = inventoryGroupList.stream().map(t -> t.getContainerCode()).collect(Collectors.toSet()); - Set<String> inventoryStatus = inventoryGroupList.stream().map(t -> t.getInventoryStatus()).collect(Collectors.toSet()); compareLocationDto.setInventoryContainerCode(StringUtils.join(inventoryContainerCodes, ",")); - compareLocationDto.setInventoryStatus(StringUtils.join(inventoryStatus, ",")); } List<WcsLocationDto> wcsLocationGroupList = wcsLocationMap.get(locationCode); if (!CollectionUtils.isEmpty(wcsLocationGroupList)) { @@ -542,12 +543,32 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i compareLocationDto.setWcsContainerCode(StringUtils.join(wcsContainerCodes, ",")); compareLocationDto.setWcsLocationStatus(StringUtils.join(wcsContainerStatus, ",")); } - 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); + // 值不为null时 ,才比较数据是否匹配 + if (!StringUtils.isEmpty(compareLocationDto.getLocationContainerCode()) || !StringUtils.isEmpty(compareLocationDto.getContainerContainerCode())) { + if (ObjectUtil.compare(compareLocationDto.getLocationContainerCode(), compareLocationDto.getContainerContainerCode()) != 0) { + compareLocationDto.setConsistencyStatus(0); + } + } + // 库存表有库存信息时才比较库存表容器信息 + if (!StringUtils.isEmpty(compareLocationDto.getLocationContainerCode()) && !StringUtils.isEmpty(compareLocationDto.getInventoryContainerCode())) { + if (ObjectUtil.compare(compareLocationDto.getLocationContainerCode(), compareLocationDto.getInventoryContainerCode()) != 0) { + compareLocationDto.setConsistencyStatus(0); + } + } + if (!StringUtils.isEmpty(compareLocationDto.getLocationContainerCode()) || !StringUtils.isEmpty(compareLocationDto.getWcsContainerCode())) { + if (ObjectUtil.compare(compareLocationDto.getLocationContainerCode(), compareLocationDto.getWcsContainerCode()) != 0) { + compareLocationDto.setConsistencyStatus(0); + } + } + if (!StringUtils.isEmpty(compareLocationDto.getLocationStatus()) || !StringUtils.isEmpty(compareLocationDto.getWcsLocationStatus())) { + if (ObjectUtil.compare(compareLocationDto.getLocationStatus(), compareLocationDto.getWcsLocationStatus()) != 0) { + compareLocationDto.setConsistencyStatus(0); + } + } + if (!StringUtils.isEmpty(location.getContainerCode())) { + if (ObjectUtil.compare(compareLocationDto.getLocationStatus(), compareLocationDto.getContainerStatus()) != 0) { + compareLocationDto.setConsistencyStatus(0); + } } compareLocationDtoList.add(compareLocationDto); } @@ -563,11 +584,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 (queryCompareLocationTaskDto.getLocationCode() == null) { + 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 +598,25 @@ 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())); } + LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); + locationLambdaQueryWrapper.eq(Location::getCode, queryCompareLocationTaskDto.getLocationCode()); + Location location = locationService.getOne(locationLambdaQueryWrapper); + if (location == null) { + return PageUtil.create(finalCompareLocationTaskList, queryCompareLocationTaskDto.getPageNo(), queryCompareLocationTaskDto.getPageSize()); + } 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(), location.getZoneCode()); Map<String, Object> queryParamMap = new HashMap<String, Object>(); if (StringUtils.isNotEmpty(queryCompareLocationTaskDto.getWarehouseCode())) { queryParamMap.put("warehouseCode", queryCompareLocationTaskDto.getWarehouseCode()); @@ -599,18 +630,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)) { @@ -635,11 +663,29 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i compareLocationTaskDto.setWcsContainerCode(wcsTaskDto.getContainerCode()); compareLocationTaskDto.setWcsTaskStatus(wcsTaskDto.getTaskStatus()); compareLocationTaskDto.setWcsTaskCreateTime(wcsTaskDto.getCreated()); - if (ObjectUtil.compare(compareLocationTaskDto.getFromLocationCode(), compareLocationTaskDto.getWcsFromLocationCode()) != 0 - || ObjectUtil.compare(compareLocationTaskDto.getToLocationCode(), compareLocationTaskDto.getWcsToLocationCode()) != 0 - || ObjectUtil.compare(compareLocationTaskDto.getContainerCode(), compareLocationTaskDto.getWcsContainerCode()) != 0 - || ObjectUtil.compare(compareLocationTaskDto.getTaskStatus(), compareLocationTaskDto.getWcsTaskStatus()) != 0) { - compareLocationTaskDto.setConsistencyStatus(0); + // 值不为null时 ,才比较数据是否匹配 + if (!StringUtils.isEmpty(compareLocationTaskDto.getFromLocationCode()) + || !StringUtils.isEmpty(compareLocationTaskDto.getWcsFromLocationCode())) { + if (ObjectUtil.compare(compareLocationTaskDto.getFromLocationCode(), compareLocationTaskDto.getWcsFromLocationCode()) != 0) { + compareLocationTaskDto.setConsistencyStatus(0); + } + } + if (!StringUtils.isEmpty(compareLocationTaskDto.getToLocationCode()) + || !StringUtils.isEmpty(compareLocationTaskDto.getWcsToLocationCode())) { + if (ObjectUtil.compare(compareLocationTaskDto.getToLocationCode(), compareLocationTaskDto.getWcsToLocationCode()) != 0) { + compareLocationTaskDto.setConsistencyStatus(0); + } + } + if (!StringUtils.isEmpty(compareLocationTaskDto.getContainerCode()) || !StringUtils.isEmpty(compareLocationTaskDto.getWcsContainerCode())) { + if (ObjectUtil.compare(compareLocationTaskDto.getContainerCode(), compareLocationTaskDto.getWcsContainerCode()) != 0) { + compareLocationTaskDto.setConsistencyStatus(0); + } + } + if (!StringUtils.isEmpty(compareLocationTaskDto.getTaskStatus() + "") + || !StringUtils.isEmpty(compareLocationTaskDto.getWcsTaskStatus() + "")) { + if (ObjectUtil.compare(compareLocationTaskDto.getTaskStatus(), compareLocationTaskDto.getWcsTaskStatus()) != 0) { + compareLocationTaskDto.setConsistencyStatus(0); + } } wcsCompareLocationTaskList.add(compareLocationTaskDto); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java index 09b1e93..72df89c 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java @@ -365,7 +365,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi shipmentContainerHeader = new ShipmentContainerHeader(); shipmentContainerHeader.setContainerCode(containerCode); shipmentContainerHeader.setFromLocationCode(locationCode); - if (taskLocationRule == QuantityConstant.RULE_TASK_SET_LOCATION) { + if (taskLocationRule == QuantityConstant.RULE_TASK_SET_LOCATION && taskType == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT) { shipmentContainerHeader.setToLocationCode(locationCode); } shipmentContainerHeader.setWarehouseCode(warehouseCode); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java index 9f421af..e118dfb 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java @@ -305,6 +305,14 @@ public interface ITaskHeaderService extends IService<TaskHeader> { boolean updateStatusById(int status, int id); /** + * 更新 + * @param status + * @param id + * @return + */ + boolean updateExceptionStateById(int status, int id); + + /** * 更新状态 * @param preTaskNo * @param id diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java index febd237..4104ea2 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java @@ -550,6 +550,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @Override @Transactional(rollbackFor = Exception.class) public Result handleEmptyOut(String taskNo) { + log.info("开始处理空出任务" + taskNo); // 1、判断非空字段 if (StringUtils.isEmpty(taskNo)) { return Result.error("处理空出失败,任务号为空"); @@ -615,15 +616,18 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea } // 9 更新单据 taskHeader.setExceptionState(QuantityConstant.EXCEPTION_TASK_HANDLE); - success = taskHeaderService.updateById(taskHeader); + success = taskHeaderService.updateExceptionStateById(QuantityConstant.EXCEPTION_TASK_HANDLE, taskHeader.getId()); if (!success) { throw new JeecgBootException("处理空出失败,更新任务失败"); } + log.info("完成处理空出任务" + taskNo); return Result.ok("处理空出成功"); } @Override + @Transactional(rollbackFor = Exception.class) public Result handleDoubleIn(String taskNo) { + log.info("开始处理重入任务" + taskNo); // 1、判断非空字段 if (StringUtils.isEmpty(taskNo)) { return Result.error("处理重入失败,任务号为空"); @@ -661,22 +665,24 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (toLocation == null) { return Result.error("处理重入失败,没有找到库位"); } - toLocation.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY); - boolean success = locationService.updateById(toLocation); + boolean success = locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); if (!success) { throw new JeecgBootException("处理重入失败,更新库位失败"); } } taskHeader.setExceptionState(QuantityConstant.EXCEPTION_TASK_HANDLE); - boolean success = taskHeaderService.updateById(taskHeader); + boolean success = taskHeaderService.updateExceptionStateById(QuantityConstant.EXCEPTION_TASK_HANDLE, taskHeader.getId()); if (!success) { throw new JeecgBootException("处理重入失败,更新任务失败"); } + log.info("完成处理重入任务" + taskNo); return Result.ok("处理重入成功"); } @Override + @Transactional(rollbackFor = Exception.class) public Result handlePickupError(String taskNo) { + log.info("开始处理取货错任务" + taskNo); // 1、判断非空字段 if (StringUtils.isEmpty(taskNo)) { return Result.error("处理取货错失败,任务号为空"); @@ -691,12 +697,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea return Result.OK("处理取货错失败, 任务已经完成"); } + taskHeader = new TaskHeader(); + taskHeader.setId(Integer.parseInt(taskNo)); taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); taskHeader.setExceptionState(QuantityConstant.EXCEPTION_TASK_HANDLE); boolean success = taskHeaderService.updateById(taskHeader); if (!success) { throw new JeecgBootException("处理取货错失败,更新任务失败"); } + log.info("完成处理取货错任务" + taskNo); return Result.ok("处理取货错成功"); } @@ -1121,27 +1130,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea throw new JeecgBootException("完成入库任务时,保存库存交易失败"); } - if (StringUtils.isNotEmpty(fromLocationCode) && !fromLocationCode.equals(toLocationCode)) { - success = - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成入库任务时,更新源库位失败"); - } - } - - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成入库任务时,更新库位失败"); - } - - success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); - if (!success) { - throw new JeecgBootException("完成入库任务时,更新任务失败"); - } - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, - taskHeader.getContainerFillStatus(), warehouseCode); - if (!success) { - throw new JeecgBootException("完成入库任务时,更新容器失败"); + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode, + toLocationCode, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); } if (!taskHeaderService.combineInventoryDetail(taskHeader)) { throw new JeecgBootException("合并入库库存失败"); @@ -1159,6 +1151,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode)) { throw new JeecgBootException("完成入库任务时,更新托盘状态失败"); } + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); + if (!success) { + throw new JeecgBootException("完成出库任务,保存任务头失败"); + } receiptDetaiList = receiptDetaiList.stream().filter(t -> t.getStatus().equals(QuantityConstant.RECEIPT_HEADER_COMPLETED)).collect(Collectors.toList()); LogRecordContext.putVariable("taskHeader", taskHeader); LogRecordContext.putVariable("extraJsonString1", JSON.toJSONString(taskDetailList)); @@ -1309,44 +1305,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (!success) { throw new JeecgBootException("完成出库任务,保存库存详情失败"); } - taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); - success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); - if (!success) { - throw new JeecgBootException("完成出库任务,保存任务头失败"); - } - if (taskType == QuantityConstant.TASK_TYPE_WHOLESHIPMENT) { - success = - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成整盘出库任务,更新源库位失败"); - } - success = containerService.updateLocationCodeAndStatus(containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY, - QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成整盘出库任务,更新容器失败"); - } - } else if (taskType == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT) { - if (!fromLocationCode.equals(toLocationCode)) { - success = locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, - warehouseCode); - if (!success) { - throw new JeecgBootException("完成分拣出库任务,更新源库位失败"); - } - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成分拣出库任务,更新目标库位失败"); - } - } else { - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成分拣出库任务,更新源库位失败"); - } - } - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, - inventoryDetailList.size() == 0 ? QuantityConstant.STATUS_CONTAINER_FILL_EMPTY : QuantityConstant.STATUS_CONTAINER_FILL_SOME, warehouseCode); - if (!success) { - throw new JeecgBootException("完成分拣出库任务,更新容器失败"); - } + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode, + toLocationCode, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); } ShipmentContainerHeader shipmentContainerHeader = shipmentContainerHeaderService.getById(taskHeader.getShipmentContainerHeaderId()); if (shipmentContainerHeader == null) { @@ -1378,6 +1340,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea throw new JeecgBootException("完成出库任务,更新库存状态失败"); } } + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); + if (!success) { + throw new JeecgBootException("完成出库任务,保存任务头失败"); + } // 操作记录添加 shipmentDetailList = shipmentDetailList.stream().filter(t -> t.getStatus().equals(QuantityConstant.SHIPMENT_HEADER_COMPLETED)).collect(Collectors.toList()); LogRecordContext.putVariable("taskHeader", taskHeader); @@ -1599,7 +1565,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea } zoneCode = fromLocation.getZoneCode(); taskLockEntity.setZoneCode(zoneCode); - if (StringUtils.isNotEmpty(toLocationCode)) { + if (StringUtils.isNotEmpty(toLocationCode) && !fromLocationCode.equals(toLocationCode)) { Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); if (toLocation == null) { return Result.error("创建分拣任务时," + toLocationCode + "目标库位不存在"); @@ -1620,9 +1586,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea throw new JeecgBootException("创建分拣任务时,更新库位状态失败"); } if (StringUtils.isNotEmpty(toLocationCode)) { - success = locationService.updateStatus(toLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); - if (!success) { - throw new JeecgBootException("创建分拣任务时,更新库位状态失败"); + if (!fromLocationCode.equals(toLocationCode)) { + success = locationService.updateStatus(toLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); + if (!success) { + throw new JeecgBootException("创建分拣任务时,更新库位状态失败"); + } } } return Result.OK("创建分拣任务成功", taskLockEntity); @@ -1654,26 +1622,42 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea String toLocationCode, String warehouseCode) { Result result = null; boolean success = false; - if (StringUtils.isEmpty(toLocationCode) && taskType == QuantityConstant.TASK_TYPE_OVER_STATION) { - return Result.error("完成任务时, 目标库位号为空"); + if (StringUtils.isEmpty(containerCode)) { + return Result.error("任务类型" + taskType + "完成任务时, 容器号为空"); + } + Container container = containerService.getContainerByCode(containerCode, warehouseCode); + if (container == null) { + return Result.error("任务类型" + taskType + "完成任务时, 没有找到托盘" + containerCode); } switch (taskType) { case QuantityConstant.TASK_TYPE_WHOLERECEIPT: case QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT: + if (StringUtils.isEmpty(toLocationCode)) { + return Result.error("任务类型" + taskType + "完成任务时, 目标库位号为空"); + } success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, containerFillStatus, warehouseCode); break; case QuantityConstant.TASK_TYPE_EMPTYRECEIPT: + if (StringUtils.isEmpty(toLocationCode)) { + return Result.error("任务类型" + taskType + "完成任务时, 目标库位号为空"); + } success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode); break; case QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT: + if (StringUtils.isEmpty(toLocationCode)) { + return Result.error("任务类型" + taskType + "完成任务时, 目标库位号为空"); + } success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, QuantityConstant.STATUS_CONTAINER_FILL_MANY, warehouseCode); break; case QuantityConstant.TASK_TYPE_WHOLESHIPMENT: case QuantityConstant.TASK_TYPE_EMPTYSHIPMENT: case QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT: + if (StringUtils.isEmpty(fromLocationCode)) { + return Result.error("任务类型" + taskType + "完成任务时, 起始库位号为空"); + } success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode); break; @@ -1681,13 +1665,27 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea case QuantityConstant.TASK_TYPE_CYCLECOUNT: case QuantityConstant.TASK_TYPE_TRANSFER: case QuantityConstant.TASK_TYPE_CHECK_OUT: + if (StringUtils.isEmpty(fromLocationCode)) { + return Result.error("任务类型" + taskType + "完成任务时, 起始库位号为空"); + } + if (StringUtils.isEmpty(toLocationCode)) { + return Result.error("任务类型" + taskType + "完成任务时, 目标库位号为空"); + } InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode); if (inventoryHeader != null) { - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, - QuantityConstant.STATUS_CONTAINER_FILL_SOME, warehouseCode); + if (fromLocationCode.equals(toLocationCode)) { + success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); + } else { + success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, + QuantityConstant.STATUS_CONTAINER_FILL_SOME, warehouseCode); + } } else { - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, - QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode); + if (fromLocationCode.equals(toLocationCode)) { + success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); + } else { + success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, + QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode); + } } break; case QuantityConstant.TASK_TYPE_OVER_STATION: @@ -1696,20 +1694,30 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea break; } if (!success) { - throw new JeecgBootException("完成任务时,更新容器失败"); + throw new JeecgBootException("任务类型" + taskType + "完成任务时, 更新容器失败"); } if (StringUtils.isNotEmpty(fromLocationCode) && !fromLocationCode.equals(toLocationCode)) { + Location toLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode); + if (toLocation == null) { + return Result.error("任务类型" + taskType + "完成任务时," + toLocationCode + "目标库位不存在"); + } success = locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); if (!success) { - throw new JeecgBootException("完成任务时,更新源库位失败"); + throw new JeecgBootException("任务类型" + taskType + "完成任务时,更新源库位失败"); } } - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成任务时,更新库位失败"); + if (StringUtils.isNotEmpty(toLocationCode)) { + Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); + if (toLocation == null) { + return Result.error("任务类型" + taskType + "完成任务时, " + toLocationCode + "目标库位不存在"); + } + success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); + if (!success) { + throw new JeecgBootException("任务类型" + taskType + "完成任务时,更新库位失败"); + } } - return Result.OK("完成任务成功"); + return Result.OK("任务类型" + taskType + "完成任务成功"); } /** @@ -1733,27 +1741,16 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (StringUtils.isEmpty(toLocationCode)) { return Result.error("完成空托盘入库任务时, 目标库位号为空"); } - Container container = containerService.getContainerByCode(containerCode, warehouseCode); - if (container == null) { - return Result.error("完成空托盘入库任务时, 没有找到托盘" + containerCode); - } - Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); - if (toLocation == null) { - return Result.error("完成空托盘入库任务时," + toLocationCode + "目标库位不存在"); - } - boolean success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成空托盘入库任务时, 更新容器的库位号和状态失败"); + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_EMPTYRECEIPT, + containerCode, QuantityConstant.EMPTY_STRING, toLocationCode, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); } - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); + boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); if (!success) { - throw new JeecgBootException("完成空托盘入库任务时, 更新库位的容器编码和状态失败"); + throw new JeecgBootException("完成空托盘出库任务时, 更新任务失败"); } - success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); log.info("完成空托入库任务"); - if (!success) { - throw new JeecgBootException("完成空托盘入库任务时, 更新任务失败"); - } return Result.OK("完成空托盘入库成功"); } @@ -1787,7 +1784,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea // 1.先拿到盘点单主单据 CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(taskHeader.getShipmentContainerHeaderId()); - if ((cycleCountDetail.getCountedQty().add(cycleCountDetail.getGapQty())).compareTo(BigDecimal.ZERO) == 0) { + if (cycleCountDetail.getGapQty().compareTo(BigDecimal.ZERO) == 0) { return Result.error("盘点单据系统实盘数量跟差异数量0,不能完成 单据号" + cycleCountDetail.getCycleCountHeadCode()); } @@ -2042,17 +2039,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (port == null) { return Result.error("完成空托盘出库任务时," + toPortCode + "目标出库口不存在"); } - boolean success = - containerService.updateLocationCodeAndStatus(containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成空托盘出库任务时, 更新容器的库位号和状态失败"); - } - success = - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成空托盘出库任务时, 更新库位的容器编码和状态失败"); + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_EMPTYSHIPMENT, + containerCode, fromLocationCode, QuantityConstant.EMPTY_STRING, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); } - success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); + boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); log.info("完成空托盘出库任务" + taskHeader.getId()); if (!success) { throw new JeecgBootException("完成空托盘出库任务时, 更新任务失败"); @@ -2119,24 +2111,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea throw new JeecgBootException("完成移库任务时,保存库存交易失败"); } } - taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); - success = taskHeaderService.updateById(taskHeader); - if (!success) { - throw new JeecgBootException("完成移库任务时, 更新任务失败"); - } - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成移库任务时, 更新容器状态失败"); - } - success = - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成移库任务时, 更新起始库位状态失败"); - } - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成移库任务时, 更新目标库位状态失败"); - } LambdaUpdateWrapper<InventoryHeader> inventoryHeaderLambdaUpdateWrapper = Wrappers.lambdaUpdate(); inventoryHeaderLambdaUpdateWrapper.eq(InventoryHeader::getWarehouseCode, warehouseCode).eq(InventoryHeader::getContainerCode, containerCode) .eq(InventoryHeader::getLocationCode, fromLocationCode); @@ -2154,6 +2128,16 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea throw new JeecgBootException("完成移库任务时, 更新库存详情失败"); } } + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_TRANSFER, + containerCode, fromLocationCode, toLocationCode, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); + } + taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); + if (!success) { + throw new JeecgBootException("完成移库任务时, 更新任务失败"); + } log.info("完成移库任务" + taskHeader.getId()); return Result.OK("完成移库任务成功"); } @@ -2218,42 +2202,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (!success) { throw new JeecgBootException("完成出库查看任务时,更新库存头失败"); } - if (fromLocationCode.equals(toLocationCode)) { - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - } else { - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - } - if (!success) { - throw new JeecgBootException("完成出库查看任务时,更新容器状态失败"); - } - } else { - if (fromLocationCode.equals(toLocationCode)) { - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - } else { - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - } - if (!success) { - throw new JeecgBootException("完成出库查看任务时,更新容器状态失败"); - } } - if (!fromLocationCode.equals(toLocationCode)) { - success = - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成出库查看任务时,更新源库位失败"); - } - } else { - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成出库查看任务时,更新源库位失败"); - } - } - if (StringUtils.isNotEmpty(fromLocationCode) && !fromLocationCode.equals(toLocationCode)) { - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成出库查看任务时,更新目标库位失败"); - } + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_CHECK_OUT, + containerCode, fromLocationCode, toLocationCode, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); } taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); @@ -2301,16 +2255,21 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (toPort == null) { return Result.error("创建跨站任务时,目标站台为空"); } + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_OVER_STATION, + containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.EMPTY_STRING, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); + } taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); if (!success) { throw new JeecgBootException("创建跨站任务时, 更新任务失败"); } - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); +// success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); +// if (!success) { +// throw new JeecgBootException("创建跨站任务时, 更新容器状态失败"); +// } log.info("完成跨站任务" + taskHeader.getId()); - if (!success) { - throw new JeecgBootException("创建跨站任务时, 更新容器状态失败"); - } return Result.OK("完成跨站任务成功"); } @@ -2343,21 +2302,17 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (toLocation == null) { return Result.error("完成空托盘组入库任务时,没有找到库位" + toLocationCode); } + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT, + containerCode, QuantityConstant.EMPTY_STRING, toLocationCode, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); + } taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); if (!success) { throw new JeecgBootException("完成空托盘组入库任务时, 更新任务失败"); } - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_LOCATION_EMPTY, - QuantityConstant.STATUS_CONTAINER_FILL_MANY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成空托盘组入库任务时, 更新容器失败"); - } - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); log.info("完成空托盘组入库任务" + taskHeader.getId()); - if (!success) { - throw new JeecgBootException("完成空托盘组入库任务时, 更新库位失败"); - } return Result.ok("完成空托盘组入库任务成功"); } @@ -2372,6 +2327,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea String warehouseCode = taskHeader.getWarehouseCode(); String containerCode = taskHeader.getContainerCode(); String toPortCode = taskHeader.getToPortCode(); + String fromLocationCode = taskHeader.getFromLocationCode(); log.info("开始完成空托盘组出库任务" + taskHeader.getId()); if (StringUtils.isEmpty(containerCode)) { return Result.error("完成空托盘组出库任务时, 托盘号为空"); @@ -2382,12 +2338,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (StringUtils.isEmpty(toPortCode)) { return Result.error("完成空托盘组出库任务时, 目标出入口为空"); } + if (StringUtils.isEmpty(fromLocationCode)) { + return Result.error("完成空托盘组出库任务时, 起始库位为空"); + } Container container = containerService.getContainerByCode(containerCode, warehouseCode); if (container == null) { return Result.error("完成空托盘组出库任务时,没有找到容器" + containerCode); } - String toLocationCode = container.getLocationCode(); - if (StringUtils.isEmpty(toLocationCode)) { + String locationCode = container.getLocationCode(); + if (StringUtils.isEmpty(locationCode)) { return Result.error("完成空托盘组出库任务时, 容器不在库位上"); } Port port = portService.getPortByCode(toPortCode, warehouseCode); @@ -2399,16 +2358,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (!success) { throw new JeecgBootException("完成空托盘组出库任务时, 更新任务失败"); } - success = containerService.updateLocationCodeAndStatus(containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY, - QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成空托盘组出库任务时, 更新容器失败"); - } - success = locationService.updateContainerCodeAndStatus(toLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - log.info("开始完成空托盘组出库任务" + taskHeader.getId()); - if (!success) { - throw new JeecgBootException("完成空托盘组出库任务时, 更新库位失败"); + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT, + containerCode, fromLocationCode, QuantityConstant.EMPTY_STRING, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); } + log.info("完成空托盘组出库任务" + taskHeader.getId()); return Result.ok("完成空托盘组出库任务成功"); } @@ -2454,6 +2409,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea } @Override + public boolean updateExceptionStateById(int exceptionState, int id) { + TaskHeader taskHeader = new TaskHeader(); + taskHeader.setExceptionState(exceptionState); + taskHeader.setId(id); + boolean success = taskHeaderService.updateById(taskHeader); + return success; + } + + @Override public boolean updatePreTaskNoById(int preTaskNo, int id) { TaskHeader taskHeader = new TaskHeader(); taskHeader.setId(id);