ZengTao
2024-03-31 1de52d82ec5c3fb56e095a36571ab32bfdb15ca4
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;
@@ -287,11 +291,11 @@
    }
    // 开始任务
    public Result ClaimTasks(String flowcard, Integer state) {
    public Result ClaimTasks(String flowcard, Integer state, Integer line) {
        if (state == 1) {
            homeMapper.ClaimTasks(flowcard, 0);
            homeMapper.ClaimTasks(flowcard, 0,line);
        } else {
            homeMapper.ClaimTasks(flowcard, 1);
            homeMapper.ClaimTasks(flowcard, 1,line);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("message", "200");
@@ -313,8 +317,10 @@
    // 修改测量信息
    public Result UpdateQueue(GlassInfo glassInfo) {
        homeMapper.UpdateQueue(glassInfo.getFlowcard(), glassInfo.getWidth(), glassInfo.getHeight(),
                glassInfo.getGlasstype());
                glassInfo.getGlasstype(),glassInfo.getThickness());
        Map<String, Object> map = new HashMap<>();
        PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1);
        map.put("message", "200");
        return Result.success(map);
    }
@@ -328,8 +334,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 +349,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");
@@ -356,7 +365,8 @@
        List<Map> TypeDatas = homeMapper.SelectType();
        Map<String, String> TypeData = new HashMap<String, String>();// 得到处理完后所有的类型
        Map<String, Integer> groupby=new HashMap<String, Integer>(); // 得到处理完后所有总层数;
        Map<String, Integer> OrderFinishedProduct=new HashMap<String, Integer>(); // 得到处理完后订单成品总数量;
        //"order zong 0  1  10  2 10"
        List<Map> RemoveErrorData = IportDataStr.stream()
                .filter(item -> (item.get("order") != null && item.get("glasstype") != null && item.get("tier") != null
                        &&
@@ -370,6 +380,17 @@
        RemoveErrorData.forEach(item -> {
            String key=item.get("order").toString()+"_"+item.get("matching").toString();
            String keyCount=item.get("order").toString()+"_"+item.get("matching").toString()+"_"+item.get("tier").toString();
            String keyCountSum=item.get("order").toString()+"_"+item.get("matching").toString()+"_Sum";//订单总数
            if (OrderFinishedProduct.get(keyCount)!=null) {
                Integer count=OrderFinishedProduct.get(keyCount)+1;
                Integer sumcount=OrderFinishedProduct.get(keyCountSum)+Integer.parseInt(item.get("quantity").toString());
                OrderFinishedProduct.put(keyCount,count);
                OrderFinishedProduct.put(keyCountSum,sumcount);
            }else if(OrderFinishedProduct.get(keyCount)==null&&groupby.get(key)==null){
                OrderFinishedProduct.put(keyCount,1);
                OrderFinishedProduct.put(keyCountSum,Integer.parseInt(item.get("quantity").toString()));
            }
            if (groupby.get(key)!=null) {
                Integer Tiers=groupby.get(key)+1;
                groupby.put(key, Tiers);
@@ -380,6 +401,7 @@
        System.out.println(RemoveErrorData.size());
        // 处理完成 添加数据库
        int count=1;
        for (Map map : RemoveErrorData) {
            String key = map.get("base").toString() + "_" + map.get("height").toString() + "_"
                       + map.get("thickness").toString() + "_" + map.get("films").toString();
@@ -390,16 +412,23 @@
            Integer glasstype;
            if (TypeData.get(key) == null) {
                glasstype = homeMapper.SelectMaxType();
                if (glasstype==null) {
                    glasstype=1;
                }
            } else {
                glasstype = Integer.valueOf(value);
            }
            //
            homeMapper.AddGlassinfo(map.get("order").toString(), glasstype,
                    Integer.parseInt(map.get("glasstype").toString()) // 需要计算 配片ID
                    , glasstype+"" // 需要计算 玻璃ID
                    Integer.parseInt(map.get("matching").toString()) // 需要计算 配片ID
                    ,map.get("order").toString()+"-"+count+"" // 需要计算 玻璃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()),groupby.get(tierkey));// 需要计算总层数
            //订单内总层数
            homeMapper.InsertFlowcard(map.get("order").toString(),OrderFinishedProduct.get(tierkey+"_Sum"));
            count++;
        }
        Map<String, Object> ResultCode = new HashMap<>();
        ResultCode.put("message", "200");