| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package cn.com.goldenwater.dcproj.controller.ducha;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.dto.AllNodeDto;
- import cn.com.goldenwater.dcproj.model.*;
- import cn.com.goldenwater.dcproj.service.BisInspAllService;
- import cn.com.goldenwater.dcproj.service.BisInspPlanService;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import cn.com.goldenwater.dcproj.util.ReadExcelUtil;
- import cn.com.goldenwater.id.util.UuidUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import java.io.File;
- import java.io.IOException;
- import java.nio.file.Paths;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.Optional;
- /**
- * @author lune
- * @date 2019-2-18
- */
- @Api(value = "督查批次管理", tags = "督查批次管理")
- @RestController
- @RequestMapping("/dc/insp/plan")
- public class BisInspPlanController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private BisInspPlanService bisInspPlanService;
- @Autowired
- private BisInspAllService bisInspAllService;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- @ApiOperation(value = "新增督查批次", notes = "参数字段说明:{\n\r" +
- " \"plnaId\":\"批次id\",\n\r" +
- " \"guid\":\"机构id\",\n\r" +
- " \"prsnTitle\":\"计划标题\",\n\r" +
- " \"palnExp\":\"计划内容\",\n\r" +
- " \"guid\":\"机构id\",\n\r" +
- " \"prsnId\":\"计划制作人id\",\n\r" +
- " \"palnSttm\":\"计划开始时间\",\n\r" +
- " \"palnEntm\":\"计划结束时间\",\n\r" +
- " \"palnState\":\"状态\",\n\r" +
- " \"note\":\"备注\",\n\r" +
- " };\n\r" +
- "返回结构说明:{\n\r" +
- " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
- " \"code\":\"错误代码\",\n\r" +
- " \"data(数据信息)\":\"null\",\n\r" +
- " }")
- @RequestMapping(value = "/addBisInspPlan", method = RequestMethod.POST)
- public BaseResponse addBisInspPlan(@ApiParam(name = "bisInspPlan", value = "BisInspPlan", required = true) @RequestBody BisInspPlan bisInspPlan) {
- bisInspPlan.setOrgId(getCurrentOrgId());
- bisInspPlan.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
- OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(getCurrentOrgId());
- Optional.ofNullable(olBisInspOrg).ifPresent(o -> bisInspPlan.setOrgName(o.getOrgNm()));
- OrganizationAndBatchAndGroup organizationAndBatchAndGroup = bisInspPlanService.addBisInspPlan(bisInspPlan);
- //返回节点内容
- return buildSuccessResponse(organizationAndBatchAndGroup);
- }
- @ApiOperation(value = "根据督查类型和用户机构id添加批次")
- @RequestMapping(value = "/addInspPlanBatch", method = RequestMethod.POST)
- public BaseResponse<List<AllNodeDto>> addInspPlanBatch(@ApiParam(name = "bisInspPlan", value = "BisInspPlan", required = true) @RequestBody BisInspPlan bisInspPlan) {
- bisInspPlan.setOrgId(getCurrentOrgId());
- List<AllNodeDto> allNodeDtos = bisInspPlanService.addInspPlanBatch(bisInspPlan);
- return buildSuccessResponse(allNodeDtos);
- }
- @ApiOperation(value = "根据ID删除督查批次")
- @RequestMapping(value = "/{id}", method = RequestMethod.POST)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- Map<String, Object> map = bisInspPlanService.deletePlan(id, getCurrentOrgId());
- return buildFailResponse(Integer.parseInt(map.get("code").toString()), map.get("message").toString(), true);
- }
- @ApiOperation(value = "更新xxx信息")
- @RequestMapping(value = "/update", method = RequestMethod.POST)
- public BaseResponse update(@ApiParam(name = "bisInspPlan", value = "BisInspPlan", required = true) @RequestBody BisInspPlan bisInspPlan) {
- bisInspPlan.setOrgId(getCurrentOrgId());
- int ret = bisInspPlanService.update(bisInspPlan);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "更新组时间信息")
- @RequestMapping(value = "/updateBisInspAll", method = RequestMethod.POST)
- public BaseResponse updateBisInspAll(@ApiParam(name = "bisInspAll", value = "bisInspAll", required = true) @RequestBody BisInspAll bisInspAll) {
- bisInspAll.setOrgId(getCurrentOrgId());
- //设置年度
- bisInspAll.setInspYear(String.valueOf(bisInspAll.getSttm().getYear()));
- int ret = bisInspAllService.update(bisInspAll);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取xxx(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<BisInspPlan> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- BisInspPlan bisInspPlan = bisInspPlanService.get(id);
- return buildSuccessResponse(bisInspPlan);
- }
- public static BaseResponse buildFailResponse(Integer code, String message, boolean isSuccess) {
- BaseResponse response = new BaseResponse();
- response.setSuccess(Boolean.valueOf(isSuccess));
- response.setCode(code);
- response.setMessage(message);
- return response;
- }
- }
|