| | |
| | | package com.mes; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.smallbun.screw.core.util.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.md.entity.*; |
| | | import com.mes.md.mapper.AccountMapper; |
| | | import com.mes.md.mapper.KBBTJPDrawingBPMapper; |
| | | import com.mes.md.mapper.MachineMapper; |
| | | import com.mes.md.mapper.PrimitiveTaskMapper; |
| | | import com.mes.md.service.AccountService; |
| | | import com.mes.md.service.PrimitiveTaskService; |
| | | import com.mes.md.service.ProjectService; |
| | | import com.mes.md.service.TaskingService; |
| | | import com.mes.md.mapper.*; |
| | | import com.mes.md.service.*; |
| | | import com.mes.tools.HexConversion; |
| | | import com.mes.utils.HexUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import java.net.Socket; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Random; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Author : yanzhixin |
| | |
| | | @Autowired |
| | | MachineMapper machineMapper; |
| | | |
| | | @Autowired |
| | | TaskingMapper taskingMapper; |
| | | |
| | | @Autowired |
| | | KBBTLensSortingMapper kBBTLensSortingMapper; |
| | | |
| | | @Autowired |
| | | KBBTProgramsOperationLogBPMapper kBBTProgramsOperationLogBPMapper; |
| | | |
| | | @Autowired |
| | | KBBTProgramsOperationLogBPService kBBTProgramsOperationLogBPService; |
| | | |
| | | @Autowired |
| | | TaskingLogMapper taskingLogMapper; |
| | | |
| | | @Autowired |
| | | TaskingLogService taskingLogService; |
| | | /** |
| | | * 测试 提交报工 以及玻璃数据 |
| | | */ |
| | | @Test |
| | | public void reportTaskingLog() { |
| | | taskingLogService.reportTaskingLog(); |
| | | } |
| | | /** |
| | | * 测试 扫码后库位 |
| | | */ |
| | | @Test |
| | | public void testInset() { |
| | | |
| | | // 从数据库中查询出的对象集合 |
| | | List<Tasking> listTasking = taskingMapper.selectList(new QueryWrapper<Tasking>()); |
| | | List<KBBTProgramsOperationLogBP> abc =kBBTProgramsOperationLogBPMapper.selectList(new QueryWrapper<KBBTProgramsOperationLogBP>()); |
| | | // 判端是否为空 |
| | | if (CollectionUtils.isNotEmpty(listTasking)) { |
| | | // 进行拆解封装 |
| | | List<KBBTProgramsOperationLogBP> stationDictVOS = listTasking.stream().map(item -> { |
| | | KBBTProgramsOperationLogBP newData = new KBBTProgramsOperationLogBP(); |
| | | newData.setGlassId(item.getGlassId()); |
| | | newData.setState(item.getState()); |
| | | newData.setWorkState(item.getWorkState()); |
| | | newData.setGlassState(item.getGlassState()); |
| | | newData.setState(item.getState()); |
| | | newData.setScanId(item.getScanId()); |
| | | newData.setProgramId(item.getProgramId()); |
| | | newData.setBatchNumber(item.getBatchNumber()==null?"":item.getBatchNumber()); |
| | | newData.setTaskType(item.getTaskType()); |
| | | newData.setLength(item.getLength()); |
| | | newData.setWidth(item.getWidth()); |
| | | newData.setThickness(item.getThickness()); |
| | | newData.setDrawingMarking(item.getDrawingMarking()); |
| | | //newData.setIsMarking(item.getIsMarking());//是否打标:0不打标 1打标 |
| | | newData.setIsSilkScreen(item.getIsSilkScreen()); |
| | | newData.setIsWorking(1); |
| | | newData.setSilkScreenX(item.getSilkScreenX()); |
| | | newData.setSilkScreenY(item.getSilkScreenY()); |
| | | newData.setR_1_1(item.getR_1_1()); |
| | | newData.setR_1_2(item.getR_1_2()); |
| | | newData.setR_2_1(item.getR_2_1()); |
| | | newData.setR_2_2(item.getR_2_2()); |
| | | newData.setR_3_1(item.getR_3_1()); |
| | | newData.setR_3_2(item.getR_3_2()); |
| | | newData.setR_4_1(item.getR_4_1()); |
| | | newData.setR_4_2(item.getR_4_2()); |
| | | newData.setCreateDate(new Date()); |
| | | kBBTProgramsOperationLogBPMapper.insert(newData); |
| | | return newData; |
| | | }).collect(Collectors.toList()); |
| | | log.info("保存数据是否成功:{},{}",stationDictVOS); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 测试 扫码后库位 |
| | | */ |
| | | @Test |
| | | public void testStr() { |
| | | String str=new String("4、发送任务 任务数据:{}, ".getBytes(),StandardCharsets.UTF_8); |
| | | int a=1; |
| | | log.info(str,1); |
| | | //创建Calendar实例 |
| | | Calendar cal = Calendar.getInstance(); |
| | | //设置当前时间 |
| | | cal.setTime(new Date()); |
| | | cal.add(Calendar.DATE, -3); |
| | | int deleteCount=taskingMapper.deleteJoin(new MPJLambdaWrapper<Tasking>() |
| | | .selectAll(Tasking.class) |
| | | .le(Tasking::getOperationRecordTime,cal.getTime())); |
| | | |
| | | log.info("{},删除数据:{}",cal.getTime(),deleteCount); |
| | | } |
| | | |
| | | @Test |
| | | public void testSaoMa3() { |
| | | try { |
| | | // 创建TCP客户端并连接到服务器 |
| | | String serverAddress = "192.168.1.8"; |
| | | int serverPort = 2001; |
| | | Socket clientSocket = new Socket(serverAddress, serverPort); |
| | | // 创建输入流和输出流 |
| | | InputStream inputStream = clientSocket.getInputStream(); |
| | | OutputStream outputStream = clientSocket.getOutputStream(); |
| | | // 发送数据给服务器 |
| | | String message = "start"; |
| | | outputStream.write(message.getBytes()); |
| | | // 读取服务器响应的数据 |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead = inputStream.read(buffer); |
| | | String receivedMessage = new String(buffer, 0, bytesRead); |
| | | System.out.println("收到服务器响应:" + receivedMessage); |
| | | // 关闭连接 |
| | | clientSocket.close(); |
| | | }catch (Exception e){ |
| | | log.info("扫码异常"); |
| | | } |
| | | int deleteCount=taskingMapper.deleteJoin(new MPJLambdaWrapper<Tasking>() |
| | | .selectAll(Tasking.class) |
| | | .innerJoin(LineConfiguration.class,LineConfiguration::getId,Tasking::getLineConfigurationId) |
| | | .innerJoin(Machine.class,Machine::getId,LineConfiguration::getMachineId) |
| | | .eq(LineConfiguration::getMachineId,24L) |
| | | .eq(Tasking::getGlassState,"正常") |
| | | .eq(Tasking::getState,"线上") |
| | | .ne(Tasking::getWorkState,"完工")); |
| | | log.info("{}",deleteCount); |
| | | } |
| | | |
| | | @Test |
| | | public void testSaoMa() { |
| | | try { |
| | | // 创建TCP客户端并连接到服务器 |
| | | String serverAddress = "192.168.1.8"; |
| | | String serverAddress = "10.36.164.19"; |
| | | int serverPort = 2001; |
| | | Socket clientSocket = new Socket(serverAddress, serverPort); |
| | | // 创建输入流和输出流 |