|
@@ -13,10 +13,7 @@ import com.ruoyi.system.service.ISysConfigService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.poi.ss.usermodel.Cell;
|
|
|
-import org.apache.poi.ss.usermodel.Row;
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -30,6 +27,7 @@ import java.io.OutputStream;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.text.ParseException;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
@@ -125,15 +123,29 @@ public class ApiController extends BaseController {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
if (week != null) {
|
|
|
-// List<TwinCalc2hr> list = calc2hrService.selectWeekData(info);
|
|
|
-// List<Map<String, Object>> alarms = new ArrayList<>();
|
|
|
-// list.forEach(calc2hr -> {
|
|
|
-// Map<String, Object> temp = new HashMap<>(16);
|
|
|
-// temp.put("time", DateUtils.parseDateToStr(calc2hr.getDataDate()));
|
|
|
-// temp.put("value", calc2hr.getAlarm());
|
|
|
-// alarms.add(temp);
|
|
|
-// });
|
|
|
-// result.put("alarms", alarms);
|
|
|
+ /*
|
|
|
+ *获取前面7天的数据
|
|
|
+ */
|
|
|
+ LocalDateTime ldt = LocalDateTime.now();
|
|
|
+ if (ldt.getHour() < 7) {
|
|
|
+ //7点前是属于前一生产天
|
|
|
+ ldt = ldt.minusDays(1);
|
|
|
+ }
|
|
|
+ LocalDate localDate = ldt.toLocalDate().minusDays(7);
|
|
|
+ Date date = Date.from(localDate.atStartOfDay(ZoneOffset.of("+8")).toInstant());
|
|
|
+ List<TwinCalcDay> list = twinCalcDayService.selectTwinCalcDayListByTime(date);
|
|
|
+ List<Map<String, Object>> alarms = new ArrayList<>();
|
|
|
+ Map<Date, List<TwinCalcDay>> stopDeviceGroup = list.stream().collect(Collectors.groupingBy(TwinCalcDay::getTime, LinkedHashMap::new, Collectors.toList()));
|
|
|
+ for (Map.Entry<Date, List<TwinCalcDay>> entry : stopDeviceGroup.entrySet()) {
|
|
|
+ Map<String, Object> temp = new HashMap<>(16);
|
|
|
+ TwinCalcDay day = new TwinCalcDay(entry.getKey());
|
|
|
+ List<TwinCalcDay> days = entry.getValue();
|
|
|
+ day.calcDays(days);
|
|
|
+ temp.put("time", DateUtils.parseDateToStr(entry.getKey()));
|
|
|
+ temp.put("value", day.getAlarm());
|
|
|
+ alarms.add(temp);
|
|
|
+ }
|
|
|
+ result.put("alarms", alarms);
|
|
|
}
|
|
|
return R.ok(result);
|
|
|
}
|
|
@@ -151,6 +163,63 @@ public class ApiController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("送经量")
|
|
|
+ @GetMapping("/warp/run-in")
|
|
|
+ @CrossOrigin(origins = "*")
|
|
|
+ public void warpRunIn(HttpServletResponse response) {
|
|
|
+ Object d = CacheUtils.get(Constants.IOT_TOKEN, Constants.INDEX_WARP_RUN_IN);
|
|
|
+ if (d != null) {
|
|
|
+ List<WarpRunIn> list = (List<WarpRunIn>) d;
|
|
|
+ try (Workbook wb = new XSSFWorkbook(); OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
|
|
|
+ Sheet sheet = wb.createSheet("送经量明细");
|
|
|
+ sheet.setDefaultColumnWidth(15);
|
|
|
+ CellStyle style = wb.createCellStyle();
|
|
|
+ style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
|
|
|
+ Row titleRow = sheet.createRow(0);
|
|
|
+ Cell titleCell = titleRow.createCell(0);
|
|
|
+ titleCell.setCellValue("设备名");
|
|
|
+ titleCell = titleRow.createCell(1);
|
|
|
+ titleCell.setCellValue("L1梳栉送经量");
|
|
|
+ titleCell = titleRow.createCell(2);
|
|
|
+ titleCell.setCellValue("L2梳栉送经量");
|
|
|
+ titleCell = titleRow.createCell(3);
|
|
|
+ titleCell.setCellValue("L3梳栉送经量");
|
|
|
+ titleCell = titleRow.createCell(4);
|
|
|
+ titleCell.setCellValue("L4梳栉送经量");
|
|
|
+ titleCell = titleRow.createCell(5);
|
|
|
+ titleCell.setCellValue("L5梳栉送经量");
|
|
|
+ titleCell = titleRow.createCell(6);
|
|
|
+ titleCell.setCellValue("牵拉密度");
|
|
|
+ titleCell = titleRow.createCell(7);
|
|
|
+ titleCell.setCellValue("卷曲张力系数");
|
|
|
+ AtomicInteger rowNum = new AtomicInteger(1);
|
|
|
+ list.forEach(warp -> {
|
|
|
+ Row row = sheet.createRow(rowNum.get());
|
|
|
+ Cell[] cells = new Cell[8];
|
|
|
+ for (int i = 0; i < cells.length; i++) {
|
|
|
+ cells[i] = row.createCell(i);
|
|
|
+ }
|
|
|
+ warp.setCells(cells, style);
|
|
|
+ rowNum.getAndIncrement();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 清空response
|
|
|
+ response.reset();
|
|
|
+ // 设置response的Header
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ //Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
+ //attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
+ // filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("送经量明细导出" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ wb.write(outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ } catch (IOException ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("配方详情")
|
|
|
@GetMapping("/formula/detail/{height}")
|
|
|
@CrossOrigin(origins = "*")
|