no message

main
HUOJIN\92525 2024-06-26 17:22:10 +08:00
parent 0bc5829e0a
commit ae7f78db63
25 changed files with 562 additions and 629 deletions

View File

@ -34,6 +34,7 @@ public interface LogService {
/** /**
* *
*
* @param criteria * @param criteria
* @param pageable * @param pageable
* @return / * @return /
@ -42,6 +43,7 @@ public interface LogService {
/** /**
* *
*
* @param criteria * @param criteria
* @return / * @return /
*/ */
@ -49,6 +51,7 @@ public interface LogService {
/** /**
* *
*
* @param criteria * @param criteria
* @param pageable * @param pageable
* @return - * @return -
@ -57,19 +60,23 @@ public interface LogService {
/** /**
* *
*
* @param username * @param username
* @param browser * @param browser
* @param ip IP * @param ip IP
* @param joinPoint / * @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 saveLog(Log log);
void saveLogInfo(Object object, String ip, String url, String resultJson, String description, long time, String logType);
/** /**
* *
*
* @param id ID * @param id ID
* @return Object * @return Object
*/ */
@ -77,6 +84,7 @@ public interface LogService {
/** /**
* *
*
* @param logs * @param logs
* @param response / * @param response /
* @throws IOException / * @throws IOException /

View File

@ -19,6 +19,7 @@ import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.youchain.domain.Log; import com.youchain.domain.Log;
import com.youchain.repository.LogRepository; import com.youchain.repository.LogRepository;
import com.youchain.service.LogService; import com.youchain.service.LogService;
@ -34,6 +35,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -43,6 +45,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Parameter; import java.lang.reflect.Parameter;
import java.sql.Timestamp;
import java.util.*; 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); Page<Log> page = logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)), pageable);
return PageUtil.toPage(page.map(logSmallMapper::toDto)); return PageUtil.toPage(page.map(logSmallMapper::toDto));
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Async
public void save(String url,String returnValue,String username, String browser, String ip, JoinPoint joinPoint, Log log_data) { public void save(String url,String returnValue,String username, String browser, String ip, JoinPoint joinPoint, Log log_data) {
if (log_data == null) { if (log_data == null) {
throw new IllegalArgumentException("Log 不能为 null!"); throw new IllegalArgumentException("Log 不能为 null!");
@ -113,6 +116,7 @@ public class LogServiceImpl implements LogService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Async
public void saveLog(Log log_data) { public void saveLog(Log log_data) {
if (log_data == null) { if (log_data == null) {
throw new IllegalArgumentException("Log 不能为 null!"); throw new IllegalArgumentException("Log 不能为 null!");
@ -120,6 +124,26 @@ public class LogServiceImpl implements LogService {
logRepository.save(log_data); 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);
}
/** /**
* *
*/ */

View File

@ -1,21 +1,9 @@
package com.youchain.appupdate.rest; package com.youchain.appupdate.rest;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import com.youchain.annotation.AnonymousAccess; 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.businessdata.service.impl.*;
import com.youchain.report_data.utils.PieChart; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -28,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;

View File

@ -3,26 +3,17 @@ package com.youchain.appupdate.rest;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import com.alibaba.druid.sql.visitor.functions.Substring;
import com.youchain.annotation.AnonymousAccess; import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.appupdate.ReturnJson.RLocLayout; 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.basicdata.service.impl.PointServiceImpl;
import com.youchain.businessdata.domain.AgvTask; import com.youchain.businessdata.domain.AgvTask;
import com.youchain.businessdata.repository.AgvTaskRepository; import com.youchain.businessdata.repository.AgvTaskRepository;
import com.youchain.businessdata.repository.AsnDetailRepository;
import com.youchain.businessdata.repository.PickDetailRepository; import com.youchain.businessdata.repository.PickDetailRepository;
import com.youchain.businessdata.repository.TaskRepository;
import com.youchain.businessdata.service.*; import com.youchain.businessdata.service.*;
import com.youchain.businessdata.service.impl.AsnDetailServiceImpl; import com.youchain.businessdata.service.impl.AsnDetailServiceImpl;
import com.youchain.businessdata.service.impl.InventoryServiceImpl; import com.youchain.businessdata.service.impl.InventoryServiceImpl;
import com.youchain.businessdata.service.impl.PickDetailServiceImpl; import com.youchain.businessdata.service.impl.PickDetailServiceImpl;
import com.youchain.businessdata.service.impl.TaskServiceImpl; import com.youchain.businessdata.service.impl.TaskServiceImpl;
import com.youchain.modules.system.service.DictService;
import com.youchain.report_data.utils.PieChart; import com.youchain.report_data.utils.PieChart;
import com.youchain.utils.AreaNameDic; import com.youchain.utils.AreaNameDic;
import com.youchain.utils.BaseStatus; import com.youchain.utils.BaseStatus;

View File

@ -1,18 +1,18 @@
/* /*
* Copyright 2019-2020 Zheng Jie * Copyright 2019-2020 Zheng Jie
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.youchain.basicdata.service; package com.youchain.basicdata.service;
import com.youchain.basicdata.domain.Item; 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.PointQueryCriteria;
import com.youchain.basicdata.service.dto.PointSmallDto; import com.youchain.basicdata.service.dto.PointSmallDto;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
@ -29,23 +30,25 @@ import java.util.Set;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
* @website https://eladmin.vip * @author liuxue
* @description * @website https://eladmin.vip
* @author liuxue * @description
* @date 2023-07-26 * @date 2023-07-26
**/ **/
public interface PointService { public interface PointService {
/** /**
* *
*
* @param criteria * @param criteria
* @param pageable * @param pageable
* @return Map<String,Object> * @return Map<String, Object>
*/ */
Map<String,Object> queryAll(PointQueryCriteria criteria, Pageable pageable); Map<String, Object> queryAll(PointQueryCriteria criteria, Pageable pageable);
/** /**
* *
*
* @param criteria * @param criteria
* @return List<PointDto> * @return List<PointDto>
*/ */
@ -54,12 +57,14 @@ public interface PointService {
/** /**
* *
*
* @return List<PointDto> * @return List<PointDto>
*/ */
List<PointSmallDto> queryKyPointList(); List<PointSmallDto> queryKyPointList();
/** /**
* ID * ID
*
* @param id ID * @param id ID
* @return PointDto * @return PointDto
*/ */
@ -67,6 +72,7 @@ public interface PointService {
/** /**
* ID * ID
*
* @param id ID * @param id ID
* @return PointDto * @return PointDto
*/ */
@ -74,6 +80,7 @@ public interface PointService {
/** /**
* *
*
* @param resources / * @param resources /
* @return PointDto * @return PointDto
*/ */
@ -81,18 +88,21 @@ public interface PointService {
/** /**
* *
*
* @param resources / * @param resources /
*/ */
void update(Point resources); void update(Point resources);
/** /**
* *
*
* @param ids / * @param ids /
*/ */
void deleteAll(Long[] ids); void deleteAll(Long[] ids);
/** /**
* *
*
* @param all * @param all
* @param response / * @param response /
* @throws IOException / * @throws IOException /
@ -100,7 +110,8 @@ public interface PointService {
void download(List<PointDto> all, HttpServletResponse response) throws IOException; void download(List<PointDto> all, HttpServletResponse response) throws IOException;
/** /**
*dto * dto
*
* @param pointDto * @param pointDto
* @return * @return
*/ */
@ -109,36 +120,39 @@ public interface PointService {
void queryPoint(String pointCode); 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 * code
*
* @param code- * @param code-
* @param status- * @param status-
* @param type- * @param type-
* @param areaName- * @param areaCode-
* @param goodType- * @param goodType-
* @return * @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 code
* @param status * @param status
* @param type * @param type
* @param areaName * @param areaName
* @return * @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 * @param beat_code
* @return * @return
*/ */

View File

@ -206,7 +206,7 @@ public class PointServiceImpl implements PointService {
} }
@Override @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"); StringBuilder hql = new StringBuilder("from Point point where point.enabled = true");
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
if (code != null && !code.isEmpty()) { if (code != null && !code.isEmpty()) {
@ -225,18 +225,18 @@ public class PointServiceImpl implements PointService {
hql.append(" and point.description = :goodType"); hql.append(" and point.description = :goodType");
params.put("goodType", goodType); params.put("goodType", goodType);
} }
if (areaName != null && !areaName.isEmpty()) { if (areaCode != null && !areaCode.isEmpty()) {
hql.append(" and point.area.name = :areaName"); hql.append(" and point.area.code = :areaCode");
params.put("areaName", areaName); params.put("areaCode", areaCode);
} }
if(itemHeight!= null ){ if (itemHeight != null) {
hql.append(" and point.itemHeight = :itemHeight"); hql.append(" and point.itemHeight = :itemHeight");
params.put("itemHeight", itemHeight); params.put("itemHeight", itemHeight);
} }
Query query = entityMapper.createQuery(hql.toString()); Query query = entityMapper.createQuery(hql.toString());
params.forEach(query::setParameter); params.forEach(query::setParameter);
Optional<Point> pointList = query.getResultStream().findFirst(); List<Point> pointList = query.getResultList();
return pointList.isPresent() ? pointList.get() : null; return pointList.isEmpty() ? null : pointList.get(0);
} }
@Override @Override

View File

@ -294,14 +294,14 @@ public class StockServiceImpl implements StockService {
} }
//容器类型:小件入库则入小件缓存区、大件入库则入大件缓存区 //容器类型:小件入库则入小件缓存区、大件入库则入大件缓存区
Map<String, String> stockTypeToAreaMap = new HashMap<>(); Map<String, String> stockTypeToAreaMap = new HashMap<>();
stockTypeToAreaMap.put("小件入库", "小件存储区"); stockTypeToAreaMap.put("小件入库", AreaNameDic.XJQ);
stockTypeToAreaMap.put("大件入库", "大件存储区"); stockTypeToAreaMap.put("大件入库", AreaNameDic.DJQ);
if (!stockTypeToAreaMap.containsKey(stock.getStockType())) { if (!stockTypeToAreaMap.containsKey(stock.getStockType())) {
throw new RuntimeException(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);//验证源点位状态 checkPointStatus(srcPoint);//验证源点位状态
AgvTask agvTask = createAndSendAgvTask(BizStatus.ASN, stock, srcPoint, endPoint);//生成AGV任务 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); 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; return srcPoint;
} }
private Point validateEndPoint(Item item, String areaName) { private Point validateEndPoint(Item item, String areaCode) {
Double itemHeight = null; Double itemHeight = null;
if ("小件存储区".equals(areaName)) { if (AreaNameDic.XJQ.equals(areaCode)) {
itemHeight = item.getExtendD2();//整托高度 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) { if (endPoint == null) {
throw new RuntimeException(areaName + "没有空闲点位!"); throw new RuntimeException(areaCode + "没有空闲点位!");
} }
return endPoint; return endPoint;
} }
@ -439,19 +439,19 @@ public class StockServiceImpl implements StockService {
private void handleFullContainerCall(String itemCode, Point endPoint) { private void handleFullContainerCall(String itemCode, Point endPoint) {
Item item = validateItem(itemCode);//验证物料 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() + "点位不能叫满车!"); throw new RuntimeException(endPoint.getCode() + "点位不能叫满车!");
} }
String areaName = ""; String areaCode = AreaNameDic.DJQ+","+AreaNameDic.XJQ;
List<Inventory> inventoryList = inventoryService.queryInventory(item.getId(), areaName); List<Inventory> inventoryList = inventoryService.queryInventory(item.getId(), areaCode);
if (inventoryList.isEmpty()) { if (inventoryList.isEmpty()) {
throw new RuntimeException(itemCode + "物料无库存,呼叫失败!"); throw new RuntimeException(itemCode + "物料无库存,呼叫失败!");
} }
PickDetail pickDetail = pickDetailService.createPickDetail(item, ""); PickDetail pickDetail = pickDetailService.createPickDetail(item, "");
try { try {
pickDetailService.allocateAll(pickDetail.getId(), endPoint, areaName); pickDetailService.allocateAll(pickDetail.getId(), endPoint, areaCode);
List<Task> taskList = taskService.getPickNotAllTask(pickDetail.getId()); List<Task> taskList = taskService.getPickNotAllTask(pickDetail.getId());
AgvTask agvTask = taskList.get(0).getAgvTask(); AgvTask agvTask = taskList.get(0).getAgvTask();
sendAgvTaskAndHandleResponse(agvTask); sendAgvTaskAndHandleResponse(agvTask);
@ -464,8 +464,8 @@ public class StockServiceImpl implements StockService {
} }
private boolean isValidMCJLArea(String areaName) { private boolean isValidMCJLArea(String areaCode) {
return AreaNameDic.JLQ.equals(areaName); return AreaNameDic.JLQ.equals(areaCode);
} }
/** /**

View File

@ -1,18 +1,18 @@
/* /*
* Copyright 2019-2020 Zheng Jie * Copyright 2019-2020 Zheng Jie
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.youchain.businessdata.repository; package com.youchain.businessdata.repository;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
@ -25,13 +25,14 @@ import org.springframework.data.jpa.repository.Query;
import java.util.List; import java.util.List;
/** /**
* @website https://eladmin.vip * @author huojin
* @author huojin * @website https://eladmin.vip
* @date 2023-08-16 * @date 2023-08-16
**/ **/
public interface PickDetailRepository extends JpaRepository<PickDetail, Long>, JpaSpecificationExecutor<PickDetail> { 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 * @param status PICK_ALL ALLOCATE
* @return * @return
@ -44,6 +45,7 @@ public interface PickDetailRepository extends JpaRepository<PickDetail, Long>, J
/** /**
* *
*
* @param time 2023-12-09 00:00:00 * @param time 2023-12-09 00:00:00
* @return * @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 " + " 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) "WHERE b.name = '前桶' and a.create_time > :time ", nativeQuery = true)
List<PickDetail> queryOutQHAllData(String time); List<PickDetail> queryOutQHAllData(String time);
@Query(value = "SELECT p FROM PickDetail p WHERE p.pick.id=?1 and p.item.id=?2", nativeQuery = false) @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); List<PickDetail> findRepeat(Long pickId, Long itemId);
/** /**
* *
*
* @return * @return
*/ */
@Query(value = "SELECT p FROM PickDetail p WHERE p.orderQty>p.allocatedQty", nativeQuery = false) @Query(value = " FROM PickDetail p WHERE p.orderQty-p.allocatedQty=0 and p.pick.id=?1 ")
List<PickDetail> findByAllocate(); List<PickDetail> findByAllocate(Long pickId);
/** /**
* *
*
* @return * @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); List<PickDetail> findByPickNo(Long pickId);
/** /**
* *
*
* @return * @return
*/ */
@Query(value = "SELECT p FROM PickDetail p WHERE p.orderQty>p.allocatedQty and p.pick.id=?1", nativeQuery = false) @Query(value = "SELECT p FROM PickDetail p WHERE p.orderQty>p.allocatedQty and p.pick.id=?1")
List<PickDetail> findByAllocate(Long pickId); List<PickDetail> findByPickDetailNoAllocate(Long pickId);
} }

View File

@ -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") @Query(value = "SELECT p FROM Pick p WHERE p.id=?1 and p.lineNo=?2")
List<Pick> findRepeat(long gdDetailId, int no); List<Pick> findRepeat(long gdDetailId, int no);
@Query(value = "SELECT p FROM Pick p WHERE p.status=?1 ") @Query(value = " FROM Pick p WHERE p.status=?1 ")
List<Pick> findByStatus(String status); List<Pick> findByPickStatus(String status);
@Query(value = " FROM Pick p WHERE p.code=?1 and p.code=?2 and p.code=?3 ") @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); Pick findByPick(String gdNo, String completeCode, String station);

View File

@ -52,7 +52,6 @@ public class GdDetailController {
} }
@GetMapping @GetMapping
@Log("查询gdDetail")
@ApiOperation("查询gdDetail") @ApiOperation("查询gdDetail")
@PreAuthorize("@el.check('gdDetail:list')") @PreAuthorize("@el.check('gdDetail:list')")
public ResponseEntity<Object> queryGdDetail(GdDetailQueryCriteria criteria, Pageable pageable){ public ResponseEntity<Object> queryGdDetail(GdDetailQueryCriteria criteria, Pageable pageable){

View File

@ -1,32 +1,18 @@
package com.youchain.businessdata.rest; 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.AnonymousAccess;
import com.youchain.annotation.Log; import com.youchain.annotation.Log;
import com.youchain.appupdate.inputJson.ContainerIn;
import com.youchain.appupdate.inputJson.MissionStateCallback; 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.AgvTask;
import com.youchain.businessdata.domain.Task;
import com.youchain.businessdata.service.AgvTaskService; import com.youchain.businessdata.service.AgvTaskService;
import com.youchain.businessdata.service.TaskService;
import com.youchain.businessdata.service.dto.AgvTaskDto; import com.youchain.businessdata.service.dto.AgvTaskDto;
import com.youchain.exception.handler.ApiResult; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; 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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;

View File

@ -1,29 +1,20 @@
package com.youchain.businessdata.rest; package com.youchain.businessdata.rest;
import com.youchain.exception.handler.ApiResult;
import org.springframework.http.HttpStatus;
import com.youchain.RequestData.*; import com.youchain.RequestData.*;
import com.youchain.annotation.AnonymousAccess; import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log; 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.GdService;
import com.youchain.businessdata.service.PickService; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.OK;
@ -34,10 +25,6 @@ import static org.springframework.http.HttpStatus.OK;
@Slf4j @Slf4j
public class MesController { public class MesController {
private final GdService gdService; private final GdService gdService;
private final DeptService deptService;
private final ItemRepository itemRepository;
private final BigBomRepository bigBomRepository;
private final BigItemRepository bigItemRepository;
private final PickService pickService; private final PickService pickService;
@PostMapping("/yclbl") @PostMapping("/yclbl")
@ -45,47 +32,12 @@ public class MesController {
@ApiOperation("mes-原材料备料") @ApiOperation("mes-原材料备料")
@AnonymousAccess @AnonymousAccess
public ResponseEntity<Object> yclbl(@Validated @RequestBody Yclbl yclbl) { public ResponseEntity<Object> yclbl(@Validated @RequestBody Yclbl yclbl) {
try { try {
gdService.materialBL(yclbl); gdService.materialBL(yclbl);
return successResponse("备料成功!"); return successResponse("备料成功!");
}catch (Exception e){ } catch (Exception e) {
return badResponse("备料失败:"+e.getMessage()); 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); pickService.itemCall(orderNo, itemCode, station, pointCode);
return successResponse("叫料成功!"); return successResponse("叫料成功!");
} catch (Exception e) { } 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); 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) { private ResponseEntity<Object> badResponse(String message) {
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), message, ""), HttpStatus.BAD_REQUEST); return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), message, ""), HttpStatus.BAD_REQUEST);
} }
private ResponseEntity<Object> successResponse(String message) { private ResponseEntity<Object> successResponse(String message) {
return new ResponseEntity<>(ApiResult.fail(OK.value(), message, ""), HttpStatus.OK); return new ResponseEntity<>(ApiResult.fail(OK.value(), message, ""), HttpStatus.OK);
} }

View File

@ -52,7 +52,6 @@ public class PickController {
} }
@GetMapping @GetMapping
@Log("查询pick")
@ApiOperation("查询pick") @ApiOperation("查询pick")
@PreAuthorize("@el.check('pick:list')") @PreAuthorize("@el.check('pick:list')")
public ResponseEntity<Object> queryPick(PickQueryCriteria criteria, Pageable pageable){ public ResponseEntity<Object> queryPick(PickQueryCriteria criteria, Pageable pageable){

View File

@ -128,7 +128,7 @@ public class PickDetailController {
if (pickDetailIds.size() > 0) { if (pickDetailIds.size() > 0) {
for (Long id : pickDetailIds) { for (Long id : pickDetailIds) {
PickDetailDto pickDetailDto = pickDetailService.findById(id); PickDetailDto pickDetailDto = pickDetailService.findById(id);
pickDetailService.allocate(id, pickDetailDto.getOrderQty(),null); pickDetailService.allocate(id, pickDetailDto.getOrderQty(),null,null);
} }
} else { } else {
return new ResponseEntity(ApiResult.fail(BAD_REQUEST.value(), "参数错误或者为null", ""), HttpStatus.BAD_REQUEST); return new ResponseEntity(ApiResult.fail(BAD_REQUEST.value(), "参数错误或者为null", ""), HttpStatus.BAD_REQUEST);

View File

@ -1,18 +1,18 @@
/* /*
* Copyright 2019-2020 Zheng Jie * Copyright 2019-2020 Zheng Jie
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.youchain.businessdata.service; package com.youchain.businessdata.service;
import com.youchain.basicdata.domain.BigItem; import com.youchain.basicdata.domain.BigItem;
@ -22,29 +22,32 @@ import com.youchain.businessdata.domain.GdDetail;
import com.youchain.businessdata.service.dto.GdDetailDto; import com.youchain.businessdata.service.dto.GdDetailDto;
import com.youchain.businessdata.service.dto.GdDetailQueryCriteria; import com.youchain.businessdata.service.dto.GdDetailQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
* @website https://eladmin.vip * @author huojin
* @description * @website https://eladmin.vip
* @author huojin * @description
* @date 2024-06-06 * @date 2024-06-06
**/ **/
public interface GdDetailService { public interface GdDetailService {
/** /**
* *
*
* @param criteria * @param criteria
* @param pageable * @param pageable
* @return Map<String,Object> * @return Map<String, Object>
*/ */
Map<String,Object> queryAll(GdDetailQueryCriteria criteria, Pageable pageable); Map<String, Object> queryAll(GdDetailQueryCriteria criteria, Pageable pageable);
/** /**
* *
*
* @param criteria * @param criteria
* @return List<GdDetailDto> * @return List<GdDetailDto>
*/ */
@ -52,6 +55,7 @@ public interface GdDetailService {
/** /**
* ID * ID
*
* @param id ID * @param id ID
* @return GdDetailDto * @return GdDetailDto
*/ */
@ -59,6 +63,7 @@ public interface GdDetailService {
/** /**
* *
*
* @param resources / * @param resources /
* @return GdDetailDto * @return GdDetailDto
*/ */
@ -66,35 +71,24 @@ public interface GdDetailService {
/** /**
* *
*
* @param resources / * @param resources /
*/ */
void update(GdDetail resources); void update(GdDetail resources);
/** /**
* *
*
* @param ids / * @param ids /
*/ */
void deleteAll(Long[] ids); void deleteAll(Long[] ids);
/** /**
* *
*
* @param all * @param all
* @param response / * @param response /
* @throws IOException / * @throws IOException /
*/ */
void download(List<GdDetailDto> all, HttpServletResponse 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
*/
GdDetail save(int lineNo,Gd gd, String orderType, BigItem bigItem, Double completeQty, Item item, Double itemQty,Double orderQty);
} }

View File

@ -1,18 +1,18 @@
/* /*
* Copyright 2019-2020 Zheng Jie * Copyright 2019-2020 Zheng Jie
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.youchain.businessdata.service; package com.youchain.businessdata.service;
import com.youchain.basicdata.domain.Box; import com.youchain.basicdata.domain.Box;
@ -27,30 +27,33 @@ import com.youchain.businessdata.service.dto.InventoryDto;
import com.youchain.businessdata.service.dto.InventoryQueryCriteria; import com.youchain.businessdata.service.dto.InventoryQueryCriteria;
import com.youchain.modules.system.domain.Dept; import com.youchain.modules.system.domain.Dept;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
* @website https://eladmin.vip * @author huojin
* @description * @website https://eladmin.vip
* @author huojin * @description
* @date 2023-08-22 * @date 2023-08-22
**/ **/
public interface InventoryService { public interface InventoryService {
/** /**
* *
*
* @param criteria * @param criteria
* @param pageable * @param pageable
* @return Map<String,Object> * @return Map<String, Object>
*/ */
Map<String,Object> queryAll(InventoryQueryCriteria criteria, Pageable pageable); Map<String, Object> queryAll(InventoryQueryCriteria criteria, Pageable pageable);
/** /**
* *
*
* @param criteria * @param criteria
* @return List<InventoryDto> * @return List<InventoryDto>
*/ */
@ -60,6 +63,7 @@ public interface InventoryService {
/** /**
* ID * ID
*
* @param id ID * @param id ID
* @return InventoryDto * @return InventoryDto
*/ */
@ -67,6 +71,7 @@ public interface InventoryService {
/** /**
* *
*
* @param resources / * @param resources /
* @return InventoryDto * @return InventoryDto
*/ */
@ -74,18 +79,21 @@ public interface InventoryService {
/** /**
* *
*
* @param resources / * @param resources /
*/ */
void update(Inventory resources); void update(Inventory resources);
/** /**
* *
*
* @param ids / * @param ids /
*/ */
void deleteAll(Long[] ids); void deleteAll(Long[] ids);
/** /**
* *
*
* @param all * @param all
* @param response / * @param response /
* @throws IOException / * @throws IOException /
@ -94,13 +102,13 @@ public interface InventoryService {
Inventory toEntity(InventoryDto inventoryDto); 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> 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); Inventory updateInventory(Task task, Stock stock);
} }

View File

@ -1,18 +1,18 @@
/* /*
* Copyright 2019-2020 Zheng Jie * Copyright 2019-2020 Zheng Jie
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.youchain.businessdata.service; package com.youchain.businessdata.service;
import com.youchain.basicdata.domain.Box; import com.youchain.basicdata.domain.Box;
@ -25,29 +25,32 @@ import com.youchain.businessdata.domain.PickDetail;
import com.youchain.businessdata.service.dto.PickDetailDto; import com.youchain.businessdata.service.dto.PickDetailDto;
import com.youchain.businessdata.service.dto.PickDetailQueryCriteria; import com.youchain.businessdata.service.dto.PickDetailQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
* @website https://eladmin.vip * @author huojin
* @description * @website https://eladmin.vip
* @author huojin * @description
* @date 2023-08-16 * @date 2023-08-16
**/ **/
public interface PickDetailService { public interface PickDetailService {
/** /**
* *
*
* @param criteria * @param criteria
* @param pageable * @param pageable
* @return Map<String,Object> * @return Map<String, Object>
*/ */
Map<String,Object> queryAll(PickDetailQueryCriteria criteria, Pageable pageable); Map<String, Object> queryAll(PickDetailQueryCriteria criteria, Pageable pageable);
/** /**
* *
*
* @param criteria * @param criteria
* @return List<PickDetailDto> * @return List<PickDetailDto>
*/ */
@ -55,6 +58,7 @@ public interface PickDetailService {
/** /**
* ID * ID
*
* @param id ID * @param id ID
* @return PickDetailDto * @return PickDetailDto
*/ */
@ -62,6 +66,7 @@ public interface PickDetailService {
/** /**
* *
*
* @param resources / * @param resources /
* @return PickDetailDto * @return PickDetailDto
*/ */
@ -69,18 +74,21 @@ public interface PickDetailService {
/** /**
* *
*
* @param resources / * @param resources /
*/ */
void update(PickDetail resources); void update(PickDetail resources);
/** /**
* *
*
* @param ids / * @param ids /
*/ */
void deleteAll(Long[] ids); void deleteAll(Long[] ids);
/** /**
* *
*
* @param all * @param all
* @param response / * @param response /
* @throws IOException / * @throws IOException /
@ -90,39 +98,49 @@ public interface PickDetailService {
/** /**
* *
*/ */
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 * @return
*/ */
long count(); long count();
/** /**
* Dto * Dto
*
* @param pickDetailDto * @param pickDetailDto
* @return * @return
*/ */
PickDetail toEntity(PickDetailDto pickDetailDto); PickDetail toEntity(PickDetailDto pickDetailDto);
PickDetail createPickDetail(Item item,String po); PickDetail createPickDetail(Item item, String po);
void save(Pick pick); void save(Pick pick);
/** /**
* *
*
* @param pick-> * @param pick->
* @param gdDetails-> * @param gdDetails->
*/ */
void createPickDetail(Pick pick, List<GdDetail> gdDetails); void createPickDetail(Pick pick, List<GdDetail> gdDetails);
/**
*
*
* @param pick->
*/
void allocatePick(Pick pick);
} }

View File

@ -1,34 +1,44 @@
/* /*
* Copyright 2019-2020 Zheng Jie * Copyright 2019-2020 Zheng Jie
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.youchain.businessdata.service.dto; package com.youchain.businessdata.service.dto;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
import com.youchain.annotation.Query; import com.youchain.annotation.Query;
/** /**
* @website https://eladmin.vip * @author huojin
* @author huojin * @website https://eladmin.vip
* @date 2024-06-11 * @date 2024-06-11
**/ **/
@Data @Data
public class PickQueryCriteria{ public class PickQueryCriteria {
/** 模糊 */ /**
*
*/
@Query(type = Query.Type.INNER_LIKE) @Query(type = Query.Type.INNER_LIKE)
private String code; private String gdCode;
/**
*
*/
@Query(type = Query.Type.EQUAL)
private String status;
} }

View File

@ -200,8 +200,8 @@ public class GdServiceImpl implements GdService {
/** 创建工单明细 */ /** 创建工单明细 */
List<GdDetail> gdDetailList = createGdDetailsCPAndDP(gd, yclbl); List<GdDetail> gdDetailList = createGdDetailsCPAndDP(gd, yclbl);
/** 创建出库单和出库明细 */ /** 添加出库单和出库明细 */
createPickAndPickDetail(gd, gdDetailList); addPickAndPickDetail(gd, gdDetailList);
} }
@ -414,7 +414,7 @@ public class GdServiceImpl implements GdService {
return packageCheck; return packageCheck;
} }
private void createPickAndPickDetail(Gd gd, List<GdDetail> gdDetailList) { private void addPickAndPickDetail(Gd gd, List<GdDetail> gdDetailList) {
AtomicInteger lineNo = new AtomicInteger(1); AtomicInteger lineNo = new AtomicInteger(1);
/** 成品工单明细集合 */ /** 成品工单明细集合 */
List<GdDetail> cpGdDetailList = gdDetailList.stream() List<GdDetail> cpGdDetailList = gdDetailList.stream()
@ -425,19 +425,8 @@ public class GdServiceImpl implements GdService {
Map<String, List<GdDetail>> groupedByCpCodeMap = cpGdDetailList.stream() Map<String, List<GdDetail>> groupedByCpCodeMap = cpGdDetailList.stream()
.collect(Collectors.groupingBy(gdDetail -> gdDetail.getBigItem().getCode())); .collect(Collectors.groupingBy(gdDetail -> gdDetail.getBigItem().getCode()));
/** 根据工单明细生成出库单和出库单明细 */ /** 根据成品工单明细生成出库单和出库单明细 */
groupedByCpCodeMap.forEach((code, gdDetails) -> { createPickAndPickDetail(gd, groupedByCpCodeMap, lineNo);
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);
}
});
/** 单品工单明细集合 */ /** 单品工单明细集合 */
List<GdDetail> dpGdDetailList = gdDetailList.stream() List<GdDetail> dpGdDetailList = gdDetailList.stream()
@ -448,11 +437,29 @@ public class GdServiceImpl implements GdService {
Map<String, List<GdDetail>> groupedByDpCodeMap = dpGdDetailList.stream() Map<String, List<GdDetail>> groupedByDpCodeMap = dpGdDetailList.stream()
.collect(Collectors.groupingBy(gdDetail -> gdDetail.getItem().getCode())); .collect(Collectors.groupingBy(gdDetail -> gdDetail.getItem().getCode()));
/** 根据工单明细生成出库单和出库单明细 */ /** 根据单品工单明细生成出库单和出库单明细 */
groupedByDpCodeMap.forEach((code, gdDetails) -> { createPickAndPickDetail(gd, groupedByDpCodeMap, lineNo);
Pick pick = pickService.createPick(gd, lineNo.getAndIncrement(), code);
pickDetailService.createPickDetail(pick, gdDetails);
});
} }
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);
}
});
}
} }

View File

@ -137,17 +137,17 @@ public class InventoryServiceImpl implements InventoryService {
} }
@Override @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 "); StringBuilder hql = new StringBuilder("FROM Inventory inv WHERE inv.itemKey.item.id = :itemId AND inv.quantity > inv.queuedQty ");
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("itemId", itemId); params.put("itemId", itemId);
if (areaName.contains(",")) { if (areaCode.contains(",")) {
List<String> areas = Arrays.asList(areaName.split(",")); List<String> areas = Arrays.asList(areaCode.split(","));
hql.append(" AND inv.point.area.name IN (:areaNames)"); hql.append(" AND inv.point.area.code IN (:areaCode)");
params.put("areaNames", areas); params.put("areaCode", areas);
} else { } else {
hql.append(" AND inv.point.area.name = :areaName"); hql.append(" AND inv.point.area.code = :areaCode");
params.put("areaName", areaName); params.put("areaCode", areaCode);
} }
hql.append(" ORDER BY inv.createTime"); hql.append(" ORDER BY inv.createTime");

View File

@ -15,12 +15,9 @@
*/ */
package com.youchain.businessdata.service.impl; package com.youchain.businessdata.service.impl;
import com.youchain.basicdata.domain.Box;
import com.youchain.basicdata.domain.Item; import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point; import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock; 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.ItemService;
import com.youchain.basicdata.service.PointService; import com.youchain.basicdata.service.PointService;
import com.youchain.basicdata.service.dto.ItemDto; 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.InventoryService;
import com.youchain.businessdata.service.TaskService; import com.youchain.businessdata.service.TaskService;
import com.youchain.businessdata.service.dto.InventoryDto; 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.quartz.utils.TimeNumberUtils;
import com.youchain.modules.system.domain.Dept; import com.youchain.modules.system.domain.Dept;
import com.youchain.service.LogService;
import com.youchain.utils.*; import com.youchain.utils.*;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.service.PickDetailService; import com.youchain.businessdata.service.PickDetailService;
import com.youchain.businessdata.service.dto.PickDetailDto; import com.youchain.businessdata.service.dto.PickDetailDto;
import com.youchain.businessdata.service.dto.PickDetailQueryCriteria; import com.youchain.businessdata.service.dto.PickDetailQueryCriteria;
import com.youchain.businessdata.service.mapstruct.PickDetailMapper; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -54,8 +47,6 @@ import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
/** /**
* @author huojin * @author huojin
* @website https://eladmin.vip * @website https://eladmin.vip
@ -70,10 +61,11 @@ public class PickDetailServiceImpl implements PickDetailService {
private final GdDetailRepository gdDetailRepository; private final GdDetailRepository gdDetailRepository;
private final PickDetailMapper pickDetailMapper; private final PickDetailMapper pickDetailMapper;
private final InventoryService inventoryService; private final InventoryService inventoryService;
private final BoxRepository boxRepository;
private final AgvTaskRepository agvTaskRepository; private final AgvTaskRepository agvTaskRepository;
private final TaskService taskService; private final TaskService taskService;
private final ItemService itemService; private final ItemService itemService;
private final PointService pointService;
private final LogService logService;
private final EntityManager entityMapper; private final EntityManager entityMapper;
@Override @Override
@ -141,7 +133,7 @@ public class PickDetailServiceImpl implements PickDetailService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @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) { if (areaName == null) {
areaName = "大件存储区,小件存储区"; areaName = "大件存储区,小件存储区";
} }
@ -151,15 +143,18 @@ public class PickDetailServiceImpl implements PickDetailService {
Item item = itemService.toEntity(itemDto); Item item = itemService.toEntity(itemDto);
Dept dept = item.getDept();//仓库 Dept dept = item.getDept();//仓库
Pick pick = pd.getPick(); Pick pick = pd.getPick();
// Box box = boxRepository.getBoxByItem(item.getId());
Point endPoint = pick.getPoint();//目标点位
if (pd.getOrderQty() > pd.getAllocatedQty()) { if (pd.getAllocatedQty() >= pd.getOrderQty()) {
return pick.getCode() + "出库单;" + item.getCode() + "数量已分配!";
}
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaName); List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaName);
if (Inventorys.size() > 0) { if (Inventorys.isEmpty()) {
return pick.getCode() + "出库单;" + item.getCode() + "物料库存不足,请先补充库存!";
}
double allocateQty = 0; double allocateQty = 0;
double unQty = quantity;//未分配数量 double unQty = quantity;//未分配数量
for (Inventory inv : Inventorys) { for (Inventory inv : Inventorys) {
Stock stock = inv.getStock();//容器
Point startPoint = inv.getPoint();//起始点位 Point startPoint = inv.getPoint();//起始点位
if (unQty == 0) { if (unQty == 0) {
break; break;
@ -176,24 +171,8 @@ public class PickDetailServiceImpl implements PickDetailService {
unQty -= allocateQty; unQty -= allocateQty;
/* 更新出库单明细状态*/ /* 更新出库单明细状态*/
pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty); pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty);
if (pd.getOrderQty().equals(pd.getAllocatedQty())) {
pd.setStatus(BizStatus.ALLOCATE);
}
pickDetailRepository.save(pd); 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 task = new Task(); Task task = new Task();
task.setTaskType(BizStatus.PICK); task.setTaskType(BizStatus.PICK);
@ -213,27 +192,21 @@ public class PickDetailServiceImpl implements PickDetailService {
task.setPlanQty(allocateQty); task.setPlanQty(allocateQty);
task.setInventory(inv); task.setInventory(inv);
task.setDept(dept); task.setDept(dept);
// task.setAgvTask(agvTask);
taskService.create(task); taskService.create(task);
} }
} else { return pick.getCode() + "出库单;" + item.getCode() + "分配成功!";
throw new BadRequestException(HttpStatus.NOT_IMPLEMENTED, "库存不足:" + item.getCode());
}
} else {
throw new RuntimeException("已分配,请勿重复操作!");
}
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @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); PickDetailDto pickDetailDto = findById(id);
PickDetail pd = toEntity(pickDetailDto);//Dto转实体 PickDetail pd = toEntity(pickDetailDto);//Dto转实体
ItemDto itemDto = pickDetailDto.getItem(); ItemDto itemDto = pickDetailDto.getItem();
Item item = itemService.toEntity(itemDto); Item item = itemService.toEntity(itemDto);
Dept dept = item.getDept();//仓库 Dept dept = item.getDept();//仓库
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaName); List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaCode);
if (Inventorys.size() > 0) { if (Inventorys.size() > 0) {
Inventory inv = Inventorys.get(0); Inventory inv = Inventorys.get(0);
//库存冻结状态不允许出库 //库存冻结状态不允许出库
@ -396,10 +369,63 @@ public class PickDetailServiceImpl implements PickDetailService {
pickDetail.setItem(gdDetail.getItem()); pickDetail.setItem(gdDetail.getItem());
pickDetail.setLineNo(lineNo.getAndIncrement()); pickDetail.setLineNo(lineNo.getAndIncrement());
pickDetail.setStatus(BizStatus.OPEN); pickDetail.setStatus(BizStatus.OPEN);
if (BaseStatus.GD_TYPE_CT.equals(gdDetail.getOrderType())) {
pickDetail.setOrderQty(gdDetail.getItemQty() * gdDetail.getBigItemQty());
} else {
pickDetail.setOrderQty(gdDetail.getItemQty()); pickDetail.setOrderQty(gdDetail.getItemQty());
}
pickDetail.setSourceId(gdDetail.getId()); pickDetail.setSourceId(gdDetail.getId());
pickDetail.setDept(gdDetail.getDept()); pickDetail.setDept(gdDetail.getDept());
pickDetailRepository.save(pickDetail); 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);
}
}
} }

View File

@ -113,7 +113,6 @@ public class QuartzJobController {
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }
@Log("执行定时任务")
@ApiOperation("执行定时任务") @ApiOperation("执行定时任务")
@PutMapping(value = "/exec/{id}") @PutMapping(value = "/exec/{id}")
@PreAuthorize("@el.check('timing:edit')") @PreAuthorize("@el.check('timing:edit')")

View File

@ -31,59 +31,51 @@ import java.util.concurrent.CopyOnWriteArrayList;
@Slf4j @Slf4j
@Service @Service
public class pickTask { public class pickTask {
@Autowired
public PickDetailRepository pickDetailRepository;
@Autowired @Autowired
public PickDetailService pickDetailService; public PickDetailService pickDetailService;
@Autowired
public PickDetailRepository pickDetailRepository;
@Autowired @Autowired
public PickRepository pickRepository; public PickRepository pickRepository;
@Autowired @Autowired
public TaskRepository taskRepository; public TaskRepository taskRepository;
@Autowired @Autowired
public AgvTaskRepository agvTaskRepository; public AgvTaskRepository agvTaskRepository;
@Autowired @Autowired
public AgvTaskService agvTaskService; public AgvTaskService agvTaskService;
private Map<String, List<Integer>> groupedTasks = new HashMap<>();
private long lastTaskTime = System.currentTimeMillis();
/** /**
* *
*/ */
public void allocate() { public void allocatePick() {
System.out.println("定时检测物料,分配库存");
/* 查询待分配的出库明细*/ List<Pick> pickList = pickRepository.findByPickStatus(BizStatus.OPEN);
List<PickDetail> pickDetailList=pickDetailRepository.findByAllocate(); if (pickList.isEmpty()) {
List<String> arr=new ArrayList<>();//没有库存的物料集合 throw new RuntimeException("无待分配的出库单!");
for (PickDetail pickDetail:pickDetailList){ } else {
/* 没有库存 不用分配*/ for (Pick pick : pickList) {
if (arr.contains(pickDetail.getItem().getCode())){ pickDetailService.allocatePick(pick);
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);
} }
} }
} }
System.out.println("分配出库单,库存不足:"+arr);
}
/** /**
* *
*/ */
public void pickAgvTask() { public void pickAgvTask() {
/*查询分配完成的出库单*/ /*查询分配完成的出库单*/
List<Pick> pickList=pickRepository.findByStatus(BizStatus.ALLOCATE); List<Pick> pickList = pickRepository.findByPickStatus(BizStatus.ALLOCATE);
for (Pick pick:pickList){ for (Pick pick : pickList) {
List<Task> taskList=taskRepository.findByPick(pick.getId()); List<Task> taskList = taskRepository.findByPick(pick.getId());
for (Task task:taskList){ for (Task task : taskList) {
/*生成搬运任务*/ /*生成搬运任务*/
AgvTask agvTask = agvTaskService.addAgvTask(BizStatus.PICK, task.getSrcStockCode(), task.getSrcPointCode(), task.getDstPointCode(), BizStatus.OPEN, "01"); AgvTask agvTask = agvTaskService.addAgvTask(BizStatus.PICK, task.getSrcStockCode(), task.getSrcPointCode(), task.getDstPointCode(), BizStatus.OPEN, "01");
/*更新Task任务*/ /*更新Task任务*/
@ -95,68 +87,7 @@ public class pickTask {
pick.setStatus(BizStatus.PICKUP); pick.setStatus(BizStatus.PICKUP);
pickRepository.save(pick); 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);
}
}
} }

View File

@ -28,7 +28,7 @@ public class BaseStatus {
public static Boolean F =false; public static Boolean F =false;
/** /**
* - * -线
*/ */
public static String BOX = "BOX"; public static String BOX = "BOX";

View File

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -22,13 +23,10 @@ public class EladminSystemApplicationTests {
} }
public static void main(String[] args) { public static void main(String[] args) {
List<Integer> list1 = Arrays.asList(); Map<String, List<String>> concurrentMapMsg = new ConcurrentHashMap<>();
List<Integer> list2 = Arrays.asList(); List<String> list1 = Arrays.asList("001库存不足!","002库存不足!", "003分配成功");
concurrentMapMsg.put("GD202406261053", list1);
List<Integer> list3 = new ArrayList<>(list1); System.out.println(list1);
list3.addAll(list2);
System.out.println(list3); // 输出: [1, 2, 3, 4, 5]
} }
private static final int MAX_TASK_COUNT = 4; private static final int MAX_TASK_COUNT = 4;
@ -37,6 +35,14 @@ public class EladminSystemApplicationTests {
private List<Integer> taskQueue = new ArrayList<>(MAX_TASK_COUNT); private List<Integer> taskQueue = new ArrayList<>(MAX_TASK_COUNT);
void aa(){ 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 taoQty=2;//基础套数
double xTaoQty=3;//需求套数 double xTaoQty=3;//需求套数
double ckdQty=Math.ceil(xTaoQty/taoQty);//生成出库单数量 double ckdQty=Math.ceil(xTaoQty/taoQty);//生成出库单数量