diff --git a/web/src/main/java/com/zhehekeji/web/controller/PLCController.java b/web/src/main/java/com/zhehekeji/web/controller/PLCController.java index 0f00274..1707705 100644 --- a/web/src/main/java/com/zhehekeji/web/controller/PLCController.java +++ b/web/src/main/java/com/zhehekeji/web/controller/PLCController.java @@ -4,16 +4,14 @@ import com.zhehekeji.core.pojo.Result; import com.zhehekeji.core.util.Assert; import com.zhehekeji.web.entity.Street; import com.zhehekeji.web.mapper.StreetMapper; -import com.zhehekeji.web.service.NettyClient; -import com.zhehekeji.web.service.PlcService; -import com.zhehekeji.web.service.StreetConn; -import com.zhehekeji.web.service.StreetService; +import com.zhehekeji.web.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.Map; @Api(value = "PLCController",tags = "PLC管理") @RestController(value = "PLCController") @@ -58,6 +56,12 @@ public class PLCController { return Result.success(plcService.plcStatus()); } + @GetMapping("/orderAction") + @ApiOperation(value = "执行的工单情况") + public Result orderAction(){ + return Result.success(OrderAction.get()); + } + } diff --git a/web/src/main/java/com/zhehekeji/web/service/OrderAction.java b/web/src/main/java/com/zhehekeji/web/service/OrderAction.java index daabd71..e771f8b 100644 --- a/web/src/main/java/com/zhehekeji/web/service/OrderAction.java +++ b/web/src/main/java/com/zhehekeji/web/service/OrderAction.java @@ -22,19 +22,25 @@ public class OrderAction { * @return */ public static Integer put(String orderNum){ - if(orderActions.get(orderNum) == null){ - orderActions.put(orderNum,1); - return 1; + synchronized (orderNum.intern()){ + if(orderActions.get(orderNum) == null){ + orderActions.put(orderNum,1); + return 1; + } + int times = orderActions.get(orderNum); + times++; + //该订单的任务达到4次了,不会再有任务了,清除缓存 + //具体看取货、放货、货物库内转移的流程 + if(times >= 4){ + orderActions.remove(orderNum); + }else { + orderActions.put(orderNum,times); + } + return times; } - int times = orderActions.get(orderNum); - times++; - //该订单的任务达到4次了,不会再有任务了,清除缓存 - //具体看取货、放货、货物库内转移的流程 - if(times >= 4){ - orderActions.remove(orderNum); - }else { - orderActions.put(orderNum,times); - } - return times; + } + + public static Map get(){ + return orderActions; } }