| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- package platform.modules.government.web;
- import java.time.LocalDateTime;
- import java.util.List;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.DeleteMapping;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import com.github.pagehelper.PageInfo;
- import platform.common.Constant;
- import platform.common.annotation.OperationLog;
- import platform.common.base.controller.BaseController;
- import platform.common.base.model.DictionaryItem;
- import platform.common.base.service.DictionaryItemService;
- import platform.common.exception.BaseException;
- import platform.modules.company.entity.ProjectMaterial;
- import platform.modules.company.service.ProjectMaterialService;
- import platform.modules.government.entity.Project;
- import platform.modules.government.entity.ProjectType;
- import platform.modules.government.service.ProjectService;
- import platform.modules.government.service.ProjectTypeService;
- import platform.modules.sys.web.ResponseMessage;
- @Controller
- @RequestMapping("/project")
- public class ProjectController extends BaseController {
- @Autowired
- private ProjectService projectService;
- @Autowired
- private ProjectMaterialService projectMaterialService;
- @Autowired
- private ProjectTypeService projectTypeService;
- @Autowired
- private DictionaryItemService dictionaryItemService;
- @OperationLog(value = "查看项目申报项目列表")
- @RequestMapping("/list")
- public String list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- String keyword, ModelMap modelMap) {
- PageInfo<Project> pageInfo = projectService.findPage(pageNum, PAGESIZE, keyword);
- modelMap.put("keyword", keyword);
- modelMap.put("pageInfo", pageInfo);
- return BASE_GOVERNMENT_PATH + "project/list";
- }
- /**
- * 跳转到项目添加页面
- */
- @GetMapping(value = "/add")
- public String add(ModelMap modelMap) {
- log.info("跳转到项目添加页面!");
- projectService.getDictInfo(modelMap);
- // List<ProjectType> projectTypes = projectTypeService.findBySuperType("1");
- List<ProjectType> projectTypes = projectTypeService.findByYear(LocalDateTime.now().getYear());
- modelMap.put("projectTypes", projectTypes);
- return BASE_GOVERNMENT_PATH + "project/project_add";
- }
- /**
- * 按年份获取项目大类
- *
- * @return
- */
- @GetMapping("/getProjectByYear")
- @ResponseBody
- public Object getProjectByYear(Integer year) {
- List<ProjectType> projectTypes = projectTypeService.findByYear(year);
- return ResponseMessage.success("success", projectTypes);
- }
- /**
- * 添加/编辑项目
- */
- @OperationLog(value = "新增项目申报项目")
- @ResponseBody
- @PostMapping(value = "/save")
- public ResponseMessage save(Project project) throws Exception {
- if (IsTooFrequently()) {
- return ResponseMessage.error("操作过于频繁,请稍后再试!");
- }
- Boolean flag = true;
- if (null != project.getId()) {
- projectService.updateProject(project);
- } else {
- projectService.saveProject(project);
- }
- if (flag) {
- return ResponseMessage.success("保存成功!");
- }
- return ResponseMessage.error("保存失败!");
- }
- /**
- * 跳转到项目编辑页面
- */
- @GetMapping(value = "/edit/{id}")
- public String edit(@PathVariable("id") int id, ModelMap modelMap) {
- Project project = projectService.findById(id);
- log.info("跳转到项目编辑页面!id = {}", id);
- modelMap.put("project", project);
- projectService.getDictInfo(modelMap);
- // if(StringUtils.isNotBlank(project.getProject_super_type())) {
- // List<ProjectType> projectTypeList = projectTypeService.findBySuperType(project.getProject_super_type());
- // }
- List<ProjectType> projectTypeList = projectTypeService.findByYear(project.getProject_year());
- modelMap.put("projectTypeList", projectTypeList);
- return BASE_GOVERNMENT_PATH + "project/project_edit";
- }
- /**
- * 删除项目
- */
- @OperationLog(value = "删除项目申报项目")
- @ResponseBody
- @DeleteMapping(value = "/delete/{id}")
- public ResponseMessage delete(@PathVariable("id") String id) throws Exception {
- try {
- projectService.deleteProject(id);
- return ResponseMessage.success("删除成功!");
- } catch (BaseException e) {
- return ResponseMessage.success(e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return ResponseMessage.error("删除失败!");
- }
- /**
- * 检验项目名称是否存在
- *
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExistProjectName")
- public Boolean isExistProjectName(String id, String name, String type, Integer year) throws Exception {
- boolean flag = true;
- log.debug("检验项目名称是否存在参数! id= {}, name= {}", id, name, type);
- Project project = projectService.findProjectByName(name, type);
- // Project project= projectService.findProjectByYear(name, type, year);
- if (null != project) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (project.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验项目名称是否存在结果! flag = {}", flag);
- return flag;
- }
- /**
- * 获取相应类型的项目
- */
- @ResponseBody
- @GetMapping(value = "/getProjectByType")
- public ResponseMessage getProjectByType(@Param("type") String type, @Param("isApplication") String isApplication) {
- List<Project> projects = projectService.findByType(type, isApplication);
- return ResponseMessage.success("查询成功", projects);
- }
- /**
- * 获取相应类型的项目
- */
- @ResponseBody
- @GetMapping(value = "/getProjectMaterials")
- public ResponseMessage getProjectMaterials(ModelMap modelMap, Integer id) {
- List<ProjectMaterial> materials = projectMaterialService.findProjectMaterialByType(id);
- modelMap.put("applyMaterials", materials);
- return ResponseMessage.success("查询成功", modelMap);
- }
- /**
- * 项目类别列表页
- *
- * @param pageNum
- * @param keyword
- * @param modelMap
- * @return
- */
- @RequestMapping("/type/list")
- public String typeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- String keyword, ModelMap modelMap) {
- PageInfo<ProjectType> pageInfo = projectTypeService.findPage(pageNum, PAGESIZE, keyword);
- modelMap.put("keyword", keyword);
- modelMap.put("pageInfo", pageInfo);
- return BASE_GOVERNMENT_PATH + "project/type_list";
- }
- /**
- * 跳转到项目类别添加页面
- */
- @GetMapping(value = "type/add")
- public String addType(ModelMap modelMap) {
- log.info("跳转到项目类别添加页面!");
- List<DictionaryItem> projectSuperTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_APPLICATION_SUPER_TYPE);
- modelMap.put("projectSuperTypeList", projectSuperTypeList);
- return BASE_GOVERNMENT_PATH + "project/project_type_add";
- }
- /**
- * 添加/编辑项目
- */
- @OperationLog(value = "新增项目申报类别")
- @ResponseBody
- @PostMapping(value = "type/save")
- public ResponseMessage saveType(ProjectType projectType) throws Exception {
- if (IsTooFrequently()) {
- return ResponseMessage.error("操作过于频繁,请稍后再试!");
- }
- Boolean flag = true;
- if (null != projectType.getId()) {
- projectTypeService.updateType(projectType);
- } else {
- projectTypeService.saveType(projectType);
- }
- if (flag) {
- return ResponseMessage.success("保存成功!");
- }
- return ResponseMessage.error("保存失败!");
- }
- /**
- * 跳转到项目编辑页面
- */
- @GetMapping(value = "type/edit/{id}")
- public String editType(@PathVariable("id") int id, ModelMap modelMap) {
- ProjectType projectType = projectTypeService.findById(id);
- log.info("跳转到项目编辑页面!id = {}", id);
- modelMap.put("projectType", projectType);
- List<DictionaryItem> projectSuperTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_APPLICATION_SUPER_TYPE);
- modelMap.put("projectSuperTypeList", projectSuperTypeList);
- return BASE_GOVERNMENT_PATH + "project/project_type_edit";
- }
- /**
- * 删除项目
- */
- @OperationLog(value = "删除项目申报项目")
- @ResponseBody
- @DeleteMapping(value = "type/delete/{id}")
- public ResponseMessage deleteType(@PathVariable("id") Integer id) throws Exception {
- try {
- projectTypeService.deleteProjectType(id);
- return ResponseMessage.success("删除成功!");
- } catch (BaseException e) {
- return ResponseMessage.success(e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return ResponseMessage.error("删除失败!");
- }
- /**
- * 检验项目类型是否存在
- */
- @ResponseBody
- @GetMapping(value = "/isExistProjectTypeName")
- public Boolean isExistProjectTypeName(String id, String name, String type, Integer project_year) throws Exception {
- boolean flag = true;
- log.debug("检验项目类型是否存在参数! id= {}, name= {}", id, name, type);
- ProjectType projectType = projectTypeService.findProjectTypeByName(name, type, project_year);
- if (null != projectType) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (projectType.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验项目名称是否存在结果! flag = {}", flag);
- return flag;
- }
- /**
- * 获取相应大类的项目类型
- */
- @ResponseBody
- @GetMapping(value = "/getProjectTypeBySuper")
- public ResponseMessage getProjectTypeBySuper(ModelMap modelMap, String superType) {
- List<ProjectType> projectTypes = projectTypeService.findBySuperType(superType);
- return ResponseMessage.success("查询成功", projectTypes);
- }
- }
|