no message
parent
e4733b37de
commit
3ed42758a5
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.cpte.modules.constant.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库单类型
|
||||||
|
*
|
||||||
|
* @author: cpte
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum AsnTypeEnum {
|
||||||
|
|
||||||
|
CP(0, "成品入库"),
|
||||||
|
|
||||||
|
PJ(1, "配件入库"),
|
||||||
|
|
||||||
|
JY(8, "检验入库"),
|
||||||
|
|
||||||
|
CPC(2, "成品拆托入库"),
|
||||||
|
|
||||||
|
PJC(3, "配件拆托入库"),
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
AsnTypeEnum(Integer value, String desc) {
|
||||||
|
this.value = value;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
|
final Integer value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
final String desc;
|
||||||
|
|
||||||
|
public static final Set<Integer> ALLOWED_INBOUND_TYPES = Set.of(
|
||||||
|
AsnTypeEnum.CP.getValue(),
|
||||||
|
AsnTypeEnum.PJ.getValue(),
|
||||||
|
AsnTypeEnum.JY.getValue(),
|
||||||
|
AsnTypeEnum.CPC.getValue(),
|
||||||
|
AsnTypeEnum.PJC.getValue()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.cpte.modules.constant.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库单类型状态
|
||||||
|
*
|
||||||
|
* @author: cpte
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum PickTypeEnum {
|
||||||
|
|
||||||
|
CP(4, "成品出库"),
|
||||||
|
|
||||||
|
PJ(5, "配件出库"),
|
||||||
|
|
||||||
|
FG(6, "返工出库"),
|
||||||
|
|
||||||
|
JY(7, "检验出库"),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
PickTypeEnum(Integer value, String desc) {
|
||||||
|
this.value = value;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
|
final Integer value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
final String desc;
|
||||||
|
|
||||||
|
public static final Set<Integer> ALLOWED_OUTBOUND_TYPES = Set.of(
|
||||||
|
PickTypeEnum.CP.getValue(),
|
||||||
|
PickTypeEnum.PJ.getValue(),
|
||||||
|
PickTypeEnum.FG.getValue(),
|
||||||
|
PickTypeEnum.JY.getValue()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -2,6 +2,9 @@ package org.cpte.modules.quartz.job;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.cpte.modules.constant.enums.PickStatusEnum;
|
||||||
|
import org.cpte.modules.constant.enums.PickTypeEnum;
|
||||||
|
import org.cpte.modules.shipping.entity.Pick;
|
||||||
import org.cpte.modules.shipping.mapper.PickMapper;
|
import org.cpte.modules.shipping.mapper.PickMapper;
|
||||||
import org.cpte.modules.shipping.service.IPickService;
|
import org.cpte.modules.shipping.service.IPickService;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
|
@ -35,26 +38,47 @@ public class AllocateJob implements Job {
|
||||||
// 缓存最大大小,防止内存溢出
|
// 缓存最大大小,防止内存溢出
|
||||||
private static final int MAX_CACHE_SIZE = 1000;
|
private static final int MAX_CACHE_SIZE = 1000;
|
||||||
|
|
||||||
// 记录上次分配的索引
|
|
||||||
private static int lastProcessedIndex = -1;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext jobExecutionContext) {
|
public void execute(JobExecutionContext jobExecutionContext) {
|
||||||
// 查询未分配或者部分分配的出库
|
List<Pick> pickList = pickMapper.queryUnallocatedPick();
|
||||||
List<Long> pickList = pickMapper.queryUnallocatedPick();
|
|
||||||
if (CollectionUtils.isEmpty(pickList)) {
|
if (CollectionUtils.isEmpty(pickList)) {
|
||||||
log.info("没有待分配的出库单");
|
log.info("没有待分配的出库单");
|
||||||
lastProcessedIndex = -1; // 重置索引
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pickList.sort(Long::compareTo);
|
for (Pick pick : pickList) {
|
||||||
|
//成品、配件
|
||||||
|
if (isCPOrPJType(pick.getOrderType())) {
|
||||||
|
// 判断出库单任务是否正在执行
|
||||||
|
if (isPickExecuting(pick.getId())) {
|
||||||
|
log.info("出库单任务未完成,ID: {}", pick.getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 非成品/配件类型且已分配,则跳过
|
||||||
|
if (isAlreadyAssigned(pick.getStatus())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 执行分配
|
||||||
|
allocatePick(pick.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int currentIndex = (lastProcessedIndex + 1) % pickList.size();
|
// 辅助方法
|
||||||
Long pickId = pickList.get(currentIndex);
|
private boolean isCPOrPJType(Integer orderType) {
|
||||||
|
return PickTypeEnum.CP.getValue().equals(orderType)
|
||||||
|
|| PickTypeEnum.PJ.getValue().equals(orderType);
|
||||||
|
}
|
||||||
|
|
||||||
log.info("上次分配索引: {}, 本次分配索引: {}, 分配出库单ID: {}", lastProcessedIndex, currentIndex, pickId);
|
private boolean isAlreadyAssigned(Integer status) {
|
||||||
|
return PickStatusEnum.ASSIGNED.getValue().equals(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPickExecuting(Long pickId) {
|
||||||
|
return pickMapper.queryPickIsExecuting(pickId) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void allocatePick(Long pickId) {
|
||||||
// 分配单个出库单
|
// 分配单个出库单
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
List<String> resultMsg;
|
List<String> resultMsg;
|
||||||
|
|
@ -79,21 +103,15 @@ public class AllocateJob implements Job {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新索引
|
|
||||||
lastProcessedIndex = currentIndex;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
resultMsg = List.of(e.getMessage());
|
resultMsg = List.of(e.getMessage());
|
||||||
log.error("分配出库单失败,ID: {}, 错误: {}", pickId, e.getMessage());
|
log.error("分配出库单失败,ID: {}, 错误: {}", pickId, resultMsg);
|
||||||
// 失败也更新索引,等待下次继续分配
|
|
||||||
lastProcessedIndex = currentIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
log.info("分配出库明细耗时:{}ms,处理ID:{}", endTime - startTime, pickId);
|
log.info("分配出库明细耗时:{}ms,处理ID:{}", endTime - startTime, pickId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成缓存键 - 基于分配结果生成唯一标识
|
* 生成缓存键 - 基于分配结果生成唯一标识
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,8 @@ public class InBoundTaskProcessor {
|
||||||
throw new RuntimeException("任务类型(Type)必填");
|
throw new RuntimeException("任务类型(Type)必填");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Set.of(0, 1, 2, 3, 8).contains(inboundRequest.getType())) {
|
if (! AsnTypeEnum.ALLOWED_INBOUND_TYPES.contains(inboundRequest.getType())) {
|
||||||
throw new RuntimeException("【" + inboundRequest.getType() + "】任务类型错误");
|
throw new IllegalArgumentException("【" + inboundRequest.getType() + "】任务类型错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (AsnOrderTypeEnum.PRODUCT.getValue().equals(inboundRequest.getType())) {
|
/* if (AsnOrderTypeEnum.PRODUCT.getValue().equals(inboundRequest.getType())) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ import org.cpte.modules.base.service.IStockService;
|
||||||
import org.cpte.modules.constant.GeneralConstant;
|
import org.cpte.modules.constant.GeneralConstant;
|
||||||
import org.cpte.modules.constant.enums.AreaTypeEnum;
|
import org.cpte.modules.constant.enums.AreaTypeEnum;
|
||||||
import org.cpte.modules.constant.enums.AsnOrderTypeEnum;
|
import org.cpte.modules.constant.enums.AsnOrderTypeEnum;
|
||||||
|
import org.cpte.modules.constant.enums.AsnTypeEnum;
|
||||||
|
import org.cpte.modules.constant.enums.PickTypeEnum;
|
||||||
import org.cpte.modules.saiWms.request.OutboundRequest;
|
import org.cpte.modules.saiWms.request.OutboundRequest;
|
||||||
import org.cpte.modules.shipping.entity.Pick;
|
import org.cpte.modules.shipping.entity.Pick;
|
||||||
import org.cpte.modules.shipping.entity.PickDetail;
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
|
@ -90,8 +92,8 @@ public class OutBoundTaskProcessor {
|
||||||
throw new RuntimeException("任务类型(Type)必填");
|
throw new RuntimeException("任务类型(Type)必填");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Set.of(4, 5, 6, 7).contains(outboundRequest.getType())) {
|
if (!PickTypeEnum.ALLOWED_OUTBOUND_TYPES.contains(outboundRequest.getType())) {
|
||||||
throw new RuntimeException("【" + outboundRequest.getType() + "】任务类型错误");
|
throw new IllegalArgumentException("【" + outboundRequest.getType() + "】任务类型错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(outboundRequest.getDetails())) {
|
if (CollectionUtils.isEmpty(outboundRequest.getDetails())) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,14 @@ public interface PickMapper extends BaseMapper<Pick> {
|
||||||
*
|
*
|
||||||
* @return List<Pick>
|
* @return List<Pick>
|
||||||
*/
|
*/
|
||||||
@Select("select id from data_pick where status in (1,2,4) ")
|
@Select("select * from data_pick where status in (1,2,3,4) order by order_date")
|
||||||
List<Long> queryUnallocatedPick();
|
List<Pick> queryUnallocatedPick();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询出库单任务是否正在执行
|
||||||
|
*
|
||||||
|
* @param pickId 出库单id
|
||||||
|
* @return Long
|
||||||
|
*/
|
||||||
|
Long queryPickIsExecuting(@Param("pickId") Long pickId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,6 @@
|
||||||
<foreach item="pickId" index="index" collection="pickIds" open="(" separator="," close=")">
|
<foreach item="pickId" index="index" collection="pickIds" open="(" separator="," close=")">
|
||||||
#{pickId}
|
#{pickId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
ORDER BY line_no
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="org.cpte.modules.shipping.mapper.PickMapper">
|
<mapper namespace="org.cpte.modules.shipping.mapper.PickMapper">
|
||||||
|
<select id="queryPickIsExecuting" resultType="long">
|
||||||
|
SELECT count(p.id) FROM data_pick p
|
||||||
|
JOIN data_task t ON t.pick_id=p.id
|
||||||
|
JOIN data_agv_task agv ON agv.id=t.agv_task_id
|
||||||
|
WHERE p.id = #{pickId}
|
||||||
|
AND agv.`status` in (1,2,3)
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -173,6 +173,12 @@ public class ITesAgvServiceImpl implements ITesAgvService {
|
||||||
@Override
|
@Override
|
||||||
public void cancelTes(Long id) {
|
public void cancelTes(Long id) {
|
||||||
AgvTask agvTask = agvTaskMapper.selectById(id);
|
AgvTask agvTask = agvTaskMapper.selectById(id);
|
||||||
|
// 检查接口开关, 未开启则返回
|
||||||
|
if (sysDictMapper.queryByDictCode(GeneralConstant.OPEN_FLAG) == null) {
|
||||||
|
updateAgvTaskResponse(agvTask, null, "接口未开启", GeneralConstant.TES_FAIL_CODE);
|
||||||
|
handleCelled(agvTask);
|
||||||
|
return;
|
||||||
|
}
|
||||||
String url = openApiMapper.getRequestUrl(GeneralConstant.TES_CANCEL_TASK).getOriginUrl();
|
String url = openApiMapper.getRequestUrl(GeneralConstant.TES_CANCEL_TASK).getOriginUrl();
|
||||||
String json = generateCancelTaskJson(agvTask);
|
String json = generateCancelTaskJson(agvTask);
|
||||||
Integer returnCode = null;
|
Integer returnCode = null;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.cpte.modules.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jeecg.common.util.RestUtil;
|
||||||
|
|
||||||
|
|
||||||
|
public class TesStock {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
params.put("warehouseID", "HETU");
|
||||||
|
params.put("clientCode", "WMS");
|
||||||
|
params.put("regionCode", 3);
|
||||||
|
params.put("pageNum", 1);
|
||||||
|
params.put("pageSize", 10000);
|
||||||
|
|
||||||
|
String url = "http://10.254.27.191/tes/apiv2/getPodList";
|
||||||
|
JSONObject stockInfo = RestUtil.post(url, params);
|
||||||
|
JSONObject data = stockInfo.getJSONObject("data");
|
||||||
|
if (data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONArray podList = data.getJSONArray("podList");
|
||||||
|
for (int i = 0; i < podList.size(); i++) {
|
||||||
|
JSONObject podObject = podList.getJSONObject(i);
|
||||||
|
String podID = podObject.getString("podID");
|
||||||
|
String storageID = podObject.getString("storageID");
|
||||||
|
if (StringUtils.isNotBlank(storageID)) {
|
||||||
|
System.out.println(podID + "-" + storageID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package org.cpte.modules.utils;
|
package org.cpte.modules.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.jeecg.common.util.RestUtil;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
@ -32,6 +35,18 @@ public class test {
|
||||||
System.out.println("agv-timestamp:" + timestamp);
|
System.out.println("agv-timestamp:" + timestamp);
|
||||||
System.out.println("agv-signature:" + md5(agvMap.get("ak")+ agvMap.get("sk") + timestamp));
|
System.out.println("agv-signature:" + md5(agvMap.get("ak")+ agvMap.get("sk") + timestamp));
|
||||||
|
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
params.put("warehouseID", "HETU");
|
||||||
|
params.put("clientCode", "WMS");
|
||||||
|
params.put("regionCode", 3);
|
||||||
|
params.put("pageNum", 1);
|
||||||
|
params.put("pageSize", 10000);
|
||||||
|
|
||||||
|
String url="http://10.254.27.191/tes/apiv2/getPodList";
|
||||||
|
RestUtil.post(url, params);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue