y_ys79
2024-01-05 e5840972b6b17ec03bfc1069a9cacfe0cef189c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package com.qianwen.mdc.controller;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.qianwen.mdc.domain.*;
import com.qianwen.mdc.domain.workshop.Workshop;
import com.qianwen.mdc.mapper.*;
 
import java.util.List;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
/**
 * 工件控制器
 */
@RestController
@CrossOrigin
@RequestMapping(value = "/machine", method = RequestMethod.POST)
public class ComponentController {
    //@Autowired
    //private MdcTokenMapper mdcTokenMapper;
    @Autowired
    private MachineMapper mdcMachineMapper;
    //@Autowired
    //private MdcMachineTypeMapper mdcMachineTypeMapper;
    @Autowired
    private MachiningDataMapper mdcDataMapper;
    @Autowired
    private MdcDataHistoryMapper mdcDataHistoryMapper;
    @Autowired
    private WorkshopMapper mdcWorkshopMapper;
    @Autowired
    private SectionMapper mdcSectionMapper;
    //@Autowired
    //private MdcMachineDataMapper mdcMachineDataMapper;
    @Autowired
    private MachineStatusMapper mdcMachineStatusMapper;
    @Autowired
    private MdcMachineStatusHistoryMapper mdcMachineStatusHistoryMapper;
    @Autowired
    private DncProcessingMapper mdcDncProgParseMapper;
    @Autowired
    private MonitorlogMapper monitorlogMapper;
    @Autowired
    private MdcAlarmPromptMapper mdcAlarmPromptMapper;
 
    public static final Logger logger = LoggerFactory.getLogger(ComponentController.class);
    
    @RequestMapping(value = "/component/list", method = RequestMethod.POST)
    public List<String> getComponentList() {
        return mdcDncProgParseMapper.getComponentList();
    }
 
    @RequestMapping(value = "/process/list", method = RequestMethod.POST)
    public List<String> getProcessList() {
        return mdcDncProgParseMapper.getProcessList();
    }
 
    @RequestMapping(value = "/component/info", method = RequestMethod.POST)
    public JSONObject getComponentInfo(Integer pageNo,
                String component, String process, String timeBegin, String timeEnd) {
        JSONObject jsonObject = new JSONObject();
        int cycleTime;
 
//        JSONArray jsonArray = new JSONArray();
//        jsonObject.put("list", jsonArray);
//        List<Integer> machineIdList = mdcDncProgParseMapper
//                .selectProgParseMachineList(component, process, timeBegin, timeEnd);
////        List<Integer> machineIdList = mdcDncProgParseMapper.selectProgParseList(component, process, timeBegin, timeEnd);
//        for (Integer machineId : machineIdList) {
//            JSONObject obj = new JSONObject();
//            jsonArray.add(obj);
//
//            MdcMachine mdcMachineObj = new MdcMachine();
//            mdcMachineObj.setMachineId(machineId);
//            MdcMachine mdcMachine = mdcMachineMapper.selectOne(mdcMachineObj);
//            obj.put("name", mdcMachine.getName());
//
//            obj.put("component", component);
//            obj.put("process", process);
//
//            cycleTime = 0;
//            Example parseExample = new Example(MdcDncProgParse.class);
//            parseExample.setOrderByClause("time asc");
//            parseExample.createCriteria().andEqualTo("machineId", machineId)
//                    .andBetween("time", timeBegin, timeEnd);
//            List<MdcDncProgParse> parseList = mdcDncProgParseMapper.selectByExample(parseExample);
//            Date parseTime = null;
//            for (MdcDncProgParse dncProgParse : parseList) {
//                if (parseTime == null) {
//
//                }
//                if (component.equals(dncProgParse.getComponent()) && process.equals(dncProgParse.getProcess())) {
//                    if (parseTime == null) {
//                        parseTime = dncProgParse.getTime();
//                    } else {
////                        cycleTime += ;
//                    }
//                } else {
//
//                }
//            }
//
//            Example historyExample = new Example(MdcMachineStatusHistory.class);
//            historyExample.createCriteria().andEqualTo("machineId", machineId)
//                    .andLessThan("time", timeEnd);
//            List<MdcMachineStatusHistory> histories = mdcMachineStatusHistoryMapper.selectByExample(historyExample);
//            for (MdcMachineStatusHistory history : histories) {
//                String str = history.getVar2();
//                if (null != str) {
//                    cycleTime += Integer.parseInt(history.getVar2());
//                }
//            }
//
//            jsonObject.put("cycleTime", cycleTime);
//        }
 
        JSONArray jsonArray = new JSONArray();
        jsonObject.put("list", jsonArray);
        int curRecord = (pageNo - 1) * 10;
        for (int i=curRecord; i<curRecord+10; i++) {
            if (i >= 20) {
                break;
            }
 
            JSONObject obj = new JSONObject();
            jsonArray.add(obj);
 
            obj.put("name", "aaa" + i + "_Fn");
            obj.put("component", "bbb" + i);
            obj.put("process", "ccc" + i);
            obj.put("time", "123" + i);
        }
        String totalPage = String.format("%d", (20 - 1) / 10 + 1);
        jsonObject.put("totalPage", totalPage);
        jsonObject.put("result", "SUCCESS");
 
        return jsonObject;
    }
 
    
}