Search in sources :

Example 1 with AbnormalRecordDetail

use of com.eservice.api.model.abnormal_record.AbnormalRecordDetail in project sinsim by WilsonHu.

the class AbnormalRecordController method selectAbnormalRecordDetails.

/**
 * 根据 task_record.id 返回abnormalRecordDetail
 *
 * @param taskRecordId
 * @return
 */
@PostMapping("/selectAbnormalRecordDetails")
public Result selectAbnormalRecordDetails(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, @RequestParam Integer taskRecordId) {
    PageHelper.startPage(page, size);
    List<AbnormalRecordDetail> abnormalRecordDetailList = abnormalRecordService.selectAbnormalRecordDetails(taskRecordId);
    PageInfo pageInfo = new PageInfo(abnormalRecordDetailList);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) AbnormalRecordDetail(com.eservice.api.model.abnormal_record.AbnormalRecordDetail) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with AbnormalRecordDetail

use of com.eservice.api.model.abnormal_record.AbnormalRecordDetail in project sinsim by WilsonHu.

the class AbnormalRecordController method export.

/**
 * 根据异常类型、异常提交时间、提交者、解决者,返回abnormalRecordDetail
 *
 * @return
 */
@PostMapping("/export")
public Result export(String nameplate, Integer abnormalType, String taskName, Integer submitUser, Integer solutionUser, Integer finishStatus, String queryStartTime, String queryFinishTime) {
    List<AbnormalRecordDetail> list = abnormalRecordService.selectAbnormalRecordDetailList(nameplate, abnormalType, taskName, submitUser, solutionUser, finishStatus, queryStartTime, queryFinishTime);
    InputStream fs = null;
    POIFSFileSystem pfs = null;
    HSSFWorkbook wb = null;
    FileOutputStream out = null;
    String downloadPath = "";
    /*
        返回给docker外部下载
         */
    String downloadPathForNginx = "";
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
    String dateString;
    try {
        // 生成一个空的Excel文件
        wb = new HSSFWorkbook();
        Sheet sheet1 = wb.createSheet("sheet1");
        // 设置标题行格式
        HSSFCellStyle headcellstyle = wb.createCellStyle();
        HSSFFont headfont = wb.createFont();
        headfont.setFontHeightInPoints((short) 10);
        // 粗体显示
        headfont.setBold(true);
        headcellstyle.setFont(headfont);
        Row row;
        // 创建行和列
        for (int r = 0; r < list.size() + 1; r++) {
            // 新创建一行,行号为row+1
            row = sheet1.createRow(r);
            // 序号,异常类型,工序,提交者,解决者,创建时间,解决时间
            for (int c = 0; c < 9; c++) {
                // 创建一个单元格,列号为col+1
                row.createCell(c);
                sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
            }
        }
        sheet1.setColumnWidth(0, 2000);
        sheet1.setColumnWidth(1, 4000);
        sheet1.setColumnWidth(2, 4000);
        sheet1.setColumnWidth(3, 4000);
        sheet1.setColumnWidth(4, 4000);
        sheet1.setColumnWidth(5, 4000);
        sheet1.setColumnWidth(6, 10000);
        sheet1.setColumnWidth(7, 4000);
        sheet1.setColumnWidth(8, 4000);
        // 第一行为标题
        sheet1.getRow(0).getCell(0).setCellValue("序号");
        sheet1.getRow(0).getCell(1).setCellValue("机器编号");
        sheet1.getRow(0).getCell(2).setCellValue("异常类型");
        sheet1.getRow(0).getCell(3).setCellValue("工序");
        sheet1.getRow(0).getCell(4).setCellValue("提交者");
        sheet1.getRow(0).getCell(5).setCellValue("解决者");
        sheet1.getRow(0).getCell(6).setCellValue("解决方法");
        sheet1.getRow(0).getCell(7).setCellValue("创建时间");
        sheet1.getRow(0).getCell(8).setCellValue("解决时间");
        // 第二行开始,填入值
        for (int r = 0; r < list.size(); r++) {
            row = sheet1.getRow(r + 1);
            row.getCell(0).setCellValue(r + 1);
            row.getCell(1).setCellValue(list.get(r).getMachine().getNameplate());
            row.getCell(2).setCellValue(list.get(r).getAbnormal().getAbnormalName());
            row.getCell(3).setCellValue(list.get(r).getTaskRecord().getTaskName());
            int userID = list.get(r).getSubmitUser();
            row.getCell(4).setCellValue(userService.findById(userID).getName());
            userID = list.get(r).getSolutionUser();
            row.getCell(5).setCellValue(userService.findById(userID).getName());
            row.getCell(6).setCellValue(list.get(r).getSolution());
            dateString = formatter.format(list.get(r).getCreateTime());
            row.getCell(7).setCellValue(dateString);
            dateString = formatter.format(list.get(r).getSolveTime());
            row.getCell(8).setCellValue(dateString);
        }
        downloadPath = abnoramlExcelOutputDir + "异常统计" + ".xls";
        downloadPathForNginx = "/excel/" + "异常统计" + ".xls";
        out = new FileOutputStream(downloadPath);
        wb.write(out);
        out.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    if ("".equals(downloadPath)) {
        return ResultGenerator.genFailResult("异常导出失败!");
    } else {
        return ResultGenerator.genSuccessResult(downloadPathForNginx);
    }
}
Also used : InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) FileOutputStream(java.io.FileOutputStream) AbnormalRecordDetail(com.eservice.api.model.abnormal_record.AbnormalRecordDetail) Row(org.apache.poi.ss.usermodel.Row) SimpleDateFormat(java.text.SimpleDateFormat) Sheet(org.apache.poi.ss.usermodel.Sheet) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with AbnormalRecordDetail

use of com.eservice.api.model.abnormal_record.AbnormalRecordDetail in project sinsim by WilsonHu.

the class AbnormalRecordController method selectAbnormalRecordDetailList.

/**
 * 根据异常类型、异常提交时间、提交者、解决者,返回abnormalRecordDetail
 *
 * @return
 */
@PostMapping("/selectAbnormalRecordDetailList")
public Result selectAbnormalRecordDetailList(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, String nameplate, Integer abnormalType, String taskName, Integer submitUser, Integer solutionUser, Integer finishStatus, String queryStartTime, String queryFinishTime) {
    PageHelper.startPage(page, size);
    List<AbnormalRecordDetail> abnormalRecordDetailList = abnormalRecordService.selectAbnormalRecordDetailList(nameplate, abnormalType, taskName, submitUser, solutionUser, finishStatus, queryStartTime, queryFinishTime);
    PageInfo pageInfo = new PageInfo(abnormalRecordDetailList);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) AbnormalRecordDetail(com.eservice.api.model.abnormal_record.AbnormalRecordDetail) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with AbnormalRecordDetail

use of com.eservice.api.model.abnormal_record.AbnormalRecordDetail in project sinsim by WilsonHu.

the class AbnormalRecordController method updateAbnormalRecordDetail.

/**
 * 根据传入的strAbnormalRecordDetail,更新对应多表:
 * "machine_id":"", --> machine.machine_id
 * "安装是否异常":"", --> task_record.status  task状态,“1”==>未开始, “2”==>进行中,“3”==>安装完成, “4”==>质检完成,“5“===>异常
 * "异常类型":"",	--> abnormal_record.abnormal_type
 * "异常原因":"", --> abnormal_record.comment
 * "异常照片":"", -->abnormal_image.image
 * "安装完成":"",  -->   task_record.status或machine.status都可以,反正这两个表都更新
 * 注意:有外键的字段,需要上传实际存在的外键数据。
 * 一项update失败的情况下,全部update无效(事务OK)
 *
 * @param strAbnormalRecordDetail
 * @return
 */
@PostMapping("/updateAbnormalRecordDetail")
@Transactional
public Result updateAbnormalRecordDetail(@RequestParam String strAbnormalRecordDetail) {
    // 获取整体detail
    AbnormalRecordDetail abnormalRecordDetail1 = JSON.parseObject(strAbnormalRecordDetail, AbnormalRecordDetail.class);
    Integer abnormalRecordDetail_ID = abnormalRecordDetail1.getId();
    AbnormalRecord abnormalRecord = abnormalRecordService.findById(abnormalRecordDetail_ID);
    abnormalRecord.setAbnormalType(abnormalRecordDetail1.getAbnormalType());
    abnormalRecord.setTaskRecordId(abnormalRecordDetail1.getTaskRecordId());
    abnormalRecord.setSubmitUser(abnormalRecordDetail1.getSubmitUser());
    abnormalRecord.setSolutionUser(abnormalRecordDetail1.getSolutionUser());
    abnormalRecord.setComment(abnormalRecordDetail1.getComment());
    abnormalRecord.setSolution(abnormalRecordDetail1.getSolution());
    Abnormal abnormal = abnormalRecordDetail1.getAbnormal();
    AbnormalImage abnormalImage = abnormalRecordDetail1.getAbnormalImage();
    TaskRecord taskRecord = abnormalRecordDetail1.getTaskRecord();
    Machine machine = abnormalRecordDetail1.getMachine();
    abnormalRecordService.update(abnormalRecord);
    abnormalService.update(abnormal);
    abnormalImageService.update(abnormalImage);
    taskRecordService.update(taskRecord);
    machineService.update(machine);
    return ResultGenerator.genSuccessResult();
}
Also used : TaskRecord(com.eservice.api.model.task_record.TaskRecord) AbnormalRecord(com.eservice.api.model.abnormal_record.AbnormalRecord) AbnormalImage(com.eservice.api.model.abnormal_image.AbnormalImage) AbnormalRecordDetail(com.eservice.api.model.abnormal_record.AbnormalRecordDetail) Abnormal(com.eservice.api.model.abnormal.Abnormal) Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AbnormalRecordDetail (com.eservice.api.model.abnormal_record.AbnormalRecordDetail)4 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 PageInfo (com.github.pagehelper.PageInfo)2 Abnormal (com.eservice.api.model.abnormal.Abnormal)1 AbnormalImage (com.eservice.api.model.abnormal_image.AbnormalImage)1 AbnormalRecord (com.eservice.api.model.abnormal_record.AbnormalRecord)1 Machine (com.eservice.api.model.machine.Machine)1 TaskRecord (com.eservice.api.model.task_record.TaskRecord)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)1 Row (org.apache.poi.ss.usermodel.Row)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1 Transactional (org.springframework.transaction.annotation.Transactional)1