ProjectPostGeneralController.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. package cn.com.lzt.projectpostgeneral.controller;
  2. import cn.com.lzt.projectpostdetail.entity.ProjectPostDetailEntity;
  3. import cn.com.lzt.projectpostdetail.service.ProjectPostDetailServiceI;
  4. import cn.com.lzt.projectpostgeneral.dto.ProjectPostGeneralDto;
  5. import cn.com.lzt.projectpostgeneral.entity.ProjectPostGeneralEntity;
  6. import cn.com.lzt.projectpostgeneral.service.ProjectPostGeneralServiceI;
  7. import org.apache.log4j.Logger;
  8. import org.jeecgframework.core.beanvalidator.BeanValidators;
  9. import org.jeecgframework.core.common.controller.BaseController;
  10. import org.jeecgframework.core.common.exception.BusinessException;
  11. import org.jeecgframework.core.common.model.json.AjaxJson;
  12. import org.jeecgframework.core.common.model.json.DataGrid;
  13. import org.jeecgframework.core.constant.Globals;
  14. import org.jeecgframework.core.util.*;
  15. import org.jeecgframework.minidao.pojo.MiniDaoPage;
  16. import org.jeecgframework.poi.excel.ExcelImportUtil;
  17. import org.jeecgframework.poi.excel.entity.ExportParams;
  18. import org.jeecgframework.poi.excel.entity.ImportParams;
  19. import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
  20. import org.jeecgframework.tag.core.easyui.TagUtil;
  21. import org.jeecgframework.web.system.service.SystemService;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.http.HttpHeaders;
  24. import org.springframework.http.HttpStatus;
  25. import org.springframework.http.MediaType;
  26. import org.springframework.http.ResponseEntity;
  27. import org.springframework.stereotype.Controller;
  28. import org.springframework.ui.ModelMap;
  29. import org.springframework.web.bind.annotation.*;
  30. import org.springframework.web.multipart.MultipartFile;
  31. import org.springframework.web.multipart.MultipartHttpServletRequest;
  32. import org.springframework.web.servlet.ModelAndView;
  33. import org.springframework.web.util.UriComponentsBuilder;
  34. import javax.servlet.http.HttpServletRequest;
  35. import javax.servlet.http.HttpServletResponse;
  36. import javax.validation.ConstraintViolation;
  37. import javax.validation.Validator;
  38. import java.io.IOException;
  39. import java.net.URI;
  40. import java.util.ArrayList;
  41. import java.util.List;
  42. import java.util.Map;
  43. import java.util.Set;
  44. /**
  45. * @Title: Controller
  46. * @Description: 项目岗位总览表
  47. * @author onlineGenerator
  48. * @date 2017-10-16 11:56:52
  49. * @version V1.0
  50. *
  51. */
  52. @Controller
  53. @RequestMapping("/projectPostGeneralController")
  54. public class ProjectPostGeneralController extends BaseController {
  55. /**
  56. * Logger for this class
  57. */
  58. private static final Logger logger = Logger.getLogger(ProjectPostGeneralController.class);
  59. @Autowired
  60. private ProjectPostGeneralServiceI projectPostGeneralService;
  61. @Autowired
  62. private SystemService systemService;
  63. @Autowired
  64. private Validator validator;
  65. @Autowired
  66. private ProjectPostDetailServiceI projectPostDetailService;
  67. /**
  68. * 项目岗位总览表列表 页面跳转
  69. *
  70. * @return
  71. */
  72. @RequestMapping(params = "list")
  73. public ModelAndView list(HttpServletRequest request) {
  74. return new ModelAndView("cn/com/lzt/projectpostgeneral/projectPostGeneralList");
  75. }
  76. /**
  77. * easyui AJAX请求数据
  78. *
  79. * @param request
  80. * @param response
  81. * @param dataGrid
  82. * @param user
  83. */
  84. @RequestMapping(params = "datagrid")
  85. public void datagrid(ProjectPostGeneralDto projectPostGeneralDto,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  86. /*CriteriaQuery cq = new CriteriaQuery(ProjectPostGeneralEntity.class, dataGrid);
  87. //查询条件组装器
  88. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, projectPostGeneral, request.getParameterMap());
  89. try{
  90. //自定义追加查询条件
  91. String myPId=projectPostGeneral.getPid();
  92. if(myPId!=null&&myPId.length()>0&&myPId.indexOf(",")!=-1){
  93. cq.eq("pid", myPId.substring(0, myPId.indexOf(",")));
  94. }
  95. cq.eq("deleteFlag", Globals.Delete_Normal.toString());
  96. //排序
  97. Map<String, Object> map = new HashMap<String, Object>();
  98. map.put("createDate", "desc");
  99. cq.setOrder(map);
  100. }catch (Exception e) {
  101. throw new BusinessException(e.getMessage());
  102. }
  103. cq.add();
  104. this.projectPostGeneralService.getDataGridReturn(cq, true);
  105. TagUtil.datagrid(response, dataGrid);*/
  106. String myPId=projectPostGeneralDto.getPid();
  107. if(myPId!=null&&myPId.length()>0&&myPId.indexOf(",")!=-1){
  108. projectPostGeneralDto.setPid(myPId.substring(0, myPId.indexOf(",")));
  109. }
  110. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  111. MiniDaoPage<ProjectPostGeneralDto> projectPostGeneralDtoList = projectPostGeneralService.getProjectPostGeneralDtoPage(projectPostGeneralDto, dataGrid.getPage(), dataGrid.getRows(),authSql);
  112. dataGrid.setTotal(projectPostGeneralDtoList.getTotal());
  113. dataGrid.setResults(projectPostGeneralDtoList.getResults());
  114. TagUtil.datagrid(response, dataGrid);
  115. }
  116. /**
  117. * 删除项目岗位总览表
  118. *
  119. * @return
  120. */
  121. @RequestMapping(params = "doDel")
  122. @ResponseBody
  123. public AjaxJson doDel(ProjectPostGeneralEntity projectPostGeneral, HttpServletRequest request) {
  124. String message = null;
  125. AjaxJson j = new AjaxJson();
  126. projectPostGeneral = systemService.getEntity(ProjectPostGeneralEntity.class, projectPostGeneral.getId());
  127. message = "项目岗位删除成功";
  128. try{
  129. projectPostGeneralService.delete(projectPostGeneral);
  130. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  131. }catch(Exception e){
  132. e.printStackTrace();
  133. message = "项目岗位删除失败";
  134. throw new BusinessException(e.getMessage());
  135. }
  136. j.setMsg(message);
  137. return j;
  138. }
  139. /**
  140. * 批量删除项目岗位总览表
  141. *
  142. * @return
  143. */
  144. @RequestMapping(params = "doBatchDel")
  145. @ResponseBody
  146. public AjaxJson doBatchDel(String ids,HttpServletRequest request){
  147. String message = null;
  148. AjaxJson j = new AjaxJson();
  149. message = "项目岗位总览删除成功";
  150. try{
  151. for(String id:ids.split(",")){
  152. ProjectPostGeneralEntity projectPostGeneral = systemService.getEntity(ProjectPostGeneralEntity.class,
  153. id
  154. );
  155. projectPostGeneralService.delete(projectPostGeneral);
  156. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  157. }
  158. }catch(Exception e){
  159. e.printStackTrace();
  160. message = "项目岗位总览删除失败";
  161. throw new BusinessException(e.getMessage());
  162. }
  163. j.setMsg(message);
  164. return j;
  165. }
  166. /**
  167. * 添加项目岗位总览表
  168. *
  169. * @param ids
  170. * @return
  171. */
  172. @RequestMapping(params = "doAdd")
  173. @ResponseBody
  174. public AjaxJson doAdd(ProjectPostGeneralEntity projectPostGeneral, HttpServletRequest request) {
  175. String message = null;
  176. AjaxJson j = new AjaxJson();
  177. message = "项目岗位添加成功";
  178. try{
  179. projectPostGeneralService.save(projectPostGeneral);
  180. systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
  181. }catch(Exception e){
  182. e.printStackTrace();
  183. message = "项目岗位添加失败";
  184. throw new BusinessException(e.getMessage());
  185. }
  186. j.setMsg(message);
  187. return j;
  188. }
  189. /**
  190. * 更新项目岗位总览表
  191. *
  192. * @param ids
  193. * @return
  194. */
  195. @RequestMapping(params = "doUpdate")
  196. @ResponseBody
  197. public AjaxJson doUpdate(ProjectPostGeneralEntity projectPostGeneral, HttpServletRequest request) {
  198. String message = null;
  199. AjaxJson j = new AjaxJson();
  200. message = "项目岗位更新成功";
  201. ProjectPostGeneralEntity t = projectPostGeneralService.get(ProjectPostGeneralEntity.class, projectPostGeneral.getId());
  202. try {
  203. MyBeanUtils.copyBeanNotNull2Bean(projectPostGeneral, t);
  204. projectPostGeneralService.saveOrUpdate(t);
  205. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  206. } catch (Exception e) {
  207. e.printStackTrace();
  208. message = "项目岗位更新失败";
  209. throw new BusinessException(e.getMessage());
  210. }
  211. j.setMsg(message);
  212. return j;
  213. }
  214. /**
  215. * 项目岗位总览表新增页面跳转
  216. *
  217. * @return
  218. */
  219. @RequestMapping(params = "goAdd")
  220. public ModelAndView goAdd(ProjectPostGeneralEntity projectPostGeneral, HttpServletRequest req) {
  221. if (StringUtil.isNotEmpty(projectPostGeneral.getId())) {
  222. projectPostGeneral = projectPostGeneralService.getEntity(ProjectPostGeneralEntity.class, projectPostGeneral.getId());
  223. req.setAttribute("projectPostGeneralPage", projectPostGeneral);
  224. }
  225. return new ModelAndView("cn/com/lzt/projectpostgeneral/projectPostGeneral-add");
  226. }
  227. /**
  228. * 项目岗位总览表编辑页面跳转
  229. *
  230. * @return
  231. */
  232. @RequestMapping(params = "goUpdate")
  233. public ModelAndView goUpdate(ProjectPostGeneralEntity projectPostGeneral, HttpServletRequest req) {
  234. if (StringUtil.isNotEmpty(projectPostGeneral.getId())) {
  235. projectPostGeneral = projectPostGeneralService.getEntity(ProjectPostGeneralEntity.class, projectPostGeneral.getId());
  236. req.setAttribute("projectPostGeneralPage", projectPostGeneral);
  237. }
  238. return new ModelAndView("cn/com/lzt/projectpostgeneral/projectPostGeneral-update");
  239. }
  240. /**
  241. * 导入功能跳转
  242. *
  243. * @return
  244. */
  245. @RequestMapping(params = "upload")
  246. public ModelAndView upload(HttpServletRequest req) {
  247. req.setAttribute("controller_name","projectPostGeneralController");
  248. return new ModelAndView("common/upload/pub_excel_upload");
  249. }
  250. /**
  251. * 导出excel
  252. *
  253. * @param request
  254. * @param response
  255. */
  256. @RequestMapping(params = "exportXls")
  257. public String exportXls(ProjectPostGeneralDto projectPostGeneralDto,HttpServletRequest request,HttpServletResponse response
  258. , DataGrid dataGrid,ModelMap modelMap) {
  259. /*//获取项目名称
  260. List<DictEntity> departList=systemService.queryDict("t_s_depart", "id", "departname");
  261. Map<String, String> departMap=new HashMap<String, String>();
  262. for (int i = 0; i < departList.size(); i++) {
  263. departMap.put(departList.get(i).getTypecode(), departList.get(i).getTypename());
  264. }
  265. //获取用户名称
  266. List<DictEntity> baseUserList=systemService.queryDict("t_s_base_user", "id", "realname");
  267. Map<String, String> baseUserMap=new HashMap<String, String>();
  268. for (int i = 0; i < baseUserList.size(); i++) {
  269. baseUserMap.put(baseUserList.get(i).getTypecode(), baseUserList.get(i).getTypename());
  270. }
  271. //标题 该list中用于存储标题的信息,每一个ExcelExportEntity 表示一列,根据List 的入栈顺序,由左至右,一次排序
  272. List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
  273. ExcelExportEntity head1=new ExcelExportEntity("项目名称", "pid", 15);
  274. entityList.add(head1);
  275. ExcelExportEntity head2=new ExcelExportEntity("岗位分配", "overallSituation", 15);
  276. entityList.add(head2);
  277. ExcelExportEntity head3=new ExcelExportEntity("分配人", "setterId", 15);
  278. entityList.add(head3);
  279. //组建数据集
  280. List<Map<String,Object>> dataResult = new ArrayList<Map<String,Object>>();
  281. List<ProjectPostGeneralEntity> projectPostGeneralEntityList=new ArrayList<ProjectPostGeneralEntity>();
  282. StringBuffer hql = new StringBuffer(" from ProjectPostGeneralEntity t where 1=1 and t.deleteFlag = '0' ");
  283. if(projectPostGeneral.getPid()!=null&&projectPostGeneral.getPid().length()>0){
  284. hql.append(" and t.pid = ? ");
  285. projectPostGeneralEntityList = projectPostGeneralService.findHql(hql.toString(),projectPostGeneral.getPid());
  286. }else{
  287. projectPostGeneralEntityList = projectPostGeneralService.findHql(hql.toString());
  288. }
  289. for (int i = 0; i < projectPostGeneralEntityList.size(); i++) {
  290. Map<String, Object> map = new HashMap<String, Object>();
  291. map.put("pid", departMap.get(projectPostGeneralEntityList.get(i).getPid()));
  292. map.put("overallSituation", projectPostGeneralEntityList.get(i).getOverallSituation());
  293. map.put("setterId", baseUserMap.get(projectPostGeneralEntityList.get(i).getSetterId()));
  294. dataResult.add(map);
  295. }
  296. modelMap.put(MapExcelConstants.ENTITY_LIST, entityList);
  297. modelMap.put(MapExcelConstants.MAP_LIST, dataResult);
  298. modelMap.put(NormalExcelConstants.FILE_NAME,"项目岗位设定");
  299. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("项目岗位设定", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  300. "导出信息"));
  301. return MapExcelConstants.JEECG_MAP_EXCEL_VIEW;*/
  302. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  303. List<ProjectPostGeneralDto> projectPostGeneralDtoList=null;
  304. try {
  305. projectPostGeneralDtoList = projectPostGeneralService.getProjectPostGeneralDtoExport(projectPostGeneralDto, authSql);
  306. } catch (Exception e) {
  307. // TODO Auto-generated catch block
  308. e.printStackTrace();
  309. }
  310. modelMap.put(NormalExcelConstants.FILE_NAME,"项目岗位设定");
  311. modelMap.put(NormalExcelConstants.CLASS,ProjectPostGeneralDto.class);
  312. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("项目岗位设定", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  313. "导出信息"));
  314. modelMap.put(NormalExcelConstants.DATA_LIST,projectPostGeneralDtoList);
  315. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  316. /*CriteriaQuery cq = new CriteriaQuery(ProjectPostGeneralEntity.class, dataGrid);
  317. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, projectPostGeneral, request.getParameterMap());
  318. List<ProjectPostGeneralEntity> projectPostGenerals = this.projectPostGeneralService.getListByCriteriaQuery(cq,false);
  319. modelMap.put(NormalExcelConstants.FILE_NAME,"项目岗位总览表");
  320. modelMap.put(NormalExcelConstants.CLASS,ProjectPostGeneralEntity.class);
  321. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("项目岗位总览表列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  322. "导出信息"));
  323. modelMap.put(NormalExcelConstants.DATA_LIST,projectPostGenerals);
  324. return NormalExcelConstants.JEECG_EXCEL_VIEW;*/
  325. }
  326. /**
  327. * 导出excel 使模板
  328. *
  329. * @param request
  330. * @param response
  331. */
  332. @RequestMapping(params = "exportXlsByT")
  333. public String exportXlsByT(ProjectPostGeneralEntity projectPostGeneral,HttpServletRequest request,HttpServletResponse response
  334. , DataGrid dataGrid,ModelMap modelMap) {
  335. modelMap.put(NormalExcelConstants.FILE_NAME,"项目岗位总览");
  336. modelMap.put(NormalExcelConstants.CLASS,ProjectPostGeneralEntity.class);
  337. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("项目岗位总览列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  338. "导出信息"));
  339. modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
  340. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  341. }
  342. @SuppressWarnings("unchecked")
  343. @RequestMapping(params = "importExcel", method = RequestMethod.POST)
  344. @ResponseBody
  345. public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
  346. AjaxJson j = new AjaxJson();
  347. MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
  348. Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
  349. for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
  350. MultipartFile file = entity.getValue();// 获取上传文件对象
  351. ImportParams params = new ImportParams();
  352. params.setTitleRows(2);
  353. params.setHeadRows(1);
  354. params.setNeedSave(true);
  355. try {
  356. List<ProjectPostGeneralEntity> listProjectPostGeneralEntitys = ExcelImportUtil.importExcel(file.getInputStream(),ProjectPostGeneralEntity.class,params);
  357. for (ProjectPostGeneralEntity projectPostGeneral : listProjectPostGeneralEntitys) {
  358. projectPostGeneralService.save(projectPostGeneral);
  359. }
  360. j.setMsg("文件导入成功!");
  361. } catch (Exception e) {
  362. j.setMsg("文件导入失败!");
  363. logger.error(ExceptionUtil.getExceptionMessage(e));
  364. }finally{
  365. try {
  366. file.getInputStream().close();
  367. } catch (IOException e) {
  368. e.printStackTrace();
  369. }
  370. }
  371. }
  372. return j;
  373. }
  374. @RequestMapping(method = RequestMethod.GET)
  375. @ResponseBody
  376. public List<ProjectPostGeneralEntity> list() {
  377. List<ProjectPostGeneralEntity> listProjectPostGenerals=projectPostGeneralService.getList(ProjectPostGeneralEntity.class);
  378. return listProjectPostGenerals;
  379. }
  380. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  381. @ResponseBody
  382. public ResponseEntity<?> get(@PathVariable("id") String id) {
  383. ProjectPostGeneralEntity task = projectPostGeneralService.get(ProjectPostGeneralEntity.class, id);
  384. if (task == null) {
  385. return new ResponseEntity(HttpStatus.NOT_FOUND);
  386. }
  387. return new ResponseEntity(task, HttpStatus.OK);
  388. }
  389. @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
  390. @ResponseBody
  391. public ResponseEntity<?> create(@RequestBody ProjectPostGeneralEntity projectPostGeneral, UriComponentsBuilder uriBuilder) {
  392. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  393. Set<ConstraintViolation<ProjectPostGeneralEntity>> failures = validator.validate(projectPostGeneral);
  394. if (!failures.isEmpty()) {
  395. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  396. }
  397. //保存
  398. try{
  399. projectPostGeneralService.save(projectPostGeneral);
  400. } catch (Exception e) {
  401. e.printStackTrace();
  402. return new ResponseEntity(HttpStatus.NO_CONTENT);
  403. }
  404. //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
  405. String id = projectPostGeneral.getId();
  406. URI uri = uriBuilder.path("/rest/projectPostGeneralController/" + id).build().toUri();
  407. HttpHeaders headers = new HttpHeaders();
  408. headers.setLocation(uri);
  409. return new ResponseEntity(headers, HttpStatus.CREATED);
  410. }
  411. @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
  412. public ResponseEntity<?> update(@RequestBody ProjectPostGeneralEntity projectPostGeneral) {
  413. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  414. Set<ConstraintViolation<ProjectPostGeneralEntity>> failures = validator.validate(projectPostGeneral);
  415. if (!failures.isEmpty()) {
  416. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  417. }
  418. //保存
  419. try{
  420. projectPostGeneralService.saveOrUpdate(projectPostGeneral);
  421. } catch (Exception e) {
  422. e.printStackTrace();
  423. return new ResponseEntity(HttpStatus.NO_CONTENT);
  424. }
  425. //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
  426. return new ResponseEntity(HttpStatus.NO_CONTENT);
  427. }
  428. @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  429. @ResponseStatus(HttpStatus.NO_CONTENT)
  430. public void delete(@PathVariable("id") String id) {
  431. projectPostGeneralService.deleteEntityById(ProjectPostGeneralEntity.class, id);
  432. }
  433. @RequestMapping(params = "projectSelect")
  434. public String projectSelect(HttpServletRequest req) {
  435. // req.setAttribute("orgIds", req.getParameter("orgIds"));
  436. return "cn/com/lzt/projectpostgeneral/projectSelect";
  437. }
  438. /**
  439. * 保存新增/更新的行数据项目岗位总览表
  440. * 同时更新项目岗位明细表
  441. * @author zbw
  442. * 2017-10-18
  443. * @param projectPostGeneral
  444. * @param request
  445. * @return
  446. */
  447. @RequestMapping(params = "saveRows")
  448. @ResponseBody
  449. public AjaxJson saveRows(ProjectPostDetailEntity projectPostDetailEntity,String overallSituation, HttpServletRequest request){
  450. AjaxJson j = new AjaxJson();
  451. if(projectPostDetailEntity.getPid()!=null&&projectPostDetailEntity.getPid().length()>0){
  452. projectPostDetailEntity.setPid(projectPostDetailEntity.getPid().split(",")[0]);
  453. }
  454. if(projectPostDetailEntity.getPostid()!=null&&projectPostDetailEntity.getPostid().length()>0){
  455. projectPostDetailEntity.setPostid(projectPostDetailEntity.getPostid().split(",")[0]);
  456. }
  457. try {
  458. j=projectPostGeneralService.saveProjectPostGeneralEntity(projectPostDetailEntity,overallSituation);
  459. if(j.isSuccess()){
  460. j.setMsg("保存成功");
  461. }else{
  462. j.setMsg("保存失败");
  463. }
  464. } catch (Exception e) {
  465. // TODO Auto-generated catch block
  466. e.printStackTrace();
  467. }
  468. return j;
  469. }
  470. /**
  471. * 逻辑删除项目岗位总览表
  472. * 同时逻辑删除项目岗位明细表数据
  473. * @author zbw
  474. * 2017-10-18
  475. * @param projectPostDetail
  476. * @param request
  477. * @return
  478. */
  479. @RequestMapping(params = "logicDelProjectPostGeneralAndProjectPostDetail")
  480. @ResponseBody
  481. public AjaxJson logicDelProjectPostGeneralAndProjectPostDetail(ProjectPostGeneralEntity projectPostGeneralEntity, HttpServletRequest request) {
  482. AjaxJson j = new AjaxJson();
  483. try {
  484. j=projectPostGeneralService.logicDelProjectPostGeneralEntity(projectPostGeneralEntity);
  485. } catch (Exception e) {
  486. // TODO Auto-generated catch block
  487. e.printStackTrace();
  488. }
  489. return j;
  490. }
  491. /**
  492. * 逻辑删除项目岗位明细表数据
  493. * 同时更新项目岗位总览表
  494. * @author zbw
  495. * 2017-11-28
  496. * @param projectPostDetailEntity
  497. * @param overallSituation
  498. * @param request
  499. * @return
  500. */
  501. @RequestMapping(params = "logicDelProjectPostDetailUpdateProjectPostGeneral")
  502. @ResponseBody
  503. public AjaxJson logicDelProjectPostDetailUpdateProjectPostGeneral(ProjectPostDetailEntity projectPostDetailEntity,String overallSituation, HttpServletRequest request) {
  504. AjaxJson j = new AjaxJson();
  505. try {
  506. j=projectPostGeneralService.logicDelProjectPostDetailUpdateProjectPostGeneral(projectPostDetailEntity,overallSituation);
  507. if(j.isSuccess()){
  508. j.setMsg("操作成功");
  509. }else{
  510. j.setMsg("操作失败");
  511. }
  512. } catch (Exception e) {
  513. // TODO Auto-generated catch block
  514. e.printStackTrace();
  515. }
  516. return j;
  517. }
  518. /**
  519. * 异步验证项目名称是否已存在
  520. * @author zbw
  521. * 2017-11-12
  522. * @param projectPostGeneral
  523. * @param request
  524. * @return
  525. */
  526. @RequestMapping(params = "ajaxCheckProjectName")
  527. @ResponseBody
  528. public AjaxJson ajaxCheckProjectName(ProjectPostGeneralEntity projectPostGeneral, HttpServletRequest request) {
  529. String message = null;
  530. AjaxJson j = new AjaxJson();
  531. message = "";
  532. StringBuffer hql = new StringBuffer(" from ProjectPostGeneralEntity t where delete_flag = '0' and t.pid=? ");
  533. List<ProjectPostGeneralEntity> projectPostGeneralList = projectPostGeneralService.findHql(hql.toString(), projectPostGeneral.getPid().split(",")[0]);
  534. if(projectPostGeneralList.size()!=0){
  535. j.setSuccess(false);
  536. message="项目名称已存在";
  537. }
  538. j.setMsg(message);
  539. return j;
  540. }
  541. /**
  542. * 验证项目岗位名称是否存在
  543. * @author zbw
  544. * 2017-11-28
  545. * @param projectPostDetailEntity
  546. * @param request
  547. * @return
  548. */
  549. @RequestMapping(params = "ajaxCheckPtjPostName")
  550. @ResponseBody
  551. public AjaxJson ajaxCheckPtjPostName(ProjectPostDetailEntity projectPostDetailEntity, HttpServletRequest request) {
  552. String message = null;
  553. AjaxJson j = new AjaxJson();
  554. message = "";
  555. StringBuffer hql = new StringBuffer(" from ProjectPostDetailEntity t where delete_flag = '0' and t.pid=? ");
  556. List<ProjectPostDetailEntity> projectPostDetailList = projectPostGeneralService.findHql(hql.toString(), projectPostDetailEntity.getPid().split(",")[0]);
  557. for (int i = 0; i < projectPostDetailList.size(); i++) {
  558. if(projectPostDetailEntity.getId()!=null&&projectPostDetailEntity.getId().length()!=0){
  559. if(!projectPostDetailList.get(i).getId().equals(projectPostDetailEntity.getId())){
  560. if(projectPostDetailList.get(i).getPtjPostName().equals(projectPostDetailEntity.getPtjPostName())){
  561. j.setSuccess(false);
  562. message="项目岗位名称已存在";
  563. break;
  564. }
  565. }
  566. }else{
  567. if(projectPostDetailList.get(i).getPtjPostName().equals(projectPostDetailEntity.getPtjPostName())){
  568. j.setSuccess(false);
  569. message="项目岗位名称已存在";
  570. break;
  571. }
  572. }
  573. }
  574. j.setMsg(message);
  575. return j;
  576. }
  577. }