f129e654f2f66c962438bdb5de7d8eee5627add1.svn-base 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. package cn.com.goldenwater.dcproj.controller.other;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.dto.BisInspOtherPblmDto;
  5. import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers;
  6. import cn.com.goldenwater.dcproj.model.BisInspOtherPblm;
  7. import cn.com.goldenwater.dcproj.model.GwComFile;
  8. import cn.com.goldenwater.dcproj.param.BisInspOtherPblmParam;
  9. import cn.com.goldenwater.dcproj.param.FileParam;
  10. import cn.com.goldenwater.dcproj.service.BisInspAllRlationPersService;
  11. import cn.com.goldenwater.dcproj.service.BisInspOtherPblmService;
  12. import cn.com.goldenwater.dcproj.service.GwComFileService;
  13. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  14. import cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil;
  15. import cn.com.goldenwater.id.util.UuidUtil;
  16. import com.github.pagehelper.PageInfo;
  17. import io.swagger.annotations.Api;
  18. import io.swagger.annotations.ApiOperation;
  19. import io.swagger.annotations.ApiParam;
  20. import org.apache.commons.lang3.StringUtils;
  21. import org.slf4j.Logger;
  22. import org.slf4j.LoggerFactory;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.beans.factory.annotation.Value;
  25. import org.springframework.data.redis.core.RedisTemplate;
  26. import org.springframework.web.bind.annotation.*;
  27. import org.springframework.web.multipart.MultipartFile;
  28. import javax.servlet.http.HttpServletResponse;
  29. import java.io.File;
  30. import java.io.IOException;
  31. import java.util.LinkedHashMap;
  32. import java.util.List;
  33. import java.util.Map;
  34. import static cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil.getDateFormatPath;
  35. /**
  36. * @author lune
  37. * @date 2019-7-19
  38. */
  39. @Api(value = "BIS 其他检查问题信息表管理", tags = "BIS 其他检查问题信息表管理")
  40. @RestController
  41. @RequestMapping("/bis/insp/other/pblm")
  42. public class BisInspOtherPblmController extends BaseController {
  43. private Logger logger = LoggerFactory.getLogger(getClass());
  44. @Value("${export.templatePath}")
  45. private String templatePath;
  46. @Value("${impExcel.basePath}")
  47. private String impExcelPath;
  48. @Autowired
  49. private OlBisInspOrgService olBisInspOrgService;
  50. @Autowired
  51. private BisInspOtherPblmService bisInspOtherPblmService;
  52. @Autowired
  53. private RedisTemplate redisTemplate;
  54. @Autowired
  55. private GwComFileService gwComFileService;
  56. @Autowired
  57. private BisInspAllRlationPersService persService;
  58. @ApiOperation(value = "添加/修改其他检查问题信息表")
  59. @RequestMapping(value = "", method = RequestMethod.POST)
  60. public BaseResponse<BisInspOtherPblm> insert(@ApiParam(name = "bisInspOtherPblm", value = "BisInspOtherPblm", required = true) @RequestBody BisInspOtherPblm bisInspOtherPblm) {
  61. if (StringUtils.isBlank(bisInspOtherPblm.getId())) {
  62. String uuid = UuidUtil.uuid(); // 生成uuid
  63. bisInspOtherPblm.setId(uuid);
  64. bisInspOtherPblmService.insert(bisInspOtherPblm);
  65. } else {
  66. bisInspOtherPblmService.updatePblm(bisInspOtherPblm);
  67. }
  68. return buildSuccessResponse(bisInspOtherPblm);
  69. }
  70. @ApiOperation(value = "根据ID删除其他检查问题信息表")
  71. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  72. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  73. int ret = bisInspOtherPblmService.delete(id);
  74. return buildSuccessResponse();
  75. }
  76. @ApiOperation(value = "根据ID获取其他检查问题信息表(单表)")
  77. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  78. public BaseResponse<BisInspOtherPblm> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  79. BisInspOtherPblm bisInspOtherPblm = bisInspOtherPblmService.get(id);
  80. if (StringUtils.isNotBlank(bisInspOtherPblm.getPersId())) {
  81. BisInspAllRlationPers pers = persService.get(bisInspOtherPblm.getPersId());
  82. if (pers != null) {
  83. bisInspOtherPblm.setPersName(pers.getPersName());
  84. }
  85. }
  86. List<GwComFile> gwComFiles = gwComFileService.findFileByBiz(bisInspOtherPblm.getId());
  87. bisInspOtherPblm.setGwComFiles(gwComFiles);
  88. return buildSuccessResponse(bisInspOtherPblm);
  89. }
  90. @ApiOperation(value = "获取其他检查问题信息表(列表所有)")
  91. @RequestMapping(value = "/list", method = RequestMethod.POST)
  92. public BaseResponse<List<BisInspOtherPblm>> list(@ApiParam(name = "bisInspOtherPblmParam", value = "bisInspOtherPblmParam", required = true) @RequestBody BisInspOtherPblmParam bisInspOtherPblmParam) {
  93. List<BisInspOtherPblm> bisInspOtherPblmList = bisInspOtherPblmService.findList(bisInspOtherPblmParam);
  94. return buildSuccessResponse(bisInspOtherPblmList);
  95. }
  96. @ApiOperation(value = "获取其他检查问题信息表(列表--分页)")
  97. @RequestMapping(value = "/page", method = RequestMethod.POST)
  98. public BaseResponse<PageInfo<BisInspOtherPblm>> page(@ApiParam(name = "bisInspOtherPblmParam", value = "bisInspOtherPblmParam", required = true) @RequestBody BisInspOtherPblmParam bisInspOtherPblmParam) {
  99. bisInspOtherPblmParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  100. PageInfo<BisInspOtherPblm> bisInspOtherPblmList = bisInspOtherPblmService.findPageInfo(bisInspOtherPblmParam);
  101. return buildSuccessResponse(bisInspOtherPblmList);
  102. }
  103. @ApiOperation(value = "下载飞检模板")
  104. @RequestMapping(value = "/downTemplate", method = {RequestMethod.GET, RequestMethod.POST})
  105. public BaseResponse downTemplate(HttpServletResponse response, FileParam param) {
  106. try {
  107. param.setOrgId(getCurrentOrgId());
  108. param.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  109. List<Map<String, Object>> pblmList = bisInspOtherPblmService.findPblmList(param);
  110. ExpAndImpUtil.download(response, pblmList, templatePath + File.separator + param.getFileName(), param.getStartRow(), param.getSheetName());
  111. } catch (Exception e) {
  112. return buildFailResponse(e);
  113. }
  114. return buildSuccessResponse();
  115. }
  116. @ApiOperation(value = "上传飞检模板")
  117. @RequestMapping(value = "/uploadTemplate", method = RequestMethod.POST)
  118. public BaseResponse uploadTemplate(MultipartFile file, FileParam param) {
  119. String filaPath = "";
  120. try {
  121. filaPath = ExpAndImpUtil.upload(file, getDateFormatPath(impExcelPath));
  122. } catch (Exception e) {
  123. return buildFailResponse(e);
  124. }
  125. return buildSuccessResponse(filaPath);
  126. }
  127. @ApiOperation(value = "解析文件上传数据")
  128. @RequestMapping(value = "/parseUpload", method = RequestMethod.POST)
  129. public BaseResponse<Map<String, Object>> parseUpload(FileParam param) {
  130. Map<String, Object> map = new LinkedHashMap<>();
  131. try {
  132. List<LinkedHashMap<String, Object>> list = ExpAndImpUtil.parseData(param.getPath(), param.getStartRow(), BisInspOtherPblmDto.class);
  133. if (list.size() > 0) {
  134. String uuid = UuidUtil.uuid();
  135. redisTemplate.opsForList().rightPushAll(uuid, list);
  136. map.put("dataId", uuid);
  137. }
  138. map.put("list", list);
  139. } catch (IOException e) {
  140. buildFailResponse(e.getMessage());
  141. }
  142. return buildSuccessResponse(map);
  143. }
  144. @ApiOperation(value = "文件数据入库")
  145. @RequestMapping(value = "/insertIntoData", method = RequestMethod.POST)
  146. public BaseResponse insertIntoData(FileParam param) {
  147. if (StringUtils.isBlank(param.getDataId())) {
  148. return buildFailResponse();
  149. }
  150. List<LinkedHashMap<String, Object>> list = redisTemplate.opsForList().range(param.getDataId(), 0, -1);
  151. redisTemplate.delete(param.getDataId());
  152. if (bisInspOtherPblmService.insertIntoData(list) == 0) {
  153. return buildFailResponse("问题导入失败");
  154. }
  155. return buildSuccessResponse();
  156. }
  157. }