123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571 |
- package com.ruoyi.project.sems.controller;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.concurrent.CopyOnWriteArrayList;
- import com.alibaba.fastjson.JSON;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.ruoyi.common.utils.DateUtils;
- import com.ruoyi.common.utils.ServletUtils;
- import com.ruoyi.common.utils.file.ExcelUtils;
- import com.ruoyi.common.utils.spring.SpringUtils;
- import com.ruoyi.framework.security.LoginUser;
- import com.ruoyi.framework.security.service.TokenService;
- import com.ruoyi.project.sems.domain.*;
- import com.ruoyi.project.sems.his.controller.TApproveSpecModifyController;
- import com.ruoyi.project.sems.his.controller.TSpechiDzsbController;
- import com.ruoyi.project.sems.his.domain.TApproveSpecModify;
- import com.ruoyi.project.sems.his.service.ITApproveSpecModifyService;
- import com.ruoyi.project.sems.service.ITSpecCheckService;
- import com.ruoyi.project.system.domain.SysDept;
- import com.ruoyi.project.system.domain.SysDictData;
- import com.ruoyi.project.system.service.ISysDeptService;
- import com.ruoyi.project.system.service.ISysDictTypeService;
- import org.activiti.engine.RuntimeService;
- import org.activiti.engine.impl.identity.Authentication;
- import org.activiti.engine.runtime.ProcessInstance;
- import org.apache.commons.lang.StringUtils;
- import org.apache.poi.ss.usermodel.*;
- import org.apache.poi.xssf.streaming.SXSSFWorkbook;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import com.ruoyi.framework.aspectj.lang.annotation.Log;
- import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
- import com.ruoyi.project.sems.service.ITSpecdevDzsbService;
- import com.ruoyi.framework.web.controller.BaseController;
- import com.ruoyi.framework.web.domain.AjaxResult;
- import com.ruoyi.common.utils.poi.ExcelUtil;
- import com.ruoyi.framework.web.page.TableDataInfo;
- import org.springframework.web.multipart.MultipartFile;
- /**
- * 特种设备吊装设备台账Controller
- *
- * @author ruoyi
- * @date 2021-07-26
- */
- @RestController
- @RequestMapping("/sems/specDzsb")
- public class TSpecdevDzsbController extends BaseController {
- @Autowired
- private ITSpecdevDzsbService tSpecdevDzsbService;
- @Autowired
- private ITSpecCheckService tSpecCheckService;
- @Autowired
- private ISysDeptService iSysDeptService;
- @Autowired
- private ISysDictTypeService iSysDictTypeService;
- @Autowired
- private ITApproveSpecModifyService tApproveSpecModifyService;
- @Autowired
- private RuntimeService runtimeService;
- @Autowired
- private TApproveSpecModifyController approveSpecModifyController;
- @Autowired
- private TSpechiDzsbController tSpechiDzsbController;
- /**
- * 查询特种设备吊装设备台账列表
- */
- @PreAuthorize("@ss.hasPermi('sems:specDzsb:list')")
- @GetMapping("/list")
- public TableDataInfo list(TSpecdevDzsb tSpecdevDzsb) {
- startPage();
- List<TSpecdevDzsb> list = tSpecdevDzsbService.selectTSpecdevDzsbList(tSpecdevDzsb);
- return getDataTable(list);
- }
- /**
- * 导出特种设备吊装设备台账列表
- */
- @PreAuthorize("@ss.hasPermi('sems:specDzsb:export')")
- @Log(title = "特种设备吊装设备台账", businessType = BusinessType.EXPORT)
- @GetMapping("/export")
- public AjaxResult export(TSpecdevDzsb tSpecdevDzsb) {
- List<TSpecdevDzsb> list = tSpecdevDzsbService.selectTSpecdevDzsbList(tSpecdevDzsb);
- ExcelUtil<TSpecdevDzsb> util = new ExcelUtil<TSpecdevDzsb>(TSpecdevDzsb.class);
- return util.exportExcel(list, "specDzsb");
- }
- /**
- * 获取特种设备吊装设备台账详细信息
- */
- @PreAuthorize("@ss.hasPermi('sems:specDzsb:query')")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") Long id) {
- return AjaxResult.success(tSpecdevDzsbService.selectTSpecdevDzsbById(id));
- }
- /**
- * 新增特种设备吊装设备台账
- */
- @PreAuthorize("@ss.hasPermi('sems:specDzsb:add')")
- @Log(title = "特种设备吊装设备台账", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody TSpecdevDzsb tSpecdevDzsb) {
- tSpecdevDzsb.setApproveStatus(22l);
- tSpecdevDzsbService.insertTSpecdevDzsb(tSpecdevDzsb);
- TApproveSpecModify tApproveSpecModify = new TApproveSpecModify();
- Long userid = getUserId();
- tApproveSpecModify.setUserId(userid);
- tApproveSpecModify.setApproveType(3l);
- tApproveSpecModify.setDevType(3l);
- tApproveSpecModify.setDevId(String.valueOf(tSpecdevDzsb.getId()));
- //审批编号
- Date dt = new Date();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
- String data = sdf.format(dt) + userid;
- tApproveSpecModify.setApNo(data);
- //
- Authentication.setAuthenticatedUserId(userid.toString());
- tApproveSpecModifyService.insertTApproveSpecModify(tApproveSpecModify);
- long bussniseeKey = tApproveSpecModify.getId();
- //开始工作流、监听
- Map<String, Object> variables = new HashMap<>();
- variables.put("applyUser", userid.toString());
- variables.put("wxjlusers", tSpecdevDzsb.getWxjl());
- //采用key来启动流程定义并设置流程变量,返回流程实例
- ProcessInstance pi = runtimeService.startProcessInstanceByKey("semsAddDelProcess", String.valueOf(bussniseeKey), variables);
- logger.info("流程部署id:" + pi.getDeploymentId());
- logger.info("流程定义id:" + pi.getProcessDefinitionId());
- logger.info("流程实例id:" + pi.getProcessInstanceId());
- tApproveSpecModify.setProcessId(pi.getProcessInstanceId());
- new Thread(() -> {
- approveSpecModifyController.sendMail(tApproveSpecModify , tSpecdevDzsb.getWxjl());
- },"发送邮件").start();
- LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
- String userName =loginUser != null? loginUser.getUsername(): "";
- new Thread(() -> {
- tSpechiDzsbController.addOperLog(String.valueOf(tSpecdevDzsb.getId()),userName,new Date() , "新增申请" );
- },"特种设备操作日志").start();
- return AjaxResult.success();
- }
- /**
- * 修改特种设备吊装设备台账
- */
- @PreAuthorize("@ss.hasPermi('sems:specDzsb:edit')")
- @Log(title = "特种设备吊装设备台账", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody TSpecdevDzsb tSpecdevDzsb) {
- TSpecdevDzsb old = tSpecdevDzsbService.selectTSpecdevDzsbById(tSpecdevDzsb.getId());
- if (StringUtils.isNotEmpty(tSpecdevDzsb.getReportNo()) && !tSpecdevDzsb.getReportNo().equals(old.getReportNo())) {
- TSpecCheck tc = new TSpecCheck();
- tc.setDevType(3l);
- tc.setCheckUnit(tSpecdevDzsb.getCheckUnit());
- tc.setDevId(tSpecdevDzsb.getId());
- tc.setNextWarnDate(tSpecdevDzsb.getNextWarnDate());
- tc.setReportNo(tSpecdevDzsb.getReportNo());
- tc.setWarnDate(tSpecdevDzsb.getWarnDate());
- tc.setCheckConclusion(tSpecdevDzsb.getPerTestConclusion());
- tSpecCheckService.insertTSpecCheck(tc);
- }
- tSpecdevDzsbService.updateTSpecdevDzsb(tSpecdevDzsb);
- LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
- String userName =loginUser != null? loginUser.getUsername(): "";
- new Thread(() -> {
- tSpechiDzsbController.addOperLog(String.valueOf(tSpecdevDzsb.getId()),userName,new Date() , "修改" );
- },"特种设备操作日志").start();
- return AjaxResult.success();
- }
- /**
- * 删除特种设备吊装设备台账
- */
- @PreAuthorize("@ss.hasPermi('sems:specDzsb:remove')")
- @Log(title = "特种设备吊装设备台账", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids) {
- return toAjax(tSpecdevDzsbService.deleteTSpecdevDzsbByIds(ids));
- }
- /**
- * 去重
- */
- @PreAuthorize("@ss.hasPermi('system:plant:remove')")
- @Log(title = "特种设备起重机械台账去重", businessType = BusinessType.OTHER)
- @GetMapping("/duplicate")
- public AjaxResult duplicate() {
- tSpecdevDzsbService.duplicateTSpecdevDzsb();
- return AjaxResult.success();
- }
- /**
- * 批量导入
- */
- @PreAuthorize("@ss.hasPermi('sems:specDzsb:add')")
- @Log(title = "特种设备批量导入", businessType = BusinessType.INSERT)
- @PostMapping("/importData")
- public AjaxResult importData(@RequestParam("file") MultipartFile file,@RequestParam("wxjl") String wxjl) throws IOException {
- //获取操作人员ID
- Long userId = getUserId();
- //报错行数统计
- List<Integer> failRow = new ArrayList<Integer>();
- Workbook workbook = ExcelUtils.getWorkBook(file);
- Sheet sheet = workbook.getSheetAt(0);
- List<TSpecdevDzsb> list = new ArrayList<TSpecdevDzsb>();
- //字典查询
- List<SysDictData> plant = iSysDictTypeService.selectDictDataByType("PLANT_DIVIDE");
- //部门查询
- List<SysDept> dept = iSysDeptService.selectDeptList(new SysDept());
- int rowNum = sheet.getPhysicalNumberOfRows();
- logger.info("rowNum:" + rowNum);
- int failNumber = 0;
- for (int i = 1; i < rowNum; i++) {
- try {
- logger.info("读取行数:" + i);
- Row row = sheet.getRow(i);
- int cellNum = row.getLastCellNum();
- logger.info("cellNum:" + cellNum);
- TSpecdevDzsb entity = new TSpecdevDzsb();
- for (int j = 0; j <= cellNum; j++) {
- Cell cell = row.getCell(j);
- if (cell == null) {
- continue;
- }
- String cellValue = ExcelUtils.getCellValue(cell);
- logger.info("cellValue:" + cellValue);
- if (j == 0) {
- //序号
- } else if (j == 1) {
- entity.setPlantCode(cellValue);//装置
- } else if (j == 2) {
- entity.setUnit(cellValue);//装置维修组
- } else if (j == 3) {
- entity.setPlantMaint(cellValue);//装置维修组
- } else if (j == 4) {
- entity.setEngineer(cellValue);//装置维修工程师
- } else if (j == 5) {
- entity.setDevname(cellValue);//设备名称
- } else if (j == 6) {
- entity.setDevno(cellValue);//设备位号
- } else if (j == 7) {
- entity.setDocno(cellValue);//档案号
- } else if (j == 8) {
- entity.setFactoryNo(cellValue);//出厂编号
- } else if (j == 9) {
- entity.setModel(cellValue);//设备型号
- } else if (j == 10) {
- entity.setCapacity(cellValue);//起吊重量
- } else if (j == 11) {
- entity.setLocation(cellValue);//设备使用地点
- } else if (j == 12) {
- entity.setRegno(cellValue);//设备注册编号
- } else if (j == 13) {
- entity.setDevCode(cellValue);//设备代码
- } else if (j == 14) {
- if (cellValue.length() > 3) {//投用日期
- entity.setSubmitdate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
- }
- } else if (j == 15) {
- entity.setCreateUnit(cellValue);//制造单位
- } else if (j == 16) {
- entity.setIsEx(cellValue);//是否防爆
- } else if (j == 17) {
- entity.setCheckStrategy(cellValue);//检验策略
- } else if (j == 18) {
- entity.setCheckUnit(cellValue);//检验单位
- } else if (j == 19) {
- if (cellValue.length() > 3) {//检验日期
- entity.setWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
- }
- } else if (j == 20) {
- entity.setReportNo(cellValue);//报告编号
- } else if (j == 21) {
- if (cellValue.length() > 3) {//下次到期日期
- entity.setNextWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
- }
- } else if (j == 22) { //检验结论
- entity.setPerTestConclusion(cellValue);
- } else if (j == 23) {
- entity.setRemarks(cellValue);//备注
- }/*else if (j == 20) {
- for (SysDept d : dept) {
- if (d.getDeptName().equals(cellValue)) {
- entity.setDeptId(d.getDeptId());//部门编号
- }
- }
- }*/
- }
- entity.setCreaterCode(userId);
- logger.info("entity:" + JSON.toJSONString(entity));
- list.add(entity);
- } catch (Exception e) {
- failNumber++;
- logger.error("e:" + JSON.toJSONString(e));
- failRow.add(i + 1);
- }
- }
- int successNumber = 0;
- int failNum = 0;
- CopyOnWriteArrayList<String> ids = new CopyOnWriteArrayList();
- for (TSpecdevDzsb t : list
- ) {
- failNum++;
- try {
- t.setApproveStatus(22l);
- tSpecdevDzsbService.insertTSpecdevDzsb(t);
- ids.add(t.getId().toString());
- successNumber++;
- } catch (Exception e) {
- failNumber++;
- logger.error("e:" + e);
- failRow.add(failNum + 1);
- }
- }
- //申请流程
- String devIds = StringUtils.join(ids.toArray(),",");
- TApproveSpecModify tApproveSpecModify = new TApproveSpecModify();
- Long userid = getUserId();
- tApproveSpecModify.setUserId(userid);
- tApproveSpecModify.setApproveType(3l);
- tApproveSpecModify.setDevType(3l);
- tApproveSpecModify.setDevId(devIds);
- //审批编号
- Date dt = new Date();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
- String data = sdf.format(dt) + userid;
- tApproveSpecModify.setApNo(data);
- //
- Authentication.setAuthenticatedUserId(userid.toString());
- tApproveSpecModifyService.insertTApproveSpecModify(tApproveSpecModify);
- long bussniseeKey = tApproveSpecModify.getId();
- //开始工作流、监听
- Map<String, Object> variables = new HashMap<>();
- variables.put("applyUser", userid.toString());
- variables.put("wxjlusers", wxjl);
- //采用key来启动流程定义并设置流程变量,返回流程实例
- ProcessInstance pi = runtimeService.startProcessInstanceByKey("semsAddDelProcess", String.valueOf(bussniseeKey), variables);
- logger.info("流程部署id:" + pi.getDeploymentId());
- logger.info("流程定义id:" + pi.getProcessDefinitionId());
- logger.info("流程实例id:" + pi.getProcessInstanceId());
- tApproveSpecModify.setProcessId(pi.getProcessInstanceId());
- new Thread(() -> {
- approveSpecModifyController.sendMail(tApproveSpecModify , wxjl);
- },"发送邮件").start();
- LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
- String userName =loginUser != null? loginUser.getUsername(): "";
- new Thread(() -> {
- tSpechiDzsbController.addOperLog(ids.toArray(),userName,new Date() , "新增申请" );
- },"特种设备操作日志").start();
- logger.info("list:" + JSON.toJSONString(list));
- logger.info("successNumber:" + String.valueOf(successNumber));
- logger.info("failNumber:" + String.valueOf(failNumber));
- logger.info("failRow:" + String.valueOf(failRow));
- return AjaxResult.success(String.valueOf(successNumber), failRow);
- }
- /**
- * 批量导入
- * 检验更新中的批量导入
- */
- @PreAuthorize("@ss.hasPermi('sems:specDzsb:add')")
- @Log(title = "特种设备批量导入", businessType = BusinessType.INSERT)
- @PostMapping("/updateData")
- public AjaxResult updateData(@RequestParam("file") MultipartFile file) throws IOException, ParseException {
- //获取操作人员ID
- Long userId = getUserId();
- //报错行数统计
- List<Integer> failRow = new ArrayList<Integer>();
- Workbook workbook = ExcelUtils.getWorkBook(file);
- Sheet sheet = workbook.getSheetAt(0);
- List<TSpecdevDzsb> list = new ArrayList<TSpecdevDzsb>();
- List<TSpecdevDzsb> oldList = new ArrayList<TSpecdevDzsb>();
- TSpecdevDzsb oldEntity = new TSpecdevDzsb();
- //字典查询
- List<SysDictData> plant = iSysDictTypeService.selectDictDataByType("PLANT_DIVIDE");
- //部门查询
- List<SysDept> dept = iSysDeptService.selectDeptList(new SysDept());
- int rowNum = sheet.getPhysicalNumberOfRows();
- int failNumber = 0;
- for (int i = 1; i < rowNum; i++) {
- // try {
- logger.info("读取行数:" + i);
- Row row = sheet.getRow(i);
- int cellNum = row.getLastCellNum();
- TSpecdevDzsb entity = new TSpecdevDzsb();
- for (int j = 0; j < cellNum; j++) {
- Cell cell = row.getCell(j);
- if (cell == null) {
- continue;
- }
- String cellValue = ExcelUtils.getCellValue(cell);
- logger.info("cellValue:" + cellValue);
- if (j == 0) {
- //序号
- Double d = Double.parseDouble(cellValue);
- long s = new Double(d).longValue();
- entity.setId(s);
- } else if (j == 1) { //装置
- entity.setPlantCode(cellValue);
- } else if (j == 3) { //设备位号
- entity.setDevno(cellValue);
- } else if (j == 4) { //档案号
- entity.setDocno(cellValue);
- } else if (j == 2) { //设备名称
- entity.setDevname(cellValue);
- } else if (j == 5) { //检验单位
- entity.setCheckUnit(cellValue);
- } else if (j == 6) { //检验日期
- logger.info("日期格式:" + cellValue);
- if (cellValue.length() > 3) {
- entity.setWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
- }
- } else if (j == 7) { //报告编号
- entity.setReportNo(cellValue);
- } else if (j == 8) { //下次检验日期
- logger.info("日期格式:" + cellValue);
- if (cellValue.length() > 3) {
- entity.setNextWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
- }
- } else if (j == 9) { //
- entity.setPerTestConclusion(cellValue);
- }
- }
- logger.info("entity:" + JSON.toJSONString(entity));
- list.add(entity);
- oldEntity = entity;
- oldList.add(oldEntity);
- // }catch (Exception e){
- // failNumber++;
- // logger.info("e:" + JSON.toJSONString(e));
- // failRow.add(i + 1);
- // }
- }
- int successNumber = 0;
- int failNum = 0;
- for (TSpecdevDzsb t : list) {
- failNum++;
- try {
- tSpecdevDzsbService
- .update(t,
- new QueryWrapper<TSpecdevDzsb>()
- .eq("DOCNO", t.getDocno())
- .eq("PLANT_CODE", t.getPlantCode())
- );
- successNumber++;
- } catch (Exception e) {
- failNumber++;
- logger.error("e:" + e);
- failRow.add(failNum + 1);
- e.printStackTrace();
- }
- }
- for (TSpecdevDzsb t : oldList) {
- TSpecCheck tc = new TSpecCheck();
- tc.setDevType(3l);
- tc.setCheckUnit(t.getCheckUnit());
- tc.setDevId(t.getId());
- tc.setNextWarnDate(t.getNextWarnDate());
- tc.setReportNo(t.getReportNo());
- tc.setWarnDate(t.getWarnDate());
- tc.setCheckConclusion(t.getPerTestConclusion());
- tSpecCheckService.insertTSpecCheck(tc);
- }
- logger.info("list:" + JSON.toJSONString(list));
- logger.info("successNumber:" + String.valueOf(successNumber));
- logger.info("failNumber:" + String.valueOf(failNumber));
- logger.info("failRow:" + String.valueOf(failRow));
- return AjaxResult.success(String.valueOf(successNumber), failRow);
- }
- @GetMapping("/exportDevList")
- public AjaxResult exportbmy(ParamData params) throws IOException {
- logger.info(JSON.toJSONString(params));
- String id = params.getIds();
- String[] ids = id.split(",");
- List<TSpecdevDzsb> list = new ArrayList<>();
- for (String i : ids
- ) {
- TSpecdevDzsb t = tSpecdevDzsbService.getById(i);
- list.add(t);
- }
- SXSSFWorkbook wb = new SXSSFWorkbook(1000);
- CellStyle wrapStyle = wb.createCellStyle();
- wrapStyle.setWrapText(true); //设置自动换行
- //创建sheet页
- Sheet sheet = wb.createSheet("sheet1");
- //设置列的宽度,第一个参数为列的序号,从0开始,第二参数为列宽,单位1/256个字节
- sheet.setColumnWidth(0, 12 * 256);
- sheet.setColumnWidth(1, 26 * 256);
- sheet.setColumnWidth(2, 26 * 256);
- sheet.setColumnWidth(3, 26 * 256);
- sheet.setColumnWidth(4, 26 * 256);
- sheet.setColumnWidth(5, 26 * 256);
- sheet.setColumnWidth(6, 26 * 256);
- sheet.setColumnWidth(7, 26 * 256);
- sheet.setColumnWidth(8, 40 * 256);
- sheet.setColumnWidth(9, 40 * 256);
- //设置开始行和开始列
- Row row0 = sheet.createRow(0);
- CellStyle style = wb.createCellStyle();
- style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
- style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- // Font headerFont = wb.createFont();
- // headerFont.setFontName("Arial");
- // headerFont.setFontHeightInPoints((short) 12);
- // headerFont.setBold(false);
- // headerFont.setColor(IndexedColors.BLACK.getIndex());
- // style.setFont(headerFont);
- Cell cell0 = row0.createCell(0);
- row0.createCell(0).setCellValue("序号");
- row0.createCell(1).setCellValue("装置");
- row0.createCell(2).setCellValue("设备位号");
- row0.createCell(3).setCellValue("档案号");
- row0.createCell(4).setCellValue("设备名称");
- row0.createCell(5).setCellValue("检验单位");
- row0.getCell(5).setCellStyle(style);
- row0.createCell(6).setCellValue("检验日期");
- row0.getCell(6).setCellStyle(style);
- row0.createCell(7).setCellValue("报告编号");
- row0.getCell(7).setCellStyle(style);
- row0.createCell(8).setCellValue("下次检验日期");
- row0.getCell(8).setCellStyle(style);
- row0.createCell(9).setCellValue("定期检验结论");
- row0.getCell(9).setCellStyle(style);
- //填充数据
- int rowIndex = 1;
- int columnIndex = 1;
- for (TSpecdevDzsb t : list
- ) {
- Row row = sheet.createRow(rowIndex);
- row.createCell(0).setCellValue(t.getId());
- row.createCell(1).setCellValue(t.getPlantCode());
- row.createCell(2).setCellValue(t.getDevno());
- row.createCell(3).setCellValue(t.getDocno());
- row.createCell(4).setCellValue(t.getDevname());
- row.createCell(5).setCellValue(t.getCheckUnit());
- if (t.getWarnDate() != null) {
- row.createCell(6).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getWarnDate()));
- }
- row.createCell(7).setCellValue(t.getReportNo());
- if (t.getNextWarnDate() != null) {
- row.createCell(8).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getNextWarnDate()));
- }
- row.createCell(9).setCellValue(t.getPerTestConclusion());
- rowIndex++;
- }
- OutputStream out = null;
- String filename = ExcelUtil.encodingFilename("起重机械批量更新");
- out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
- wb.write(out);
- wb.close();
- out.close();
- return AjaxResult.success(filename);
- }
- }
|