no message
parent
0bc5829e0a
commit
ae7f78db63
|
|
@ -34,6 +34,7 @@ public interface LogService {
|
|||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 查询条件
|
||||
* @param pageable 分页参数
|
||||
* @return /
|
||||
|
|
@ -42,6 +43,7 @@ public interface LogService {
|
|||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 查询条件
|
||||
* @return /
|
||||
*/
|
||||
|
|
@ -49,6 +51,7 @@ public interface LogService {
|
|||
|
||||
/**
|
||||
* 查询用户日志
|
||||
*
|
||||
* @param criteria 查询条件
|
||||
* @param pageable 分页参数
|
||||
* @return -
|
||||
|
|
@ -57,19 +60,23 @@ public interface LogService {
|
|||
|
||||
/**
|
||||
* 保存日志数据
|
||||
* @param username 用户
|
||||
* @param browser 浏览器
|
||||
* @param ip 请求IP
|
||||
*
|
||||
* @param username 用户
|
||||
* @param browser 浏览器
|
||||
* @param ip 请求IP
|
||||
* @param joinPoint /
|
||||
* @param log 日志实体
|
||||
* @param log 日志实体
|
||||
*/
|
||||
@Async
|
||||
void save(String url,String returnValue,String username, String browser, String ip, JoinPoint joinPoint, Log log);
|
||||
void save(String url, String returnValue, String username, String browser, String ip, JoinPoint joinPoint, Log log);
|
||||
|
||||
@Async
|
||||
void saveLog(Log log);
|
||||
|
||||
void saveLogInfo(Object object, String ip, String url, String resultJson, String description, long time, String logType);
|
||||
|
||||
|
||||
/**
|
||||
* 查询异常详情
|
||||
*
|
||||
* @param id 日志ID
|
||||
* @return Object
|
||||
*/
|
||||
|
|
@ -77,7 +84,8 @@ public interface LogService {
|
|||
|
||||
/**
|
||||
* 导出日志
|
||||
* @param logs 待导出的数据
|
||||
*
|
||||
* @param logs 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import cn.hutool.core.lang.Dict;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.youchain.domain.Log;
|
||||
import com.youchain.repository.LogRepository;
|
||||
import com.youchain.service.LogService;
|
||||
|
|
@ -34,6 +35,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
|||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
|
@ -43,6 +45,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
|
@ -77,9 +80,9 @@ public class LogServiceImpl implements LogService {
|
|||
Page<Log> page = logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)), pageable);
|
||||
return PageUtil.toPage(page.map(logSmallMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Async
|
||||
public void save(String url,String returnValue,String username, String browser, String ip, JoinPoint joinPoint, Log log_data) {
|
||||
if (log_data == null) {
|
||||
throw new IllegalArgumentException("Log 不能为 null!");
|
||||
|
|
@ -113,6 +116,7 @@ public class LogServiceImpl implements LogService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Async
|
||||
public void saveLog(Log log_data) {
|
||||
if (log_data == null) {
|
||||
throw new IllegalArgumentException("Log 不能为 null!");
|
||||
|
|
@ -120,6 +124,26 @@ public class LogServiceImpl implements LogService {
|
|||
logRepository.save(log_data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Async
|
||||
public void saveLogInfo(Object object,String ip, String url, String resultJson, String description, long time, String logType) {
|
||||
// 设置日志信息
|
||||
Log log_data = new Log();
|
||||
log_data.setDescription(description);
|
||||
log_data.setLogType(logType);
|
||||
log_data.setMethod(url);
|
||||
log_data.setParams(JSON.toJSONString(object));
|
||||
log_data.setReturnData(resultJson);
|
||||
log_data.setRequestIp(ip);
|
||||
log_data.setTime(time);
|
||||
log_data.setUsername("admin");
|
||||
log_data.setAddress("内网IP");
|
||||
log_data.setBrowser("Chrome 123");
|
||||
log_data.setCreateTime(new Timestamp(new Date().getTime()));
|
||||
logRepository.save(log_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据方法和传入的参数获取请求参数
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,21 +1,9 @@
|
|||
package com.youchain.appupdate.rest;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.youchain.annotation.AnonymousAccess;
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.appupdate.ReturnJson.RLocLayout;
|
||||
import com.youchain.basicdata.service.impl.PointServiceImpl;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.repository.AgvTaskRepository;
|
||||
import com.youchain.businessdata.repository.PickDetailRepository;
|
||||
import com.youchain.businessdata.repository.TaskRepository;
|
||||
import com.youchain.businessdata.service.impl.*;
|
||||
import com.youchain.report_data.utils.PieChart;
|
||||
import com.youchain.utils.AreaNameDic;
|
||||
import com.youchain.utils.BaseStatus;
|
||||
import com.youchain.utils.DateUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -28,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,26 +3,17 @@ package com.youchain.appupdate.rest;
|
|||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.alibaba.druid.sql.visitor.functions.Substring;
|
||||
import com.youchain.annotation.AnonymousAccess;
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.appupdate.ReturnJson.RLocLayout;
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
import com.youchain.basicdata.repository.ItemRepository;
|
||||
import com.youchain.basicdata.service.ItemService;
|
||||
import com.youchain.basicdata.service.StockService;
|
||||
import com.youchain.basicdata.service.impl.PointServiceImpl;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.repository.AgvTaskRepository;
|
||||
import com.youchain.businessdata.repository.AsnDetailRepository;
|
||||
import com.youchain.businessdata.repository.PickDetailRepository;
|
||||
import com.youchain.businessdata.repository.TaskRepository;
|
||||
import com.youchain.businessdata.service.*;
|
||||
import com.youchain.businessdata.service.impl.AsnDetailServiceImpl;
|
||||
import com.youchain.businessdata.service.impl.InventoryServiceImpl;
|
||||
import com.youchain.businessdata.service.impl.PickDetailServiceImpl;
|
||||
import com.youchain.businessdata.service.impl.TaskServiceImpl;
|
||||
import com.youchain.modules.system.service.DictService;
|
||||
import com.youchain.report_data.utils.PieChart;
|
||||
import com.youchain.utils.AreaNameDic;
|
||||
import com.youchain.utils.BaseStatus;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.youchain.basicdata.service;
|
||||
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
|
|
@ -22,6 +22,7 @@ import com.youchain.basicdata.service.dto.PointDto;
|
|||
import com.youchain.basicdata.service.dto.PointQueryCriteria;
|
||||
import com.youchain.basicdata.service.dto.PointSmallDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
|
|
@ -29,37 +30,41 @@ import java.util.Set;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author liuxue
|
||||
* @date 2023-07-26
|
||||
**/
|
||||
* @author liuxue
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @date 2023-07-26
|
||||
**/
|
||||
public interface PointService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(PointQueryCriteria criteria, Pageable pageable);
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(PointQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<PointDto>
|
||||
*/
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param criteria 条件参数
|
||||
* @return List<PointDto>
|
||||
*/
|
||||
List<PointDto> queryAll(PointQueryCriteria criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @return List<PointDto>
|
||||
*/
|
||||
List<PointSmallDto> queryKyPointList();
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return PointDto
|
||||
*/
|
||||
|
|
@ -67,40 +72,46 @@ public interface PointService {
|
|||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return PointDto
|
||||
*/
|
||||
Point findEntityById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return PointDto
|
||||
*/
|
||||
* 创建
|
||||
*
|
||||
* @param resources /
|
||||
* @return PointDto
|
||||
*/
|
||||
PointDto create(Point resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
* 编辑
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void update(Point resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
* 导出数据
|
||||
*
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<PointDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
*dto转实体
|
||||
* dto转实体
|
||||
*
|
||||
* @param pointDto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -109,36 +120,39 @@ public interface PointService {
|
|||
|
||||
void queryPoint(String pointCode);
|
||||
|
||||
List<Point> getPoint(String type,String areaCode);
|
||||
List<Point> getPoint(String type, String areaCode);
|
||||
|
||||
|
||||
List<Point> getPoint(String type,String areaCode,int page,int pageSize);
|
||||
List<Point> getPoint(String type, String areaCode, int page, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据code查找库区
|
||||
*
|
||||
* @param code-编号
|
||||
* @param status-状态
|
||||
* @param type-类型
|
||||
* @param areaName-库区名称
|
||||
* @param areaCode-库区代码
|
||||
* @param goodType-存储类型
|
||||
* @return
|
||||
*/
|
||||
Point findByCode(String code,String status,String type,String areaName,String goodType,Double itemHeight);
|
||||
Point findByCode(String code, String status, String type, String areaCode, String goodType, Double itemHeight);
|
||||
|
||||
/**
|
||||
* 得到指定点位
|
||||
*
|
||||
* @param code
|
||||
* @param status
|
||||
* @param type
|
||||
* @param areaName
|
||||
* @return
|
||||
*/
|
||||
Point getPoint(String code,String status,String type,String areaName);
|
||||
Point getPoint(String code, String status, String type, String areaName);
|
||||
|
||||
Map<String,Point> findByCodes(Set pointCodes);
|
||||
Map<String, Point> findByCodes(Set pointCodes);
|
||||
|
||||
/**
|
||||
* 根据小库区编号查询点位集合
|
||||
*
|
||||
* @param beat_code
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ public class PointServiceImpl implements PointService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Point findByCode(String code, String status, String type, String areaName, String goodType,Double itemHeight) {
|
||||
public Point findByCode(String code, String status, String type, String areaCode, String goodType, Double itemHeight) {
|
||||
StringBuilder hql = new StringBuilder("from Point point where point.enabled = true");
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
if (code != null && !code.isEmpty()) {
|
||||
|
|
@ -225,18 +225,18 @@ public class PointServiceImpl implements PointService {
|
|||
hql.append(" and point.description = :goodType");
|
||||
params.put("goodType", goodType);
|
||||
}
|
||||
if (areaName != null && !areaName.isEmpty()) {
|
||||
hql.append(" and point.area.name = :areaName");
|
||||
params.put("areaName", areaName);
|
||||
if (areaCode != null && !areaCode.isEmpty()) {
|
||||
hql.append(" and point.area.code = :areaCode");
|
||||
params.put("areaCode", areaCode);
|
||||
}
|
||||
if(itemHeight!= null ){
|
||||
if (itemHeight != null) {
|
||||
hql.append(" and point.itemHeight = :itemHeight");
|
||||
params.put("itemHeight", itemHeight);
|
||||
}
|
||||
Query query = entityMapper.createQuery(hql.toString());
|
||||
params.forEach(query::setParameter);
|
||||
Optional<Point> pointList = query.getResultStream().findFirst();
|
||||
return pointList.isPresent() ? pointList.get() : null;
|
||||
List<Point> pointList = query.getResultList();
|
||||
return pointList.isEmpty() ? null : pointList.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -294,14 +294,14 @@ public class StockServiceImpl implements StockService {
|
|||
}
|
||||
//容器类型:小件入库则入小件缓存区、大件入库则入大件缓存区
|
||||
Map<String, String> stockTypeToAreaMap = new HashMap<>();
|
||||
stockTypeToAreaMap.put("小件入库", "小件存储区");
|
||||
stockTypeToAreaMap.put("大件入库", "大件存储区");
|
||||
stockTypeToAreaMap.put("小件入库", AreaNameDic.XJQ);
|
||||
stockTypeToAreaMap.put("大件入库", AreaNameDic.DJQ);
|
||||
if (!stockTypeToAreaMap.containsKey(stock.getStockType())) {
|
||||
throw new RuntimeException(stock.getStockType() + "容器类型错误!");
|
||||
}
|
||||
String areaName = stockTypeToAreaMap.get(stock.getStockType());
|
||||
String areaCode = stockTypeToAreaMap.get(stock.getStockType());
|
||||
|
||||
Point endPoint = validateEndPoint(item, areaName);//验证目标点位
|
||||
Point endPoint = validateEndPoint(item, areaCode);//验证目标点位
|
||||
checkPointStatus(srcPoint);//验证源点位状态
|
||||
AgvTask agvTask = createAndSendAgvTask(BizStatus.ASN, stock, srcPoint, endPoint);//生成AGV任务
|
||||
AsnDetail asnDetail = asnDetailService.createAsnDetail(item, stock, srcPoint, propC1, boxNumber, propC3, Timestamp.valueOf(DateUtil.formatDateTime(DateUtil.parse(propD1))), orderQty, QRCode);
|
||||
|
|
@ -389,14 +389,14 @@ public class StockServiceImpl implements StockService {
|
|||
return srcPoint;
|
||||
}
|
||||
|
||||
private Point validateEndPoint(Item item, String areaName) {
|
||||
private Point validateEndPoint(Item item, String areaCode) {
|
||||
Double itemHeight = null;
|
||||
if ("小件存储区".equals(areaName)) {
|
||||
if (AreaNameDic.XJQ.equals(areaCode)) {
|
||||
itemHeight = item.getExtendD2();//整托高度
|
||||
}
|
||||
Point endPoint = pointService.findByCode(null, BaseStatus.FREE, BaseStatus.STORAGE, areaName, null, itemHeight);
|
||||
Point endPoint = pointService.findByCode(null, BaseStatus.FREE, BaseStatus.STORAGE, areaCode, null, itemHeight);
|
||||
if (endPoint == null) {
|
||||
throw new RuntimeException(areaName + "没有空闲点位!");
|
||||
throw new RuntimeException(areaCode + "没有空闲点位!");
|
||||
}
|
||||
return endPoint;
|
||||
}
|
||||
|
|
@ -439,19 +439,19 @@ public class StockServiceImpl implements StockService {
|
|||
|
||||
private void handleFullContainerCall(String itemCode, Point endPoint) {
|
||||
Item item = validateItem(itemCode);//验证物料
|
||||
String endPointAreaName = endPoint.getArea().getCode();
|
||||
String endPointAreaCode = endPoint.getArea().getCode();
|
||||
//只允许叫料区叫满车
|
||||
if (!isValidMCJLArea(endPointAreaName)) {
|
||||
if (!isValidMCJLArea(endPointAreaCode)) {
|
||||
throw new RuntimeException(endPoint.getCode() + "点位不能叫满车!");
|
||||
}
|
||||
String areaName = "";
|
||||
List<Inventory> inventoryList = inventoryService.queryInventory(item.getId(), areaName);
|
||||
String areaCode = AreaNameDic.DJQ+","+AreaNameDic.XJQ;
|
||||
List<Inventory> inventoryList = inventoryService.queryInventory(item.getId(), areaCode);
|
||||
if (inventoryList.isEmpty()) {
|
||||
throw new RuntimeException(itemCode + "物料无库存,呼叫失败!");
|
||||
}
|
||||
PickDetail pickDetail = pickDetailService.createPickDetail(item, "");
|
||||
try {
|
||||
pickDetailService.allocateAll(pickDetail.getId(), endPoint, areaName);
|
||||
pickDetailService.allocateAll(pickDetail.getId(), endPoint, areaCode);
|
||||
List<Task> taskList = taskService.getPickNotAllTask(pickDetail.getId());
|
||||
AgvTask agvTask = taskList.get(0).getAgvTask();
|
||||
sendAgvTaskAndHandleResponse(agvTask);
|
||||
|
|
@ -464,8 +464,8 @@ public class StockServiceImpl implements StockService {
|
|||
|
||||
}
|
||||
|
||||
private boolean isValidMCJLArea(String areaName) {
|
||||
return AreaNameDic.JLQ.equals(areaName);
|
||||
private boolean isValidMCJLArea(String areaCode) {
|
||||
return AreaNameDic.JLQ.equals(areaCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.youchain.businessdata.repository;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
|
|
@ -25,14 +25,15 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author huojin
|
||||
* @date 2023-08-16
|
||||
**/
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
* @date 2023-08-16
|
||||
**/
|
||||
public interface PickDetailRepository extends JpaRepository<PickDetail, Long>, JpaSpecificationExecutor<PickDetail> {
|
||||
/**
|
||||
* 查询前后桶出库的数量
|
||||
* @param time 2023-12-09 00:00:00
|
||||
*
|
||||
* @param time 2023-12-09 00:00:00
|
||||
* @param status PICK_ALL 已完成 ALLOCATE 待执行
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -44,6 +45,7 @@ public interface PickDetailRepository extends JpaRepository<PickDetail, Long>, J
|
|||
|
||||
/**
|
||||
* 查询前后桶出库全部数据
|
||||
*
|
||||
* @param time 2023-12-09 00:00:00
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -52,25 +54,31 @@ public interface PickDetailRepository extends JpaRepository<PickDetail, Long>, J
|
|||
" UNION select a.* from data_pick_detail a INNER JOIN base_item b on a.item_id = b.id " +
|
||||
"WHERE b.name = '前桶' and a.create_time > :time ", nativeQuery = true)
|
||||
List<PickDetail> queryOutQHAllData(String time);
|
||||
|
||||
@Query(value = "SELECT p FROM PickDetail p WHERE p.pick.id=?1 and p.item.id=?2", nativeQuery = false)
|
||||
List<PickDetail> findRepeat(Long pickId, Long itemId);
|
||||
|
||||
/**
|
||||
* 查询待分配的出库明细
|
||||
* 查询已分配的出库明细
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT p FROM PickDetail p WHERE p.orderQty>p.allocatedQty", nativeQuery = false)
|
||||
List<PickDetail> findByAllocate();
|
||||
@Query(value = " FROM PickDetail p WHERE p.orderQty-p.allocatedQty=0 and p.pick.id=?1 ")
|
||||
List<PickDetail> findByAllocate(Long pickId);
|
||||
|
||||
/**
|
||||
* 查询未拣货完成的出库明细
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT p FROM PickDetail p WHERE p.allocatedQty>p.pickedQty and p.pick.id=?1", nativeQuery = false)
|
||||
@Query(value = "SELECT p FROM PickDetail p WHERE p.allocatedQty>p.pickedQty and p.pick.id=?1")
|
||||
List<PickDetail> findByPickNo(Long pickId);
|
||||
|
||||
/**
|
||||
* 查询当前出库单是否有未分配完的明细
|
||||
* 查询当前出库单未分配完的明细
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT p FROM PickDetail p WHERE p.orderQty>p.allocatedQty and p.pick.id=?1", nativeQuery = false)
|
||||
List<PickDetail> findByAllocate(Long pickId);
|
||||
@Query(value = "SELECT p FROM PickDetail p WHERE p.orderQty>p.allocatedQty and p.pick.id=?1")
|
||||
List<PickDetail> findByPickDetailNoAllocate(Long pickId);
|
||||
}
|
||||
|
|
@ -31,8 +31,8 @@ public interface PickRepository extends JpaRepository<Pick, Long>, JpaSpecificat
|
|||
@Query(value = "SELECT p FROM Pick p WHERE p.id=?1 and p.lineNo=?2")
|
||||
List<Pick> findRepeat(long gdDetailId, int no);
|
||||
|
||||
@Query(value = "SELECT p FROM Pick p WHERE p.status=?1 ")
|
||||
List<Pick> findByStatus(String status);
|
||||
@Query(value = " FROM Pick p WHERE p.status=?1 ")
|
||||
List<Pick> findByPickStatus(String status);
|
||||
|
||||
@Query(value = " FROM Pick p WHERE p.code=?1 and p.code=?2 and p.code=?3 ")
|
||||
Pick findByPick(String gdNo, String completeCode, String station);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ public class GdDetailController {
|
|||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询gdDetail")
|
||||
@ApiOperation("查询gdDetail")
|
||||
@PreAuthorize("@el.check('gdDetail:list')")
|
||||
public ResponseEntity<Object> queryGdDetail(GdDetailQueryCriteria criteria, Pageable pageable){
|
||||
|
|
|
|||
|
|
@ -1,32 +1,18 @@
|
|||
package com.youchain.businessdata.rest;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.annotation.AnonymousAccess;
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.appupdate.inputJson.ContainerIn;
|
||||
import com.youchain.appupdate.inputJson.MissionStateCallback;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.domain.Stock;
|
||||
import com.youchain.basicdata.repository.StockRepository;
|
||||
import com.youchain.basicdata.service.PointService;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.domain.Task;
|
||||
import com.youchain.businessdata.service.AgvTaskService;
|
||||
import com.youchain.businessdata.service.TaskService;
|
||||
import com.youchain.businessdata.service.dto.AgvTaskDto;
|
||||
import com.youchain.exception.handler.ApiResult;
|
||||
import com.youchain.utils.AreaNameDic;
|
||||
import com.youchain.utils.BaseStatus;
|
||||
import com.youchain.utils.BizStatus;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
|
|||
|
|
@ -1,29 +1,20 @@
|
|||
package com.youchain.businessdata.rest;
|
||||
|
||||
import com.youchain.exception.handler.ApiResult;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import com.youchain.RequestData.*;
|
||||
import com.youchain.annotation.AnonymousAccess;
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.basicdata.domain.BigBom;
|
||||
import com.youchain.basicdata.domain.BigItem;
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
import com.youchain.basicdata.repository.BigBomRepository;
|
||||
import com.youchain.basicdata.repository.BigItemRepository;
|
||||
import com.youchain.basicdata.repository.ItemRepository;
|
||||
import com.youchain.businessdata.service.GdDetailService;
|
||||
import com.youchain.businessdata.service.GdService;
|
||||
import com.youchain.businessdata.service.PickService;
|
||||
import com.youchain.exception.BadRequestException;
|
||||
import com.youchain.exception.handler.ApiResult;
|
||||
import com.youchain.modules.system.service.DeptService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
|
|
@ -34,10 +25,6 @@ import static org.springframework.http.HttpStatus.OK;
|
|||
@Slf4j
|
||||
public class MesController {
|
||||
private final GdService gdService;
|
||||
private final DeptService deptService;
|
||||
private final ItemRepository itemRepository;
|
||||
private final BigBomRepository bigBomRepository;
|
||||
private final BigItemRepository bigItemRepository;
|
||||
private final PickService pickService;
|
||||
|
||||
@PostMapping("/yclbl")
|
||||
|
|
@ -45,47 +32,12 @@ public class MesController {
|
|||
@ApiOperation("mes-原材料备料")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> yclbl(@Validated @RequestBody Yclbl yclbl) {
|
||||
|
||||
try {
|
||||
gdService.materialBL(yclbl);
|
||||
return successResponse("备料成功!");
|
||||
}catch (Exception e){
|
||||
return badResponse("备料失败:"+e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return badResponse("备料失败:" + e.getMessage());
|
||||
}
|
||||
|
||||
/* *//* 添加工单单头*//*
|
||||
Gd gd = gdService.createGd(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());
|
||||
if (yclbl.getBlzc() != null) {
|
||||
String orderType = BaseStatus.GD_TYPE_CT;
|
||||
Set<ZcData> blzc = yclbl.getBlzc();
|
||||
for (ZcData zcData : blzc) {
|
||||
*//* 验证成套 物料*//*
|
||||
BigItem bigItem = verifiedBigItem(zcData.getCompleteCode());
|
||||
Set<ItemDate> itemDates = zcData.getBlzcmx();
|
||||
for (ItemDate itemDate : itemDates) {
|
||||
*//* 验证单品 物料*//*
|
||||
Item item = verifiedItem(itemDate.getItemCode());
|
||||
*//* 验证BOM*//*
|
||||
BigBom bigBom = verifiedBigBom(bigItem, item, itemDate.getItemQty());
|
||||
*//* 添加工单明细*//*
|
||||
GdDetail gdDetail = gdDetailService.save(zcData.getLineNo(), gd, orderType, bigItem, zcData.getCompleteQty(), item, itemDate.getItemQty(), itemDate.getItemQty() * zcData.getCompleteQty());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (yclbl.getBlzcmx() != null) {
|
||||
String orderType = BaseStatus.GD_TYPE_DP;
|
||||
Set<ItemDate> itemDateList = yclbl.getBlzcmx();
|
||||
for (ItemDate itemDate : itemDateList) {
|
||||
*//* 验证单品物料*//*
|
||||
Item item = verifiedItem(itemDate.getItemCode());
|
||||
*//* 添加工单明细*//*
|
||||
GdDetail gdDetail = gdDetailService.save(itemDate.getLineNo(), gd, orderType, null, null, item, itemDate.getItemQty(), itemDate.getItemQty());
|
||||
}
|
||||
}
|
||||
*//* 生成 出库明细*//*
|
||||
gdService.addPickDetail(gd);
|
||||
ApiResult apiResult = ApiResult.result(200, "成功", null);
|
||||
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));*/
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -111,7 +63,7 @@ public class MesController {
|
|||
pickService.itemCall(orderNo, itemCode, station, pointCode);
|
||||
return successResponse("叫料成功!");
|
||||
} catch (Exception e) {
|
||||
return badResponse("叫料失败!"+e.getMessage());
|
||||
return badResponse("叫料失败!" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,47 +102,13 @@ public class MesController {
|
|||
return new ResponseEntity<>(ApiResult.result(200, "成功", null), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证成套物料
|
||||
*/
|
||||
private BigItem verifiedBigItem(String completeCode) {
|
||||
BigItem bigItem = bigItemRepository.findByBigItemCode(completeCode);
|
||||
if (bigItem == null) {
|
||||
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护成套物料" + completeCode);
|
||||
} else {
|
||||
return bigItem;
|
||||
}
|
||||
}
|
||||
|
||||
private Item verifiedItem(String itemCode) {
|
||||
Item item = itemRepository.findByItemCode(itemCode);
|
||||
if (item == null) {
|
||||
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护单品物料" + itemCode);
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
private BigBom verifiedBigBom(BigItem bigItem, Item item, Double itemQty) {
|
||||
List<BigBom> bigBomList = bigBomRepository.findRepeat(bigItem.getId(), item.getId());
|
||||
if (bigBomList.size() > 0) {
|
||||
return bigBomList.get(0);
|
||||
} else {
|
||||
// 添加BOM
|
||||
BigBom bigBom = new BigBom();
|
||||
bigBom.setBigItem(bigItem);
|
||||
bigBom.setItem(item);
|
||||
bigBom.setQuantity(itemQty);
|
||||
bigBom.setDept(deptService.getDefaultDept());
|
||||
bigBomRepository.save(bigBom);
|
||||
return bigBom;
|
||||
}
|
||||
}
|
||||
|
||||
private ResponseEntity<Object> badResponse(String message) {
|
||||
|
||||
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), message, ""), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
|
||||
private ResponseEntity<Object> successResponse(String message) {
|
||||
return new ResponseEntity<>(ApiResult.fail(OK.value(), message, ""), HttpStatus.OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ public class PickController {
|
|||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询pick")
|
||||
@ApiOperation("查询pick")
|
||||
@PreAuthorize("@el.check('pick:list')")
|
||||
public ResponseEntity<Object> queryPick(PickQueryCriteria criteria, Pageable pageable){
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class PickDetailController {
|
|||
if (pickDetailIds.size() > 0) {
|
||||
for (Long id : pickDetailIds) {
|
||||
PickDetailDto pickDetailDto = pickDetailService.findById(id);
|
||||
pickDetailService.allocate(id, pickDetailDto.getOrderQty(),null);
|
||||
pickDetailService.allocate(id, pickDetailDto.getOrderQty(),null,null);
|
||||
}
|
||||
} else {
|
||||
return new ResponseEntity(ApiResult.fail(BAD_REQUEST.value(), "参数错误或者为null", ""), HttpStatus.BAD_REQUEST);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.youchain.businessdata.service;
|
||||
|
||||
import com.youchain.basicdata.domain.BigItem;
|
||||
|
|
@ -22,79 +22,73 @@ import com.youchain.businessdata.domain.GdDetail;
|
|||
import com.youchain.businessdata.service.dto.GdDetailDto;
|
||||
import com.youchain.businessdata.service.dto.GdDetailQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author huojin
|
||||
* @date 2024-06-06
|
||||
**/
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @date 2024-06-06
|
||||
**/
|
||||
public interface GdDetailService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(GdDetailQueryCriteria criteria, Pageable pageable);
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(GdDetailQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<GdDetailDto>
|
||||
*/
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param criteria 条件参数
|
||||
* @return List<GdDetailDto>
|
||||
*/
|
||||
List<GdDetailDto> queryAll(GdDetailQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return GdDetailDto
|
||||
*/
|
||||
GdDetailDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return GdDetailDto
|
||||
*/
|
||||
* 创建
|
||||
*
|
||||
* @param resources /
|
||||
* @return GdDetailDto
|
||||
*/
|
||||
GdDetailDto create(GdDetail resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
* 编辑
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void update(GdDetail resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<GdDetailDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 添加工单明细
|
||||
* @param lineNo 行号
|
||||
* @param gd 工单
|
||||
* @param orderType 分配类型 成套,单品
|
||||
* @param bigItem 成套 物料
|
||||
* @param completeQty 成套数
|
||||
* @param item 单品物料
|
||||
* @param itemQty 每套单品数
|
||||
* @param orderQty 未拆分数量
|
||||
* @return
|
||||
* 导出数据
|
||||
*
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
GdDetail save(int lineNo,Gd gd, String orderType, BigItem bigItem, Double completeQty, Item item, Double itemQty,Double orderQty);
|
||||
void download(List<GdDetailDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.youchain.businessdata.service;
|
||||
|
||||
import com.youchain.basicdata.domain.Box;
|
||||
|
|
@ -27,80 +27,88 @@ import com.youchain.businessdata.service.dto.InventoryDto;
|
|||
import com.youchain.businessdata.service.dto.InventoryQueryCriteria;
|
||||
import com.youchain.modules.system.domain.Dept;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author huojin
|
||||
* @date 2023-08-22
|
||||
**/
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @date 2023-08-22
|
||||
**/
|
||||
public interface InventoryService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(InventoryQueryCriteria criteria, Pageable pageable);
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(InventoryQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<InventoryDto>
|
||||
*/
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param criteria 条件参数
|
||||
* @return List<InventoryDto>
|
||||
*/
|
||||
List<InventoryDto> queryAll(InventoryQueryCriteria criteria);
|
||||
|
||||
List<InventoryDto> queryAll(InvQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return InventoryDto
|
||||
*/
|
||||
InventoryDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return InventoryDto
|
||||
*/
|
||||
* 创建
|
||||
*
|
||||
* @param resources /
|
||||
* @return InventoryDto
|
||||
*/
|
||||
InventoryDto create(Inventory resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
* 编辑
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void update(Inventory resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
* 导出数据
|
||||
*
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<InventoryDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
Inventory toEntity(InventoryDto inventoryDto);
|
||||
|
||||
List<Inventory> queryInventory(long itemId,String areaName);
|
||||
List<Inventory> queryInventory(long itemId, String areaCode);
|
||||
|
||||
Inventory getInventory(ItemKey itemKey, Point point, Stock stock, Dept dept,String type);
|
||||
Inventory getInventory(ItemKey itemKey, Point point, Stock stock, Dept dept, String type);
|
||||
|
||||
List<Inventory> queryInventory(Stock stock);
|
||||
|
||||
List<Inventory> getInvForPlan(String type,Long areaId,Long itemId,Long deptId);
|
||||
List<Inventory> getInvForPlan(String type, Long areaId, Long itemId, Long deptId);
|
||||
|
||||
Inventory updateInventory(Task task, Stock stock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.youchain.businessdata.service;
|
||||
|
||||
import com.youchain.basicdata.domain.Box;
|
||||
|
|
@ -25,104 +25,122 @@ import com.youchain.businessdata.domain.PickDetail;
|
|||
import com.youchain.businessdata.service.dto.PickDetailDto;
|
||||
import com.youchain.businessdata.service.dto.PickDetailQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author huojin
|
||||
* @date 2023-08-16
|
||||
**/
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @date 2023-08-16
|
||||
**/
|
||||
public interface PickDetailService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(PickDetailQueryCriteria criteria, Pageable pageable);
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(PickDetailQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<PickDetailDto>
|
||||
*/
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param criteria 条件参数
|
||||
* @return List<PickDetailDto>
|
||||
*/
|
||||
List<PickDetailDto> queryAll(PickDetailQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return PickDetailDto
|
||||
*/
|
||||
PickDetailDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return PickDetailDto
|
||||
*/
|
||||
* 创建
|
||||
*
|
||||
* @param resources /
|
||||
* @return PickDetailDto
|
||||
*/
|
||||
PickDetailDto create(PickDetail resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
* 编辑
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void update(PickDetail resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
* 导出数据
|
||||
*
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<PickDetailDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 分配
|
||||
*/
|
||||
void allocate(long id,double quantity,String areaName);
|
||||
String allocate(long id, double quantity, String areaName, Point endPoint);
|
||||
|
||||
/**
|
||||
* 整出分配
|
||||
*/
|
||||
void allocateAll(long id, Point endPoint,String areaName) throws Exception;
|
||||
void allocateAll(long id, Point endPoint, String areaName) throws Exception;
|
||||
|
||||
/**
|
||||
* 取消分配
|
||||
*/
|
||||
void cancelAllocate(long id,double quantity) throws Exception;
|
||||
void cancelAllocate(long id, double quantity) throws Exception;
|
||||
|
||||
/**
|
||||
* 统计数量
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Dto转实体
|
||||
*
|
||||
* @param pickDetailDto
|
||||
* @return
|
||||
*/
|
||||
PickDetail toEntity(PickDetailDto pickDetailDto);
|
||||
|
||||
PickDetail createPickDetail(Item item,String po);
|
||||
PickDetail createPickDetail(Item item, String po);
|
||||
|
||||
void save(Pick pick);
|
||||
|
||||
/**
|
||||
* 创建出库单明细
|
||||
*
|
||||
* @param pick->出库单
|
||||
* @param gdDetails->工单明细
|
||||
*/
|
||||
void createPickDetail(Pick pick, List<GdDetail> gdDetails);
|
||||
|
||||
/**
|
||||
* 分配出库单
|
||||
*
|
||||
* @param pick->出库单
|
||||
*/
|
||||
void allocatePick(Pick pick);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,44 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.youchain.businessdata.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.youchain.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author huojin
|
||||
* @date 2024-06-11
|
||||
**/
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
* @date 2024-06-11
|
||||
**/
|
||||
@Data
|
||||
public class PickQueryCriteria{
|
||||
public class PickQueryCriteria {
|
||||
|
||||
/** 模糊 */
|
||||
/**
|
||||
* 工单编码
|
||||
*/
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String code;
|
||||
private String gdCode;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Query(type = Query.Type.EQUAL)
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,8 +200,8 @@ public class GdServiceImpl implements GdService {
|
|||
/** 创建工单明细 */
|
||||
List<GdDetail> gdDetailList = createGdDetailsCPAndDP(gd, yclbl);
|
||||
|
||||
/** 创建出库单和出库明细 */
|
||||
createPickAndPickDetail(gd, gdDetailList);
|
||||
/** 添加出库单和出库明细 */
|
||||
addPickAndPickDetail(gd, gdDetailList);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -414,7 +414,7 @@ public class GdServiceImpl implements GdService {
|
|||
return packageCheck;
|
||||
}
|
||||
|
||||
private void createPickAndPickDetail(Gd gd, List<GdDetail> gdDetailList) {
|
||||
private void addPickAndPickDetail(Gd gd, List<GdDetail> gdDetailList) {
|
||||
AtomicInteger lineNo = new AtomicInteger(1);
|
||||
/** 成品工单明细集合 */
|
||||
List<GdDetail> cpGdDetailList = gdDetailList.stream()
|
||||
|
|
@ -425,19 +425,8 @@ public class GdServiceImpl implements GdService {
|
|||
Map<String, List<GdDetail>> groupedByCpCodeMap = cpGdDetailList.stream()
|
||||
.collect(Collectors.groupingBy(gdDetail -> gdDetail.getBigItem().getCode()));
|
||||
|
||||
/** 根据工单明细生成出库单和出库单明细 */
|
||||
groupedByCpCodeMap.forEach((code, gdDetails) -> {
|
||||
PackageCheck packageCheck = validatePackageCheck(code);// 验证翻包套数是否存在
|
||||
double xqTaoQty = gdDetails.get(0).getBigItemQty();//需求套数
|
||||
double fbTaoQty = packageCheck.getQuantity();//翻包套数
|
||||
double chkQty = Math.ceil(xqTaoQty / fbTaoQty);//生成出库单数量
|
||||
|
||||
for (int i = 0; i < chkQty; i++) {
|
||||
Pick pick = pickService.createPick(gd, lineNo.getAndIncrement(), code);
|
||||
pickDetailService.createPickDetail(pick, gdDetails);
|
||||
}
|
||||
|
||||
});
|
||||
/** 根据成品工单明细生成出库单和出库单明细 */
|
||||
createPickAndPickDetail(gd, groupedByCpCodeMap, lineNo);
|
||||
|
||||
/** 单品工单明细集合 */
|
||||
List<GdDetail> dpGdDetailList = gdDetailList.stream()
|
||||
|
|
@ -448,11 +437,29 @@ public class GdServiceImpl implements GdService {
|
|||
Map<String, List<GdDetail>> groupedByDpCodeMap = dpGdDetailList.stream()
|
||||
.collect(Collectors.groupingBy(gdDetail -> gdDetail.getItem().getCode()));
|
||||
|
||||
/** 根据工单明细生成出库单和出库单明细 */
|
||||
groupedByDpCodeMap.forEach((code, gdDetails) -> {
|
||||
Pick pick = pickService.createPick(gd, lineNo.getAndIncrement(), code);
|
||||
pickDetailService.createPickDetail(pick, gdDetails);
|
||||
});
|
||||
/** 根据单品工单明细生成出库单和出库单明细 */
|
||||
createPickAndPickDetail(gd, groupedByDpCodeMap, lineNo);
|
||||
|
||||
}
|
||||
|
||||
private void createPickAndPickDetail(Gd gd, Map<String, List<GdDetail>> groupedByDpCodeMap, AtomicInteger lineNo) {
|
||||
|
||||
groupedByDpCodeMap.forEach((code, gdDetails) -> {
|
||||
PackageCheck packageCheck = validatePackageCheck(code);// 验证翻包套数是否存在
|
||||
double xqTaoQty = 0;//需求套数
|
||||
if (BaseStatus.GD_TYPE_CT.equals(gdDetails.get(0).getOrderType())) {
|
||||
xqTaoQty = gdDetails.get(0).getBigItemQty();
|
||||
} else if (BaseStatus.GD_TYPE_DP.equals(gdDetails.get(0).getOrderType())) {
|
||||
xqTaoQty = gdDetails.get(0).getItemQty();//需求套数
|
||||
}
|
||||
double fbTaoQty = packageCheck.getQuantity();//翻包套数
|
||||
double chkQty = Math.ceil(xqTaoQty / fbTaoQty);//生成出库单数量
|
||||
for (int i = 0; i < chkQty; i++) {
|
||||
Pick pick = pickService.createPick(gd, lineNo.getAndIncrement(), code);
|
||||
pickDetailService.createPickDetail(pick, gdDetails);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,17 +137,17 @@ public class InventoryServiceImpl implements InventoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Inventory> queryInventory(long itemId, String areaName) {
|
||||
public List<Inventory> queryInventory(long itemId, String areaCode) {
|
||||
StringBuilder hql = new StringBuilder("FROM Inventory inv WHERE inv.itemKey.item.id = :itemId AND inv.quantity > inv.queuedQty ");
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("itemId", itemId);
|
||||
if (areaName.contains(",")) {
|
||||
List<String> areas = Arrays.asList(areaName.split(","));
|
||||
hql.append(" AND inv.point.area.name IN (:areaNames)");
|
||||
params.put("areaNames", areas);
|
||||
if (areaCode.contains(",")) {
|
||||
List<String> areas = Arrays.asList(areaCode.split(","));
|
||||
hql.append(" AND inv.point.area.code IN (:areaCode)");
|
||||
params.put("areaCode", areas);
|
||||
} else {
|
||||
hql.append(" AND inv.point.area.name = :areaName");
|
||||
params.put("areaName", areaName);
|
||||
hql.append(" AND inv.point.area.code = :areaCode");
|
||||
params.put("areaCode", areaCode);
|
||||
}
|
||||
|
||||
hql.append(" ORDER BY inv.createTime");
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
*/
|
||||
package com.youchain.businessdata.service.impl;
|
||||
|
||||
import com.youchain.basicdata.domain.Box;
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.domain.Stock;
|
||||
import com.youchain.basicdata.repository.BoxRepository;
|
||||
import com.youchain.basicdata.repository.StockRepository;
|
||||
import com.youchain.basicdata.service.ItemService;
|
||||
import com.youchain.basicdata.service.PointService;
|
||||
import com.youchain.basicdata.service.dto.ItemDto;
|
||||
|
|
@ -29,24 +26,20 @@ import com.youchain.businessdata.repository.*;
|
|||
import com.youchain.businessdata.service.InventoryService;
|
||||
import com.youchain.businessdata.service.TaskService;
|
||||
import com.youchain.businessdata.service.dto.InventoryDto;
|
||||
import com.youchain.exception.BadRequestException;
|
||||
import com.youchain.exception.handler.ApiResult;
|
||||
import com.youchain.modules.quartz.utils.TimeNumberUtils;
|
||||
import com.youchain.modules.system.domain.Dept;
|
||||
import com.youchain.service.LogService;
|
||||
import com.youchain.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.youchain.businessdata.service.PickDetailService;
|
||||
import com.youchain.businessdata.service.dto.PickDetailDto;
|
||||
import com.youchain.businessdata.service.dto.PickDetailQueryCriteria;
|
||||
import com.youchain.businessdata.service.mapstruct.PickDetailMapper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
|
@ -54,8 +47,6 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.Query;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
|
||||
/**
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -70,10 +61,11 @@ public class PickDetailServiceImpl implements PickDetailService {
|
|||
private final GdDetailRepository gdDetailRepository;
|
||||
private final PickDetailMapper pickDetailMapper;
|
||||
private final InventoryService inventoryService;
|
||||
private final BoxRepository boxRepository;
|
||||
private final AgvTaskRepository agvTaskRepository;
|
||||
private final TaskService taskService;
|
||||
private final ItemService itemService;
|
||||
private final PointService pointService;
|
||||
private final LogService logService;
|
||||
private final EntityManager entityMapper;
|
||||
|
||||
@Override
|
||||
|
|
@ -141,7 +133,7 @@ public class PickDetailServiceImpl implements PickDetailService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized void allocate(long id, double quantity, String areaName) {
|
||||
public synchronized String allocate(long id, double quantity, String areaName, Point endPoint) {
|
||||
if (areaName == null) {
|
||||
areaName = "大件存储区,小件存储区";
|
||||
}
|
||||
|
|
@ -151,89 +143,70 @@ public class PickDetailServiceImpl implements PickDetailService {
|
|||
Item item = itemService.toEntity(itemDto);
|
||||
Dept dept = item.getDept();//仓库
|
||||
Pick pick = pd.getPick();
|
||||
// Box box = boxRepository.getBoxByItem(item.getId());
|
||||
Point endPoint = pick.getPoint();//目标点位
|
||||
if (pd.getOrderQty() > pd.getAllocatedQty()) {
|
||||
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaName);
|
||||
if (Inventorys.size() > 0) {
|
||||
double allocateQty = 0;
|
||||
double unQty = quantity;//未分配数量
|
||||
for (Inventory inv : Inventorys) {
|
||||
Stock stock = inv.getStock();//容器
|
||||
Point startPoint = inv.getPoint();//起始点位
|
||||
if (unQty == 0) {
|
||||
break;
|
||||
}
|
||||
allocateQty = inv.getQuantity() - inv.getQueuedQty();//库存可用数量
|
||||
if (allocateQty <= 0) {
|
||||
continue;
|
||||
}
|
||||
if (unQty < allocateQty) {
|
||||
allocateQty = unQty;
|
||||
}
|
||||
inv.setQueuedQty(inv.getQueuedQty() + allocateQty);
|
||||
inventoryService.update(inv);
|
||||
unQty -= allocateQty;
|
||||
/* 更新出库单明细状态*/
|
||||
pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty);
|
||||
if (pd.getOrderQty().equals(pd.getAllocatedQty())) {
|
||||
pd.setStatus(BizStatus.ALLOCATE);
|
||||
}
|
||||
pickDetailRepository.save(pd);
|
||||
/* 更新出库单状态*/
|
||||
List<PickDetail> pickDetailList = pickDetailRepository.findByAllocate(pick.getId());
|
||||
if (pickDetailList.size() < 1) {
|
||||
pick.setStatus(BizStatus.ALLOCATE);
|
||||
pickRepository.save(pick);
|
||||
} else {
|
||||
if (pick.getStatus().equals(BizStatus.OPEN)) {
|
||||
pick.setStatus(BizStatus.ASSIGN);
|
||||
pickRepository.save(pick);
|
||||
}
|
||||
}
|
||||
//生成搬运任务
|
||||
/*AgvTask agvTask = new AgvTask(BizStatus.PICK, stock.getCode(), startPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "01");
|
||||
agvTaskRepository.save(agvTask);*/
|
||||
//生成Task
|
||||
Task task = new Task();
|
||||
task.setTaskType(BizStatus.PICK);
|
||||
task.setItem(item);
|
||||
task.setItemKey(inv.getItemKey());
|
||||
task.setPickDetail(pd);
|
||||
task.setBillCode(pd.getPo());
|
||||
task.setSrcStock(inv.getStock());
|
||||
task.setDstStock(inv.getStock());
|
||||
task.setSrcPoint(startPoint);
|
||||
task.setDstPoint(endPoint);
|
||||
task.setSrcStockCode(inv.getStock().getCode());
|
||||
task.setSrcPointCode(startPoint.getCode());
|
||||
task.setDstPointCode(endPoint.getCode());
|
||||
task.setInvStatus(inv.getStatus());
|
||||
task.setTaskStatus(BizStatus.OPEN);
|
||||
task.setPlanQty(allocateQty);
|
||||
task.setInventory(inv);
|
||||
task.setDept(dept);
|
||||
// task.setAgvTask(agvTask);
|
||||
taskService.create(task);
|
||||
}
|
||||
} else {
|
||||
throw new BadRequestException(HttpStatus.NOT_IMPLEMENTED, "库存不足:" + item.getCode());
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("已分配,请勿重复操作!");
|
||||
|
||||
|
||||
if (pd.getAllocatedQty() >= pd.getOrderQty()) {
|
||||
return pick.getCode() + "出库单;" + item.getCode() + "数量已分配!";
|
||||
}
|
||||
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaName);
|
||||
if (Inventorys.isEmpty()) {
|
||||
return pick.getCode() + "出库单;" + item.getCode() + "物料库存不足,请先补充库存!";
|
||||
}
|
||||
double allocateQty = 0;
|
||||
double unQty = quantity;//未分配数量
|
||||
for (Inventory inv : Inventorys) {
|
||||
Point startPoint = inv.getPoint();//起始点位
|
||||
if (unQty == 0) {
|
||||
break;
|
||||
}
|
||||
allocateQty = inv.getQuantity() - inv.getQueuedQty();//库存可用数量
|
||||
if (allocateQty <= 0) {
|
||||
continue;
|
||||
}
|
||||
if (unQty < allocateQty) {
|
||||
allocateQty = unQty;
|
||||
}
|
||||
inv.setQueuedQty(inv.getQueuedQty() + allocateQty);
|
||||
inventoryService.update(inv);
|
||||
unQty -= allocateQty;
|
||||
/* 更新出库单明细状态*/
|
||||
pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty);
|
||||
pickDetailRepository.save(pd);
|
||||
|
||||
//生成Task
|
||||
Task task = new Task();
|
||||
task.setTaskType(BizStatus.PICK);
|
||||
task.setItem(item);
|
||||
task.setItemKey(inv.getItemKey());
|
||||
task.setPickDetail(pd);
|
||||
task.setBillCode(pd.getPo());
|
||||
task.setSrcStock(inv.getStock());
|
||||
task.setDstStock(inv.getStock());
|
||||
task.setSrcPoint(startPoint);
|
||||
task.setDstPoint(endPoint);
|
||||
task.setSrcStockCode(inv.getStock().getCode());
|
||||
task.setSrcPointCode(startPoint.getCode());
|
||||
task.setDstPointCode(endPoint.getCode());
|
||||
task.setInvStatus(inv.getStatus());
|
||||
task.setTaskStatus(BizStatus.OPEN);
|
||||
task.setPlanQty(allocateQty);
|
||||
task.setInventory(inv);
|
||||
task.setDept(dept);
|
||||
taskService.create(task);
|
||||
}
|
||||
return pick.getCode() + "出库单;" + item.getCode() + "分配成功!";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized void allocateAll(long id, Point endPoint, String areaName) throws Exception {
|
||||
public synchronized void allocateAll(long id, Point endPoint, String areaCode) throws Exception {
|
||||
PickDetailDto pickDetailDto = findById(id);
|
||||
PickDetail pd = toEntity(pickDetailDto);//Dto转实体
|
||||
ItemDto itemDto = pickDetailDto.getItem();
|
||||
Item item = itemService.toEntity(itemDto);
|
||||
Dept dept = item.getDept();//仓库
|
||||
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaName);
|
||||
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaCode);
|
||||
if (Inventorys.size() > 0) {
|
||||
Inventory inv = Inventorys.get(0);
|
||||
//库存冻结状态不允许出库
|
||||
|
|
@ -396,10 +369,63 @@ public class PickDetailServiceImpl implements PickDetailService {
|
|||
pickDetail.setItem(gdDetail.getItem());
|
||||
pickDetail.setLineNo(lineNo.getAndIncrement());
|
||||
pickDetail.setStatus(BizStatus.OPEN);
|
||||
pickDetail.setOrderQty(gdDetail.getItemQty());
|
||||
if (BaseStatus.GD_TYPE_CT.equals(gdDetail.getOrderType())) {
|
||||
pickDetail.setOrderQty(gdDetail.getItemQty() * gdDetail.getBigItemQty());
|
||||
} else {
|
||||
pickDetail.setOrderQty(gdDetail.getItemQty());
|
||||
}
|
||||
pickDetail.setSourceId(gdDetail.getId());
|
||||
pickDetail.setDept(gdDetail.getDept());
|
||||
pickDetailRepository.save(pickDetail);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void allocatePick(Pick pick) {
|
||||
|
||||
//目标库位
|
||||
Point endPoint = null;
|
||||
if (pick.getPoint() == null) {
|
||||
endPoint = pointService.findByCode(null, BaseStatus.FREE, BaseStatus.BOX, AreaNameDic.FBQ, null, null);
|
||||
if (endPoint == null) {
|
||||
logService.saveLogInfo(pick.getCode(), pick.getCode(), "/pick/allocatePick", "分配失败,翻包区没有空闲点位!", "出库单分配", 200, "info");
|
||||
throw new IllegalArgumentException(pick.getCode() + "分配失败,翻包区没有空闲点位!");
|
||||
}
|
||||
} else {
|
||||
endPoint = pick.getPoint();
|
||||
}
|
||||
|
||||
|
||||
List<String> MsgList = new ArrayList<>();//存放提示信息
|
||||
//查询出待分配的pickDetail
|
||||
List<PickDetail> pickDetails = pickDetailRepository.findByPickDetailNoAllocate(pick.getId());
|
||||
for (PickDetail pickDetail : pickDetails) {
|
||||
MsgList.add(allocate(pickDetail.getId(), pickDetail.getOrderQty(), null, endPoint));
|
||||
}
|
||||
|
||||
/* 更新出库单状态并写入目标点位*/
|
||||
refreshPickStatus(pick, endPoint, pickDetails);
|
||||
|
||||
//保存日志
|
||||
logService.saveLogInfo(pick.getCode(), pick.getCode(), "/pick/allocatePick", MsgList.toString(), "出库单分配", 200, "info");
|
||||
}
|
||||
|
||||
private void refreshPickStatus(Pick pick, Point endPoint, List<PickDetail> openPickDetails) {
|
||||
List<PickDetail> allocatePickDetailList = pickDetailRepository.findByAllocate(pick.getId());
|
||||
if (allocatePickDetailList.size() == openPickDetails.size()) {
|
||||
pick.setStatus(BizStatus.ALLOCATE);
|
||||
pick.setPoint(endPoint);
|
||||
pickRepository.save(pick);
|
||||
endPoint.setStatus(BaseStatus.USED);
|
||||
pointService.update(endPoint);
|
||||
} else if (allocatePickDetailList.size() > 0) {
|
||||
pick.setStatus(BizStatus.ASSIGN);
|
||||
pick.setPoint(endPoint);
|
||||
pickRepository.save(pick);
|
||||
endPoint.setStatus(BaseStatus.USED);
|
||||
pointService.update(endPoint);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ public class QuartzJobController {
|
|||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("执行定时任务")
|
||||
@ApiOperation("执行定时任务")
|
||||
@PutMapping(value = "/exec/{id}")
|
||||
@PreAuthorize("@el.check('timing:edit')")
|
||||
|
|
|
|||
|
|
@ -31,59 +31,51 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
@Slf4j
|
||||
@Service
|
||||
public class pickTask {
|
||||
@Autowired
|
||||
public PickDetailRepository pickDetailRepository;
|
||||
|
||||
@Autowired
|
||||
public PickDetailService pickDetailService;
|
||||
|
||||
@Autowired
|
||||
public PickDetailRepository pickDetailRepository;
|
||||
|
||||
@Autowired
|
||||
public PickRepository pickRepository;
|
||||
|
||||
@Autowired
|
||||
public TaskRepository taskRepository;
|
||||
|
||||
@Autowired
|
||||
public AgvTaskRepository agvTaskRepository;
|
||||
|
||||
@Autowired
|
||||
public AgvTaskService agvTaskService;
|
||||
|
||||
private Map<String, List<Integer>> groupedTasks = new HashMap<>();
|
||||
|
||||
private long lastTaskTime = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
* 定时检测出库单,分配库存
|
||||
*/
|
||||
public void allocate() {
|
||||
System.out.println("定时检测物料,分配库存");
|
||||
/* 查询待分配的出库明细*/
|
||||
List<PickDetail> pickDetailList=pickDetailRepository.findByAllocate();
|
||||
List<String> arr=new ArrayList<>();//没有库存的物料集合
|
||||
for (PickDetail pickDetail:pickDetailList){
|
||||
/* 没有库存 不用分配*/
|
||||
if (arr.contains(pickDetail.getItem().getCode())){
|
||||
continue;
|
||||
}
|
||||
/* 分配库存*/
|
||||
try {
|
||||
pickDetailService.allocate(pickDetail.getId(), pickDetail.getOrderQty()-pickDetail.getAllocatedQty(), null);
|
||||
}catch (BadRequestException b){
|
||||
if (b.getStatus().equals(501)){
|
||||
/* 库存不足*/
|
||||
String itemCode= StringUtils.substringAfterLast(b.getMessage(), ":");
|
||||
arr.add(itemCode);
|
||||
}
|
||||
public void allocatePick() {
|
||||
|
||||
List<Pick> pickList = pickRepository.findByPickStatus(BizStatus.OPEN);
|
||||
if (pickList.isEmpty()) {
|
||||
throw new RuntimeException("无待分配的出库单!");
|
||||
} else {
|
||||
for (Pick pick : pickList) {
|
||||
pickDetailService.allocatePick(pick);
|
||||
}
|
||||
}
|
||||
System.out.println("分配出库单,库存不足:"+arr);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时检测出库单,生成《备料》搬运任务
|
||||
*/
|
||||
public void pickAgvTask() {
|
||||
/*查询分配完成的出库单*/
|
||||
List<Pick> pickList=pickRepository.findByStatus(BizStatus.ALLOCATE);
|
||||
for (Pick pick:pickList){
|
||||
List<Task> taskList=taskRepository.findByPick(pick.getId());
|
||||
for (Task task:taskList){
|
||||
List<Pick> pickList = pickRepository.findByPickStatus(BizStatus.ALLOCATE);
|
||||
for (Pick pick : pickList) {
|
||||
List<Task> taskList = taskRepository.findByPick(pick.getId());
|
||||
for (Task task : taskList) {
|
||||
/*生成搬运任务*/
|
||||
AgvTask agvTask = agvTaskService.addAgvTask(BizStatus.PICK, task.getSrcStockCode(), task.getSrcPointCode(), task.getDstPointCode(), BizStatus.OPEN, "01");
|
||||
/*更新Task任务*/
|
||||
|
|
@ -95,68 +87,7 @@ public class pickTask {
|
|||
pick.setStatus(BizStatus.PICKUP);
|
||||
pickRepository.save(pick);
|
||||
}
|
||||
}
|
||||
public void pickTask() {
|
||||
//按线边分组 下发出库任务
|
||||
List<Object> objectList = agvTaskRepository.queryGroupAgvTask();
|
||||
for (Object obj : objectList) {
|
||||
List<AgvTask> agvTaskList = agvTaskRepository.queryLineAgvTask(obj.toString());
|
||||
for (AgvTask agvTask : agvTaskList) {
|
||||
List<Integer> agvTaskList1 = groupedTasks.get(obj.toString());
|
||||
if (agvTaskList1 == null) {
|
||||
groupedTasks.computeIfAbsent(obj.toString(), k -> new CopyOnWriteArrayList<>()).add(agvTask.getId());
|
||||
} else if (agvTaskList1.size() <= 4) {
|
||||
boolean containsElement = agvTaskList1.contains(agvTask.getId());
|
||||
if (!containsElement) {
|
||||
groupedTasks.computeIfAbsent(obj.toString(), k -> new CopyOnWriteArrayList<>()).add(agvTask.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检查是否满足四个为一组或者时间超过五分钟
|
||||
if ((isGroupingConditionsMet() || timeExceeded()) && isLine() ) {
|
||||
issueGroupedTasks();
|
||||
groupedTasks.clear();
|
||||
lastTaskTime = System.currentTimeMillis();
|
||||
}else{
|
||||
log.info("小件出库料箱任务未满足条件!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean isLine() {
|
||||
// 判断缓存输送线上的料箱总数+AGV执行中的数量 不能超过6个
|
||||
int queryCount = agvTaskService.QueryCount("6x1");
|
||||
|
||||
//出库料箱AGV执行中的数量
|
||||
//List<AgvTask> agvTaskList= agvTaskService.findByAgvList(BizStatus.PICK,"PICKER_MOVE");
|
||||
if(queryCount<=6){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isGroupingConditionsMet() {
|
||||
// 判断是否满足四个为一组的条件
|
||||
return groupedTasks.values().stream().anyMatch(tasks -> tasks.size() == 4);
|
||||
}
|
||||
|
||||
private boolean timeExceeded() {
|
||||
// 判断时间是否超过3分钟
|
||||
return System.currentTimeMillis() - lastTaskTime >= 2 * 60 * 1000;
|
||||
}
|
||||
|
||||
private void issueGroupedTasks() {
|
||||
// 实现任务下发的逻辑
|
||||
// 可以遍历groupedTasks,处理每个分组的任务
|
||||
for (List<Integer> tasksInGroup : groupedTasks.values()) {
|
||||
List<AgvTask> agvTaskList= agvTaskService.findById(tasksInGroup);
|
||||
String rul=agvTaskService.sendAgvTaskLXImpl(agvTaskList);
|
||||
System.out.println(rul);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class BaseStatus {
|
|||
public static Boolean F =false;
|
||||
|
||||
/**
|
||||
* 点位类型-按钮盒点位
|
||||
* 点位类型-线边点位
|
||||
*/
|
||||
public static String BOX = "BOX";
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -22,13 +23,10 @@ public class EladminSystemApplicationTests {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Integer> list1 = Arrays.asList();
|
||||
List<Integer> list2 = Arrays.asList();
|
||||
|
||||
List<Integer> list3 = new ArrayList<>(list1);
|
||||
list3.addAll(list2);
|
||||
|
||||
System.out.println(list3); // 输出: [1, 2, 3, 4, 5]
|
||||
Map<String, List<String>> concurrentMapMsg = new ConcurrentHashMap<>();
|
||||
List<String> list1 = Arrays.asList("001库存不足!","002库存不足!", "003分配成功");
|
||||
concurrentMapMsg.put("GD202406261053", list1);
|
||||
System.out.println(list1);
|
||||
}
|
||||
|
||||
private static final int MAX_TASK_COUNT = 4;
|
||||
|
|
@ -37,6 +35,14 @@ public class EladminSystemApplicationTests {
|
|||
private List<Integer> taskQueue = new ArrayList<>(MAX_TASK_COUNT);
|
||||
|
||||
void aa(){
|
||||
List<Integer> list1 = Arrays.asList();
|
||||
List<Integer> list2 = Arrays.asList();
|
||||
|
||||
List<Integer> list3 = new ArrayList<>(list1);
|
||||
list3.addAll(list2);
|
||||
|
||||
System.out.println(list3); // 输出: [1, 2, 3, 4, 5]
|
||||
|
||||
/*double taoQty=2;//基础套数
|
||||
double xTaoQty=3;//需求套数
|
||||
double ckdQty=Math.ceil(xTaoQty/taoQty);//生成出库单数量
|
||||
|
|
|
|||
Loading…
Reference in New Issue