package com.fdkankan.site.controller; import com.fdkankan.site.common.ResultCode; import com.fdkankan.site.common.ResultData; import com.fdkankan.site.entity.Project; import com.fdkankan.site.entity.ProjectNum; import com.fdkankan.site.exception.BusinessException; import com.fdkankan.site.response.ProjectNumAddParam; import com.fdkankan.site.service.IProjectNumService; import com.fdkankan.site.service.IProjectService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.xml.transform.Result; import java.util.List; /** * 四维看看调用,项目关联场景 */ @RestController @RequestMapping("/fdkk") @Slf4j public class FdkkController { @Autowired IProjectNumService projectNumService; @Autowired IProjectService projectService; @PostMapping("/projectAddNum") public ResultData projectAddNum(@RequestBody ProjectNumAddParam param){ log.info("四维通知项目添加场景---{}",param); try { if(StringUtils.isBlank(param.getNum()) || StringUtils.isBlank(param.getParentScene()) || StringUtils.isBlank(param.getProjectId()) || param.getSceneSource() == null){ throw new BusinessException(ResultCode.PARAM_MISS); } Project project = projectService.getById(param.getProjectId()); if(project == null){ throw new BusinessException(ResultCode.PROJECT_NOT_EXIST); } List dbNums = projectNumService.getByNum(param.getNum()); if(dbNums.size() >0){ throw new BusinessException(ResultCode.SCENE_BIND); } ProjectNum projectNum = new ProjectNum(); projectNum.setParentScene(param.getParentScene()); projectNum.setProjectId(param.getProjectId()); projectNum.setNum(param.getNum()); switch (param.getSceneSource()){ case 3: projectNum.setType(1); break; case 4: projectNum.setType(2); break; default: projectNum.setType(0); break; } projectNumService.save(projectNum); log.info("四维通知项目添加场景成功"); }catch (Exception e){ log.error("四维通知项目添加场景失败---{}",e.getMessage()); } return ResultData.ok(); } }