wu
2024-03-26 c1d88895501846c4ad1ba2b16f4a8ae10ca2b061
springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java
@@ -21,6 +21,7 @@
import com.example.springboot.entity.StorageTask;
import com.example.springboot.entity.device.PlcParameterObject;
import com.example.springboot.mapper.HomeMapper;
import com.example.springboot.mapper.QueueMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
@Service
@@ -30,6 +31,9 @@
    @Autowired
    private OutSliceServive outSliceServive;
    @Autowired
    private QueueMapper QueueMapper;
    @Autowired
    private SpianService spianService;
@@ -280,9 +284,9 @@
    // 查询订单任务
    public List<FlowCard> SelectOrderTask() {
        List<FlowCard> OrderTask = homeMapper.SelectOrderTask();
        for (FlowCard flowcard : OrderTask) {
            flowcard.setglassinfo(homeMapper.SelectOrderView(flowcard.getFlowcard()));
        }
        // for (FlowCard flowcard : OrderTask) {
        //     flowcard.setglassinfo(homeMapper.SelectOrderView(flowcard.getFlowcard()));
        // }
        return OrderTask;
    }
@@ -328,8 +332,10 @@
        // 读取DB105区文件
        PlcParameterObject plcmes = PLCAutoMes.PlcMesObject;
        // 移除
        // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),
        // (short) 3);
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 3);
        //删除数据
        QueueMapper.DeleteErrorQueue();
        // plcmes.getPlcParameter("GaToMES").setValue("3");
        Map<String, Object> map = new HashMap<>();
        map.put("message", "200");
@@ -341,8 +347,9 @@
        // 读取DB105区文件
        PlcParameterObject plcmes = PLCAutoMes.PlcMesObject;
        // 重新测量
        // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),
        // (short) 2);
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 2);
        //删除数据
        QueueMapper.DeleteErrorQueue();
        // plcmes.getPlcParameter("GaToMES").setValue("2");
        Map<String, Object> map = new HashMap<>();
        map.put("message", "200");
@@ -355,26 +362,37 @@
        // 筛选处理数据 1.去除无用数据 2.计算配片ID 3.计算ID 4. 计算总层数
        List<Map> TypeDatas = homeMapper.SelectType();
        Map<String, String> TypeData = new HashMap<String, String>();// 得到处理完后所有的类型
        Map<String, Integer> groupby=new HashMap<String, Integer>(); // 得到处理完后所有总层数;
        List<Map> RemoveErrorData = IportDataStr.stream()
                .filter(item -> (item.get("order") != null && item.get("glasstype") != null && item.get("tier") != null
                        &&
                        item.get("films") != null && item.get("base") != null && item.get("height") != null
                        && item.get("thickness") != null && item.get("quantity") != null))
                        && item.get("thickness") != null && item.get("quantity") != null&& item.get("matching") != null))
                .collect(Collectors.toList());
        // 取出RemoveErrorData 里面的列当作TypeData的key
        TypeDatas.forEach(item -> {
            TypeData.put(item.get("type").toString(), item.get("glasstype").toString());
        });
        RemoveErrorData.forEach(item -> {
            String key=item.get("order").toString()+"_"+item.get("matching").toString();
            if (groupby.get(key)!=null) {
                Integer Tiers=groupby.get(key)+1;
                groupby.put(key, Tiers);
            }else{
                groupby.put(key, 1);
            }
        });
        System.out.println(RemoveErrorData.size());
        // 处理完成 添加数据库
        for (Map map : RemoveErrorData) {
            // GlassInfo glassInfo = mapper.convertValue(map, GlassInfo.class);
            String key = map.get("base").toString() + "_" + map.get("height").toString() + "_"
                    + map.get("thickness").toString() + "_" + map.get("films").toString();
                       + map.get("thickness").toString() + "_" + map.get("films").toString();
            String tierkey = map.get("order").toString() + "_" + map.get("matching").toString();
            String value = TypeData.get(key);
            Integer glasstype;
            if (TypeData.get(key) == null) {
@@ -384,11 +402,11 @@
            }
            homeMapper.AddGlassinfo(map.get("order").toString(), glasstype,
                    Integer.parseInt(map.get("glasstype").toString()) // 需要计算 配片ID
                    , map.get("glasstype").toString() // 需要计算 玻璃ID
                    , glasstype+"" // 需要计算 玻璃ID
                    , Integer.parseInt(map.get("tier").toString()), map.get("films").toString(),
                    Double.parseDouble(map.get("base").toString()), Double.parseDouble(map.get("height").toString()),
                    Double.parseDouble(map.get("thickness").toString()),
                    Integer.parseInt(map.get("quantity").toString()), 1);// 需要计算总层数
                    Integer.parseInt(map.get("quantity").toString()),groupby.get(tierkey));// 需要计算总层数
        }
        Map<String, Object> ResultCode = new HashMap<>();
        ResultCode.put("message", "200");