7e9067fc7ec3678070ec751c13928862d207193d.svn-base 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package cn.com.goldenwater.dcproj.controller.accunt;
  2. import cn.com.goldenwater.dcproj.model.BisInspAccunt;
  3. import cn.com.goldenwater.dcproj.model.BisInspMtprggd;
  4. import cn.com.goldenwater.dcproj.param.BisInspAccuntParam;
  5. import cn.com.goldenwater.dcproj.service.BisInspAccuntService;
  6. import cn.com.goldenwater.core.web.BaseController;
  7. import cn.com.goldenwater.core.web.BaseResponse;
  8. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  9. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  10. import cn.com.goldenwater.id.util.UuidUtil;
  11. import com.github.pagehelper.PageInfo;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import io.swagger.annotations.ApiParam;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.beans.factory.annotation.Value;
  20. import org.springframework.util.Assert;
  21. import org.springframework.web.bind.annotation.*;
  22. import org.springframework.web.multipart.MultipartFile;
  23. import javax.servlet.http.HttpServletResponse;
  24. import java.io.FileInputStream;
  25. import java.io.IOException;
  26. import java.io.InputStream;
  27. import java.net.URLEncoder;
  28. import java.util.List;
  29. /**
  30. * @author lhc
  31. * @date 2022-3-17
  32. */
  33. @Api(value = "整改追责管理", tags = "整改追责管理")
  34. @RestController
  35. @RequestMapping("/bis/insp/accunt")
  36. public class BisInspAccuntController extends BaseController {
  37. private Logger logger = LoggerFactory.getLogger(getClass());
  38. @Autowired
  39. private BisInspAccuntService bisInspAccuntService;
  40. @Autowired
  41. private OlBisInspOrgService olBisInspOrgService;
  42. @Value("${export.templatePath}")
  43. String excelFilePath;
  44. @ApiOperation(value = "添加整改追责")
  45. @RequestMapping(value = "/", method = RequestMethod.POST)
  46. public BaseResponse<BisInspAccunt> insert(@ApiParam(name = "bisInspAccunt", value = "BisInspAccunt", required = true) @RequestBody BisInspAccunt bisInspAccunt) {
  47. if (StringUtils.isBlank(bisInspAccunt.getId())) {
  48. bisInspAccunt.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  49. bisInspAccunt.setOrgId(getCurrentOrgId());
  50. bisInspAccunt.setPersId(getCurrentPersId());
  51. bisInspAccuntService.insert(bisInspAccunt);
  52. } else {
  53. bisInspAccuntService.update(bisInspAccunt);
  54. }
  55. return buildSuccessResponse(bisInspAccunt);
  56. }
  57. @ApiOperation(value = "批量更新")
  58. @RequestMapping(value = "/batch", method = RequestMethod.POST)
  59. public BaseResponse batch(@ApiParam(name = "bisInspAccunt", value = "BisInspAccunt", required = true) @RequestBody List<BisInspAccunt> bisInspAccunt) {
  60. bisInspAccuntService.batch(bisInspAccunt);
  61. return buildSuccessResponse();
  62. }
  63. @ApiOperation(value = "根据ID删除整改追责")
  64. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  65. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  66. int ret = bisInspAccuntService.delete(id);
  67. return buildSuccessResponse();
  68. }
  69. @ApiOperation(value = "更新整改追责信息")
  70. @RequestMapping(value = "/update", method = RequestMethod.POST)
  71. public BaseResponse<BisInspAccunt> update(@ApiParam(name = "bisInspAccunt", value = "BisInspAccunt", required = true) @RequestBody BisInspAccunt bisInspAccunt) {
  72. Assert.notNull(bisInspAccunt.getId(), "主键id为必填参数");
  73. int ret = bisInspAccuntService.update(bisInspAccunt);
  74. return buildSuccessResponse(bisInspAccunt);
  75. }
  76. @ApiOperation(value = "根据ID获取整改追责(单表)")
  77. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  78. public BaseResponse<BisInspAccunt> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  79. BisInspAccunt bisInspAccunt = bisInspAccuntService.get(id);
  80. return buildSuccessResponse(bisInspAccunt);
  81. }
  82. @ApiOperation(value = "获取列表数据")
  83. @RequestMapping(value = "/page", method = RequestMethod.POST)
  84. public BaseResponse<PageInfo> findPcPage(@RequestBody BisInspAccuntParam bisInspAccuntParam) {
  85. bisInspAccuntParam.setProvince(AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId())));
  86. bisInspAccuntParam.setOrgId(getCurrentOrgId());
  87. PageInfo<BisInspAccunt> pageInfo = bisInspAccuntService.findPageInfo(bisInspAccuntParam);
  88. return buildSuccessResponse(pageInfo);
  89. }
  90. @ApiOperation(value = "导出追责表")
  91. @RequestMapping(value = "/export", method = RequestMethod.POST)
  92. public void export(HttpServletResponse response, @RequestBody BisInspAccuntParam bisInspAccuntParam) {
  93. bisInspAccuntService.export(response, bisInspAccuntParam);
  94. }
  95. @ApiOperation(value = "导入追责表")
  96. @RequestMapping(value = "/import", method = RequestMethod.POST)
  97. public BaseResponse<List<String>> importFile(@RequestParam(value = "file") MultipartFile file) throws Exception {
  98. BisInspAccunt accunt = new BisInspAccunt();
  99. accunt.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  100. accunt.setOrgId(getCurrentOrgId());
  101. accunt.setPersId(getCurrentPersId());
  102. List<String> result = bisInspAccuntService.importFile(file, accunt);
  103. return buildSuccessResponse(result);
  104. }
  105. @ApiOperation(value = "下载Excel导入模板")
  106. @GetMapping("/downloadExcel")
  107. public void downExcelModel(HttpServletResponse response) throws Exception {
  108. InputStream inStream = new FileInputStream(excelFilePath + "/importBisInspAccunt.xls");
  109. response.reset();
  110. response.setContentType("application/octet-stream; charset=UTF-8");
  111. response.setCharacterEncoding("utf-8");
  112. response.addHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("追责导入模板.xls", "UTF-8"));
  113. byte[] b = new byte[4096];
  114. int len;
  115. try {
  116. while ((len = inStream.read(b)) > 0)
  117. response.getOutputStream().write(b, 0, len);
  118. inStream.close();
  119. } catch (IOException e) {
  120. e.printStackTrace();
  121. }
  122. }
  123. }