no message
parent
c42824a0aa
commit
77a5d00542
|
|
@ -5,14 +5,13 @@ import java.io.Serializable;
|
|||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.jeecg.common.aspect.annotation.AutoDict;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
|
|
@ -21,10 +20,11 @@ import lombok.experimental.Accessors;
|
|||
* @Date: 2025-10-28
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_point")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "库位")
|
||||
public class Point implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -79,12 +79,6 @@ public class Point implements Serializable {
|
|||
@Schema(description = "层")
|
||||
private java.lang.String layerNum;
|
||||
|
||||
/**
|
||||
* 储位编码
|
||||
*/
|
||||
@Schema(description = "储位编码")
|
||||
private String nodeCode;
|
||||
|
||||
/**
|
||||
* 位置坐标x
|
||||
*/
|
||||
|
|
@ -101,6 +95,7 @@ public class Point implements Serializable {
|
|||
|
||||
/**
|
||||
* 是否双通道
|
||||
* 0-单通道 1-双通道
|
||||
*/
|
||||
@Schema(description = "是否双通道")
|
||||
private Integer izDoubleLane;
|
||||
|
|
|
|||
|
|
@ -46,18 +46,6 @@ public interface IItemService extends IService<Item> {
|
|||
*/
|
||||
Map<Long, Item> queryByItemIdsToMap(List<Long> itemIds);
|
||||
|
||||
|
||||
/**
|
||||
* 构建物料信息
|
||||
*
|
||||
* @param itemCode 物料信息
|
||||
* @param itemName 物料信息
|
||||
* @param unit 物料信息
|
||||
* @param izActive 物料信息
|
||||
* @return Item
|
||||
*/
|
||||
Item buildItem(String itemCode, String itemName, String unit, Integer izActive);
|
||||
|
||||
/**
|
||||
* 同步物料信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.cpte.modules.base.service;
|
||||
|
||||
import org.cpte.modules.base.entity.Item;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
|
@ -109,10 +110,11 @@ public interface IPointService extends IService<Point> {
|
|||
/**
|
||||
* 同步库位信息
|
||||
*
|
||||
* @param pageNum 页数
|
||||
* @param pageSize 结束时间
|
||||
* @param regionCode 子仓编码
|
||||
* @param pageNum 页数
|
||||
* @param pageSize 结束时间
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean syncPoint(Integer pageNum, Integer pageSize);
|
||||
Boolean syncPoint(String regionCode, Integer pageNum, Integer pageSize);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,11 +69,4 @@ public interface IStockService extends IService<Stock> {
|
|||
*/
|
||||
Map<Long, Stock> queryByStockIdsToMap(List<Long> stockIds);
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*
|
||||
* @param insertToStock 创建的容器
|
||||
* @param updateToStock 更新的容器
|
||||
*/
|
||||
void batchOperation(List<Stock> insertToStock, List<Stock> updateToStock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,21 @@
|
|||
package org.cpte.modules.base.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.cpte.modules.base.entity.Item;
|
||||
import org.cpte.modules.base.mapper.ItemMapper;
|
||||
import org.cpte.modules.base.response.ItemResponse;
|
||||
import org.cpte.modules.base.service.IItemService;
|
||||
import org.cpte.modules.base.service.processor.SyncItemProcessor;
|
||||
import org.cpte.modules.constant.GeneralConstant;
|
||||
import org.cpte.modules.utils.BatchUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.RestUtil;
|
||||
import org.jeecg.modules.openapi.mapper.OpenApiMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
|
@ -48,6 +40,9 @@ public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements II
|
|||
@Autowired
|
||||
private BatchUtil batchUtil;
|
||||
|
||||
@Autowired
|
||||
private SyncItemProcessor syncItemProcessor;
|
||||
|
||||
/**
|
||||
* 验证物料
|
||||
*
|
||||
|
|
@ -120,29 +115,6 @@ public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements II
|
|||
}
|
||||
|
||||
@Override
|
||||
public Item buildItem(String itemCode, String itemName, String unit, Integer izActive) {
|
||||
LoginUser sysUser = null;
|
||||
try {
|
||||
sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
} catch (Exception e) {
|
||||
log.error("获取登录用户信息失败");
|
||||
}
|
||||
return Item.builder()
|
||||
.id(IdWorker.getId())
|
||||
.itemCode(itemCode)
|
||||
.itemName(itemName)
|
||||
.unit(unit)
|
||||
.izActive(izActive == 1 ? 1 : 0)
|
||||
.delFlag(0)
|
||||
.sysOrgCode(sysUser == null ? "A05" : sysUser.getOrgCode())
|
||||
.tenantId(sysUser == null ? 1000L : Long.parseLong(sysUser.getRelTenantIds()))
|
||||
.createBy(sysUser == null ? "saiWms" : sysUser.getUsername())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean syncItem(String startDate, String endDate) {
|
||||
LocalDate sDate = LocalDate.parse(startDate.trim());
|
||||
LocalDate eDate = LocalDate.parse(endDate.trim());
|
||||
|
|
@ -160,8 +132,7 @@ public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements II
|
|||
JSONObject materials = GetProductAddList(params);
|
||||
|
||||
// 处理物料数据
|
||||
return processMaterials(materials);
|
||||
|
||||
return syncItemProcessor.syncItem(materials);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -178,102 +149,4 @@ public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements II
|
|||
throw new RuntimeException("获取物料数据失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理物料数据
|
||||
*
|
||||
* @param materials 物料数据
|
||||
* @return Boolean
|
||||
*/
|
||||
private Boolean processMaterials(JSONObject materials) {
|
||||
try {
|
||||
JSONObject data = materials.getJSONObject("data");
|
||||
if (data == null) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
JSONObject result = data.getJSONObject("result");
|
||||
if (result == null) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
JSONArray item1array = result.getJSONArray("item1");
|
||||
if (CollectionUtils.isEmpty(item1array)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
List<String> itemCodes = new ArrayList<>();
|
||||
for (int i = 0; i < item1array.size(); i++) {
|
||||
// 获取每个 LinkedHashMap
|
||||
JSONObject item = item1array.getJSONObject(i);
|
||||
// 获取 itmreF_0 的值
|
||||
String itemCode = item.getString("itmreF_0");
|
||||
itemCodes.add(itemCode);
|
||||
}
|
||||
|
||||
Map<String, Item> itemMap = queryByItemCodesToMap(itemCodes);
|
||||
|
||||
//批量处理
|
||||
List<Item> insertItems = new ArrayList<>();
|
||||
List<Item> updateItems = new ArrayList<>();
|
||||
Set<String> processedItemCodes = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < item1array.size(); i++) {
|
||||
JSONObject item = item1array.getJSONObject(i);
|
||||
String itemCode = item.getString("itmreF_0");
|
||||
String itemName = item.getString("itmdeS1_0");
|
||||
String unit = item.getString("stU_0");
|
||||
Integer izActive = item.getInteger("itmstA_0");
|
||||
// 去重处理
|
||||
if (processedItemCodes.contains(itemCode)) {
|
||||
continue;
|
||||
}
|
||||
processedItemCodes.add(itemCode);
|
||||
|
||||
// 判断新增或更新
|
||||
Item existingItem = itemMap.get(itemCode);
|
||||
if (existingItem == null) {
|
||||
Item newItem = buildItem(itemCode, itemName, unit, izActive);
|
||||
insertItems.add(newItem);
|
||||
} else {
|
||||
// 只有字段变化时才更新
|
||||
if (isItemChanged(existingItem, itemName, unit, izActive)) {
|
||||
updateItemFromMaterial(existingItem, itemName, unit, izActive);
|
||||
updateItems.add(existingItem);
|
||||
}
|
||||
}
|
||||
log.info("处理物料: {}", itemCode);
|
||||
}
|
||||
|
||||
// 批量保存
|
||||
if (CollectionUtils.isNotEmpty(insertItems)) {
|
||||
batchUtil.saveBatchItem(insertItems);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(updateItems)) {
|
||||
batchUtil.updateBatchItem(updateItems);
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
} catch (Exception e) {
|
||||
log.error("处理物料数据失败", e);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查物料是否发生变化
|
||||
*/
|
||||
private boolean isItemChanged(Item item, String itemName, String unit, Integer izActive) {
|
||||
return !Objects.equals(item.getItemName(), itemName) ||
|
||||
!Objects.equals(item.getUnit(), unit) ||
|
||||
!Objects.equals(item.getIzActive(), izActive == 1 ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新物料信息
|
||||
*/
|
||||
private void updateItemFromMaterial(Item item, String itemName, String unit, Integer izActive) {
|
||||
item.setItemName(itemName);
|
||||
item.setUnit(unit);
|
||||
item.setIzActive(izActive == 1 ? 1 : 0);
|
||||
// 添加更新时间戳
|
||||
item.setUpdateTime(new Date());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,14 @@ package org.cpte.modules.base.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.cpte.modules.base.entity.Area;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
import org.cpte.modules.base.mapper.PointMapper;
|
||||
import org.cpte.modules.base.service.IAreaService;
|
||||
import org.cpte.modules.base.service.IPointService;
|
||||
import org.cpte.modules.base.service.processor.SyncPointProcessor;
|
||||
import org.cpte.modules.constant.GeneralConstant;
|
||||
import org.cpte.modules.constant.enums.AreaTypeEnum;
|
||||
import org.cpte.modules.constant.enums.CommonStatusEnum;
|
||||
|
|
@ -16,13 +20,9 @@ import org.jeecg.common.util.RestUtil;
|
|||
import org.jeecg.modules.openapi.mapper.OpenApiMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 库位
|
||||
|
|
@ -31,8 +31,15 @@ import java.util.Map;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements IPointService {
|
||||
|
||||
@Autowired
|
||||
private IAreaService areaService;
|
||||
|
||||
@Autowired
|
||||
private SyncPointProcessor syncPointProcessor;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
|
|
@ -161,22 +168,30 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean syncPoint(Integer pageNum, Integer pageSize) {
|
||||
public Boolean syncPoint(String regionCode, Integer pageNum, Integer pageSize) {
|
||||
if (pageSize > 2000) {
|
||||
throw new RuntimeException("同步库位数据每页不能超过2000条");
|
||||
}
|
||||
// 构造请求参数
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("warehouseID","HETU");
|
||||
params.put("clientCode","WMS");
|
||||
params.put("regionCode","3");
|
||||
params.put("pageNum",pageNum);
|
||||
params.put("warehouseID", "HETU");
|
||||
params.put("clientCode", "WMS");
|
||||
params.put("regionCode", regionCode);
|
||||
params.put("pageNum", pageNum);
|
||||
params.put("pageSize", pageSize);
|
||||
|
||||
//根据子仓编码获取对应的库区
|
||||
String areaCode = AreaTypeEnum.CPCCQ.getValue();
|
||||
if (!regionCode.equals("3")) {
|
||||
areaCode = AreaTypeEnum.MJCCQ.getValue();
|
||||
}
|
||||
Area area = areaService.validateArea(areaCode);
|
||||
|
||||
// 调用接口获取物料数据
|
||||
JSONObject pointAddList = GetPointAddList(params);
|
||||
return pointAddList.isEmpty();
|
||||
JSONObject pointAddList = getPointAddList(params);
|
||||
|
||||
// 处理库位数据
|
||||
return syncPointProcessor.syncPoint(area, pointAddList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -185,13 +200,12 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
|
|||
* @param params 请求参数
|
||||
* @return ItemResponse
|
||||
*/
|
||||
private JSONObject GetPointAddList(JSONObject params) {
|
||||
private JSONObject getPointAddList(JSONObject params) {
|
||||
try {
|
||||
String url = openApiMapper.getRequestUrl(GeneralConstant.SYNC_POINT).getOriginUrl();
|
||||
return RestUtil.post(url, params, null);
|
||||
return RestUtil.post(url, params);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("获取库位数据失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,20 +5,15 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
import org.cpte.modules.base.entity.Stock;
|
||||
import org.cpte.modules.base.mapper.StockMapper;
|
||||
import org.cpte.modules.base.service.IStockService;
|
||||
import org.cpte.modules.constant.enums.CommonStatusEnum;
|
||||
import org.cpte.modules.constant.enums.StockTypeEnum;
|
||||
import org.cpte.modules.saiWms.request.SyncStockRequest;
|
||||
import org.cpte.modules.utils.BatchUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -31,9 +26,6 @@ import java.util.*;
|
|||
@Service
|
||||
public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements IStockService {
|
||||
|
||||
@Autowired
|
||||
private BatchUtil batchUtil;
|
||||
|
||||
@Override
|
||||
public Stock buildStocK(SyncStockRequest.StockDTO stockDTO) {
|
||||
LoginUser sysUser = null;
|
||||
|
|
@ -139,15 +131,4 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|||
}
|
||||
return stockMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchOperation(List<Stock> insertToStock, List<Stock> updateToStock) {
|
||||
if (CollectionUtils.isNotEmpty(insertToStock)) {
|
||||
batchUtil.saveBatchStock(insertToStock);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToStock)) {
|
||||
batchUtil.batchUpdateStocks(updateToStock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,173 @@
|
|||
package org.cpte.modules.base.service.processor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.cpte.modules.base.entity.Item;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
import org.cpte.modules.base.entity.Stock;
|
||||
import org.cpte.modules.base.mapper.PointMapper;
|
||||
import org.cpte.modules.base.mapper.StockMapper;
|
||||
import org.cpte.modules.inventory.entity.Inventory;
|
||||
import org.cpte.modules.inventory.mapper.InventoryMapper;
|
||||
import org.cpte.modules.inventoryLog.entity.InventoryLog;
|
||||
import org.cpte.modules.receive.entity.AsnDetail;
|
||||
import org.cpte.modules.receive.entity.ReceiveRecord;
|
||||
import org.cpte.modules.shipping.entity.PickDetail;
|
||||
import org.cpte.modules.shipping.entity.Task;
|
||||
import org.cpte.modules.shipping.mapper.TaskMapper;
|
||||
import org.cpte.modules.utils.BatchUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BatchProcessor {
|
||||
|
||||
@Autowired
|
||||
private PointMapper pointMapper;
|
||||
|
||||
@Autowired
|
||||
private StockMapper stockMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskMapper taskMapper;
|
||||
|
||||
@Autowired
|
||||
private InventoryMapper inventoryMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private BatchUtil batchUtil;
|
||||
|
||||
/**
|
||||
* 批量保存点位
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchSavePoints(List<Point> insertPoints, List<Point> updatePoints) {
|
||||
if (CollectionUtils.isNotEmpty(insertPoints)) {
|
||||
batchUtil.saveBatchPoint(insertPoints);
|
||||
log.info("批量插入{}个点位", insertPoints.size());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(updatePoints)) {
|
||||
batchUtil.batchUpdatePoint(updatePoints);
|
||||
log.info("批量更新{}个点位", updatePoints.size());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存物料
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchSaveItems(List<Item> insertItems, List<Item> updateItems) {
|
||||
if (CollectionUtils.isNotEmpty(insertItems)) {
|
||||
batchUtil.saveBatchItem(insertItems);
|
||||
log.info("批量插入{}个物料", insertItems.size());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(updateItems)) {
|
||||
batchUtil.updateBatchItem(updateItems);
|
||||
log.info("批量更新{}个物料", updateItems.size());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存容器
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchSaveStock(List<Stock> insertToStock, List<Stock> updateToStock) {
|
||||
if (CollectionUtils.isNotEmpty(insertToStock)) {
|
||||
batchUtil.saveBatchStock(insertToStock);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToStock)) {
|
||||
batchUtil.batchUpdateStock(updateToStock);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理收货操作
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchReceive(List<AsnDetail> updateToAsnDetail, List<ReceiveRecord> records,
|
||||
Map<Long, Inventory> inventoryMap, List<InventoryLog> inventoryLogs) {
|
||||
if (CollectionUtils.isNotEmpty(updateToAsnDetail)) {
|
||||
batchUtil.updateBatchAsnDetail(updateToAsnDetail);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(records)) {
|
||||
batchUtil.saveBatchReceiveRecord(records);
|
||||
}
|
||||
if (inventoryMap != null && !inventoryMap.isEmpty()) {
|
||||
List<Inventory> createToInventory = new ArrayList<>(inventoryMap.values());
|
||||
batchUtil.saveBatchInventory(createToInventory);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(inventoryLogs)) {
|
||||
batchUtil.saveBatchInventoryLog(inventoryLogs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理分配操作
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchAllocate(Map<Long, Inventory> inventoryUpdateMap, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> createToTask) {
|
||||
|
||||
List<Inventory> updateToInventory = new ArrayList<>(inventoryUpdateMap.values());
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>(pickDetailUpdateMap.values());
|
||||
if (CollectionUtils.isNotEmpty(updateToInventory)) {
|
||||
batchUtil.updateBatchInventory(updateToInventory);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToPickDetail)) {
|
||||
batchUtil.updateBatchPickDetail(updateToPickDetail);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(createToTask)) {
|
||||
batchUtil.saveBatchTask(createToTask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理取消操作
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchCancel(Map<Long, Inventory> inventoryUpdateMap, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> deleteToTask) {
|
||||
List<Inventory> updateToInventory = new ArrayList<>(inventoryUpdateMap.values());
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>(pickDetailUpdateMap.values());
|
||||
if (CollectionUtils.isNotEmpty(updateToInventory)) {
|
||||
batchUtil.updateBatchInventory(updateToInventory);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToPickDetail)) {
|
||||
batchUtil.updateBatchPickDetail(updateToPickDetail);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(deleteToTask)) {
|
||||
taskMapper.deleteByIds(deleteToTask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理拣货操作
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchPick(List<Inventory> deleteToInventory, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> updateToTask, List<Stock> updateToStock, List<Point> updateToPoint) {
|
||||
if (CollectionUtils.isNotEmpty(deleteToInventory)) {
|
||||
List<Long> deleteToInventoryIds = deleteToInventory.stream().map(Inventory::getId).toList();
|
||||
inventoryMapper.deleteByIds(deleteToInventoryIds);
|
||||
}
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>(pickDetailUpdateMap.values());
|
||||
if (CollectionUtils.isNotEmpty(updateToPickDetail)) {
|
||||
batchUtil.updateBatchPickDetail(updateToPickDetail);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToTask)) {
|
||||
batchUtil.updateBatchTask(updateToTask);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToStock)) {
|
||||
stockMapper.updateById(updateToStock);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToPoint)) {
|
||||
pointMapper.updateById(updateToPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
package org.cpte.modules.base.service.processor;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.cpte.modules.base.entity.Item;
|
||||
import org.cpte.modules.base.mapper.ItemMapper;
|
||||
import org.cpte.modules.base.vo.SyncItemData;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SyncItemProcessor {
|
||||
|
||||
@Autowired
|
||||
private ItemMapper itemMapper;
|
||||
|
||||
@Autowired
|
||||
private BatchProcessor batchProcessor;
|
||||
|
||||
public Boolean syncItem(JSONObject materials) {
|
||||
try {
|
||||
JSONArray itemArray = extractItemArray(materials);
|
||||
if (CollectionUtils.isEmpty(itemArray)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
//查询物料
|
||||
List<String> itemCodes = extractItemCodes(itemArray);
|
||||
Map<String, Item> itemMap = queryByItemCodesToMap(itemCodes);
|
||||
|
||||
// 批量处理
|
||||
SyncItemData data = processItemArray(itemArray, itemMap);
|
||||
|
||||
// 批量保存
|
||||
batchProcessor.batchSaveItems(data.getInsertItems(), data.getUpdateItems());
|
||||
|
||||
return Boolean.TRUE;
|
||||
} catch (JSONException e) {
|
||||
log.error("处理物料数据失败: JSON解析错误", e);
|
||||
throw new RuntimeException("物料数据格式错误", e);
|
||||
} catch (Exception e) {
|
||||
log.error("处理物料数据失败", e);
|
||||
throw new RuntimeException("处理物料数据失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从JSON中提取物料数组
|
||||
*/
|
||||
private JSONArray extractItemArray(JSONObject materials) {
|
||||
JSONObject data = materials.getJSONObject("data");
|
||||
if (data == null) {
|
||||
return new JSONArray();
|
||||
}
|
||||
|
||||
JSONObject result = data.getJSONObject("result");
|
||||
if (result == null) {
|
||||
return new JSONArray();
|
||||
}
|
||||
|
||||
return result.getJSONArray("item1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 从物料数组中提取所有物料编码
|
||||
*/
|
||||
private List<String> extractItemCodes(JSONArray itemArray) {
|
||||
List<String> itemCodes = new ArrayList<>();
|
||||
for (int i = 0; i < itemArray.size(); i++) {
|
||||
JSONObject item = itemArray.getJSONObject(i);
|
||||
String itemCode = item.getString("itmreF_0");
|
||||
if (StringUtils.isNotBlank(itemCode)) {
|
||||
itemCodes.add(itemCode);
|
||||
}
|
||||
}
|
||||
return itemCodes;
|
||||
}
|
||||
|
||||
private Map<String, Item> queryByItemCodesToMap(List<String> itemCodes) {
|
||||
if (CollectionUtils.isEmpty(itemCodes)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
//查询物料
|
||||
LambdaQueryWrapper<Item> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(Item::getItemCode, itemCodes);
|
||||
List<Item> items = itemMapper.selectList(queryWrapper);
|
||||
//封装成map
|
||||
Map<String, Item> itemMap = Maps.newHashMap();
|
||||
for (Item item : items) {
|
||||
itemMap.put(item.getItemCode(), item);
|
||||
}
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理物料数组
|
||||
*/
|
||||
private SyncItemData processItemArray(JSONArray itemArray, Map<String, Item> itemMap) {
|
||||
SyncItemData data = new SyncItemData();
|
||||
Set<String> processedItemCodes = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < itemArray.size(); i++) {
|
||||
JSONObject item = itemArray.getJSONObject(i);
|
||||
processSingleItem(item, itemMap, data, processedItemCodes);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理单个物料
|
||||
*/
|
||||
private void processSingleItem(JSONObject item, Map<String, Item> itemMap,
|
||||
SyncItemData data, Set<String> processedItemCodes) {
|
||||
String itemCode = item.getString("itmreF_0");
|
||||
if (StringUtils.isBlank(itemCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 去重处理
|
||||
if (!processedItemCodes.add(itemCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String itemName = item.getString("itmdeS1_0");
|
||||
String unit = item.getString("stU_0");
|
||||
Integer izActive = Integer.parseInt(item.getString("itmstA_0"));
|
||||
|
||||
Item existingItem = itemMap.get(itemCode);
|
||||
|
||||
if (existingItem == null) {
|
||||
Item newItem = buildItem(itemCode, itemName, unit, izActive);
|
||||
data.addInsertItem(newItem);
|
||||
} else {
|
||||
if (isItemChanged(existingItem, itemName, unit, izActive)) {
|
||||
updateItemFromMaterial(existingItem, itemName, unit, izActive);
|
||||
data.addUpdateItem(existingItem);
|
||||
}
|
||||
}
|
||||
log.debug("处理物料: {}", itemCode);
|
||||
}
|
||||
|
||||
private Item buildItem(String itemCode, String itemName, String unit, Integer izActive) {
|
||||
LoginUser sysUser = null;
|
||||
try {
|
||||
sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
} catch (Exception e) {
|
||||
log.error("获取登录用户信息失败");
|
||||
}
|
||||
return Item.builder()
|
||||
.id(IdWorker.getId())
|
||||
.itemCode(itemCode)
|
||||
.itemName(itemName)
|
||||
.unit(unit)
|
||||
.izActive(izActive == 1 ? 1 : 0)
|
||||
.delFlag(0)
|
||||
.sysOrgCode(sysUser == null ? "A05" : sysUser.getOrgCode())
|
||||
.tenantId(sysUser == null ? 1000L : Long.parseLong(sysUser.getRelTenantIds()))
|
||||
.createBy(sysUser == null ? "ERP" : sysUser.getUsername())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查物料是否发生变化
|
||||
*/
|
||||
private boolean isItemChanged(Item item, String itemName, String unit, Integer izActive) {
|
||||
return !Objects.equals(item.getItemName(), itemName) ||
|
||||
!Objects.equals(item.getUnit(), unit) ||
|
||||
!Objects.equals(item.getIzActive(), izActive == 1 ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新物料信息
|
||||
*/
|
||||
private void updateItemFromMaterial(Item item, String itemName, String unit, Integer izActive) {
|
||||
item.setItemName(itemName);
|
||||
item.setUnit(unit);
|
||||
item.setIzActive(izActive == 1 ? 1 : 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,241 @@
|
|||
package org.cpte.modules.base.service.processor;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.cpte.modules.base.entity.Area;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
import org.cpte.modules.base.mapper.PointMapper;
|
||||
import org.cpte.modules.base.vo.SyncPointData;
|
||||
import org.cpte.modules.constant.enums.CommonStatusEnum;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SyncPointProcessor {
|
||||
|
||||
@Autowired
|
||||
private PointMapper pointMapper;
|
||||
|
||||
@Autowired
|
||||
private BatchProcessor batchProcessor;
|
||||
|
||||
public Boolean syncPoint(Area area, JSONObject pointJsonObject) {
|
||||
try {
|
||||
JSONArray laneListArray = extractLaneList(pointJsonObject);
|
||||
if (CollectionUtils.isEmpty(laneListArray)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
//查询库位
|
||||
List<String> pointCodes = extractPointCodes(laneListArray);
|
||||
Map<String, Point> pointMap = queryByPointCodesToMap(pointCodes);
|
||||
|
||||
// 批量处理
|
||||
SyncPointData data = processLaneList(area, laneListArray, pointMap);
|
||||
|
||||
// 批量保存
|
||||
batchProcessor.batchSavePoints(data.getInsertPoints(), data.getUpdatePoints());
|
||||
|
||||
return Boolean.TRUE;
|
||||
} catch (JSONException e) {
|
||||
log.error("处理库位数据失败: JSON解析错误", e);
|
||||
throw new RuntimeException("库位数据格式错误", e);
|
||||
} catch (Exception e) {
|
||||
log.error("处理库位数据失败", e);
|
||||
throw new RuntimeException("处理库位数据失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从JSON中提取巷道列表
|
||||
*/
|
||||
private JSONArray extractLaneList(JSONObject pointJsonObject) {
|
||||
JSONObject data = pointJsonObject.getJSONObject("data");
|
||||
if (data == null) {
|
||||
return new JSONArray();
|
||||
}
|
||||
return data.getJSONArray("laneList");
|
||||
}
|
||||
|
||||
/**
|
||||
* 从巷道列表中提取所有点位编码
|
||||
*/
|
||||
private List<String> extractPointCodes(JSONArray laneListArray) {
|
||||
List<String> pointCodes = new ArrayList<>();
|
||||
for (int i = 0; i < laneListArray.size(); i++) {
|
||||
JSONObject laneObject = laneListArray.getJSONObject(i);
|
||||
JSONArray nodeArray = laneObject.getJSONArray("nodeList");
|
||||
if (CollectionUtils.isEmpty(nodeArray)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < nodeArray.size(); j++) {
|
||||
JSONObject nodeObject = nodeArray.getJSONObject(j);
|
||||
String pointCode = nodeObject.getString("nodeCode");
|
||||
if (StringUtils.isNotBlank(pointCode)) {
|
||||
pointCodes.add(pointCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pointCodes;
|
||||
}
|
||||
|
||||
private Map<String, Point> queryByPointCodesToMap(List<String> pointCodes) {
|
||||
if (CollectionUtils.isEmpty(pointCodes)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
//查询库位
|
||||
LambdaQueryWrapper<Point> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(Point::getPointCode, pointCodes);
|
||||
List<Point> points = pointMapper.selectList(queryWrapper);
|
||||
//封装成map
|
||||
Map<String, Point> PointMap = Maps.newHashMap();
|
||||
for (Point Point : points) {
|
||||
PointMap.put(Point.getPointCode(), Point);
|
||||
}
|
||||
return PointMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理巷道列表数据
|
||||
*/
|
||||
private SyncPointData processLaneList(Area area, JSONArray laneListArray, Map<String, Point> pointMap) {
|
||||
SyncPointData data = new SyncPointData();
|
||||
Set<String> processedPointCodes = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < laneListArray.size(); i++) {
|
||||
JSONObject laneObject = laneListArray.getJSONObject(i);
|
||||
processSingleLane(area, laneObject, pointMap, data, processedPointCodes);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理单个巷道
|
||||
*/
|
||||
private void processSingleLane(Area area, JSONObject laneObject,
|
||||
Map<String, Point> pointMap,
|
||||
SyncPointData data,
|
||||
Set<String> processedPointCodes) {
|
||||
String colNum = laneObject.getString("laneCode");
|
||||
JSONArray faceDirArray = laneObject.getJSONArray("faceDir");
|
||||
JSONArray nodeArray = laneObject.getJSONArray("nodeList");
|
||||
|
||||
if (CollectionUtils.isEmpty(nodeArray)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int lineNo = 1;
|
||||
boolean isDoubleLane = faceDirArray != null && faceDirArray.size() > 1;
|
||||
|
||||
for (int j = 0; j < nodeArray.size(); j++) {
|
||||
JSONObject nodeObject = nodeArray.getJSONObject(j);
|
||||
processSingleNode(area, nodeObject, colNum, String.valueOf(lineNo),
|
||||
isDoubleLane, pointMap, data, processedPointCodes);
|
||||
lineNo++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理单个节点
|
||||
*/
|
||||
private void processSingleNode(Area area, JSONObject nodeObject, String colNum,
|
||||
String rowNum, boolean isDoubleLane,
|
||||
Map<String, Point> pointMap, SyncPointData data,
|
||||
Set<String> processedPointCodes) {
|
||||
String pointCode = nodeObject.getString("nodeCode");
|
||||
if (StringUtils.isBlank(pointCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 去重处理
|
||||
if (!processedPointCodes.add(pointCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Integer positionX = nodeObject.getInteger("x");
|
||||
Integer positionY = nodeObject.getInteger("y");
|
||||
String layerNum = nodeObject.getString("z");
|
||||
Integer izDoubleLane = isDoubleLane ? 1 : 0;
|
||||
|
||||
Point existingPoint = pointMap.get(pointCode);
|
||||
|
||||
if (existingPoint == null) {
|
||||
Point newPoint = buildPoint(area.getId(), pointCode, colNum, layerNum,
|
||||
rowNum, positionX, positionY, izDoubleLane);
|
||||
data.addInsertPoint(newPoint);
|
||||
} else {
|
||||
if (isPointChanged(existingPoint, colNum, layerNum, rowNum,
|
||||
positionX, positionY, izDoubleLane)) {
|
||||
updatePointFrom(existingPoint, colNum, layerNum, rowNum,
|
||||
positionX, positionY, izDoubleLane);
|
||||
data.addUpdatePoint(existingPoint);
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("处理库位: {}", pointCode);
|
||||
}
|
||||
|
||||
private Point buildPoint(Long adreaId, String pointCode, String colNum, String layerNum, String rowNum, Integer positionX, Integer positionY, Integer izDoubleLane) {
|
||||
LoginUser sysUser = null;
|
||||
try {
|
||||
sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
} catch (Exception e) {
|
||||
log.error("获取登录用户信息失败");
|
||||
}
|
||||
return Point.builder()
|
||||
.id(IdWorker.getId())
|
||||
.areaId(adreaId)
|
||||
.pointCode(pointCode)
|
||||
.colNum(colNum)
|
||||
.layerNum(layerNum)
|
||||
.rowNum(rowNum)
|
||||
.positionX(positionX)
|
||||
.positionY(positionY)
|
||||
.izDoubleLane(izDoubleLane)
|
||||
.status(CommonStatusEnum.FREE.getValue())
|
||||
.izActive(1)
|
||||
.delFlag(0)
|
||||
.sysOrgCode(sysUser == null ? "A05" : sysUser.getOrgCode())
|
||||
.tenantId(sysUser == null ? 1000L : Long.parseLong(sysUser.getRelTenantIds()))
|
||||
.createBy(sysUser == null ? "TES" : sysUser.getUsername())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查库位是否发生变化
|
||||
*/
|
||||
private boolean isPointChanged(Point point, String rowNum, String colNum, String layerNum, Integer positionX, Integer positionY, Integer izDoubleLane) {
|
||||
return !Objects.equals(point.getRowNum(), rowNum) ||
|
||||
!Objects.equals(point.getColNum(), colNum) ||
|
||||
!Objects.equals(point.getLayerNum(), layerNum) ||
|
||||
!Objects.equals(point.getPositionX(), positionX) ||
|
||||
!Objects.equals(point.getPositionY(), positionY) ||
|
||||
!Objects.equals(point.getIzDoubleLane(), izDoubleLane);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新物料信息
|
||||
*/
|
||||
private void updatePointFrom(Point existingPoint, String rowNum, String colNum, String layerNum, Integer positionX, Integer positionY, Integer izDoubleLane) {
|
||||
existingPoint.setColNum(colNum);
|
||||
existingPoint.setLayerNum(layerNum);
|
||||
existingPoint.setRowNum(rowNum);
|
||||
existingPoint.setPositionX(positionX);
|
||||
existingPoint.setPositionY(positionY);
|
||||
existingPoint.setIzDoubleLane(izDoubleLane);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package org.cpte.modules.base.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.cpte.modules.base.entity.Item;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Data
|
||||
public class SyncItemData {
|
||||
private final List<Item> insertItems = new ArrayList<>();
|
||||
private final List<Item> updateItems = new ArrayList<>();
|
||||
|
||||
public void addInsertItem(Item item) {
|
||||
insertItems.add(item);
|
||||
}
|
||||
|
||||
public void addUpdateItem(Item item) {
|
||||
updateItems.add(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package org.cpte.modules.base.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Data
|
||||
public class SyncPointData {
|
||||
private final List<Point> insertPoints = new ArrayList<>();
|
||||
private final List<Point> updatePoints = new ArrayList<>();
|
||||
|
||||
public void addInsertPoint(Point point) {
|
||||
insertPoints.add(point);
|
||||
}
|
||||
|
||||
public void addUpdatePoint(Point point) {
|
||||
updatePoints.add(point);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ package org.cpte.modules.quartz.job;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.cpte.modules.base.service.IItemService;
|
||||
import org.cpte.modules.base.service.IPointService;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
|
|
@ -13,9 +12,6 @@ import org.quartz.JobExecutionContext;
|
|||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 同步库位任务
|
||||
*/
|
||||
|
|
@ -36,34 +32,56 @@ public class SyncPointJob implements Job {
|
|||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
private static final Integer MAX_PAGE_NUM=10000;
|
||||
private static final Integer MAX_PAGE_NUM = 100;
|
||||
|
||||
private static final String PAGE_NUM_KEY = "PAGE_NUM_KEY";
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
try {
|
||||
//获取配置的参数
|
||||
long startTime = System.currentTimeMillis();
|
||||
JSONObject params = JSON.parseObject(this.parameter);
|
||||
int pageSize = Integer.parseInt(params.getString("pageSize"));
|
||||
int pageNum = Integer.parseInt(params.getString("pageNum"));
|
||||
log.info("当前页数: {} - 每页条数: {}", pageNum, pageSize);
|
||||
String regionCode = params.getString("regionCode");
|
||||
Integer pageSize = Integer.parseInt(params.getString("pageSize"));
|
||||
Integer pageNum = Integer.parseInt(params.getString("pageNum"));
|
||||
|
||||
// 检查是否需要处理
|
||||
if (pageNum>=MAX_PAGE_NUM) {
|
||||
if (pageNum >= MAX_PAGE_NUM) {
|
||||
log.info("已处理到最新页数,无需继续查询");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean success = pointService.syncPoint(pageNum,pageSize);
|
||||
pageNum = getLastProcessedKey(pageNum);
|
||||
log.info("当前页数: {} - 每页条数: {}", pageNum, pageSize);
|
||||
boolean success = pointService.syncPoint(regionCode, pageNum, pageSize);
|
||||
if (success) {
|
||||
updateLastProcessedDate(pageNum);
|
||||
}
|
||||
log.info("同步库位完成,耗时: {} ms", System.currentTimeMillis() - startTime);
|
||||
|
||||
} catch (Exception e) {
|
||||
baseCommonService.addLog(String.valueOf(e), CommonConstant.LOG_TYPE_4, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上次处理的页数+1页数
|
||||
*/
|
||||
private Integer getLastProcessedKey(Integer pageNum) {
|
||||
try {
|
||||
Object dateObj = redisUtil.get(PAGE_NUM_KEY);
|
||||
if (dateObj != null) {
|
||||
return Integer.parseInt(dateObj.toString())+1;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("从Redis获取上次处理页数失败,使用默认页数", e);
|
||||
}
|
||||
|
||||
// 默认页数
|
||||
pageNum = 1;
|
||||
redisUtil.set(PAGE_NUM_KEY, pageNum);
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import org.cpte.modules.base.entity.Item;
|
|||
import org.cpte.modules.base.entity.ItemKey;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
import org.cpte.modules.base.entity.Stock;
|
||||
import org.cpte.modules.inventory.entity.Inventory;
|
||||
import org.cpte.modules.inventoryLog.entity.InventoryLog;
|
||||
import org.cpte.modules.receive.entity.Asn;
|
||||
import org.cpte.modules.receive.entity.AsnDetail;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
|
@ -90,14 +88,4 @@ public interface IAsnDetailService extends IService<AsnDetail> {
|
|||
*/
|
||||
ReceiveRecord buildReceiveRecord(AsnDetail asnDetail, BigDecimal receivedQty, ItemKey itemKey, Long dstPointId);
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*
|
||||
* @param updateToAsnDetail 更新入库单明细
|
||||
* @param records 创建收货记录
|
||||
* @param inventoryMap 创建库存
|
||||
* @param inventoryLogs 创建库存日志
|
||||
*/
|
||||
void batchOperation(List<AsnDetail> updateToAsnDetail, List<ReceiveRecord> records, Map<Long, Inventory> inventoryMap, List<InventoryLog> inventoryLogs);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.cpte.modules.receive.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.cpte.modules.agvTask.service.IAgvTaskService;
|
||||
import org.cpte.modules.base.entity.Item;
|
||||
|
|
@ -12,8 +11,6 @@ import org.cpte.modules.base.service.IPointService;
|
|||
import org.cpte.modules.base.service.IStockService;
|
||||
import org.cpte.modules.constant.GeneralConstant;
|
||||
import org.cpte.modules.constant.enums.*;
|
||||
import org.cpte.modules.inventory.entity.Inventory;
|
||||
import org.cpte.modules.inventoryLog.entity.InventoryLog;
|
||||
import org.cpte.modules.receive.entity.Asn;
|
||||
import org.cpte.modules.receive.entity.AsnDetail;
|
||||
import org.cpte.modules.receive.entity.ReceiveRecord;
|
||||
|
|
@ -22,7 +19,6 @@ import org.cpte.modules.receive.mapper.AsnMapper;
|
|||
import org.cpte.modules.receive.service.IAsnDetailService;
|
||||
import org.cpte.modules.saiWms.request.InboundRequest;
|
||||
import org.cpte.modules.serialNumber.AsnSerialNumberRule;
|
||||
import org.cpte.modules.utils.BatchUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -58,9 +54,6 @@ public class AsnDetailServiceImpl extends ServiceImpl<AsnDetailMapper, AsnDetail
|
|||
@Autowired
|
||||
private IAgvTaskService agvTaskService;
|
||||
|
||||
@Autowired
|
||||
private BatchUtil batchUtil;
|
||||
|
||||
@Autowired
|
||||
private AsnSerialNumberRule asnSerialNumberRule;
|
||||
|
||||
|
|
@ -230,22 +223,4 @@ public class AsnDetailServiceImpl extends ServiceImpl<AsnDetailMapper, AsnDetail
|
|||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchOperation(List<AsnDetail> updateToAsnDetail, List<ReceiveRecord> records,
|
||||
Map<Long, Inventory> inventoryMap, List<InventoryLog> inventoryLogs) {
|
||||
if (CollectionUtils.isNotEmpty(updateToAsnDetail)) {
|
||||
batchUtil.updateBatchAsnDetail(updateToAsnDetail);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(records)) {
|
||||
batchUtil.saveBatchReceiveRecord(records);
|
||||
}
|
||||
if (inventoryMap != null && !inventoryMap.isEmpty()) {
|
||||
List<Inventory> createToInventory = new ArrayList<>(inventoryMap.values());
|
||||
batchUtil.saveBatchInventory(createToInventory);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(inventoryLogs)) {
|
||||
batchUtil.saveBatchInventoryLog(inventoryLogs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.cpte.modules.base.entity.Stock;
|
|||
import org.cpte.modules.base.mapper.PointMapper;
|
||||
import org.cpte.modules.base.mapper.StockMapper;
|
||||
import org.cpte.modules.base.service.IItemKeyService;
|
||||
import org.cpte.modules.base.service.processor.BatchProcessor;
|
||||
import org.cpte.modules.constant.enums.AsnStatusEnum;
|
||||
import org.cpte.modules.inventory.entity.Inventory;
|
||||
import org.cpte.modules.inventory.service.IInventoryService;
|
||||
|
|
@ -64,6 +65,9 @@ public class ReceiveProcessor {
|
|||
@Autowired
|
||||
private ReceiveBackProcessor receiveBackProcessor;
|
||||
|
||||
@Autowired
|
||||
private BatchProcessor batchProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* 收货
|
||||
|
|
@ -84,7 +88,7 @@ public class ReceiveProcessor {
|
|||
receive(data, updateToAsnDetail, createRecords, inventoryMap, createInventoryLogs);
|
||||
|
||||
//5.批量操作
|
||||
asnDetailService.batchOperation(updateToAsnDetail, createRecords, inventoryMap, createInventoryLogs);
|
||||
batchProcessor.batchReceive(updateToAsnDetail, createRecords, inventoryMap, createInventoryLogs);
|
||||
|
||||
//6.刷新入库
|
||||
refreshData(data);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
package org.cpte.modules.saiWms.service.processor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.cpte.modules.base.entity.Stock;
|
||||
import org.cpte.modules.base.service.IStockService;
|
||||
import org.cpte.modules.base.service.processor.BatchProcessor;
|
||||
import org.cpte.modules.saiWms.request.SyncStockRequest;
|
||||
import org.cpte.modules.utils.BatchUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -19,11 +17,11 @@ import java.util.*;
|
|||
@Service
|
||||
@Slf4j
|
||||
public class SyncStockProcessor {
|
||||
|
||||
@Autowired
|
||||
private IStockService stockService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private BatchProcessor batchProcessor;
|
||||
|
||||
/**
|
||||
* 接收容器同步信息
|
||||
|
|
@ -45,7 +43,7 @@ public class SyncStockProcessor {
|
|||
processStock(syncStockRequest.getStocks(), stockMap, insertToStock, updateToStock);
|
||||
|
||||
//5.批量操作
|
||||
stockService.batchOperation(insertToStock, updateToStock);
|
||||
batchProcessor.batchSaveStock(insertToStock, updateToStock);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -79,35 +79,6 @@ public interface IPickDetailService extends IService<PickDetail> {
|
|||
*/
|
||||
void processOutBoundTask(OutboundRequest outboundRequest, Map<String, Item> itemMap);
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*
|
||||
* @param inventoryUpdateMap 库存更新
|
||||
* @param pickDetailUpdateMap 出库单明细更新
|
||||
* @param createToTask 创建任务
|
||||
*/
|
||||
void batchOperationAllocate(Map<Long, Inventory> inventoryUpdateMap, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> createToTask);
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*
|
||||
* @param inventoryUpdateMap 库存更新
|
||||
* @param pickDetailUpdateMap 出库单明细更新
|
||||
* @param deleteToTask 删除任务
|
||||
*/
|
||||
void batchOperationCancel(Map<Long, Inventory> inventoryUpdateMap, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> deleteToTask);
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*
|
||||
* @param deleteToInventory 删除库存
|
||||
* @param pickDetailUpdateMap 出库单明细更新
|
||||
* @param updateToTask 更新任务
|
||||
* @param updateToStock 更新库存
|
||||
* @param updateToPoint 更新点位
|
||||
*/
|
||||
void batchOperationPick(List<Inventory> deleteToInventory, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> updateToTask, List<Stock> updateToStock, List<Point> updateToPoint);
|
||||
|
||||
/**
|
||||
* 刷新出库单
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,25 +3,15 @@ package org.cpte.modules.shipping.service.impl;
|
|||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.cpte.modules.base.entity.Item;
|
||||
import org.cpte.modules.base.entity.Point;
|
||||
import org.cpte.modules.base.entity.Stock;
|
||||
import org.cpte.modules.base.service.IPointService;
|
||||
import org.cpte.modules.base.service.IStockService;
|
||||
import org.cpte.modules.constant.GeneralConstant;
|
||||
import org.cpte.modules.constant.enums.PickStatusEnum;
|
||||
import org.cpte.modules.inventory.entity.Inventory;
|
||||
import org.cpte.modules.inventory.mapper.InventoryMapper;
|
||||
import org.cpte.modules.inventory.service.IInventoryService;
|
||||
import org.cpte.modules.saiWms.request.OutboundRequest;
|
||||
import org.cpte.modules.serialNumber.PickSerialNumberRule;
|
||||
import org.cpte.modules.shipping.entity.Pick;
|
||||
import org.cpte.modules.shipping.entity.PickDetail;
|
||||
import org.cpte.modules.shipping.entity.Task;
|
||||
import org.cpte.modules.shipping.mapper.PickDetailMapper;
|
||||
import org.cpte.modules.shipping.mapper.PickMapper;
|
||||
import org.cpte.modules.shipping.mapper.TaskMapper;
|
||||
import org.cpte.modules.shipping.service.IPickDetailService;
|
||||
import org.cpte.modules.utils.BatchUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -44,23 +34,6 @@ public class PickDetailServiceImpl extends ServiceImpl<PickDetailMapper, PickDet
|
|||
@Autowired
|
||||
private PickMapper pickMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskMapper taskMapper;
|
||||
|
||||
@Autowired
|
||||
private InventoryMapper inventoryMapper;
|
||||
|
||||
@Autowired
|
||||
private IStockService stockService;
|
||||
|
||||
@Autowired
|
||||
private IPointService pointService;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private BatchUtil batchUtil;
|
||||
|
||||
@Autowired
|
||||
private PickSerialNumberRule pickSerialNumberRule;
|
||||
|
||||
|
|
@ -180,62 +153,6 @@ public class PickDetailServiceImpl extends ServiceImpl<PickDetailMapper, PickDet
|
|||
processorSaveMain(createPick, pickDetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchOperationAllocate(Map<Long, Inventory> inventoryUpdateMap, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> createToTask) {
|
||||
|
||||
List<Inventory> updateToInventory = new ArrayList<>(inventoryUpdateMap.values());
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>(pickDetailUpdateMap.values());
|
||||
if (CollectionUtils.isNotEmpty(updateToInventory)) {
|
||||
batchUtil.updateBatchInventory(updateToInventory);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToPickDetail)) {
|
||||
batchUtil.updateBatchPickDetail(updateToPickDetail);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(createToTask)) {
|
||||
batchUtil.saveBatchTask(createToTask);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchOperationCancel(Map<Long, Inventory> inventoryUpdateMap, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> deleteToTask) {
|
||||
List<Inventory> updateToInventory = new ArrayList<>(inventoryUpdateMap.values());
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>(pickDetailUpdateMap.values());
|
||||
if (CollectionUtils.isNotEmpty(updateToInventory)) {
|
||||
batchUtil.updateBatchInventory(updateToInventory);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToPickDetail)) {
|
||||
batchUtil.updateBatchPickDetail(updateToPickDetail);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(deleteToTask)) {
|
||||
taskMapper.deleteByIds(deleteToTask);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchOperationPick(List<Inventory> deleteToInventory, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> updateToTask, List<Stock> updateToStock, List<Point> updateToPoint) {
|
||||
if (CollectionUtils.isNotEmpty(deleteToInventory)) {
|
||||
List<Long> deleteToInventoryIds = deleteToInventory.stream().map(Inventory::getId).toList();
|
||||
inventoryMapper.deleteByIds(deleteToInventoryIds);
|
||||
}
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>(pickDetailUpdateMap.values());
|
||||
if (CollectionUtils.isNotEmpty(updateToPickDetail)) {
|
||||
batchUtil.updateBatchPickDetail(updateToPickDetail);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToTask)) {
|
||||
batchUtil.updateBatchTask(updateToTask);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToStock)) {
|
||||
stockService.updateBatchById(updateToStock);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateToPoint)) {
|
||||
pointService.updateBatchById(updateToPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新出库单状态
|
||||
*
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.cpte.modules.base.service.IItemKeyService;
|
|||
import org.cpte.modules.base.service.IItemService;
|
||||
import org.cpte.modules.base.service.IPointService;
|
||||
import org.cpte.modules.base.service.IStockService;
|
||||
import org.cpte.modules.base.service.processor.BatchProcessor;
|
||||
import org.cpte.modules.constant.GeneralConstant;
|
||||
import org.cpte.modules.constant.enums.*;
|
||||
import org.cpte.modules.conveyorLine.service.processor.ScanTrayProcessor;
|
||||
|
|
@ -78,6 +79,9 @@ public class AllocateProcessor {
|
|||
@Autowired
|
||||
private ScanTrayProcessor scanTrayProcessor;
|
||||
|
||||
@Autowired
|
||||
private BatchProcessor batchProcessor;
|
||||
|
||||
@Autowired
|
||||
private MoveSerialNumberRule moveSerialNumberRule;
|
||||
|
||||
|
|
@ -116,7 +120,7 @@ public class AllocateProcessor {
|
|||
moveTask(createToTask, movePoints);
|
||||
|
||||
//6.批量操作
|
||||
pickDetailService.batchOperationAllocate(inventoryUpdateMap, pickDetailUpdateMap, createToTask);
|
||||
batchProcessor.batchAllocate(inventoryUpdateMap, pickDetailUpdateMap, createToTask);
|
||||
|
||||
//7.刷新出库单
|
||||
refreshData(data);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.cpte.modules.shipping.service.processor;
|
|||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.cpte.modules.base.service.processor.BatchProcessor;
|
||||
import org.cpte.modules.constant.enums.InventoryStatusEnum;
|
||||
import org.cpte.modules.constant.enums.PickStatusEnum;
|
||||
import org.cpte.modules.inventory.entity.Inventory;
|
||||
|
|
@ -45,6 +46,9 @@ public class CancelAllocateProcessor {
|
|||
@Autowired
|
||||
private IInventoryLogService inventoryLogService;
|
||||
|
||||
@Autowired
|
||||
private BatchProcessor batchProcessor;
|
||||
|
||||
@Autowired
|
||||
private RedisDistributedLockUtil redissonLock;
|
||||
|
||||
|
|
@ -70,7 +74,7 @@ public class CancelAllocateProcessor {
|
|||
cancelAllocate(data, inventoryUpdateMap, pickDetailUpdateMap, deleteToTask, errorMsgSet);
|
||||
|
||||
//4.批量操作
|
||||
pickDetailService.batchOperationCancel(inventoryUpdateMap, pickDetailUpdateMap, deleteToTask);
|
||||
batchProcessor.batchCancel(inventoryUpdateMap, pickDetailUpdateMap, deleteToTask);
|
||||
|
||||
//5.刷新出库单
|
||||
refreshData(data);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.cpte.modules.base.entity.Point;
|
|||
import org.cpte.modules.base.entity.Stock;
|
||||
import org.cpte.modules.base.service.IPointService;
|
||||
import org.cpte.modules.base.service.IStockService;
|
||||
import org.cpte.modules.base.service.processor.BatchProcessor;
|
||||
import org.cpte.modules.constant.enums.CommonStatusEnum;
|
||||
import org.cpte.modules.constant.enums.PickStatusEnum;
|
||||
import org.cpte.modules.constant.enums.TaskStatusEnum;
|
||||
|
|
@ -63,6 +64,9 @@ public class PickProcessor {
|
|||
@Autowired
|
||||
private PickBackProcessor pickBackProcessor;
|
||||
|
||||
@Autowired
|
||||
private BatchProcessor batchProcessor;
|
||||
|
||||
@Autowired
|
||||
private RedisDistributedLockUtil redissonLock;
|
||||
|
||||
|
|
@ -87,7 +91,7 @@ public class PickProcessor {
|
|||
pickTask(data, pickDetailUpdateMap, updateToTask, deleteToInventory, inventoryUpdateMap, updateToStock, updateToPoint);
|
||||
|
||||
//4.批量操作
|
||||
pickDetailService.batchOperationPick(deleteToInventory, pickDetailUpdateMap, updateToTask, updateToStock, updateToPoint);
|
||||
batchProcessor.batchPick(deleteToInventory, pickDetailUpdateMap, updateToTask, updateToStock, updateToPoint);
|
||||
|
||||
//5.回传
|
||||
pickBackProcessor.pickBack(data, updateToTask);
|
||||
|
|
|
|||
|
|
@ -62,16 +62,13 @@ public class ITesAgvServiceImpl implements ITesAgvService {
|
|||
NewMovePodTaskRequest newMovePodTaskRequest = new NewMovePodTaskRequest();
|
||||
newMovePodTaskRequest.setWarehouseID("HETU");
|
||||
newMovePodTaskRequest.setRequestID(String.valueOf(System.currentTimeMillis()));
|
||||
newMovePodTaskRequest.setRequestTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
newMovePodTaskRequest.setClientCode("WMS");
|
||||
|
||||
newMovePodTaskRequest.setPriority(agvTask.getPriority());
|
||||
newMovePodTaskRequest.setSrcType(1);
|
||||
newMovePodTaskRequest.setPodID(agvTask.getCarrierCode());
|
||||
newMovePodTaskRequest.setPriority(agvTask.getPriority());
|
||||
newMovePodTaskRequest.setBizID(agvTask.getId().toString());
|
||||
newMovePodTaskRequest.setReplacePodTask(0);
|
||||
newMovePodTaskRequest.setDesType(2);
|
||||
//newMovePodTaskRequest.setDesStorageID(agvTask.getDestination());
|
||||
newMovePodTaskRequest.setDestination(agvTask.getEndCode());
|
||||
|
||||
NewMovePodTaskRequest.DesExt desExt = new NewMovePodTaskRequest.DesExt();
|
||||
desExt.setUnload(1);
|
||||
|
|
|
|||
|
|
@ -105,15 +105,14 @@ public class BatchUtil {
|
|||
*/
|
||||
@Transactional
|
||||
public void updateBatchItem(List<Item> items) {
|
||||
String sql = "UPDATE base_item SET item_code = ?, item_name = ?, unit = ?, iz_active = ?, del_flag = ? WHERE id = ?";
|
||||
String sql = "UPDATE base_item SET item_name = ?, unit = ?, iz_active = ?, del_flag = ? WHERE id = ?";
|
||||
batchUpdate(sql, items, (ps, item) -> {
|
||||
try {
|
||||
ps.setString(1, item.getItemCode());
|
||||
ps.setString(2, item.getItemName());
|
||||
ps.setString(3, item.getUnit());
|
||||
ps.setInt(4, item.getIzActive());
|
||||
ps.setInt(5, item.getDelFlag());
|
||||
ps.setLong(6, item.getId());
|
||||
ps.setString(1, item.getItemName());
|
||||
ps.setString(2, item.getUnit());
|
||||
ps.setInt(3, item.getIzActive());
|
||||
ps.setInt(4, item.getDelFlag());
|
||||
ps.setLong(5, item.getId());
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
@ -125,7 +124,8 @@ public class BatchUtil {
|
|||
*/
|
||||
@Transactional
|
||||
public void saveBatchPoint(List<Point> points) {
|
||||
String sql = "INSERT INTO base_point (id,area_id, point_code,status,row_num,col_num,layer_num,description,iz_active,del_flag,sys_org_code,tenant_id,create_by,create_time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
String sql = "INSERT INTO base_point (`id`, `area_id`, `point_code`, `status`, `row_num`, `col_num`, `layer_num`, `position_x`, `position_y` , `iz_double_lane`, `iz_active`, `del_flag`, `sys_org_code`, `tenant_id`, `create_by`, `create_time`) " +
|
||||
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
batchInsert(sql, points, (ps, point) -> {
|
||||
try {
|
||||
ps.setLong(1, point.getId());
|
||||
|
|
@ -135,13 +135,15 @@ public class BatchUtil {
|
|||
ps.setString(5, point.getRowNum());
|
||||
ps.setString(6, point.getColNum());
|
||||
ps.setString(7, point.getLayerNum());
|
||||
ps.setString(8, point.getDescription());
|
||||
ps.setInt(9, point.getIzActive());
|
||||
ps.setInt(10, point.getDelFlag());
|
||||
ps.setString(11, point.getSysOrgCode());
|
||||
ps.setLong(12, point.getTenantId());
|
||||
ps.setString(13, point.getCreateBy());
|
||||
ps.setDate(14, new Date(point.getCreateTime().getTime()));
|
||||
ps.setInt(8, point.getPositionX());
|
||||
ps.setInt(9, point.getPositionY());
|
||||
ps.setInt(10, point.getIzDoubleLane());
|
||||
ps.setInt(11, point.getIzActive());
|
||||
ps.setInt(12, point.getDelFlag());
|
||||
ps.setString(13, point.getSysOrgCode());
|
||||
ps.setLong(14, point.getTenantId());
|
||||
ps.setString(15, point.getCreateBy());
|
||||
ps.setDate(16, new Date(point.getCreateTime().getTime()));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
@ -152,20 +154,17 @@ public class BatchUtil {
|
|||
* 批量更新点位
|
||||
*/
|
||||
@Transactional
|
||||
public void batchUpdatePoints(List<Point> points) {
|
||||
String sql = "UPDATE base_point SET area_id = ?, point_code = ?, status = ?, row_num = ?, col_num = ?, layer_num = ?, description = ?, iz_active = ?, del_flag = ? WHERE id = ?";
|
||||
public void batchUpdatePoint(List<Point> points) {
|
||||
String sql = "UPDATE base_point SET row_num = ?, col_num = ?, layer_num = ?,position_x = ?,position_y = ?,iz_double_lane = ? WHERE id = ?";
|
||||
batchUpdate(sql, points, (ps, point) -> {
|
||||
try {
|
||||
ps.setLong(1, point.getAreaId());
|
||||
ps.setString(2, point.getPointCode());
|
||||
ps.setInt(3, point.getStatus());
|
||||
ps.setString(4, point.getRowNum());
|
||||
ps.setString(5, point.getColNum());
|
||||
ps.setString(6, point.getLayerNum());
|
||||
ps.setString(7, point.getDescription());
|
||||
ps.setInt(8, point.getIzActive());
|
||||
ps.setInt(9, point.getDelFlag());
|
||||
ps.setLong(10, point.getId());
|
||||
ps.setString(1, point.getRowNum());
|
||||
ps.setString(2, point.getColNum());
|
||||
ps.setString(3, point.getLayerNum());
|
||||
ps.setInt(4, point.getPositionX());
|
||||
ps.setInt(5, point.getPositionY());
|
||||
ps.setInt(6, point.getIzDoubleLane());
|
||||
ps.setLong(7, point.getId());
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
@ -201,7 +200,7 @@ public class BatchUtil {
|
|||
* 批量更新点位
|
||||
*/
|
||||
@Transactional
|
||||
public void batchUpdateStocks(List<Stock> stocks) {
|
||||
public void batchUpdateStock(List<Stock> stocks) {
|
||||
String sql = "UPDATE base_stock SET iz_active = ?, del_flag = ? WHERE id = ?";
|
||||
batchUpdate(sql, stocks, (ps, stock) -> {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue