no message
							parent
							
								
									2214bdfbc5
								
							
						
					
					
						commit
						56883489ca
					
				| 
						 | 
				
			
			@ -22,8 +22,8 @@ import java.security.cert.X509Certificate;
 | 
			
		|||
@Slf4j
 | 
			
		||||
public class HttpPostUtil {
 | 
			
		||||
    public static String sendPostReq(String api_url, String request) {
 | 
			
		||||
        System.out.println("api:"+api_url);
 | 
			
		||||
        System.out.println("request:"+request);
 | 
			
		||||
        System.out.println("发送api:"+api_url);
 | 
			
		||||
        System.out.println("接收request:"+request);
 | 
			
		||||
        InputStream instr = null;
 | 
			
		||||
        String str = "";
 | 
			
		||||
        try {
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ public class HttpPostUtil {
 | 
			
		|||
                System.out.println("返回空");
 | 
			
		||||
            }
 | 
			
		||||
            str = ResponseString;
 | 
			
		||||
            System.out.println("返回:"+str);
 | 
			
		||||
            System.out.println("返回报文:"+str);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.info("接口异常");
 | 
			
		||||
            // throw new Error(e.getMessage());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -129,6 +129,7 @@
 | 
			
		|||
 | 
			
		||||
    <!-- 打包 -->
 | 
			
		||||
    <build>
 | 
			
		||||
        <finalName>youchain-java0.4</finalName>
 | 
			
		||||
        <plugins>
 | 
			
		||||
            <plugin>
 | 
			
		||||
                <groupId>org.springframework.boot</groupId>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,4 +16,7 @@ public class MissionStateCallback {
 | 
			
		|||
 | 
			
		||||
    @ApiModelProperty(value = "作业当前状态")
 | 
			
		||||
    String missionStatus;
 | 
			
		||||
    /* 当前点位*/
 | 
			
		||||
    @ApiModelProperty(value = "当前点位")
 | 
			
		||||
    String slotCode;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,6 +33,8 @@ public interface PointRepository extends JpaRepository<Point, Long>, JpaSpecific
 | 
			
		|||
    public List<Map<String, String>> getKyPointList();
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE p.code=?1", nativeQuery = false)
 | 
			
		||||
    Point findByCode(String code);
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE p.area.name=?1 and p.status=?2 and p.enabled=1", nativeQuery = false)
 | 
			
		||||
    List<Point> findByAreaAndStatus(String areaName,String status);
 | 
			
		||||
 | 
			
		||||
    /** 库位信息化看板*/
 | 
			
		||||
    @Query(value = " select p.`code` 'pointCode',i.`code` 'itemCode' from base_point p  "
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,6 +109,7 @@ public class PointController {
 | 
			
		|||
                String code = readAll.get(i).get("外部编码").toString().trim();
 | 
			
		||||
                String name = readAll.get(i).get("名称").toString().trim();
 | 
			
		||||
                String types = readAll.get(i).get("存储类型").toString().trim();
 | 
			
		||||
                String beatCode = readAll.get(i).get("地标码").toString().trim();
 | 
			
		||||
                String areaCode = readAll.get(i).get("库区").toString().trim();
 | 
			
		||||
                String enabled = readAll.get(i).get("是否启用").toString().trim();
 | 
			
		||||
                Double x = readAll.get(i).get("坐标X") == null ? 0 : Double.parseDouble(readAll.get(i).get("坐标X").toString());
 | 
			
		||||
| 
						 | 
				
			
			@ -137,6 +138,7 @@ public class PointController {
 | 
			
		|||
                    point.setPosX(x);
 | 
			
		||||
                    point.setPosY(y);
 | 
			
		||||
                    point.setPosZ(z);
 | 
			
		||||
                    point.setBeatCode(beatCode);
 | 
			
		||||
                    point.setEnabled(true);
 | 
			
		||||
                    point.setStatus(BaseStatus.FREE);
 | 
			
		||||
                    pointService.create(point);
 | 
			
		||||
| 
						 | 
				
			
			@ -153,6 +155,7 @@ public class PointController {
 | 
			
		|||
                    }
 | 
			
		||||
                    point.setType(lx);
 | 
			
		||||
                    point.setArea(area);
 | 
			
		||||
                    point.setBeatCode(beatCode);
 | 
			
		||||
                    point.setDept(dept);
 | 
			
		||||
                    point.setPosX(x);
 | 
			
		||||
                    if (ImportEntityUtils.stringFlag(enabled)){
 | 
			
		||||
| 
						 | 
				
			
			@ -310,14 +313,6 @@ public class PointController {
 | 
			
		|||
            double y=Double.valueOf(pointList.get(i).get("pos_y")+"");
 | 
			
		||||
            dataArray.add(pointRepository.getDataPointList(x,y));
 | 
			
		||||
        }
 | 
			
		||||
       /*
 | 
			
		||||
 | 
			
		||||
       JSONArray pointArray=new JSONArray();
 | 
			
		||||
       JSONArray jsonArray=new JSONArray();
 | 
			
		||||
        for (int i = 0; i < 5; i++) {
 | 
			
		||||
            jsonArray.add(pointList.get(i));
 | 
			
		||||
        }
 | 
			
		||||
       pointArray.add(jsonArray);*/
 | 
			
		||||
       JSONObject object=new JSONObject();
 | 
			
		||||
        object.put("total",total);
 | 
			
		||||
        object.put("pageSize",12);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,6 +48,8 @@ public class PointQueryCriteria {
 | 
			
		|||
    /** 库区ID */
 | 
			
		||||
    @Query(joinName = "area", propName="name",type = Query.Type.EQUAL)
 | 
			
		||||
    private String areaName;
 | 
			
		||||
    @Query(joinName = "point", propName="code",type = Query.Type.INNER_LIKE)
 | 
			
		||||
    private String pointCode;
 | 
			
		||||
 | 
			
		||||
    /** 状态:1启用、0禁用 */
 | 
			
		||||
    @Query(type = Query.Type.EQUAL)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,7 +49,7 @@ public class StockQueryCriteria{
 | 
			
		|||
    private String stockTypeName;
 | 
			
		||||
 | 
			
		||||
    /** 点位code */
 | 
			
		||||
    @Query(joinName = "point", propName="code",type = Query.Type.EQUAL)
 | 
			
		||||
    @Query(joinName = "point", propName="code",type = Query.Type.INNER_LIKE)
 | 
			
		||||
    private String pointCode;
 | 
			
		||||
 | 
			
		||||
    @Query(joinName = "point>area>", propName="name",type = Query.Type.EQUAL)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -148,6 +148,7 @@ public class PointServiceImpl implements PointService {
 | 
			
		|||
            map.put("状态", point.getStatus());
 | 
			
		||||
            map.put("描述", point.getDescription());
 | 
			
		||||
            map.put("库区", point.getArea().getName());
 | 
			
		||||
            map.put("地标码", point.getBeatCode());
 | 
			
		||||
            map.put("是否启用", point.getEnabled());
 | 
			
		||||
            map.put("仓库名称", point.getDept().getName());
 | 
			
		||||
            list.add(map);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSON;
 | 
			
		|||
import com.youchain.basicdata.domain.Item;
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.basicdata.domain.Stock;
 | 
			
		||||
import com.youchain.basicdata.repository.PointRepository;
 | 
			
		||||
import com.youchain.basicdata.service.dto.ItemDto;
 | 
			
		||||
import com.youchain.businessdata.domain.AsnDetail;
 | 
			
		||||
import com.youchain.businessdata.domain.Inventory;
 | 
			
		||||
| 
						 | 
				
			
			@ -57,6 +58,7 @@ import java.util.LinkedHashMap;
 | 
			
		|||
public class StockServiceImpl implements StockService {
 | 
			
		||||
 | 
			
		||||
    private final StockRepository stockRepository;
 | 
			
		||||
    private final PointRepository pointRepository;
 | 
			
		||||
    private final StockMapper stockMapper;
 | 
			
		||||
    private final EntityManager entityMapper;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -97,9 +99,23 @@ public class StockServiceImpl implements StockService {
 | 
			
		|||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public void update(Stock resources) {
 | 
			
		||||
        Stock stock = stockRepository.findById(resources.getId()).orElseGet(Stock::new);
 | 
			
		||||
        ValidationUtil.isNull(stock.getId(), "Stock", "id", resources.getId());
 | 
			
		||||
        stock.copy(resources);
 | 
			
		||||
        stockRepository.save(stock);
 | 
			
		||||
//        ValidationUtil.isNull(stock.getId(), "Stock", "id", resources.getId());
 | 
			
		||||
        if (!(stock.getPoint()+"").equals(resources.getPoint()+"")){
 | 
			
		||||
            // 库位变化
 | 
			
		||||
            Point startPoint=stock.getPoint();
 | 
			
		||||
            if (startPoint!=null){
 | 
			
		||||
                /* 清空原库位*/
 | 
			
		||||
                startPoint.setStatus(BaseStatus.FREE);
 | 
			
		||||
                pointRepository.save(startPoint);
 | 
			
		||||
            }
 | 
			
		||||
            Point endPoint=resources.getPoint();
 | 
			
		||||
            if (endPoint!=null){
 | 
			
		||||
                /* 占用目标库位*/
 | 
			
		||||
                endPoint.setStatus(BaseStatus.USED);
 | 
			
		||||
                pointRepository.save(endPoint);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        stockRepository.save(resources);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ public class AgvTask  extends BaseEntity implements Serializable {
 | 
			
		|||
    private String reqMessage;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`be_scan`")
 | 
			
		||||
    @ApiModelProperty(value = "是否扫描")
 | 
			
		||||
    @ApiModelProperty(value = "重送任务次数")
 | 
			
		||||
    private Integer beScan=0;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`line_slot_code`")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,6 +37,6 @@ public interface AgvTaskRepository extends JpaRepository<AgvTask, Integer>, JpaS
 | 
			
		|||
    @Query(value = "select * FROM data_agv_task a  where a.`status` in ('ATCALL','UP_CONTAINER','OPEN') AND a.end_slot_code like 'MA1151-QH%'" +
 | 
			
		||||
            " UNION select * FROM data_agv_task a  where a.`status` in ('ATCALL','UP_CONTAINER','OPEN') AND a.start_slot_code like 'MA1151-QH%' ", nativeQuery = true)
 | 
			
		||||
    List<AgvTask> queryAgvTaskPerformedQH();
 | 
			
		||||
    @Query(value = "select agv from AgvTask agv where agv.jobForce=?1")
 | 
			
		||||
    AgvTask findByJobForce(String jobForce);
 | 
			
		||||
    @Query(value = "select agv from AgvTask agv where agv.jobForce=?1 and agv.stockCode=?2")
 | 
			
		||||
    AgvTask findByJobForce(String jobForce,String containerCode);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,7 +111,13 @@ public class AgvTaskController {
 | 
			
		|||
        agvTaskService.deleteAll(ids);
 | 
			
		||||
        return new ResponseEntity<>(HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/closeAgvTask")
 | 
			
		||||
    @Log("关闭agvTask")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> closeAgvTask(@RequestBody Long id) {
 | 
			
		||||
        agvTaskService.closeAgvTask(id);
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.fail(200, "操作成功", null),HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 料箱机器人申请取货/放货/取放完成回调
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -189,6 +195,9 @@ public class AgvTaskController {
 | 
			
		|||
        for (int i = 0; i < ids.size(); i++) {
 | 
			
		||||
            Long id=ids.getLong(i);
 | 
			
		||||
            AgvTask agvTask=agvTaskRepository.getById(Math.toIntExact(id));
 | 
			
		||||
            /* 更新编号*/
 | 
			
		||||
            agvTask.setBeScan(agvTask.getBeScan()+1);
 | 
			
		||||
            agvTaskRepository.save(agvTask);
 | 
			
		||||
            agvTasks.add(agvTask);
 | 
			
		||||
        }
 | 
			
		||||
        agvTaskService.sendAgvTaskLXImpl(agvTasks);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,39 +59,46 @@ public class KMReSController {
 | 
			
		|||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> missionStateCallback(@RequestBody MissionStateCallback missionStateCallback) {
 | 
			
		||||
        System.out.println("接口任务回调:"+missionStateCallback.toString());
 | 
			
		||||
        String id = missionStateCallback.getMissionCode(); // 作业 id
 | 
			
		||||
        String missionCode = missionStateCallback.getMissionCode(); // 作业 id
 | 
			
		||||
        String containerCode = missionStateCallback.getContainerCode(); // 容器编号
 | 
			
		||||
        String missionStatus = missionStateCallback.getMissionStatus(); // 作业当前状态
 | 
			
		||||
        AgvTask agvTask = agvTaskRepository.findByJobForce(id);
 | 
			
		||||
        String slotCode = missionStateCallback.getSlotCode(); // 作业当前状态
 | 
			
		||||
        AgvTask agvTask = agvTaskRepository.findByJobForce(missionCode,containerCode);
 | 
			
		||||
        if (agvTask!=null) {
 | 
			
		||||
            String id=agvTask.getId()+"";
 | 
			
		||||
            if (agvTask.getType().equals(BizStatus.PICK)) {
 | 
			
		||||
                //出库
 | 
			
		||||
                pickTask(id, containerCode, missionStatus);
 | 
			
		||||
            } else if (agvTask.getType().equals(BizStatus.ASN)) {
 | 
			
		||||
                //入库
 | 
			
		||||
                asnTask(id, missionStatus);
 | 
			
		||||
                asnTask(id, missionStatus,slotCode);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return ResponseEntity.ok(ApiResult.success(HttpStatus.OK.value(), "", ""));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void asnTask(String id, String missionStatus) {
 | 
			
		||||
    public void asnTask(String id, String missionStatus, String slotCode) {
 | 
			
		||||
        //执行第一个任务后 可以继续执行第二个任务 并携带第一个任务的返回值 第二个任务执行完没有返回值
 | 
			
		||||
        AgvTaskDto agvTaskDto = agvTaskService.findById(Integer.parseInt(id));
 | 
			
		||||
        AgvTask agvTask = agvTaskService.toEntity(agvTaskDto);
 | 
			
		||||
        Task task = getFirstTask(agvTask.getId());
 | 
			
		||||
        /*if (agvTask.getEndSlotCode().equals(slotCode)){
 | 
			
		||||
            missionStatus="PICKER_SEND";
 | 
			
		||||
        }*/
 | 
			
		||||
        agvTaskService.agvTaskCallback(agvTask, task, missionStatus);
 | 
			
		||||
 | 
			
		||||
        CompletableFuture.runAsync(() -> {
 | 
			
		||||
            returnMo(task.getBillCode());// 回传MO信息
 | 
			
		||||
        });
 | 
			
		||||
        if (missionStatus.equals("PICKER_SEND")) {
 | 
			
		||||
            CompletableFuture.runAsync(() -> {
 | 
			
		||||
                returnMo(task.getBillCode());// 回传MO信息
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void pickTask(String id, String containerCode, String missionStatus) {
 | 
			
		||||
        if ("CANCELED".equals(missionStatus)) {
 | 
			
		||||
            cancelAgvTasks(id);
 | 
			
		||||
        } else {
 | 
			
		||||
            AgvTask agvTask = agvTaskService.findByjobCode(id, containerCode);
 | 
			
		||||
        } else if ("PICKER_SEND".equals(missionStatus)){
 | 
			
		||||
            AgvTask agvTask = agvTaskRepository.getById(Integer.valueOf(id));
 | 
			
		||||
            Task task = getFirstTask(agvTask.getId());
 | 
			
		||||
            agvTaskService.agvTaskCallback(agvTask, missionStatus, containerCode);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -183,12 +190,13 @@ public class KMReSController {
 | 
			
		|||
    public static ReturnIssueInfo getReturnIssueInfo(Task task) {
 | 
			
		||||
        ReturnIssueInfoParams params = new ReturnIssueInfoParams();
 | 
			
		||||
        params.setOrgId(808);
 | 
			
		||||
        params.setTaskNumber(task.getBillCode());
 | 
			
		||||
        params.setTaskNumber(task.getPickDetail().getPropC2());
 | 
			
		||||
        Set<String> labelNos = new HashSet<>();
 | 
			
		||||
        labelNos.add(task.getItemKey().getPropC1());
 | 
			
		||||
        params.setLabelNo(labelNos);
 | 
			
		||||
        ReturnIssueInfo returnIssueInfo = new ReturnIssueInfo();
 | 
			
		||||
        returnIssueInfo.setIfaceCode("MLS-YC-001");
 | 
			
		||||
        returnIssueInfo.setIfaceCode("WMS-MLS-035");
 | 
			
		||||
 | 
			
		||||
        returnIssueInfo.setSourceSystem("WMS");
 | 
			
		||||
        returnIssueInfo.setParams(params);
 | 
			
		||||
        return returnIssueInfo;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,7 @@ import lombok.RequiredArgsConstructor;
 | 
			
		|||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.http.HttpStatus;
 | 
			
		||||
import org.springframework.http.ResponseEntity;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
| 
						 | 
				
			
			@ -88,13 +89,13 @@ public class MlsController {
 | 
			
		|||
    @AnonymousAccess
 | 
			
		||||
    @Log("叫料指令")
 | 
			
		||||
    @ApiOperation("叫料指令")
 | 
			
		||||
    public ResponseEntity<Object> getIssueInfo(@RequestBody IssueInfo issueInfo) {
 | 
			
		||||
        try {
 | 
			
		||||
            mlsService.getIssueInfo(issueInfo);
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.success(OK.value(), "", ""), HttpStatus.OK);
 | 
			
		||||
    public synchronized ResponseEntity<Object> getIssueInfo(@RequestBody IssueInfo issueInfo) {
 | 
			
		||||
        /*try {
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.success(BAD_REQUEST.value(), e.getMessage(), ""), HttpStatus.BAD_REQUEST);
 | 
			
		||||
        }
 | 
			
		||||
        }*/
 | 
			
		||||
        mlsService.getIssueInfo(issueInfo);
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.success(OK.value(), "", ""), HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/returnIssue")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,10 +15,12 @@
 | 
			
		|||
*/
 | 
			
		||||
package com.youchain.businessdata.rest;
 | 
			
		||||
 | 
			
		||||
import com.youchain.annotation.AnonymousAccess;
 | 
			
		||||
import com.youchain.annotation.Log;
 | 
			
		||||
import com.youchain.businessdata.domain.Order;
 | 
			
		||||
import com.youchain.businessdata.service.OrderService;
 | 
			
		||||
import com.youchain.businessdata.service.dto.OrderQueryCriteria;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import org.springframework.http.HttpStatus;
 | 
			
		||||
| 
						 | 
				
			
			@ -28,6 +30,8 @@ import org.springframework.validation.annotation.Validated;
 | 
			
		|||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
import io.swagger.annotations.*;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +54,6 @@ public class OrderController {
 | 
			
		|||
    public void exportOrder(HttpServletResponse response, OrderQueryCriteria criteria) throws IOException {
 | 
			
		||||
        orderService.download(orderService.queryAll(criteria), response);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping
 | 
			
		||||
    @ApiOperation("查询order")
 | 
			
		||||
    public ResponseEntity<Object> queryOrder(OrderQueryCriteria criteria, Pageable pageable){
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,15 +45,17 @@ public class PlcController {
 | 
			
		|||
            }
 | 
			
		||||
            String mo = json.getString("mo");// MO票
 | 
			
		||||
            String lx = json.getString("lx");// 容器
 | 
			
		||||
            String it = mo.substring(19, 33);// 料号
 | 
			
		||||
            String labelNo=mo.substring(40, 52);// 标签
 | 
			
		||||
            String[] mos=mo.split("]");
 | 
			
		||||
//            LB]A0006897]240625]12125300000145]200]240625104089]]
 | 
			
		||||
            String it = mos[3];// 料号
 | 
			
		||||
            String labelNo=mos[5];// 标签
 | 
			
		||||
            moService.scanMo(it,lx,labelNo);
 | 
			
		||||
 | 
			
		||||
            S7ConnectorUtils.write(S7ConnectorUtils.s7Connector,2);
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.success(OK.value(), "", ""), HttpStatus.OK);
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.fail(200, "入库成功", null), HttpStatus.OK);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            S7ConnectorUtils.write(S7ConnectorUtils.s7Connector,1);
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.success(BAD_REQUEST.value(), e.getMessage(), ""), HttpStatus.BAD_REQUEST);
 | 
			
		||||
            return new ResponseEntity<>(ApiResult.fail(200, "排除料箱", null), HttpStatus.BAD_REQUEST);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,15 +15,11 @@
 | 
			
		|||
 */
 | 
			
		||||
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;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
| 
						 | 
				
			
			@ -170,4 +166,5 @@ public interface AgvTaskService {
 | 
			
		|||
     */
 | 
			
		||||
    List<AgvTask> queryByAgvTask(String status,String type);
 | 
			
		||||
 | 
			
		||||
    void closeAgvTask(Long id);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ import com.alibaba.fastjson.JSONObject;
 | 
			
		|||
import com.youchain.basicdata.domain.Box;
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.basicdata.domain.Stock;
 | 
			
		||||
import com.youchain.basicdata.repository.PointRepository;
 | 
			
		||||
import com.youchain.basicdata.repository.StockRepository;
 | 
			
		||||
import com.youchain.basicdata.service.PointService;
 | 
			
		||||
import com.youchain.basicdata.service.impl.BoxServiceImpl;
 | 
			
		||||
| 
						 | 
				
			
			@ -76,6 +77,8 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
    private final InventoryLogService inventoryLogService;
 | 
			
		||||
    private final TaskService taskService;
 | 
			
		||||
    private final PointService pointService;
 | 
			
		||||
    private final PointRepository pointRepository;
 | 
			
		||||
    private final StockRepository stockRepository;
 | 
			
		||||
    private final AsnDetailRepository asnDetailRepository;
 | 
			
		||||
    private final EntityManager entityMapper;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -236,7 +239,9 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
    @Override
 | 
			
		||||
    public synchronized String sendAgvTaskLXImpl(List<AgvTask> agvTasks) {
 | 
			
		||||
        JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
 | 
			
		||||
        String agvCode = TimeNumberUtils.getLXTaskCode();
 | 
			
		||||
        String agvCode = TimeNumberUtils.getKmResCode() + agvTasks.get(0).getId()+"_"+agvTasks.get(0).getBeScan();
 | 
			
		||||
//        String agvCode = TimeNumberUtils.getLXTaskCode();
 | 
			
		||||
 | 
			
		||||
        Map<String, Object> objMap = new LinkedHashMap<>();
 | 
			
		||||
        objMap.put("orgId", agvCode);//库存组织 ID(或工厂代码,供应商代码)
 | 
			
		||||
        objMap.put("requestId", agvCode);//请求 id
 | 
			
		||||
| 
						 | 
				
			
			@ -262,10 +267,18 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
            Map<String, Object> missionDataMap = new LinkedHashMap<>();
 | 
			
		||||
            missionDataMap.put("sequence", (i + 1));//序号
 | 
			
		||||
            missionDataMap.put("binCode", agvTask.getStockCode());//料箱号
 | 
			
		||||
            missionDataMap.put("startPosition", "");//料箱所在的起始点位
 | 
			
		||||
 | 
			
		||||
            Point startPoint=pointRepository.findByCode(agvTask.getStartSlotCode());
 | 
			
		||||
            missionDataMap.put("startPosition", startPoint.getBeatCode());//料箱所在的起始点位
 | 
			
		||||
            missionDataMap.put("startSlotCode", agvTask.getStartSlotCode());//料箱所在的起始槽位
 | 
			
		||||
            missionDataMap.put("takeActionConfirm", false);//取料箱时之前是否需确认
 | 
			
		||||
            missionDataMap.put("endPosition", "");//料箱所在的目标点位
 | 
			
		||||
            //取料箱时之前是否需确认 点位
 | 
			
		||||
            if (startPoint.getCode().equals("SSX-01-001")){
 | 
			
		||||
                missionDataMap.put("takeActionConfirm", true);
 | 
			
		||||
            }else {
 | 
			
		||||
                missionDataMap.put("takeActionConfirm", false);
 | 
			
		||||
            }
 | 
			
		||||
            Point endPoint=pointRepository.findByCode(agvTask.getEndSlotCode());
 | 
			
		||||
            missionDataMap.put("endPosition", endPoint.getBeatCode());//料箱所在的目标点位
 | 
			
		||||
            missionDataMap.put("endSlotCode", agvTask.getEndSlotCode());//料箱所在的目标槽位
 | 
			
		||||
            missionDataMap.put("putActionConfirm", false);//放料箱时之前是否需要确认
 | 
			
		||||
            missionDataObj.putAll(missionDataMap);
 | 
			
		||||
| 
						 | 
				
			
			@ -366,9 +379,9 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public void agvTaskCallback(AgvTask agvTask, Task task, String status) {
 | 
			
		||||
 | 
			
		||||
        if (status.equals("COMPLETED")) {
 | 
			
		||||
        if (status.equals("PICKER_SEND")) {
 | 
			
		||||
            //入库
 | 
			
		||||
            if (agvTask.getType().equals(BizStatus.ASN)) {
 | 
			
		||||
            if (agvTask.getType().equals(BizStatus.ASN)&&task!=null) {
 | 
			
		||||
                //增加库存
 | 
			
		||||
                AsnDetail ad = task.getAsnDetail();
 | 
			
		||||
                ad.setReceivedQty(ad.getOrderQty());
 | 
			
		||||
| 
						 | 
				
			
			@ -397,9 +410,29 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
            agvTask.setEndTime(new Timestamp(new Date().getTime()));
 | 
			
		||||
            this.update(agvTask);
 | 
			
		||||
 | 
			
		||||
        } else if (status.equals("CANCELED")) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        } else if (status.equals(BizStatus.CANCEL)) {
 | 
			
		||||
            if (agvTask.getType().equals(BizStatus.ASN)&&task!=null) {
 | 
			
		||||
                //取消入库
 | 
			
		||||
                /* 关闭入库单*/
 | 
			
		||||
                AsnDetail ad = task.getAsnDetail();
 | 
			
		||||
                ad.setStatus(BizStatus.CLOSE);
 | 
			
		||||
                asnDetailRepository.save(ad);
 | 
			
		||||
                /* 解绑容器库位*/
 | 
			
		||||
                Stock stock=task.getSrcStock();
 | 
			
		||||
                Point point=stock.getPoint();
 | 
			
		||||
                point.setStatus(BaseStatus.FREE);
 | 
			
		||||
                pointRepository.save(point);
 | 
			
		||||
                stock.setStatus(BaseStatus.FREE);
 | 
			
		||||
                stock.setPoint(null);
 | 
			
		||||
                stockRepository.save(stock);
 | 
			
		||||
                /*关闭Task*/
 | 
			
		||||
                task.setTaskStatus(BizStatus.CLOSE);
 | 
			
		||||
                taskRepository.save(task);
 | 
			
		||||
            }
 | 
			
		||||
            // 任务取消
 | 
			
		||||
            agvTask.setStatus(BizStatus.CANCEL);
 | 
			
		||||
            agvTask.setEndTime(new Timestamp(new Date().getTime()));
 | 
			
		||||
            this.update(agvTask);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -408,7 +441,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public void agvTaskCallback(AgvTask agvTask, String status, String containerCode) {
 | 
			
		||||
 | 
			
		||||
        if (status.equals("PICKER_RECEIVE")) {
 | 
			
		||||
        if (status.equals("PICKER_SEND")) {
 | 
			
		||||
            //小件:AGV把料箱放到料箱车上扣减库存
 | 
			
		||||
 | 
			
		||||
            List<Task> taskList = taskRepository.getAgvTaskList(agvTask.getId());
 | 
			
		||||
| 
						 | 
				
			
			@ -474,4 +507,11 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
        return agvTaskList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void closeAgvTask(Long id) {
 | 
			
		||||
        AgvTask agvTask=agvTaskRepository.getById(Math.toIntExact(id));
 | 
			
		||||
        agvTask.setStatus(BizStatus.CLOSE);
 | 
			
		||||
        agvTaskRepository.save(agvTask);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
 | 
			
		|||
import com.youchain.basicdata.domain.Item;
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.basicdata.domain.Stock;
 | 
			
		||||
import com.youchain.basicdata.repository.PointRepository;
 | 
			
		||||
import com.youchain.basicdata.service.ItemService;
 | 
			
		||||
import com.youchain.basicdata.service.PointService;
 | 
			
		||||
import com.youchain.businessdata.domain.*;
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
 | 
			
		|||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.concurrent.CompletableFuture;
 | 
			
		||||
import java.util.concurrent.ExecutionException;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
| 
						 | 
				
			
			@ -35,6 +35,7 @@ public class MlsServiceImpl implements MlsService {
 | 
			
		|||
    private final DeptService deptService;
 | 
			
		||||
    private final MoService moService;
 | 
			
		||||
    private final PointService pointService;
 | 
			
		||||
    private final PointRepository pointRepository;
 | 
			
		||||
    private final InventoryService inventoryService;
 | 
			
		||||
    private final RedisObjectUtils redisObjectUtils;
 | 
			
		||||
    private final BatchCreateOrUpdate batchCreateOrUpdate;
 | 
			
		||||
| 
						 | 
				
			
			@ -426,15 +427,29 @@ public class MlsServiceImpl implements MlsService {
 | 
			
		|||
 | 
			
		||||
        inventoryListFuture.thenAccept((result) -> {
 | 
			
		||||
            //目标点
 | 
			
		||||
            Point endPoint = redisObjectUtils.getObjectFromCache("ckjbk", () -> pointService.findByCode(null, null, null, "出库接驳口", null),
 | 
			
		||||
                    "系统无此点位!");
 | 
			
		||||
            /*Point endPoint = redisObjectUtils.getObjectFromCache("ckjbk", () -> pointService.findByCode(null, BaseStatus.FREE, null, "出库接驳口", null),
 | 
			
		||||
                    "系统无此点位!");*/
 | 
			
		||||
 | 
			
		||||
            List<Inventory> inventoryToUpdate = new ArrayList<>();
 | 
			
		||||
            List<PickDetail> pickDetailToCreate = new ArrayList<>();
 | 
			
		||||
            List<AgvTask> agvTaskToCreate = new ArrayList<>();
 | 
			
		||||
            List<Task> taskToCreate = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
            for (Inventory inv : result) {
 | 
			
		||||
                /* 按顺序获取出库接驳点*/
 | 
			
		||||
                Point endPoint;
 | 
			
		||||
                List<Point> pointList = pointRepository.findByAreaAndStatus("出库接驳口",BaseStatus.FREE);
 | 
			
		||||
                if (pointList.size()<1) {
 | 
			
		||||
                    /* 出库接驳口无空闲库位,更新状态重新分配*/
 | 
			
		||||
                    pointList = pointRepository.findByAreaAndStatus("出库接驳口",BaseStatus.USED);
 | 
			
		||||
                    for(Point p:pointList){
 | 
			
		||||
                        p.setStatus(BaseStatus.FREE);
 | 
			
		||||
                        pointRepository.save(p);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                endPoint=pointList.get(0);
 | 
			
		||||
                endPoint.setStatus(BaseStatus.USED);
 | 
			
		||||
                pointRepository.save(endPoint);
 | 
			
		||||
 | 
			
		||||
                //根据库存信息生成叫料任务
 | 
			
		||||
                Stock stock = inv.getStock();//容器
 | 
			
		||||
                Point startPoint = inv.getPoint();//起始点位
 | 
			
		||||
| 
						 | 
				
			
			@ -445,7 +460,7 @@ public class MlsServiceImpl implements MlsService {
 | 
			
		|||
                inventoryToUpdate.add(updateInventory(inv));
 | 
			
		||||
 | 
			
		||||
                //生成出库明细
 | 
			
		||||
                PickDetail pd = createPickDetail(item, inv.getBillCode(), itemKey.getPropC1(), inv.getQuantity());
 | 
			
		||||
                PickDetail pd = createPickDetail(item, inv.getBillCode(), itemKey.getPropC1(), inv.getQuantity(),issueInfo.getTaskNumber());
 | 
			
		||||
                pickDetailToCreate.add(pd);
 | 
			
		||||
 | 
			
		||||
                //生成搬运任务
 | 
			
		||||
| 
						 | 
				
			
			@ -566,7 +581,7 @@ public class MlsServiceImpl implements MlsService {
 | 
			
		|||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PickDetail createPickDetail(Item item, String po, String propC1, Double orderQty) {
 | 
			
		||||
    public PickDetail createPickDetail(Item item, String po, String propC1, Double orderQty, String taskNumber) {
 | 
			
		||||
        PickDetail pickDetail = new PickDetail();
 | 
			
		||||
        pickDetail.setItem(item);
 | 
			
		||||
        pickDetail.setPo(po);
 | 
			
		||||
| 
						 | 
				
			
			@ -576,6 +591,7 @@ public class MlsServiceImpl implements MlsService {
 | 
			
		|||
        pickDetail.setAllocatedQty(orderQty);
 | 
			
		||||
        pickDetail.setStatus(BizStatus.ALLOCATE);
 | 
			
		||||
        pickDetail.setDept(item.getDept());
 | 
			
		||||
        pickDetail.setPropC2(taskNumber);
 | 
			
		||||
        return pickDetail;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -259,7 +259,7 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Task> findByLabelNo(String labelNo) {
 | 
			
		||||
        String hql = "from Task t where t.itemKey.propC1 = :labelNo";
 | 
			
		||||
        String hql = "from Task t where t.itemKey.propC1 = :labelNo and t.taskStatus='OPEN'";
 | 
			
		||||
        Query query = entityMapper.createQuery(hql);
 | 
			
		||||
        query.setParameter("labelNo", labelNo);
 | 
			
		||||
        List<Task> tasks = query.getResultList();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,6 +54,8 @@ public class QuartzLog implements Serializable {
 | 
			
		|||
 | 
			
		||||
    @ApiModelProperty(value = "状态", hidden = true)
 | 
			
		||||
    private Boolean isSuccess;
 | 
			
		||||
    @ApiModelProperty(value = "重复请求此时", hidden = true)
 | 
			
		||||
    private Integer freq=1;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "异常详情", hidden = true)
 | 
			
		||||
    private String exceptionDetail;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,8 @@ import com.youchain.businessdata.domain.AgvTask;
 | 
			
		|||
import com.youchain.modules.quartz.domain.QuartzJob;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaRepository;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 | 
			
		||||
import org.springframework.data.jpa.repository.Query;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -32,5 +34,4 @@ public interface QuartzJobRepository extends JpaRepository<QuartzJob,Long>, JpaS
 | 
			
		|||
     * @return List
 | 
			
		||||
     */
 | 
			
		||||
    List<QuartzJob> findByIsPauseIsFalse();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,14 +15,19 @@
 | 
			
		|||
 */
 | 
			
		||||
package com.youchain.modules.quartz.repository;
 | 
			
		||||
 | 
			
		||||
import com.youchain.basicdata.domain.Box;
 | 
			
		||||
import com.youchain.modules.quartz.domain.QuartzLog;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaRepository;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 | 
			
		||||
import org.springframework.data.jpa.repository.Query;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Liu Xue
 | 
			
		||||
 * @date 2019-01-07
 | 
			
		||||
 */
 | 
			
		||||
public interface QuartzLogRepository extends JpaRepository<QuartzLog,Long>, JpaSpecificationExecutor<QuartzLog> {
 | 
			
		||||
 | 
			
		||||
    @Query(value = "select *from sys_quartz_log WHERE job_name=?1 ORDER BY log_id DESC limit 0,1", nativeQuery = true)
 | 
			
		||||
    List<QuartzLog> findByJobName(String jobName);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,17 +1,28 @@
 | 
			
		|||
package com.youchain.modules.quartz.task;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.date.DateUtil;
 | 
			
		||||
import com.youchain.annotation.AnonymousAccess;
 | 
			
		||||
import com.youchain.annotation.Log;
 | 
			
		||||
import com.youchain.businessdata.inputJson.MoInfo;
 | 
			
		||||
import com.youchain.businessdata.inputJson.MoParams;
 | 
			
		||||
import com.youchain.businessdata.inputJson.OrderInfo;
 | 
			
		||||
import com.youchain.businessdata.service.MlsService;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import com.youchain.service.LogService;
 | 
			
		||||
import com.youchain.utils.UrlApi;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.http.HttpStatus;
 | 
			
		||||
import org.springframework.http.ResponseEntity;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +32,8 @@ import java.util.Set;
 | 
			
		|||
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Service
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/api/moTask")
 | 
			
		||||
public class moTask {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    public MlsService mlsService;
 | 
			
		||||
| 
						 | 
				
			
			@ -30,15 +43,29 @@ public class moTask {
 | 
			
		|||
 | 
			
		||||
    public void moTask() {
 | 
			
		||||
        long startTime = System.currentTimeMillis();
 | 
			
		||||
        MoInfo moInfo = getMoInfo();
 | 
			
		||||
        String resultJson = mlsService.getMoJson(moInfo);
 | 
			
		||||
        mlsService.getMoInfo(resultJson);
 | 
			
		||||
        long time = System.currentTimeMillis() - startTime;
 | 
			
		||||
        // 保存日志
 | 
			
		||||
        logService.saveLogInfo(moInfo, UrlApi.publicApi, resultJson, "获取MO票信息", time,"INFO");
 | 
			
		||||
        synchronized ("mlsOrder") {
 | 
			
		||||
            MoInfo moInfo = getMoInfo(new Date());
 | 
			
		||||
            String resultJson = mlsService.getMoJson(moInfo);
 | 
			
		||||
            mlsService.getMoInfo(resultJson);
 | 
			
		||||
            long time = System.currentTimeMillis() - startTime;
 | 
			
		||||
            // 保存日志
 | 
			
		||||
            logService.saveLogInfo(moInfo, UrlApi.publicApi, resultJson, "获取MO票信息", time, "INFO");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MoInfo getMoInfo() {
 | 
			
		||||
    @Log("获取MLS Mo票数据")
 | 
			
		||||
    @PostMapping(value = "/mlsMo")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> mlsMo(@RequestBody List<Date> dateList){
 | 
			
		||||
        for (Date date:dateList){
 | 
			
		||||
            synchronized ("mlsOrder"){
 | 
			
		||||
                MoInfo moInfo = getMoInfo(date);
 | 
			
		||||
                String resultJson = mlsService.getMoJson(moInfo);
 | 
			
		||||
                mlsService.getMoInfo(resultJson);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.fail(200, "获取成功", null), HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
    public MoInfo getMoInfo(Date date) {
 | 
			
		||||
 | 
			
		||||
        MoParams params = new MoParams();
 | 
			
		||||
        params.setOrgId(808);
 | 
			
		||||
| 
						 | 
				
			
			@ -47,12 +74,10 @@ public class moTask {
 | 
			
		|||
        params.setInvCodes(invCodes);
 | 
			
		||||
        params.setIqcResult("");
 | 
			
		||||
 | 
			
		||||
        /*String startTime = DateUtil.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
 | 
			
		||||
        String startTime = DateUtil.format(DateUtil.beginOfDay(date), "yyyy-MM-dd HH:mm:ss");
 | 
			
		||||
        params.setStartTime(startTime);
 | 
			
		||||
        String endData = DateUtil.format(new Date(), "yyyy-MM-dd");
 | 
			
		||||
        params.setEndTime(endData+" 23:59:59");*/
 | 
			
		||||
        params.setStartTime("2024-05-22 00:00:00");
 | 
			
		||||
        params.setEndTime("2024-05-22 23:59:59");
 | 
			
		||||
        String endData = DateUtil.format(date, "yyyy-MM-dd");
 | 
			
		||||
        params.setEndTime(endData+" 23:59:59");
 | 
			
		||||
 | 
			
		||||
        params.setPageNo(1);
 | 
			
		||||
        params.setPageSize(10000);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,29 +1,30 @@
 | 
			
		|||
package com.youchain.modules.quartz.task;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.date.DateUtil;
 | 
			
		||||
import com.youchain.annotation.AnonymousAccess;
 | 
			
		||||
import com.youchain.annotation.Log;
 | 
			
		||||
import com.youchain.businessdata.domain.Task;
 | 
			
		||||
import com.youchain.businessdata.inputJson.OrderInfo;
 | 
			
		||||
import com.youchain.businessdata.inputJson.OrderParams;
 | 
			
		||||
import com.youchain.businessdata.inputJson.ReturnIssueInfo;
 | 
			
		||||
import com.youchain.businessdata.inputJson.ReturnIssueInfoParams;
 | 
			
		||||
import com.youchain.businessdata.rest.MlsController;
 | 
			
		||||
import com.youchain.businessdata.service.MlsService;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import com.youchain.service.LogService;
 | 
			
		||||
import com.youchain.utils.UrlApi;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.http.HttpStatus;
 | 
			
		||||
import org.springframework.http.ResponseEntity;
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.concurrent.CompletableFuture;
 | 
			
		||||
import java.util.concurrent.ExecutionException;
 | 
			
		||||
import java.util.concurrent.ExecutorService;
 | 
			
		||||
import java.util.concurrent.Executors;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 获取送货单定时任务
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +32,8 @@ import java.util.concurrent.Executors;
 | 
			
		|||
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Service
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/api/orderTask")
 | 
			
		||||
public class orderTask {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
| 
						 | 
				
			
			@ -42,16 +45,30 @@ public class orderTask {
 | 
			
		|||
 | 
			
		||||
    public void orderTask() {
 | 
			
		||||
        long startTime = System.currentTimeMillis();
 | 
			
		||||
        OrderInfo orderInfo = getOrderInfo();
 | 
			
		||||
        String resultJson = mlsService.getOrderJson(orderInfo);
 | 
			
		||||
        mlsService.getOrderInfo(resultJson);
 | 
			
		||||
        long time = System.currentTimeMillis() - startTime;
 | 
			
		||||
        // 保存日志
 | 
			
		||||
        logService.saveLogInfo(orderInfo, UrlApi.publicApi, resultJson, "获取送货单信息", time,"INFO");
 | 
			
		||||
        OrderInfo orderInfo = getOrderInfo(new Date());
 | 
			
		||||
        synchronized ("mlsOrder"){
 | 
			
		||||
            String resultJson = mlsService.getOrderJson(orderInfo);
 | 
			
		||||
            mlsService.getOrderInfo(resultJson);
 | 
			
		||||
            long time = System.currentTimeMillis() - startTime;
 | 
			
		||||
            // 保存日志
 | 
			
		||||
            logService.saveLogInfo(orderInfo, UrlApi.publicApi, resultJson, "获取送货单信息", time,"INFO");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    @Log("获取MLS送货单数据")
 | 
			
		||||
    @PostMapping(value = "/mlsOrder")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> mlsOrder(@RequestBody List<Date> dateList){
 | 
			
		||||
        for (Date date:dateList){
 | 
			
		||||
            synchronized ("mlsOrder"){
 | 
			
		||||
                OrderInfo orderInfo = getOrderInfo(date);
 | 
			
		||||
                String resultJson = mlsService.getOrderJson(orderInfo);
 | 
			
		||||
                mlsService.getOrderInfo(resultJson);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.fail(200, "获取成功", null), HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public OrderInfo getOrderInfo() {
 | 
			
		||||
    public OrderInfo getOrderInfo(Date date) {
 | 
			
		||||
 | 
			
		||||
        OrderParams params = new OrderParams();
 | 
			
		||||
        params.setOrgId(808);
 | 
			
		||||
| 
						 | 
				
			
			@ -59,12 +76,10 @@ public class orderTask {
 | 
			
		|||
        invCodes.add("MA2111");
 | 
			
		||||
        params.setInvCodes(invCodes);
 | 
			
		||||
        params.setIqcResult("");
 | 
			
		||||
        /*String startTime = DateUtil.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
 | 
			
		||||
        String startTime = DateUtil.format(DateUtil.beginOfDay(date), "yyyy-MM-dd HH:mm:ss");
 | 
			
		||||
        params.setStartTime(startTime);
 | 
			
		||||
        String endData = DateUtil.format(new Date(), "yyyy-MM-dd");
 | 
			
		||||
        params.setEndTime(endData+" 23:59:59");*/
 | 
			
		||||
        params.setStartTime("2024-05-22 00:00:00");
 | 
			
		||||
        params.setEndTime("2024-05-22 23:59:59");
 | 
			
		||||
        String endData = DateUtil.format(date, "yyyy-MM-dd");
 | 
			
		||||
        params.setEndTime(endData+" 23:59:59");
 | 
			
		||||
        params.setPageNo(1);
 | 
			
		||||
        params.setPageSize(10000);
 | 
			
		||||
        OrderInfo orderInfo = new OrderInfo();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,42 +4,90 @@ import com.alibaba.fastjson.JSONObject;
 | 
			
		|||
import com.github.s7connector.api.S7Connector;
 | 
			
		||||
import com.youchain.businessdata.rest.MoController;
 | 
			
		||||
import com.youchain.businessdata.rest.PlcController;
 | 
			
		||||
import com.youchain.businessdata.service.MoService;
 | 
			
		||||
import com.youchain.businessdata.service.TaskService;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import com.youchain.modules.quartz.domain.QuartzLog;
 | 
			
		||||
import com.youchain.modules.quartz.repository.QuartzLogRepository;
 | 
			
		||||
import com.youchain.service.LogService;
 | 
			
		||||
import com.youchain.utils.S7ConnectorUtils;
 | 
			
		||||
import com.youchain.utils.UrlApi;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.http.HttpStatus;
 | 
			
		||||
import org.springframework.http.ResponseEntity;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Service
 | 
			
		||||
public class plcTask {
 | 
			
		||||
 | 
			
		||||
    private final PlcController plcController;
 | 
			
		||||
 | 
			
		||||
    private final MoService moService;
 | 
			
		||||
    private final TaskService taskService;
 | 
			
		||||
    private final QuartzLogRepository quartzLogRepository;
 | 
			
		||||
    public LogService logService;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    public plcTask(PlcController plcController) {
 | 
			
		||||
    public plcTask(PlcController plcController,MoService moService,TaskService taskService,QuartzLogRepository quartzLogRepository) {
 | 
			
		||||
        this.plcController = plcController;
 | 
			
		||||
        this.moService = moService;
 | 
			
		||||
        this.taskService = taskService;
 | 
			
		||||
        this.quartzLogRepository = quartzLogRepository;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void plcTask() {
 | 
			
		||||
    public synchronized void plcTask() {
 | 
			
		||||
        S7ConnectorUtils.connect();
 | 
			
		||||
        int a=0;
 | 
			
		||||
        JSONObject jsonObject=new JSONObject();
 | 
			
		||||
        String mo="LB]A0006907]240522]12125300001741]50.00]240522554318]]";
 | 
			
		||||
        String lx="01010007";
 | 
			
		||||
//        String mo = S7ConnectorUtils.readMo(S7ConnectorUtils.s7Connector,12);
 | 
			
		||||
//        String lx = S7ConnectorUtils.readMo(S7ConnectorUtils.s7Connector,0);
 | 
			
		||||
//        String mo="LB]A0006897]240625]12125300000145]200]240625104089]]";
 | 
			
		||||
//        String lx="05010010";
 | 
			
		||||
//        LB]A0006907]240522]12125300001741]50.00]240522554318]]
 | 
			
		||||
//        LB]A0006897]240625]1212504010001300000145]200]240625104089]]
 | 
			
		||||
        String mo = S7ConnectorUtils.readMo(S7ConnectorUtils.s7Connector,12);
 | 
			
		||||
        String lx = S7ConnectorUtils.readMo(S7ConnectorUtils.s7Connector,0);
 | 
			
		||||
        if (mo.length()>0&&lx.length()>0){
 | 
			
		||||
            jsonObject.put("mo",mo);
 | 
			
		||||
            jsonObject.put("lx",lx);
 | 
			
		||||
            try {
 | 
			
		||||
                plcController.scanMo(jsonObject+"");
 | 
			
		||||
                System.out.println("222");
 | 
			
		||||
            }catch (Exception e){
 | 
			
		||||
                throw new RuntimeException("校验失败:" + mo+"|"+lx+"错误信息:"+e.getMessage());
 | 
			
		||||
                JSONObject json = jsonObject;
 | 
			
		||||
                String mo1 = json.getString("mo");// MO票
 | 
			
		||||
                String lx1 = json.getString("lx");// 容器
 | 
			
		||||
                String[] mos = mo1.split("]");
 | 
			
		||||
                String it = mos[3];// 料号
 | 
			
		||||
                String labelNo = mos[5];// 标签
 | 
			
		||||
                // 验证标签是否已入库
 | 
			
		||||
                if (taskService.findByLabelNo(labelNo).size() > 0) {
 | 
			
		||||
                    a=1;
 | 
			
		||||
                }else {
 | 
			
		||||
                    moService.scanMo(it, lx1, labelNo);
 | 
			
		||||
                    S7ConnectorUtils.write(S7ConnectorUtils.s7Connector, 2);
 | 
			
		||||
                }
 | 
			
		||||
            } catch(Exception e){
 | 
			
		||||
                String ex="入库失败,MO票" + mo+",料箱码"+lx+",错误信息:"+e.getMessage();
 | 
			
		||||
                List<QuartzLog> quartzLogList=quartzLogRepository.findByJobName("访问PLC");
 | 
			
		||||
                if (quartzLogList.size()>0){
 | 
			
		||||
                    /* 重复异常*/
 | 
			
		||||
                    QuartzLog quartzLog=quartzLogList.get(0);
 | 
			
		||||
                    if (quartzLog.getJobName().equals("访问PLC")
 | 
			
		||||
                            &&quartzLog.getIsSuccess().equals(false)
 | 
			
		||||
                            &&quartzLog.getExceptionDetail().equals(ex)){
 | 
			
		||||
                        /* 重复异常*/
 | 
			
		||||
                    }else {
 | 
			
		||||
                        S7ConnectorUtils.write(S7ConnectorUtils.s7Connector, 1);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                throw new RuntimeException(ex);
 | 
			
		||||
            }
 | 
			
		||||
            if (a==1){
 | 
			
		||||
                throw new RuntimeException("入库失败,MO票" + mo+",料箱码"+lx+",错误信息:任务重复");
 | 
			
		||||
            }
 | 
			
		||||
        }else {
 | 
			
		||||
            throw new RuntimeException("数据格式错误:"+mo+"|"+lx);
 | 
			
		||||
            throw new RuntimeException("数据格式错误,MO票" + mo+",料箱码"+lx+",错误信息:");
 | 
			
		||||
        }
 | 
			
		||||
        /*try {
 | 
			
		||||
            S7ConnectorUtils.connect();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,6 +112,18 @@ public class ExecutionJob extends QuartzJobBean {
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } finally {
 | 
			
		||||
            List<QuartzLog> quartzLogList=quartzLogRepository.findByJobName(log.getJobName());
 | 
			
		||||
            if (quartzLogList.size()>0){
 | 
			
		||||
                /* 重复异常*/
 | 
			
		||||
                QuartzLog quartzLog=quartzLogList.get(0);
 | 
			
		||||
                if (log.getJobName().equals(quartzJob.getJobName())
 | 
			
		||||
                        &&log.getIsSuccess().equals(quartzLog.getIsSuccess())
 | 
			
		||||
                        &&log.getIsSuccess().equals(false)
 | 
			
		||||
                        &&log.getExceptionDetail().equals(quartzLog.getExceptionDetail())){
 | 
			
		||||
                    log=quartzLog;
 | 
			
		||||
                    log.setFreq(log.getFreq()+1);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            quartzLogRepository.save(log);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,7 +54,12 @@ public class TimeNumberUtils {
 | 
			
		|||
        String s = Integer.toString(sequence);
 | 
			
		||||
        return "KLX"+datetime +addLeftZero(s, length);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static synchronized String getKmResCode() {
 | 
			
		||||
        String datetime = new SimpleDateFormat("yyMMdd")
 | 
			
		||||
                .format(new Date());
 | 
			
		||||
        String s = Integer.toString(sequence);
 | 
			
		||||
        return "KmRes"+datetime;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 左填0
 | 
			
		||||
     * @author shijing
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ public class S7ConnectorUtils {
 | 
			
		|||
            try {
 | 
			
		||||
                s7Connector.close();
 | 
			
		||||
                //关闭连接
 | 
			
		||||
                log.info("关闭s7连接");
 | 
			
		||||
//                log.info("关闭s7连接");
 | 
			
		||||
            }catch (Exception e){
 | 
			
		||||
 | 
			
		||||
            }finally {
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ public class S7ConnectorUtils {
 | 
			
		|||
                .withSlot(1)//设置PLC的插槽号
 | 
			
		||||
                .build();
 | 
			
		||||
        S7Serializer s7Serializer2L = S7SerializerFactory.buildSerializer(s7Connector);
 | 
			
		||||
        log.info("初始化s7连接");
 | 
			
		||||
//        log.info("初始化s7连接");
 | 
			
		||||
        return s7Connector;
 | 
			
		||||
    }
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
| 
						 | 
				
			
			@ -90,7 +90,7 @@ public class S7ConnectorUtils {
 | 
			
		|||
        byte[] PlcData = connector.read(DaveArea.DB, 100, 60, offset);
 | 
			
		||||
 | 
			
		||||
        long endTime = System.currentTimeMillis();
 | 
			
		||||
        log.info("读取耗时:" + (endTime - startTime) + "ms");
 | 
			
		||||
//        log.info("读取耗时:" + (endTime - startTime) + "ms");
 | 
			
		||||
 | 
			
		||||
        String str1 = "";
 | 
			
		||||
        StringConverter converter = new StringConverter();
 | 
			
		||||
| 
						 | 
				
			
			@ -154,11 +154,11 @@ public class S7ConnectorUtils {
 | 
			
		|||
        long startTime = System.currentTimeMillis();
 | 
			
		||||
        ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES);
 | 
			
		||||
        buffer.putInt(instruct);
 | 
			
		||||
        System.out.println("写入日志:instruct"+instruct);
 | 
			
		||||
        byte[] bytes = buffer.array();
 | 
			
		||||
        connector.write(DaveArea.DB, 100, 70, bytes);
 | 
			
		||||
        long endTime = System.currentTimeMillis();
 | 
			
		||||
        System.out.println((endTime - startTime) + "ms");
 | 
			
		||||
        System.out.print("写入成功");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,12 +34,12 @@ public class UrlApi {
 | 
			
		|||
    /**
 | 
			
		||||
     * 获取ToKen
 | 
			
		||||
     */
 | 
			
		||||
    public static String extSignIn="https://"+BaseCode.MLS_IP+"/mls/system/extSignIn";
 | 
			
		||||
    public static String extSignIn="https://"+BaseCode.MLS_IP+"/api-lmes/lmes/public/extSignIn";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * MLS接口
 | 
			
		||||
     * https://apiuat.midea.com/mls/mlsapi/public/publicApi
 | 
			
		||||
     * https://apisit.midea.com/mls/mlsapi/public/publicApi
 | 
			
		||||
     */
 | 
			
		||||
    public static String publicApi="https://"+BaseCode.MLS_IP+"/mls/mlsapi/public/publicApi";
 | 
			
		||||
    public static String publicApi="https://"+BaseCode.MLS_IP+"/api-lmes/lmes/public/publicApi";
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,9 @@ spring:
 | 
			
		|||
      db-type: com.alibaba.druid.pool.DruidDataSource
 | 
			
		||||
      driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
 | 
			
		||||
#      url: jdbc:log4jdbc:mysql://${DB_HOST:47.100.54.81}:${DB_PORT:53306}/${DB_NAME:hefeihvac_wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
 | 
			
		||||
      url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:hefeihvac_wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
 | 
			
		||||
#      url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:hefeihvac_wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
 | 
			
		||||
#      url: jdbc:log4jdbc:mysql://${DB_HOST:10.175.163.49}:${DB_PORT:3306}/${DB_NAME:hefeihvac_wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
 | 
			
		||||
      url: jdbc:log4jdbc:mysql://${DB_HOST:10.173.188.206}:${DB_PORT:53306}/${DB_NAME:wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
 | 
			
		||||
      username: ${DB_USER:root}
 | 
			
		||||
#      password: ${DB_PWD:Youchain@56}
 | 
			
		||||
      password: ${DB_PWD:123456}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue