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;
|
}
|
|
|
}
|