no message
							parent
							
								
									009873c137
								
							
						
					
					
						commit
						bf7fe4e374
					
				| 
						 | 
				
			
			@ -111,33 +111,7 @@ public class AgvTaskController {
 | 
			
		|||
        agvTaskService.deleteAll(ids);
 | 
			
		||||
        return new ResponseEntity<>(HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 料箱任务接口回调
 | 
			
		||||
     *
 | 
			
		||||
     * @param json
 | 
			
		||||
     */
 | 
			
		||||
    @PostMapping("/agvTaskCallback")
 | 
			
		||||
    @Log("料箱任务接口回调")
 | 
			
		||||
    @ApiOperation("料箱任务接口回调")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> agvTaskCallback(@RequestBody String json) {
 | 
			
		||||
        JSONObject jsonObject = JSON.parseObject(json);
 | 
			
		||||
        String taskCode = jsonObject.getString("taskCode") == null ? "" : jsonObject.getString("taskCode");//任务编号
 | 
			
		||||
        String podCode = jsonObject.getString("podCode") == null ? "" : jsonObject.getString("podCode");//容器编号
 | 
			
		||||
        String currentNodeCode = jsonObject.getString("currentNodeCode") == null ? "" : jsonObject.getString("currentNodeCode");//当前位置
 | 
			
		||||
        String missionStatus = jsonObject.getString("missionStatus") == null ? "" : jsonObject.getString("missionStatus");//作业当前状态
 | 
			
		||||
        //查询对应BOX
 | 
			
		||||
        try {
 | 
			
		||||
            AgvTaskDto dto = agvTaskService.findById(Integer.parseInt(taskCode));
 | 
			
		||||
            AgvTask agvTask = agvTaskService.toEntity(dto);
 | 
			
		||||
            agvTaskService.agvTaskCallback(agvTask, missionStatus, "");
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.success("", ""), HttpStatus.OK);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.fail(400, e.getMessage(), ""), HttpStatus.OK);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 料箱机器人申请取货/放货/取放完成回调
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,31 +1,32 @@
 | 
			
		|||
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.annotation.AnonymousAccess;
 | 
			
		||||
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.ItemKey;
 | 
			
		||||
import com.youchain.businessdata.domain.Task;
 | 
			
		||||
import com.youchain.businessdata.inputJson.ReturnMoInfo;
 | 
			
		||||
import com.youchain.businessdata.inputJson.ReturnMoParams;
 | 
			
		||||
import com.youchain.businessdata.repository.TaskRepository;
 | 
			
		||||
import com.youchain.businessdata.service.AgvTaskService;
 | 
			
		||||
import com.youchain.businessdata.service.MlsService;
 | 
			
		||||
import com.youchain.businessdata.service.OrderService;
 | 
			
		||||
import com.youchain.businessdata.service.TaskService;
 | 
			
		||||
import com.youchain.businessdata.service.dto.AgvTaskDto;
 | 
			
		||||
import com.youchain.businessdata.service.dto.OrderDto;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import com.youchain.utils.BaseStatus;
 | 
			
		||||
import com.youchain.service.LogService;
 | 
			
		||||
import com.youchain.utils.BizStatus;
 | 
			
		||||
import com.youchain.utils.UrlApi;
 | 
			
		||||
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;
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +34,9 @@ import org.springframework.web.bind.annotation.RestController;
 | 
			
		|||
 | 
			
		||||
import java.sql.Timestamp;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
 | 
			
		||||
import static org.springframework.http.HttpStatus.OK;
 | 
			
		||||
| 
						 | 
				
			
			@ -46,12 +49,11 @@ import static org.springframework.http.HttpStatus.OK;
 | 
			
		|||
public class KMReSController {
 | 
			
		||||
 | 
			
		||||
    private final AgvTaskService agvTaskService;
 | 
			
		||||
 | 
			
		||||
    private final PointService pointService;
 | 
			
		||||
 | 
			
		||||
    private final TaskRepository taskRepository;
 | 
			
		||||
    private final TaskService taskService;
 | 
			
		||||
 | 
			
		||||
    private final StockRepository stockRepository;
 | 
			
		||||
    private final OrderService orderService;
 | 
			
		||||
    private final MlsService mlsService;
 | 
			
		||||
    private final LogService logService;
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/missionStateCallback")
 | 
			
		||||
    @Log("KMReS接口回调")
 | 
			
		||||
| 
						 | 
				
			
			@ -61,12 +63,76 @@ public class KMReSController {
 | 
			
		|||
        String id = missionStateCallback.getMissionCode();//作业 id
 | 
			
		||||
        String containerCode = missionStateCallback.getContainerCode();//容器编号
 | 
			
		||||
        String missionStatus = missionStateCallback.getMissionStatus();//作业当前状态
 | 
			
		||||
        try {
 | 
			
		||||
            //料箱任务
 | 
			
		||||
            AgvTaskDto agvTaskDto = agvTaskService.findById(Integer.parseInt(id));
 | 
			
		||||
            AgvTask agvTask = agvTaskService.toEntity(agvTaskDto);//转实体
 | 
			
		||||
            List<Task> taskList = taskRepository.getAgvTaskList(agvTask.getId());
 | 
			
		||||
            if (taskList.isEmpty()) {
 | 
			
		||||
                return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), "任务不存在!", ""), BAD_REQUEST);
 | 
			
		||||
            }
 | 
			
		||||
            Task task = taskList.get(0);
 | 
			
		||||
            agvTaskService.agvTaskCallback(agvTask, task, missionStatus);
 | 
			
		||||
            //回传
 | 
			
		||||
            if (agvTask.getType().equals(BizStatus.ASN)) {
 | 
			
		||||
                returnMo(task.getItemKey().getOrderNumber());
 | 
			
		||||
            }
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.success(OK.value(), "", ""), HttpStatus.OK);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), "KMReS接口回调异常", e.getMessage()), BAD_REQUEST);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //货架任务
 | 
			
		||||
        AgvTaskDto agvTaskDto = agvTaskService.findById(Integer.parseInt(id));
 | 
			
		||||
        AgvTask agvTask = agvTaskService.toEntity(agvTaskDto);//转实体
 | 
			
		||||
        agvTaskService.agvTaskCallback(agvTask, missionStatus, containerCode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.success(OK.value(), "", ""), HttpStatus.OK);
 | 
			
		||||
    public void returnMo(String orderNumber) {
 | 
			
		||||
        OrderDto orderDto = orderService.findByBarcodeNumber(orderNumber);
 | 
			
		||||
 | 
			
		||||
        if (orderDto == null) {
 | 
			
		||||
            throw new RuntimeException(orderNumber + "系统无此送货单号!");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        double receivedQty = agvTaskService.queryOrderNumberSum(orderNumber);
 | 
			
		||||
        if (receivedQty == orderDto.getReceivedQty()) {
 | 
			
		||||
            List<Task> tasks = taskService.findByOrderNumber(orderNumber);
 | 
			
		||||
            ReturnMoInfo returnMoInfo = getReturnMoInfo(tasks);
 | 
			
		||||
            long startTime = System.currentTimeMillis();
 | 
			
		||||
            String resultJson = mlsService.returnMo(returnMoInfo);
 | 
			
		||||
            long endTime = System.currentTimeMillis();
 | 
			
		||||
            long time = endTime - startTime;
 | 
			
		||||
            JSONObject resulObject = JSON.parseObject(resultJson);
 | 
			
		||||
            if (resulObject == null) {
 | 
			
		||||
                throw new RuntimeException("按MO票入库接口返回数据为空!");
 | 
			
		||||
            }
 | 
			
		||||
            com.youchain.domain.Log newlogs = new com.youchain.domain.Log();
 | 
			
		||||
            newlogs.setDescription("按MO票入库");
 | 
			
		||||
            newlogs.setLogType("INFO");
 | 
			
		||||
            newlogs.setMethod(UrlApi.publicApi);
 | 
			
		||||
            newlogs.setParams(JSON.toJSONString(returnMoInfo));
 | 
			
		||||
            newlogs.setReturnData(resultJson);
 | 
			
		||||
            newlogs.setRequestIp("127.0.0.1");
 | 
			
		||||
            newlogs.setTime(time);
 | 
			
		||||
            newlogs.setUsername("admin");
 | 
			
		||||
            newlogs.setAddress("内网IP");
 | 
			
		||||
            newlogs.setBrowser("Chrome 123");
 | 
			
		||||
            newlogs.setCreateTime(new Timestamp(new Date().getTime()));
 | 
			
		||||
            logService.saveLog(newlogs);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static ReturnMoInfo getReturnMoInfo(List<Task> tasks) {
 | 
			
		||||
        ReturnMoParams params = new ReturnMoParams();
 | 
			
		||||
        params.setOrgId(100059);
 | 
			
		||||
        params.setInvCode("MA2111");
 | 
			
		||||
        Set<String> labelNos = new HashSet<>();
 | 
			
		||||
        for (Task task : tasks) {
 | 
			
		||||
            ItemKey itemKey = task.getItemKey();
 | 
			
		||||
            labelNos.add(itemKey.getPropC1());
 | 
			
		||||
        }
 | 
			
		||||
        params.setLabelNos(labelNos);
 | 
			
		||||
        ReturnMoInfo returnMoInfo = new ReturnMoInfo();
 | 
			
		||||
        returnMoInfo.setIfaceCode("MLS-WQ-004");
 | 
			
		||||
        returnMoInfo.setSourceSystem("WQ");
 | 
			
		||||
        returnMoInfo.setParams(params);
 | 
			
		||||
        return returnMoInfo;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,9 +80,9 @@ public class MlsController {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/returnMo")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    @Log("按MO票入库")
 | 
			
		||||
    @ApiOperation("按MO票入库")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> returnMo(@RequestBody ReturnMoInfo returnMoInfo) {
 | 
			
		||||
        try {
 | 
			
		||||
            String resultJson = mlsService.returnMo(returnMoInfo);//回传MO票J
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,8 @@ package com.youchain.businessdata.service;
 | 
			
		|||
 | 
			
		||||
import com.youchain.annotation.Log;
 | 
			
		||||
import com.youchain.businessdata.domain.AgvTask;
 | 
			
		||||
import com.youchain.businessdata.domain.Task;
 | 
			
		||||
import com.youchain.businessdata.inputJson.ReturnMoInfo;
 | 
			
		||||
import com.youchain.businessdata.service.dto.AgvTaskDto;
 | 
			
		||||
import com.youchain.businessdata.service.dto.AgvTaskQueryCriteria;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
| 
						 | 
				
			
			@ -144,9 +146,12 @@ public interface AgvTaskService {
 | 
			
		|||
     * @param status
 | 
			
		||||
     * @param containerCode
 | 
			
		||||
     */
 | 
			
		||||
    void agvTaskCallback(AgvTask agvTask,String status,String containerCode);
 | 
			
		||||
    void agvTaskCallback(AgvTask agvTask,Task task, String status);
 | 
			
		||||
 | 
			
		||||
    boolean findByendSlotCode(String endSlotCode,String type,String jobType);
 | 
			
		||||
 | 
			
		||||
    List<AgvTask>  findById(List<Integer> ids);
 | 
			
		||||
 | 
			
		||||
    double queryOrderNumberSum(String orderNumber);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,8 @@ import com.youchain.businessdata.domain.ItemKey;
 | 
			
		|||
import com.youchain.businessdata.service.dto.InventoryLogDto;
 | 
			
		||||
import com.youchain.businessdata.service.dto.InventoryLogQueryCriteria;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
import org.springframework.scheduling.annotation.Async;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
| 
						 | 
				
			
			@ -84,5 +86,6 @@ public interface InventoryLogService {
 | 
			
		|||
    */
 | 
			
		||||
    void download(List<InventoryLogDto> all, HttpServletResponse response) throws IOException;
 | 
			
		||||
 | 
			
		||||
    @Async
 | 
			
		||||
    InventoryLog storeInventoryLog(String logType, int incDec, String relatedBill, ItemKey itemKey, Point srcPoint, Point dstPoint, Stock srcStock, Stock dstStock, Double srcQty, Double occurQty, String refObj, Long refObjId, Long invId,String description);
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -123,10 +123,17 @@ public interface TaskService {
 | 
			
		|||
    List<RPTaskList> queryTaskApp(IPTask t);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询待拣货任务
 | 
			
		||||
     * 根据标签号查询任务
 | 
			
		||||
     * @param labelNo 条件参数
 | 
			
		||||
     * @return List<Task>
 | 
			
		||||
     */
 | 
			
		||||
    List<Task> findByLabelNo(String labelNo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据工单号号查询任务
 | 
			
		||||
     * @param orderNumber 条件参数
 | 
			
		||||
     * @return List<Task>
 | 
			
		||||
     */
 | 
			
		||||
    List<Task> findByOrderNumber(String orderNumber);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,29 +18,20 @@ package com.youchain.businessdata.service.impl;
 | 
			
		|||
import com.alibaba.fastjson.JSON;
 | 
			
		||||
import com.alibaba.fastjson.JSONArray;
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import com.youchain.Netty.NettyUtils;
 | 
			
		||||
import com.youchain.basicdata.domain.Box;
 | 
			
		||||
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.BoxService;
 | 
			
		||||
import com.youchain.basicdata.service.PointService;
 | 
			
		||||
import com.youchain.basicdata.service.impl.BoxServiceImpl;
 | 
			
		||||
import com.youchain.businessdata.domain.*;
 | 
			
		||||
import com.youchain.businessdata.repository.AsnDetailRepository;
 | 
			
		||||
import com.youchain.businessdata.repository.TaskRepository;
 | 
			
		||||
import com.youchain.businessdata.service.InventoryLogService;
 | 
			
		||||
import com.youchain.businessdata.service.InventoryService;
 | 
			
		||||
import com.youchain.businessdata.service.TaskService;
 | 
			
		||||
import com.youchain.businessdata.service.*;
 | 
			
		||||
import com.youchain.modules.quartz.utils.TimeNumberUtils;
 | 
			
		||||
import com.youchain.modules.system.service.DictService;
 | 
			
		||||
import com.youchain.modules.system.service.dto.DictDto;
 | 
			
		||||
import com.youchain.modules.system.service.dto.DictQueryCriteria;
 | 
			
		||||
import com.youchain.service.LogService;
 | 
			
		||||
import com.youchain.utils.*;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import com.youchain.businessdata.repository.AgvTaskRepository;
 | 
			
		||||
import com.youchain.businessdata.service.AgvTaskService;
 | 
			
		||||
import com.youchain.businessdata.service.dto.AgvTaskDto;
 | 
			
		||||
import com.youchain.businessdata.service.dto.AgvTaskQueryCriteria;
 | 
			
		||||
import com.youchain.businessdata.service.mapstruct.AgvTaskMapper;
 | 
			
		||||
| 
						 | 
				
			
			@ -80,6 +71,9 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
    private final StockRepository stockRepository;
 | 
			
		||||
    private final DictService dictService;
 | 
			
		||||
    private final EntityManager entityMapper;
 | 
			
		||||
    private final OrderService orderService;
 | 
			
		||||
    private final LogService logService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> queryAll(AgvTaskQueryCriteria criteria, Pageable pageable) {
 | 
			
		||||
| 
						 | 
				
			
			@ -464,7 +458,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public synchronized void agvTaskCallback(AgvTask agvTask, String status, String containerCode) {
 | 
			
		||||
    public synchronized void agvTaskCallback(AgvTask agvTask, Task task, String status) {
 | 
			
		||||
        String agv_on_off = "OFF";
 | 
			
		||||
        agv_on_off = dictService.getDictDescription("agv_on_off") == null ? "OFF" : dictService.getDictDescription("agv_on_off").getDescription();
 | 
			
		||||
        String code = "0";
 | 
			
		||||
| 
						 | 
				
			
			@ -474,147 +468,51 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
        } else if (status.equals("UP_CONTAINER")) {
 | 
			
		||||
 | 
			
		||||
        } else if (status.equals("COMPLETED")) {
 | 
			
		||||
            List<Task> taskList = taskRepository.getAgvTaskList(agvTask.getId());
 | 
			
		||||
            if(agvTask.getType().equals(BizStatus.ASN)){
 | 
			
		||||
            if (agvTask.getType().equals(BizStatus.ASN)) {
 | 
			
		||||
                //增加库存
 | 
			
		||||
                for (Task task : taskList) {
 | 
			
		||||
                    AsnDetail ad = task.getAsnDetail();
 | 
			
		||||
                    ad.setReceivedQty(ad.getOrderQty());
 | 
			
		||||
                    ad.setStatus(BizStatus.RECEIVED);
 | 
			
		||||
                    asnDetailRepository.save(ad);
 | 
			
		||||
                    task.setTaskStatus(BizStatus.FINISH);
 | 
			
		||||
                    task.setMoveQty(task.getPlanQty());
 | 
			
		||||
                    taskService.update(task);
 | 
			
		||||
                    Stock stock=task.getSrcStock();
 | 
			
		||||
 | 
			
		||||
                    List<Inventory> inventoryList = inventoryService.queryInventory(stock);
 | 
			
		||||
                    for (Inventory inventory : inventoryList) {
 | 
			
		||||
                        Long[] ids = new Long[1];
 | 
			
		||||
                        ids[0] = inventory.getId();
 | 
			
		||||
                        inventoryService.deleteAll(ids);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    //生成库存
 | 
			
		||||
                    Inventory inventory = inventoryService.getInventory(task.getItemKey(), task.getDstPoint(), task.getSrcStock(), task.getDept(), BizStatus.RECEIVING_UP);
 | 
			
		||||
                    inventory.setQuantity(task.getPlanQty());
 | 
			
		||||
                    inventoryService.update(inventory);
 | 
			
		||||
                    inventoryLogService.storeInventoryLog(BizStatus.RECEIVING_UP, BizStatus.ADD, null, task.getItemKey(), task.getSrcPoint(), task.getDstPoint(), task.getSrcStock(), task.getSrcStock(), task.getPlanQty(), task.getPlanQty(), BizStatus.ASN, ad.getId(), inventory.getId(), ad.getRemark());
 | 
			
		||||
 | 
			
		||||
                AsnDetail ad = task.getAsnDetail();
 | 
			
		||||
                ad.setReceivedQty(ad.getOrderQty());
 | 
			
		||||
                ad.setStatus(BizStatus.RECEIVED);
 | 
			
		||||
                asnDetailRepository.save(ad);
 | 
			
		||||
                task.setTaskStatus(BizStatus.FINISH);
 | 
			
		||||
                task.setMoveQty(task.getPlanQty());
 | 
			
		||||
                taskService.update(task);
 | 
			
		||||
                Stock stock = task.getSrcStock();
 | 
			
		||||
 | 
			
		||||
                List<Inventory> inventoryList = inventoryService.queryInventory(stock);
 | 
			
		||||
                for (Inventory inventory : inventoryList) {
 | 
			
		||||
                    Long[] ids = new Long[1];
 | 
			
		||||
                    ids[0] = inventory.getId();
 | 
			
		||||
                    inventoryService.deleteAll(ids);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }else if(agvTask.getType().equals(BizStatus.PICK)){
 | 
			
		||||
 | 
			
		||||
                //生成库存
 | 
			
		||||
                Inventory inventory = inventoryService.getInventory(task.getItemKey(), task.getDstPoint(), task.getSrcStock(), task.getDept(), BizStatus.RECEIVING_UP);
 | 
			
		||||
                inventory.setQuantity(task.getPlanQty());
 | 
			
		||||
                inventoryService.update(inventory);
 | 
			
		||||
                inventoryLogService.storeInventoryLog(BizStatus.RECEIVING_UP, BizStatus.ADD, null, task.getItemKey(), task.getSrcPoint(), task.getDstPoint(), task.getSrcStock(), task.getSrcStock(), task.getPlanQty(), task.getPlanQty(), BizStatus.ASN, ad.getId(), inventory.getId(), ad.getRemark());
 | 
			
		||||
 | 
			
		||||
            } else if (agvTask.getType().equals(BizStatus.PICK)) {
 | 
			
		||||
                //处理实际逻辑
 | 
			
		||||
 | 
			
		||||
                //扣除库存
 | 
			
		||||
                for (Task task : taskList) {
 | 
			
		||||
                    try {
 | 
			
		||||
                        taskService.pickConfirm(task.getId(), task.getPlanQty());
 | 
			
		||||
                    } catch (Exception e) {
 | 
			
		||||
                        throw new RuntimeException(e.getMessage());
 | 
			
		||||
                    }
 | 
			
		||||
                try {
 | 
			
		||||
                    taskService.pickConfirm(task.getId(), task.getPlanQty());
 | 
			
		||||
                } catch (Exception e) {
 | 
			
		||||
                    throw new RuntimeException(e.getMessage());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            //任务完成
 | 
			
		||||
            agvTask.setStatus(BizStatus.FINISH);
 | 
			
		||||
            agvTask.setEndTime(new Timestamp(new Date().getTime()));
 | 
			
		||||
            this.update(agvTask);
 | 
			
		||||
 | 
			
		||||
        } else if (status.equals("CANCELED")) {
 | 
			
		||||
            //任务取消完成
 | 
			
		||||
            Point endPoint = pointService.findByCode(agvTask.getEndSlotCode(), null, null, null, null);
 | 
			
		||||
            String endAreaName = endPoint.getArea().getName();
 | 
			
		||||
            //呼叫空车时异常,容器不出场,线边点位释放
 | 
			
		||||
            if (endAreaName.equals(AreaNameDic.OneFCX)) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            } else if (endAreaName.equals(AreaNameDic.TwoFCX)) {
 | 
			
		||||
                //查询容器状态
 | 
			
		||||
                String jsonObject = this.containerQuery(containerCode);
 | 
			
		||||
                String resultJson = HttpPostUtil.sendPostReq(UrlApi.containerQuery, jsonObject.toString());
 | 
			
		||||
                JSONObject resulObject = JSON.parseObject(resultJson);
 | 
			
		||||
                if (resulObject != null) {
 | 
			
		||||
                    code = resulObject.getString("code") == null ? "" : resulObject.getString("code");
 | 
			
		||||
                    if (code.equals("0")) {
 | 
			
		||||
                        String data1 = resulObject.getString("data") == null ? "" : resulObject.getString("data");
 | 
			
		||||
                        JSONArray jsonArray = JSON.parseArray(data1);
 | 
			
		||||
                        JSONObject dataObject = JSON.parseObject(jsonArray.get(0).toString());
 | 
			
		||||
                        String isCarry = dataObject.getString("isCarry") == null ? "" : dataObject.getString("isCarry");
 | 
			
		||||
                        if (isCarry.equals("0")) {
 | 
			
		||||
                            //任务取消库存占用数还原
 | 
			
		||||
                            Stock stock = stockRepository.getStockByCode(containerCode);
 | 
			
		||||
                            if (stock != null) {
 | 
			
		||||
                                List<Inventory> inventoryList = inventoryService.queryInventory(stock);
 | 
			
		||||
                                for (Inventory inventory : inventoryList) {
 | 
			
		||||
                                    inventory.setQueuedQty(0d);
 | 
			
		||||
                                    inventoryService.update(inventory);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            log.info(agvTask.getId() + "任务" + containerCode + "容器未移动!");
 | 
			
		||||
                        } else {
 | 
			
		||||
                            //容器已经移则释放储存点位状态
 | 
			
		||||
                            Point startPoint = pointService.findByCode(agvTask.getStartSlotCode(), null, null, null, null);
 | 
			
		||||
                            startPoint.setStatus(BaseStatus.FREE);
 | 
			
		||||
                            pointService.update(startPoint);
 | 
			
		||||
 | 
			
		||||
                            //扣减库存
 | 
			
		||||
                            List<Task> taskList = taskRepository.getAgvTaskList(agvTask.getId());
 | 
			
		||||
                            for (Task task : taskList) {
 | 
			
		||||
                                try {
 | 
			
		||||
                                    taskService.pickConfirm(task.getId(), task.getPlanQty());
 | 
			
		||||
                                } catch (Exception e) {
 | 
			
		||||
                                    throw new RuntimeException(e.getMessage());
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        //呼叫满车时异常,线边点位释放
 | 
			
		||||
                        endPoint.setStatus(BaseStatus.FREE);
 | 
			
		||||
                        pointService.update(endPoint);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                } else {
 | 
			
		||||
                    throw new RuntimeException("查询容器信息接口异常");
 | 
			
		||||
                }
 | 
			
		||||
            } else if (endAreaName.equals(AreaNameDic.TwoFB) || endAreaName.equals(AreaNameDic.OneFC)) {
 | 
			
		||||
                //回存储区取消任务,不生成库存 入库任务取消即可
 | 
			
		||||
                Stock stock = stockRepository.getStockByCode(containerCode);
 | 
			
		||||
                List<Task> taskList = taskRepository.getAgvTaskList(agvTask.getId());
 | 
			
		||||
                for (Task task : taskList) {
 | 
			
		||||
                    AsnDetail ad = task.getAsnDetail();
 | 
			
		||||
                    ad.setStatus(BizStatus.CANCEL);
 | 
			
		||||
                    ad.setStock(stock);
 | 
			
		||||
                    asnDetailRepository.save(ad);
 | 
			
		||||
                    task.setTaskStatus(BizStatus.CANCEL);
 | 
			
		||||
                    task.setSrcStock(stock);
 | 
			
		||||
                    if (stock != null) {
 | 
			
		||||
                        task.setSrcStockCode(stock.getCode());
 | 
			
		||||
                        task.setDstStockCode(stock.getCode());
 | 
			
		||||
                    }
 | 
			
		||||
                    task.setDstStock(stock);
 | 
			
		||||
                    taskService.update(task);
 | 
			
		||||
                }
 | 
			
		||||
                //存储点位释放
 | 
			
		||||
                endPoint.setStatus(BaseStatus.FREE);
 | 
			
		||||
                pointService.update(endPoint);
 | 
			
		||||
                // 线边点位释放
 | 
			
		||||
                Point startPoint = pointService.findByCode(agvTask.getStartSlotCode(), null, null, null, null);
 | 
			
		||||
                startPoint.setStatus(BaseStatus.FREE);
 | 
			
		||||
                pointService.update(startPoint);
 | 
			
		||||
 | 
			
		||||
            } else if (endAreaName.equals(AreaNameDic.OneFK) || endAreaName.equals(AreaNameDic.TwoFK)) {
 | 
			
		||||
                //回空车取消任务,空车点位释放
 | 
			
		||||
                endPoint.setStatus(BaseStatus.FREE);
 | 
			
		||||
                pointService.update(endPoint);
 | 
			
		||||
                // 线边点位释放
 | 
			
		||||
                Point startPoint = pointService.findByCode(agvTask.getStartSlotCode(), null, null, null, null);
 | 
			
		||||
                startPoint.setStatus(BaseStatus.FREE);
 | 
			
		||||
                pointService.update(startPoint);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            agvTask.setStatus(BizStatus.CANCEL);
 | 
			
		||||
            agvTask.setEndTime(new Timestamp(new Date().getTime()));
 | 
			
		||||
            this.update(agvTask);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -630,6 +528,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<AgvTask> findById(List<Integer> ids) {
 | 
			
		||||
        String agvTaskIds = StringUtils.strip(ids.toString(), "[]");
 | 
			
		||||
| 
						 | 
				
			
			@ -639,4 +538,18 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
        return agvTaskList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public double queryOrderNumberSum(String orderNumber) {
 | 
			
		||||
        String hql = "select sum(task.moveQty) from Task task where  task.itemKey.orderNumber= :orderNumber";
 | 
			
		||||
        Query query = entityMapper.createQuery(hql);
 | 
			
		||||
        query.setParameter("orderNumber", orderNumber);
 | 
			
		||||
        List<Double> orderNumberSumList = query.getResultList();
 | 
			
		||||
        if (orderNumberSumList.size() > 0) {
 | 
			
		||||
            return orderNumberSumList.get(0);
 | 
			
		||||
        }
 | 
			
		||||
        return 0d;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -262,6 +262,15 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        return tasks;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Task> findByOrderNumber(String orderNumber) {
 | 
			
		||||
        String hql = "from Task t where t.itemKey.orderNumber = :orderNumber";
 | 
			
		||||
        Query query = entityMapper.createQuery(hql);
 | 
			
		||||
        query.setParameter("orderNumber", orderNumber); // 工单号
 | 
			
		||||
        List<Task> tasks = query.getResultList();
 | 
			
		||||
        return tasks;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<Object[]> queryAreaMonth(String type) {
 | 
			
		||||
        List<Object[]> taskList=null;
 | 
			
		||||
        String hql = "";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ package com.youchain.modules.quartz.task;
 | 
			
		|||
import com.github.s7connector.api.S7Connector;
 | 
			
		||||
import com.youchain.businessdata.rest.MoController;
 | 
			
		||||
import com.youchain.businessdata.rest.PlcController;
 | 
			
		||||
import com.youchain.businessdata.service.TaskService;
 | 
			
		||||
import com.youchain.utils.S7ConnectorUtils;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue