|
|
@@ -3,7 +3,9 @@ package com.ygtx.gxt.controller;
|
|
|
import java.util.List;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import com.github.pagehelper.util.StringUtil;
|
|
|
import com.ygtx.common.annotation.Excel;
|
|
|
+import com.ygtx.common.core.domain.entity.SysDictData;
|
|
|
import com.ygtx.gxt.service.IGxtEquipmentService;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -27,7 +29,11 @@ import com.ygtx.common.core.page.TableDataInfo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import com.ygtx.gxt.domain.vo.GxtFanInspectionScoreVo;
|
|
|
+import com.ygtx.system.service.ISysDictDataService;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
|
/**
|
|
|
* 风机类型检查分值Controller
|
|
|
@@ -46,6 +52,9 @@ public class GxtFanInspectionScoreController extends BaseController
|
|
|
@Autowired
|
|
|
private IGxtEquipmentService gxtEquipmentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDictDataService sysDictDataService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询风机类型检查分值列表
|
|
|
*/
|
|
|
@@ -70,13 +79,17 @@ public class GxtFanInspectionScoreController extends BaseController
|
|
|
@RequestParam(value = "exportFields", required = false) String exportFieldsStr)
|
|
|
{
|
|
|
List<GxtFanInspectionScore> list = gxtFanInspectionScoreService.selectGxtFanInspectionScoreList(gxtFanInspectionScore);
|
|
|
- ExcelUtil<GxtFanInspectionScore> util = new ExcelUtil<GxtFanInspectionScore>(GxtFanInspectionScore.class);
|
|
|
+
|
|
|
+ // 转换为VO类并填充维保类型名称
|
|
|
+ List<GxtFanInspectionScoreVo> voList = convertToVoList(list);
|
|
|
+
|
|
|
+ ExcelUtil<GxtFanInspectionScoreVo> util = new ExcelUtil<GxtFanInspectionScoreVo>(GxtFanInspectionScoreVo.class);
|
|
|
if (exportFieldsStr != null && !exportFieldsStr.isEmpty()) {
|
|
|
// 将字符串分割成数组
|
|
|
String[] exportFields = exportFieldsStr.split(",");
|
|
|
util.showColumn(exportFields);
|
|
|
}
|
|
|
- util.exportExcel(response, list, "风机类型检查分值数据");
|
|
|
+ util.exportExcel(response, voList, "风机类型检查分值数据");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -85,7 +98,7 @@ public class GxtFanInspectionScoreController extends BaseController
|
|
|
@GetMapping("/exportFields")
|
|
|
@ApiOperation("获取风机类型检查分值导出字段列表")
|
|
|
public AjaxResult getExportFields() {
|
|
|
- ExcelUtil<GxtFanInspectionScore> util = new ExcelUtil<GxtFanInspectionScore>(GxtFanInspectionScore.class);
|
|
|
+ ExcelUtil<GxtFanInspectionScoreVo> util = new ExcelUtil<GxtFanInspectionScoreVo>(GxtFanInspectionScoreVo.class);
|
|
|
util.init(null, "风机类型检查分值", "", Excel.Type.EXPORT);
|
|
|
return success(util.getExportFields());
|
|
|
}
|
|
|
@@ -161,4 +174,82 @@ public class GxtFanInspectionScoreController extends BaseController
|
|
|
List<GxtFanInspectionScore> list = gxtFanInspectionScoreService.selectGxtFanInspectionScoreByFanType(fanType);
|
|
|
return AjaxResult.success(list);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将实体类列表转换为VO类列表,并填充维保类型名称
|
|
|
+ */
|
|
|
+ private List<GxtFanInspectionScoreVo> convertToVoList(List<GxtFanInspectionScore> list) {
|
|
|
+ List<GxtFanInspectionScoreVo> voList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (GxtFanInspectionScore entity : list) {
|
|
|
+ GxtFanInspectionScoreVo vo = new GxtFanInspectionScoreVo();
|
|
|
+
|
|
|
+ // 手动复制属性
|
|
|
+ vo.setId(entity.getId());
|
|
|
+ vo.setFanType(entity.getFanType());
|
|
|
+ vo.setScore(entity.getScore());
|
|
|
+ vo.setRemark(entity.getRemark());
|
|
|
+ vo.setCreateBy(entity.getCreateBy());
|
|
|
+ vo.setCreateTime(entity.getCreateTime());
|
|
|
+ vo.setUpdateBy(entity.getUpdateBy());
|
|
|
+ vo.setUpdateTime(entity.getUpdateTime());
|
|
|
+
|
|
|
+ // 根据inspectionTypeId获取维保类型名称
|
|
|
+ if (entity.getInspectionTypeId() != null) {
|
|
|
+ String inspectionTypeName = sysDictDataService.selectDictLabel("gxt_inspection_type", entity.getInspectionTypeId().toString());
|
|
|
+ vo.setInspectionTypeName(inspectionTypeName != null ? inspectionTypeName : "");
|
|
|
+ }
|
|
|
+
|
|
|
+ voList.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入风机类型检查分值数据
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('gxt:scorefaninspection:import')")
|
|
|
+ @Log(title = "风机类型检查分值", businessType = BusinessType.IMPORT)
|
|
|
+ @PostMapping("/importData")
|
|
|
+ public AjaxResult importData(MultipartFile file, @RequestParam(defaultValue = "false") boolean updateSupport) throws Exception
|
|
|
+ {
|
|
|
+ ExcelUtil<GxtFanInspectionScore> util = new ExcelUtil<GxtFanInspectionScore>(GxtFanInspectionScore.class);
|
|
|
+ List<GxtFanInspectionScore> fanInspectionScoreList = util.importExcel(file.getInputStream());
|
|
|
+ if (!fanInspectionScoreList.isEmpty()) {
|
|
|
+ SysDictData dictData = new SysDictData();
|
|
|
+ dictData.setDictType("gxt_inspection_type");
|
|
|
+ dictData.setStatus("0");
|
|
|
+ List<SysDictData> dataList = sysDictDataService.selectDictDataList(dictData);
|
|
|
+ if (dataList.isEmpty()) {
|
|
|
+ return error("数据库风机类型为空");
|
|
|
+ }
|
|
|
+ for (GxtFanInspectionScore score:fanInspectionScoreList) {
|
|
|
+ score.setStatus(0);
|
|
|
+ String fanName = score.getInspectionTypeName();
|
|
|
+ if (StringUtil.isNotEmpty(fanName)) {
|
|
|
+ for (SysDictData data:dataList) {
|
|
|
+ if (data.getDictLabel().equals(fanName)) {
|
|
|
+ score.setInspectionTypeId(Integer.valueOf(data.getDictValue()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String operName = getUsername();
|
|
|
+ String message = gxtFanInspectionScoreService.importFanInspectionScoreList(fanInspectionScoreList, updateSupport, operName);
|
|
|
+ return success(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载风机类型检查分值导入模板
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('gxt:scorefaninspection:import')")
|
|
|
+ @PostMapping("/importTemplate")
|
|
|
+ public void importTemplate(HttpServletResponse response)
|
|
|
+ {
|
|
|
+ ExcelUtil<GxtFanInspectionScoreVo> util = new ExcelUtil<GxtFanInspectionScoreVo>(GxtFanInspectionScoreVo.class);
|
|
|
+ util.importTemplateExcel(response, "风机类型检查分值数据");
|
|
|
+ }
|
|
|
}
|