BusJcbJcxcController.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. package com.railway.business.catenary.controller;
  2. import com.railway.business.catenary.domain.BusJcbJcxc;
  3. import com.railway.business.catenary.domain.vo.JcebQueryVo;
  4. import com.railway.business.catenary.service.IBusJcbJcxcService;
  5. import com.railway.common.core.controller.BaseController;
  6. import com.railway.common.core.domain.AjaxResult;
  7. import com.railway.common.core.page.TableDataInfo;
  8. import com.railway.common.utils.LocalDateUtil;
  9. import com.railway.common.utils.StringUtils;
  10. import com.railway.common.utils.poi.WordUtils;
  11. import com.railway.system.service.ISysFileService;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.Map;
  17. import javax.validation.Valid;
  18. import lombok.extern.slf4j.Slf4j;
  19. import org.springframework.beans.factory.annotation.Value;
  20. import org.springframework.validation.annotation.Validated;
  21. import org.springframework.web.bind.annotation.DeleteMapping;
  22. import org.springframework.web.bind.annotation.GetMapping;
  23. import org.springframework.web.bind.annotation.PathVariable;
  24. import org.springframework.web.bind.annotation.PostMapping;
  25. import org.springframework.web.bind.annotation.PutMapping;
  26. import org.springframework.web.bind.annotation.RequestBody;
  27. import org.springframework.web.bind.annotation.RequestMapping;
  28. import org.springframework.web.bind.annotation.RestController;
  29. /**
  30. * @author zhangcaifeng
  31. */
  32. @Slf4j
  33. @Api(value = "rest/catenary/bus/jcb/jcxc", tags = "检查表 - 交叉线岔")
  34. @RestController
  35. @Validated
  36. @RequestMapping(value = "business/catenary/bus/jcb/jcxc")
  37. public class BusJcbJcxcController extends BaseController {
  38. @Value("${railway.template}")
  39. public String templatePath;
  40. private final IBusJcbJcxcService busJcbJcxcService;
  41. private final ISysFileService sysFileService;
  42. public BusJcbJcxcController(IBusJcbJcxcService busJcbJcxcService,
  43. ISysFileService sysFileService) {
  44. this.busJcbJcxcService = busJcbJcxcService;
  45. this.sysFileService = sysFileService;
  46. }
  47. @ApiOperation(value = "新增")
  48. @PostMapping("/add")
  49. public AjaxResult add(@Validated @RequestBody BusJcbJcxc busJcbJcxc) {
  50. return toAjax(busJcbJcxcService.create(busJcbJcxc));
  51. }
  52. @ApiOperation(value = "删除")
  53. @DeleteMapping("/{ids}")
  54. public AjaxResult delete(@PathVariable(value = "ids") String[] ids) {
  55. return toAjax(busJcbJcxcService.delete(ids));
  56. }
  57. @ApiOperation(value = "更新")
  58. @PutMapping("/update")
  59. public AjaxResult update(@RequestBody @Valid BusJcbJcxc busJcbJcxc) {
  60. log.info("交叉线岔检查表更新参数 - {}", busJcbJcxc.toString());
  61. busJcbJcxcService.update(busJcbJcxc);
  62. return AjaxResult.success();
  63. }
  64. @ApiOperation(value = "单个")
  65. @GetMapping(value = {"/", "/{id}"})
  66. public AjaxResult getInfo(String id) {
  67. BusJcbJcxc info = busJcbJcxcService.getInfo(id);
  68. AjaxResult ajax = AjaxResult.success();
  69. ajax.put("info", info);
  70. return ajax;
  71. }
  72. @ApiOperation(value = "列表")
  73. @GetMapping(value = "list")
  74. public TableDataInfo getList(BusJcbJcxc busJcbJcxc) {
  75. startPage();
  76. List<BusJcbJcxc> list = busJcbJcxcService.getList(busJcbJcxc);
  77. return getDataTable(list);
  78. }
  79. @ApiOperation(value = "获取上次检测值")
  80. @GetMapping(value = "/getLastOne")
  81. public AjaxResult getLastOne(BusJcbJcxc busJcbJcxc) {
  82. BusJcbJcxc info = busJcbJcxcService.getLastRecord(busJcbJcxc);
  83. AjaxResult ajax = AjaxResult.success();
  84. ajax.put("info", info);
  85. return ajax;
  86. }
  87. @ApiOperation(value = "提交")
  88. @PutMapping("/submit")
  89. public AjaxResult submit(@RequestBody BusJcbJcxc busJcbJcxc) {
  90. return toAjax(busJcbJcxcService.submit(busJcbJcxc));
  91. }
  92. @ApiOperation(value = "退回")
  93. @PutMapping("/reject")
  94. public AjaxResult reject(@RequestBody BusJcbJcxc busJcbJcxc) {
  95. return toAjax(busJcbJcxcService.reject(busJcbJcxc));
  96. }
  97. @ApiOperation(value = "确认")
  98. @PutMapping("/confirm")
  99. public AjaxResult confirm(@RequestBody BusJcbJcxc busJcbJcxc) {
  100. return toAjax(busJcbJcxcService.confirm(busJcbJcxc));
  101. }
  102. @ApiOperation(value = "中心领导确认")
  103. @PutMapping("/centerLeaderConfirm")
  104. public AjaxResult centerLeaderConfirm(@RequestBody BusJcbJcxc busJcbJcxc) {
  105. return toAjax(busJcbJcxcService.centerLeaderConfirm(busJcbJcxc));
  106. }
  107. @ApiOperation(value = "导出")
  108. @GetMapping("/export/{id}")
  109. public AjaxResult export(@PathVariable(value = "id") String id) {
  110. BusJcbJcxc info = busJcbJcxcService.getInfo(id);
  111. WordUtils wordUtil = new WordUtils();
  112. //填充变量
  113. Map<String, Object> params = new HashMap<>(32);
  114. params.put("${xch}", info.getXch());
  115. params.put("${qj}", info.getStationName());
  116. params.put("${wendu}", info.getTemperature() == null ? "" : info.getTemperature());
  117. params.put("${jcrq}", LocalDateUtil.convertLocalDateToShow(info.getCheckDate()));
  118. params.put("${gz1lcz}", StringUtils.bigDecimalToString(info.getGz1lcz()));
  119. params.put("${gz2lcz}", StringUtils.bigDecimalToString(info.getGz2lcz()));
  120. params.put("${zglcz}", StringUtils.bigDecimalToString(info.getZglcz()));
  121. params.put("${qglcz}", StringUtils.bigDecimalToString(info.getQglcz()));
  122. params.put("${ngj}", StringUtils.bigDecimalToString(info.getNgj()));
  123. params.put("${plz}", StringUtils.bigDecimalToString(info.getPlz()));
  124. params.put("${xcxzgazlg}", StringUtils.yesOrNo(info.getXcxzgazlg()));
  125. params.put("${hdjx}", StringUtils.yesOrNo(info.getHdjx()));
  126. params.put("${fhzzsq}", StringUtils.yesOrNo(info.getFhzzsq()));
  127. params.put("${dqssxx}", StringUtils.yesOrNo(info.getDqssxx()));
  128. params.put("${lswst}", StringUtils.yesOrNo(info.getLswst()));
  129. params.put("${xzgldydx}", StringUtils.yesOrNo(info.getXzgldydx()));
  130. params.put("${dxztlh}", StringUtils.yesOrNo(info.getDxztlh()));
  131. params.put("${czjj}", StringUtils.bigDecimalToString(info.getCzjj()));
  132. params.put("${lgzzgc}", StringUtils.bigDecimalToString(info.getLgzzgc()));
  133. params.put("${gzyfzgc}", StringUtils.bigDecimalToString(info.getGzyfzgc()));
  134. params.put("${wxj}", StringUtils.yesOrNo(info.getWxj()));
  135. params.put("${hddxxjzt}", StringUtils.yesOrNo(info.getHddxxjzt()));
  136. params.put("${jcdxzt}", StringUtils.yesOrNo(info.getJcdxzt()));
  137. params.put("${dljxzt}", StringUtils.yesOrNo(info.getDljxzt()));
  138. params.put("${jcr}", info.getCheckUser());
  139. params.put("${sbzt}", StringUtils.YES_VALUE.equals(info.getSbzt()) ? "合格" : "不合格");
  140. params.put("${qrr}", info.getConfirmUser() == null ? "" : info.getConfirmUser());
  141. params.put("${czwt}", info.getCzwt() == null ? "" : info.getCzwt());
  142. //生成word文件的文件名
  143. String fileName = "交叉线岔高速手册.docx";
  144. String template = templatePath + "/word/交叉线岔高速手册.docx";
  145. String localFilePath = wordUtil.getWord(params, template, fileName);
  146. return sysFileService.uploadFile(localFilePath);
  147. }
  148. @ApiOperation(value = "导出excel")
  149. @GetMapping(value = "exportExcel")
  150. public AjaxResult exportExcel(JcebQueryVo query) {
  151. String localFilePath = busJcbJcxcService.exportExcel(query);
  152. return sysFileService.uploadFile(localFilePath);
  153. }
  154. }