aefb62746d5d697f59ab7b9efb598153bdb1261e.svn-base 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package cn.com.goldenwater.dcproj.controller.ducha;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.dto.AllNodeDto;
  5. import cn.com.goldenwater.dcproj.model.*;
  6. import cn.com.goldenwater.dcproj.service.BisInspAllService;
  7. import cn.com.goldenwater.dcproj.service.BisInspPlanService;
  8. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  9. import cn.com.goldenwater.dcproj.util.ReadExcelUtil;
  10. import cn.com.goldenwater.id.util.UuidUtil;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import io.swagger.annotations.ApiParam;
  14. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  15. import org.slf4j.Logger;
  16. import org.slf4j.LoggerFactory;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.web.bind.annotation.*;
  19. import org.springframework.web.multipart.MultipartFile;
  20. import java.io.File;
  21. import java.io.IOException;
  22. import java.nio.file.Paths;
  23. import java.util.HashMap;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.Optional;
  27. /**
  28. * @author lune
  29. * @date 2019-2-18
  30. */
  31. @Api(value = "督查批次管理", tags = "督查批次管理")
  32. @RestController
  33. @RequestMapping("/dc/insp/plan")
  34. public class BisInspPlanController extends BaseController {
  35. private Logger logger = LoggerFactory.getLogger(getClass());
  36. @Autowired
  37. private BisInspPlanService bisInspPlanService;
  38. @Autowired
  39. private BisInspAllService bisInspAllService;
  40. @Autowired
  41. private OlBisInspOrgService olBisInspOrgService;
  42. @ApiOperation(value = "新增督查批次", notes = "参数字段说明:{\n\r" +
  43. " \"plnaId\":\"批次id\",\n\r" +
  44. " \"guid\":\"机构id\",\n\r" +
  45. " \"prsnTitle\":\"计划标题\",\n\r" +
  46. " \"palnExp\":\"计划内容\",\n\r" +
  47. " \"guid\":\"机构id\",\n\r" +
  48. " \"prsnId\":\"计划制作人id\",\n\r" +
  49. " \"palnSttm\":\"计划开始时间\",\n\r" +
  50. " \"palnEntm\":\"计划结束时间\",\n\r" +
  51. " \"palnState\":\"状态\",\n\r" +
  52. " \"note\":\"备注\",\n\r" +
  53. " };\n\r" +
  54. "返回结构说明:{\n\r" +
  55. " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
  56. " \"code\":\"错误代码\",\n\r" +
  57. " \"data(数据信息)\":\"null\",\n\r" +
  58. " }")
  59. @RequestMapping(value = "/addBisInspPlan", method = RequestMethod.POST)
  60. public BaseResponse addBisInspPlan(@ApiParam(name = "bisInspPlan", value = "BisInspPlan", required = true) @RequestBody BisInspPlan bisInspPlan) {
  61. bisInspPlan.setOrgId(getCurrentOrgId());
  62. bisInspPlan.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  63. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(getCurrentOrgId());
  64. Optional.ofNullable(olBisInspOrg).ifPresent(o -> bisInspPlan.setOrgName(o.getOrgNm()));
  65. OrganizationAndBatchAndGroup organizationAndBatchAndGroup = bisInspPlanService.addBisInspPlan(bisInspPlan);
  66. //返回节点内容
  67. return buildSuccessResponse(organizationAndBatchAndGroup);
  68. }
  69. @ApiOperation(value = "根据督查类型和用户机构id添加批次")
  70. @RequestMapping(value = "/addInspPlanBatch", method = RequestMethod.POST)
  71. public BaseResponse<List<AllNodeDto>> addInspPlanBatch(@ApiParam(name = "bisInspPlan", value = "BisInspPlan", required = true) @RequestBody BisInspPlan bisInspPlan) {
  72. bisInspPlan.setOrgId(getCurrentOrgId());
  73. List<AllNodeDto> allNodeDtos = bisInspPlanService.addInspPlanBatch(bisInspPlan);
  74. return buildSuccessResponse(allNodeDtos);
  75. }
  76. @ApiOperation(value = "根据ID删除督查批次")
  77. @RequestMapping(value = "/{id}", method = RequestMethod.POST)
  78. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  79. Map<String, Object> map = bisInspPlanService.deletePlan(id, getCurrentOrgId());
  80. return buildFailResponse(Integer.parseInt(map.get("code").toString()), map.get("message").toString(), true);
  81. }
  82. @ApiOperation(value = "更新xxx信息")
  83. @RequestMapping(value = "/update", method = RequestMethod.POST)
  84. public BaseResponse update(@ApiParam(name = "bisInspPlan", value = "BisInspPlan", required = true) @RequestBody BisInspPlan bisInspPlan) {
  85. bisInspPlan.setOrgId(getCurrentOrgId());
  86. int ret = bisInspPlanService.update(bisInspPlan);
  87. return buildSuccessResponse();
  88. }
  89. @ApiOperation(value = "更新组时间信息")
  90. @RequestMapping(value = "/updateBisInspAll", method = RequestMethod.POST)
  91. public BaseResponse updateBisInspAll(@ApiParam(name = "bisInspAll", value = "bisInspAll", required = true) @RequestBody BisInspAll bisInspAll) {
  92. bisInspAll.setOrgId(getCurrentOrgId());
  93. //设置年度
  94. bisInspAll.setInspYear(String.valueOf(bisInspAll.getSttm().getYear()));
  95. int ret = bisInspAllService.update(bisInspAll);
  96. return buildSuccessResponse();
  97. }
  98. @ApiOperation(value = "根据ID获取xxx(单表)")
  99. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  100. public BaseResponse<BisInspPlan> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  101. BisInspPlan bisInspPlan = bisInspPlanService.get(id);
  102. return buildSuccessResponse(bisInspPlan);
  103. }
  104. public static BaseResponse buildFailResponse(Integer code, String message, boolean isSuccess) {
  105. BaseResponse response = new BaseResponse();
  106. response.setSuccess(Boolean.valueOf(isSuccess));
  107. response.setCode(code);
  108. response.setMessage(message);
  109. return response;
  110. }
  111. }