use of com.eservice.api.model.machine.MachineAndTask in project sinsim by WilsonHu.
the class TaskRecordController method selectMachineOrderStructureTable.
// / 订单结构表的查询
// / 包括了 订单信息、工序信息
// / 一个订单下有多个机器时,每个机器都列为一行。
@PostMapping("selectMachineOrderStructureTable")
public Result selectMachineOrderStructureTable(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, // 订单录入时间
String queryMachineOrderCreateTime, String orderNum, // / 统一用这个写错的词
String sellMan, // /机器类型
Integer machineType, String nameplate, String needleNum, String headNum, // /剪线方式
String electricTrim, // /机器完成状态--> 固定了是查询“测试调试”工序,该工序完成,则表示机器完成安装。
String machineFinishStatus, // /工序完成(结束)时间
String taskRecordEndTime, // 回复交期,
String queryStartTimePlanShipDate, // 回复交期,
String queryFinishTimePlanShipDate, String taskName) {
PageHelper.startPage(page, size);
List<TaskRecordDetail> taskRecordDetailList = taskRecordService.selectMachineOrderStructureTable(// 订单录入时间
queryMachineOrderCreateTime, orderNum, sellMan, // /机器类型
machineType, nameplate, needleNum, headNum, // /剪线方式
electricTrim, // /工序状态
machineFinishStatus, // /工序完成(结束)时间
taskRecordEndTime, queryStartTimePlanShipDate, queryFinishTimePlanShipDate, taskName);
/**
* 对返回的数据进行处理:
* 返回数据是以工序为单位,需要转换为 以机器为单位,附带该机器的工序信息.
*/
List<MachineAndTask> machineAndTaskList = new ArrayList<>();
for (int i = 0; i < taskRecordDetailList.size(); i++) {
// 查询 machineAndTaskList 是否已经存在该机器, 如果查到了,则记录对应的taskRecordId等
boolean flagMachineExisted = false;
int taskRecordId = 0;
// 记录是哪个machineAndTask包含了该工序所在机器。
int numberOf = 0;
MachineAndTask machineAndTaskTobeAdd = new MachineAndTask();
MachineAndTask machineAndTaskTobeUpdate = new MachineAndTask();
for (int k = 0; k < machineAndTaskList.size(); k++) {
if (machineAndTaskList.get(k).getMachineStrId() != null && machineAndTaskList.get(k).getMachineStrId().equalsIgnoreCase(taskRecordDetailList.get(i).getMachine().getMachineStrId())) {
flagMachineExisted = true;
taskRecordId = taskRecordDetailList.get(i).getId();
numberOf = k;
break;
}
}
machineAndTaskTobeAdd.setMachineStrId(taskRecordDetailList.get(i).getMachine().getMachineStrId());
machineAndTaskTobeAdd.setNameplate(taskRecordDetailList.get(i).getMachine().getNameplate());
TaskRecord taskRecord = new TaskRecord();
taskRecord.setTaskName(taskRecordDetailList.get(i).getTaskName());
taskRecord.setInstallEndTime(taskRecordDetailList.get(i).getInstallEndTime());
List<TaskRecord> taskRecordList = new ArrayList<>();
taskRecordList.add(taskRecord);
machineAndTaskTobeAdd.setTaskRecordList(taskRecordList);
machineAndTaskTobeAdd.setMachineTypeWhole(taskRecordDetailList.get(i).getMachineType());
machineAndTaskTobeAdd.setMachineOrder(taskRecordDetailList.get(i).getMachineOrder());
machineAndTaskTobeAdd.setMachineStrId(taskRecordDetailList.get(i).getMachine().getMachineStrId());
machineAndTaskTobeAdd.setElectricTrim(taskRecordDetailList.get(i).getElectricTrim());
machineAndTaskTobeAdd.setAxleJump(taskRecordDetailList.get(i).getAxleJump());
machineAndTaskTobeAdd.setMachineFrameworkCreateTime(taskRecordDetailList.get(i).getMachine().getMachineFrameworkCreateTime());
/**
* 如果 machineAndTaskList 里存在该机器,则在该 machineAndTaskList 的taskRecordList里 加上工序;
* 如果 machineAndTaskList 里没有该机器,则新建一个;
*/
if (flagMachineExisted == true) {
TaskRecord taskRecord1 = taskRecordService.findById(taskRecordId);
if (taskRecord1 == null) {
logger.warn("异常,taskRecord 为空");
} else {
List<TaskRecord> taskRecordList1 = machineAndTaskList.get(numberOf).getTaskRecordList();
taskRecordList1.add(taskRecord1);
machineAndTaskList.get(numberOf).setTaskRecordList(taskRecordList1);
// logger.info("更新一个machineAndTaskTobeAdd, " + machineAndTaskTobeAdd.getMachineStrId() );
if (machineAndTaskTobeAdd.getTaskRecordList() == null) {
// logger.info("machineAndTaskTobeAdd.getTaskRecordList(). is null");
} else {
// logger.info(machineAndTaskTobeAdd.getTaskRecordList().size());
}
}
} else {
if (machineAndTaskTobeAdd.getTaskRecordList() == null) {
// logger.info("machineAndTaskTobeAdd.getTaskRecordList(). is null");
} else {
// logger.info(machineAndTaskTobeAdd.getTaskRecordList().size());
}
machineAndTaskList.add(machineAndTaskTobeAdd);
}
}
PageInfo pageInfo = new PageInfo(machineAndTaskList);
return ResultGenerator.genSuccessResult(pageInfo);
}
Aggregations