ProjectPostDetailController.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. package cn.com.lzt.projectpostdetail.controller;
  2. import java.io.IOException;
  3. import java.net.URI;
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. import java.util.Set;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import javax.validation.ConstraintViolation;
  12. import javax.validation.Validator;
  13. import org.apache.commons.lang.StringUtils;
  14. import org.apache.log4j.Logger;
  15. import org.jeecgframework.core.beanvalidator.BeanValidators;
  16. import org.jeecgframework.core.common.controller.BaseController;
  17. import org.jeecgframework.core.common.exception.BusinessException;
  18. import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
  19. import org.jeecgframework.core.common.model.json.AjaxJson;
  20. import org.jeecgframework.core.common.model.json.DataGrid;
  21. import org.jeecgframework.core.constant.Globals;
  22. import org.jeecgframework.core.util.ExceptionUtil;
  23. import org.jeecgframework.core.util.MyBeanUtils;
  24. import org.jeecgframework.core.util.ResourceUtil;
  25. import org.jeecgframework.core.util.StringUtil;
  26. import org.jeecgframework.poi.excel.ExcelImportUtil;
  27. import org.jeecgframework.poi.excel.entity.ExportParams;
  28. import org.jeecgframework.poi.excel.entity.ImportParams;
  29. import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
  30. import org.jeecgframework.tag.core.easyui.TagUtil;
  31. import org.jeecgframework.web.system.pojo.base.DictEntity;
  32. import org.jeecgframework.web.system.service.SystemService;
  33. import org.springframework.beans.factory.annotation.Autowired;
  34. import org.springframework.http.HttpHeaders;
  35. import org.springframework.http.HttpStatus;
  36. import org.springframework.http.MediaType;
  37. import org.springframework.http.ResponseEntity;
  38. import org.springframework.stereotype.Controller;
  39. import org.springframework.ui.ModelMap;
  40. import org.springframework.web.bind.annotation.PathVariable;
  41. import org.springframework.web.bind.annotation.RequestBody;
  42. import org.springframework.web.bind.annotation.RequestMapping;
  43. import org.springframework.web.bind.annotation.RequestMethod;
  44. import org.springframework.web.bind.annotation.ResponseBody;
  45. import org.springframework.web.bind.annotation.ResponseStatus;
  46. import org.springframework.web.multipart.MultipartFile;
  47. import org.springframework.web.multipart.MultipartHttpServletRequest;
  48. import org.springframework.web.servlet.ModelAndView;
  49. import org.springframework.web.util.UriComponentsBuilder;
  50. import cn.com.lzt.post.service.PostServiceI;
  51. import cn.com.lzt.projectpostdetail.dto.ProjectPostDetailDto;
  52. import cn.com.lzt.projectpostdetail.entity.ProjectPostDetailEntity;
  53. import cn.com.lzt.projectpostdetail.entity.ZTreePostEntity;
  54. import cn.com.lzt.projectpostdetail.service.ProjectPostDetailServiceI;
  55. /**
  56. * @Title: Controller
  57. * @Description: 项目岗位明细表
  58. * @author onlineGenerator
  59. * @date 2017-10-16 13:49:41
  60. * @version V1.0
  61. *
  62. */
  63. @Controller
  64. @RequestMapping("/projectPostDetailController")
  65. public class ProjectPostDetailController extends BaseController {
  66. /**
  67. * Logger for this class
  68. */
  69. private static final Logger logger = Logger.getLogger(ProjectPostDetailController.class);
  70. @Autowired
  71. private ProjectPostDetailServiceI projectPostDetailService;
  72. @Autowired
  73. private SystemService systemService;
  74. @Autowired
  75. private Validator validator;
  76. @Autowired
  77. private PostServiceI postService;
  78. /**
  79. * 项目岗位明细表列表 页面跳转
  80. *
  81. * @return
  82. */
  83. @RequestMapping(params = "list")
  84. public ModelAndView list(HttpServletRequest request) {
  85. /*TSUser user = ResourceUtil.getSessionUser();
  86. String userId = user.getId();
  87. request.setAttribute("userId", userId);*/
  88. request.setAttribute("ptjPostGeneralid", request.getParameter("ptjPostGeneralid"));
  89. // request.setAttribute("pid", request.getParameter("pid"));
  90. //获取用户名称
  91. List<DictEntity> departList=systemService.queryDict("t_s_depart", "id", "departname");
  92. String pid=request.getParameter("pid").split(",")[0];
  93. String departname="";
  94. for (int i = 0; i < departList.size(); i++) {
  95. if(departList.get(i).getTypecode().equals(pid)){
  96. departname=departList.get(i).getTypename();
  97. }
  98. }
  99. request.setAttribute("pid", request.getParameter("pid"));
  100. request.setAttribute("departname", departname);
  101. return new ModelAndView("cn/com/lzt/projectpostdetail/projectPostDetailList");
  102. }
  103. /**
  104. * easyui AJAX请求数据
  105. *
  106. * @param request
  107. * @param response
  108. * @param dataGrid
  109. * @param user
  110. */
  111. @RequestMapping(params = "datagrid")
  112. public void datagrid(ProjectPostDetailDto projectPostDetailDto,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  113. // CriteriaQuery cq = new CriteriaQuery(ProjectPostDetailEntity.class, dataGrid);
  114. // //查询条件组装器
  115. // org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, projectPostDetail, request.getParameterMap());
  116. // try{
  117. // //自定义追加查询条件
  118. // if(projectPostDetail.getPtjPostGeneralid().length()==0||projectPostDetail.getPtjPostGeneralid()=="undefined"||projectPostDetail.getPtjPostGeneralid()==null){
  119. // cq.eq("id", null);
  120. // }else{
  121. // cq.eq("ptjPostGeneralid",projectPostDetail.getPtjPostGeneralid());
  122. // }
  123. // }catch (Exception e) {
  124. // throw new BusinessException(e.getMessage());
  125. // }
  126. // cq.add();
  127. // this.projectPostDetailService.getDataGridReturn(cq, true);
  128. List<ProjectPostDetailDto> listUserAndUserPersonnelDto=projectPostDetailService.getProjectPostDetailDtoList(projectPostDetailDto);
  129. dataGrid.setResults(listUserAndUserPersonnelDto);
  130. TagUtil.datagrid(response, dataGrid);
  131. }
  132. /**
  133. * 删除项目岗位明细表
  134. *
  135. * @return
  136. */
  137. @RequestMapping(params = "doDel")
  138. @ResponseBody
  139. public AjaxJson doDel(ProjectPostDetailEntity projectPostDetail, HttpServletRequest request) {
  140. String message = null;
  141. AjaxJson j = new AjaxJson();
  142. projectPostDetail = systemService.getEntity(ProjectPostDetailEntity.class, projectPostDetail.getId());
  143. message = "项目岗位明细删除成功";
  144. try{
  145. projectPostDetailService.delete(projectPostDetail);
  146. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  147. }catch(Exception e){
  148. e.printStackTrace();
  149. message = "项目岗位明细删除失败";
  150. throw new BusinessException(e.getMessage());
  151. }
  152. j.setMsg(message);
  153. return j;
  154. }
  155. /**
  156. * 批量删除项目岗位明细表
  157. *
  158. * @return
  159. */
  160. @RequestMapping(params = "doBatchDel")
  161. @ResponseBody
  162. public AjaxJson doBatchDel(String ids,HttpServletRequest request){
  163. String message = null;
  164. AjaxJson j = new AjaxJson();
  165. message = "项目岗位明细删除成功";
  166. try{
  167. for(String id:ids.split(",")){
  168. ProjectPostDetailEntity projectPostDetail = systemService.getEntity(ProjectPostDetailEntity.class,
  169. id
  170. );
  171. projectPostDetailService.delete(projectPostDetail);
  172. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  173. }
  174. }catch(Exception e){
  175. e.printStackTrace();
  176. message = "项目岗位明细删除失败";
  177. throw new BusinessException(e.getMessage());
  178. }
  179. j.setMsg(message);
  180. return j;
  181. }
  182. /**
  183. * 添加项目岗位明细表
  184. *
  185. * @param ids
  186. * @return
  187. */
  188. @RequestMapping(params = "doAdd")
  189. @ResponseBody
  190. public AjaxJson doAdd(ProjectPostDetailEntity projectPostDetail, HttpServletRequest request) {
  191. String message = null;
  192. AjaxJson j = new AjaxJson();
  193. message = "项目岗位明细添加成功";
  194. try{
  195. projectPostDetailService.save(projectPostDetail);
  196. systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
  197. }catch(Exception e){
  198. e.printStackTrace();
  199. message = "项目岗位明细添加失败";
  200. throw new BusinessException(e.getMessage());
  201. }
  202. j.setMsg(message);
  203. return j;
  204. }
  205. /**
  206. * 更新项目岗位明细表
  207. *
  208. * @param ids
  209. * @return
  210. */
  211. @RequestMapping(params = "doUpdate")
  212. @ResponseBody
  213. public AjaxJson doUpdate(ProjectPostDetailEntity projectPostDetail, HttpServletRequest request) {
  214. String message = null;
  215. AjaxJson j = new AjaxJson();
  216. message = "项目岗位明细更新成功";
  217. ProjectPostDetailEntity t = projectPostDetailService.get(ProjectPostDetailEntity.class, projectPostDetail.getId());
  218. try {
  219. MyBeanUtils.copyBeanNotNull2Bean(projectPostDetail, t);
  220. projectPostDetailService.saveOrUpdate(t);
  221. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  222. } catch (Exception e) {
  223. e.printStackTrace();
  224. message = "项目岗位明细更新失败";
  225. throw new BusinessException(e.getMessage());
  226. }
  227. j.setMsg(message);
  228. return j;
  229. }
  230. /**
  231. * 项目岗位明细表新增页面跳转
  232. *
  233. * @return
  234. */
  235. @RequestMapping(params = "goAdd")
  236. public ModelAndView goAdd(ProjectPostDetailEntity projectPostDetail, HttpServletRequest req) {
  237. if (StringUtil.isNotEmpty(projectPostDetail.getId())) {
  238. projectPostDetail = projectPostDetailService.getEntity(ProjectPostDetailEntity.class, projectPostDetail.getId());
  239. req.setAttribute("projectPostDetailPage", projectPostDetail);
  240. }
  241. return new ModelAndView("cn/com/lzt/projectpostdetail/projectPostDetail-add");
  242. }
  243. /**
  244. * 项目岗位明细表编辑页面跳转
  245. *
  246. * @return
  247. */
  248. @RequestMapping(params = "goUpdate")
  249. public ModelAndView goUpdate(ProjectPostDetailEntity projectPostDetail, HttpServletRequest req) {
  250. if (StringUtil.isNotEmpty(projectPostDetail.getId())) {
  251. projectPostDetail = projectPostDetailService.getEntity(ProjectPostDetailEntity.class, projectPostDetail.getId());
  252. req.setAttribute("projectPostDetailPage", projectPostDetail);
  253. }
  254. return new ModelAndView("cn/com/lzt/projectpostdetail/projectPostDetail-update");
  255. }
  256. /**
  257. * 导入功能跳转
  258. *
  259. * @return
  260. */
  261. @RequestMapping(params = "upload")
  262. public ModelAndView upload(HttpServletRequest req) {
  263. req.setAttribute("controller_name","projectPostDetailController");
  264. return new ModelAndView("common/upload/pub_excel_upload");
  265. }
  266. /**
  267. * 导出excel
  268. *
  269. * @param request
  270. * @param response
  271. */
  272. @RequestMapping(params = "exportXls")
  273. public String exportXls(ProjectPostDetailEntity projectPostDetail,HttpServletRequest request,HttpServletResponse response
  274. , DataGrid dataGrid,ModelMap modelMap) {
  275. CriteriaQuery cq = new CriteriaQuery(ProjectPostDetailEntity.class, dataGrid);
  276. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, projectPostDetail, request.getParameterMap());
  277. List<ProjectPostDetailEntity> projectPostDetails = this.projectPostDetailService.getListByCriteriaQuery(cq,false);
  278. modelMap.put(NormalExcelConstants.FILE_NAME,"项目岗位明细");
  279. modelMap.put(NormalExcelConstants.CLASS,ProjectPostDetailEntity.class);
  280. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("项目岗位明细列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  281. "导出信息"));
  282. modelMap.put(NormalExcelConstants.DATA_LIST,projectPostDetails);
  283. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  284. }
  285. /**
  286. * 导出excel 使模板
  287. *
  288. * @param request
  289. * @param response
  290. */
  291. @RequestMapping(params = "exportXlsByT")
  292. public String exportXlsByT(ProjectPostDetailEntity projectPostDetail,HttpServletRequest request,HttpServletResponse response
  293. , DataGrid dataGrid,ModelMap modelMap) {
  294. modelMap.put(NormalExcelConstants.FILE_NAME,"项目岗位明细");
  295. modelMap.put(NormalExcelConstants.CLASS,ProjectPostDetailEntity.class);
  296. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("项目岗位明细列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  297. "导出信息"));
  298. modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
  299. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  300. }
  301. @SuppressWarnings("unchecked")
  302. @RequestMapping(params = "importExcel", method = RequestMethod.POST)
  303. @ResponseBody
  304. public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
  305. AjaxJson j = new AjaxJson();
  306. MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
  307. Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
  308. for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
  309. MultipartFile file = entity.getValue();// 获取上传文件对象
  310. ImportParams params = new ImportParams();
  311. params.setTitleRows(2);
  312. params.setHeadRows(1);
  313. params.setNeedSave(true);
  314. try {
  315. List<ProjectPostDetailEntity> listProjectPostDetailEntitys = ExcelImportUtil.importExcel(file.getInputStream(),ProjectPostDetailEntity.class,params);
  316. for (ProjectPostDetailEntity projectPostDetail : listProjectPostDetailEntitys) {
  317. projectPostDetailService.save(projectPostDetail);
  318. }
  319. j.setMsg("文件导入成功!");
  320. } catch (Exception e) {
  321. j.setMsg("文件导入失败!");
  322. logger.error(ExceptionUtil.getExceptionMessage(e));
  323. }finally{
  324. try {
  325. file.getInputStream().close();
  326. } catch (IOException e) {
  327. e.printStackTrace();
  328. }
  329. }
  330. }
  331. return j;
  332. }
  333. @RequestMapping(method = RequestMethod.GET)
  334. @ResponseBody
  335. public List<ProjectPostDetailEntity> list() {
  336. List<ProjectPostDetailEntity> listProjectPostDetails=projectPostDetailService.getList(ProjectPostDetailEntity.class);
  337. return listProjectPostDetails;
  338. }
  339. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  340. @ResponseBody
  341. public ResponseEntity<?> get(@PathVariable("id") String id) {
  342. ProjectPostDetailEntity task = projectPostDetailService.get(ProjectPostDetailEntity.class, id);
  343. if (task == null) {
  344. return new ResponseEntity(HttpStatus.NOT_FOUND);
  345. }
  346. return new ResponseEntity(task, HttpStatus.OK);
  347. }
  348. @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
  349. @ResponseBody
  350. public ResponseEntity<?> create(@RequestBody ProjectPostDetailEntity projectPostDetail, UriComponentsBuilder uriBuilder) {
  351. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  352. Set<ConstraintViolation<ProjectPostDetailEntity>> failures = validator.validate(projectPostDetail);
  353. if (!failures.isEmpty()) {
  354. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  355. }
  356. //保存
  357. try{
  358. projectPostDetailService.save(projectPostDetail);
  359. } catch (Exception e) {
  360. e.printStackTrace();
  361. return new ResponseEntity(HttpStatus.NO_CONTENT);
  362. }
  363. //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
  364. String id = projectPostDetail.getId();
  365. URI uri = uriBuilder.path("/rest/projectPostDetailController/" + id).build().toUri();
  366. HttpHeaders headers = new HttpHeaders();
  367. headers.setLocation(uri);
  368. return new ResponseEntity(headers, HttpStatus.CREATED);
  369. }
  370. @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
  371. public ResponseEntity<?> update(@RequestBody ProjectPostDetailEntity projectPostDetail) {
  372. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  373. Set<ConstraintViolation<ProjectPostDetailEntity>> failures = validator.validate(projectPostDetail);
  374. if (!failures.isEmpty()) {
  375. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  376. }
  377. //保存
  378. try{
  379. projectPostDetailService.saveOrUpdate(projectPostDetail);
  380. } catch (Exception e) {
  381. e.printStackTrace();
  382. return new ResponseEntity(HttpStatus.NO_CONTENT);
  383. }
  384. //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
  385. return new ResponseEntity(HttpStatus.NO_CONTENT);
  386. }
  387. @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  388. @ResponseStatus(HttpStatus.NO_CONTENT)
  389. public void delete(@PathVariable("id") String id) {
  390. projectPostDetailService.deleteEntityById(ProjectPostDetailEntity.class, id);
  391. }
  392. /**
  393. * 保存新增/更新的行数据
  394. * @author zbw
  395. * 2017-10-13
  396. * @param projectPostDetail
  397. * @param request
  398. * @return
  399. */
  400. @RequestMapping(params = "saveRows")
  401. @ResponseBody
  402. public AjaxJson saveRows(ProjectPostDetailEntity projectPostDetail, HttpServletRequest request){
  403. String myPostId=projectPostDetail.getPostid();
  404. String[] myPostIdList=myPostId.split(",");
  405. projectPostDetail.setPostid(myPostIdList[0]);
  406. String message = null;
  407. AjaxJson j = new AjaxJson();
  408. message = "";
  409. if (StringUtil.isNotEmpty(projectPostDetail.getId())) {
  410. ProjectPostDetailEntity t = projectPostDetailService.get(ProjectPostDetailEntity.class, projectPostDetail.getId());
  411. try {
  412. MyBeanUtils.copyBeanNotNull2Bean(projectPostDetail, t);
  413. projectPostDetailService.saveOrUpdate(t);
  414. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  415. message = "项目岗位明细更新成功";
  416. } catch (Exception e) {
  417. e.printStackTrace();
  418. message = "项目岗位明细更新失败";
  419. throw new BusinessException(e.getMessage());
  420. }
  421. } else {
  422. try{
  423. projectPostDetail.setDeleteFlag(Globals.Delete_Normal.toString());
  424. projectPostDetailService.save(projectPostDetail);
  425. systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
  426. message = "项目岗位明细添加成功";
  427. }catch(Exception e){
  428. e.printStackTrace();
  429. message = "项目岗位明细添加失败";
  430. throw new BusinessException(e.getMessage());
  431. }
  432. }
  433. j.setMsg(message);
  434. return j;
  435. }
  436. /**
  437. * 用户选择岗位tree跳转页面
  438. *
  439. * @return
  440. */
  441. @RequestMapping(params = "postZTree")
  442. public String departSelect(HttpServletRequest req) {
  443. req.setAttribute("orgIds", req.getParameter("orgIds"));
  444. return "cn/com/lzt/projectpostdetail/postZTree";
  445. }
  446. /**
  447. * 用户选择岗位tree跳转页面
  448. *
  449. * @return
  450. */
  451. @RequestMapping(params = "postSelectNoCheckBox")
  452. public String postSelectNoCheckBox(HttpServletRequest req) {
  453. req.setAttribute("orgIds", req.getParameter("orgIds"));
  454. return "cn/com/lzt/projectpostdetail/postZTreeNoCheckBox";
  455. }
  456. /**
  457. * 获取tree数据
  458. * @author zbw
  459. * 2017-10-12
  460. * @param request
  461. * @param response
  462. * @return
  463. */
  464. //update--start--by:jg_renjie--at:20160318 for:#942 【组件封装】组织机构弹出模式,目前是列表,得改造成树方式
  465. //update-start--Author: os_renjie Date:20160529 for:TASK #1056 【bug】用户编辑,弹出组织机构,默认没选中
  466. @RequestMapping(params = "getPostInfo")
  467. @ResponseBody
  468. public AjaxJson getPostInfo(HttpServletRequest request, HttpServletResponse response){
  469. AjaxJson j = new AjaxJson();
  470. String orgIds = request.getParameter("orgIds");
  471. String[] ids = new String[]{};
  472. if(StringUtils.isNotBlank(orgIds)){
  473. orgIds = orgIds.substring(0, orgIds.length()-1);
  474. ids = orgIds.split("\\,");
  475. }
  476. String parentid = request.getParameter("parentid");
  477. List<ZTreePostEntity> listDuties = new ArrayList<ZTreePostEntity>();
  478. // StringBuffer hql = new StringBuffer(" from TSDepart t where 1=1 ");
  479. StringBuffer hql = new StringBuffer(" from ZTreePostEntity t where t.status = 0 and t.deleteFlag = 0 ");
  480. if(StringUtils.isNotBlank(parentid)){
  481. // TSDepart dePart = this.systemService.getEntity(TSDepart.class, parentorgIds);
  482. ZTreePostEntity postEntity = postService.get(ZTreePostEntity.class, parentid);
  483. // hql.append(" and TSPDepart = ?");
  484. // tSDeparts = this.systemService.findHql(hql.toString(), dePart);
  485. hql.append(" and parentPost = ?");
  486. listDuties = this.postService.findHql(hql.toString(), postEntity);
  487. } else {
  488. // hql.append(" and t.orgType = ?");
  489. // tSDeparts = this.systemService.findHql(hql.toString(), "1");
  490. hql.append(" and t.parentPostid IS NULL");
  491. listDuties = this.postService.findHql(hql.toString());
  492. /*hql.append(" and t.parentDutiesid = ?");
  493. String str="4028e4a55f05cf9d015f05d3c55c0005";
  494. listDuties = this.postService.findHql(hql.toString(),str);*/
  495. }
  496. List<Map<String,Object>> dateList = new ArrayList<Map<String,Object>>();
  497. if(listDuties.size()>0){
  498. Map<String,Object> map = null;
  499. String sql = null;
  500. Object[] params = null;
  501. for(ZTreePostEntity postEntity:listDuties){
  502. map = new HashMap<String,Object>();
  503. map.put("id", postEntity.getId());
  504. map.put("name", postEntity.getPostName());
  505. if(ids.length>0){
  506. for(String id:ids){
  507. if(id.equals(postEntity.getId())){
  508. map.put("checked", true);
  509. }
  510. }
  511. }
  512. if(StringUtils.isNotBlank(parentid)){
  513. map.put("pId", parentid);
  514. } else{
  515. map.put("pId", "1");
  516. }
  517. //根据id判断是否有子节点
  518. sql = "select count(1) from t_bus_post t where t.status = '0' and t.delete_flag = '0' and t.parent_postid= ?";
  519. params = new Object[]{postEntity.getId()};
  520. long count = this.postService.getCountForJdbcParam(sql, params);
  521. if(count>0){
  522. map.put("isParent",true);
  523. }
  524. dateList.add(map);
  525. }
  526. }
  527. net.sf.json.JSONArray jsonArray = net.sf.json.JSONArray.fromObject(dateList);
  528. j.setMsg(jsonArray.toString());
  529. return j;
  530. }
  531. @RequestMapping(params = "getPostInfoNoCheckBox")
  532. @ResponseBody
  533. public AjaxJson getPostInfoNoCheckBox(HttpServletRequest request, HttpServletResponse response){
  534. AjaxJson j = new AjaxJson();
  535. String orgIds = request.getParameter("orgIds");
  536. /*String[] ids = new String[]{};
  537. if(StringUtils.isNotBlank(orgIds)){
  538. orgIds = orgIds.substring(0, orgIds.length()-1);
  539. ids = orgIds.split("\\,");
  540. }*/
  541. String parentid = request.getParameter("parentid");
  542. List<ZTreePostEntity> listDuties = new ArrayList<ZTreePostEntity>();
  543. // StringBuffer hql = new StringBuffer(" from TSDepart t where 1=1 ");
  544. StringBuffer hql = new StringBuffer(" from ZTreePostEntity t where t.status = 0 and t.deleteFlag = 0 ");
  545. if(StringUtils.isNotBlank(parentid)){
  546. // TSDepart dePart = this.systemService.getEntity(TSDepart.class, parentorgIds);
  547. ZTreePostEntity postEntity = postService.get(ZTreePostEntity.class, parentid);
  548. // hql.append(" and TSPDepart = ?");
  549. // tSDeparts = this.systemService.findHql(hql.toString(), dePart);
  550. hql.append(" and parentPost = ?");
  551. listDuties = this.postService.findHql(hql.toString(), postEntity);
  552. } else {
  553. // hql.append(" and t.orgType = ?");
  554. // tSDeparts = this.systemService.findHql(hql.toString(), "1");
  555. hql.append(" and t.parentPostid IS NULL");
  556. listDuties = this.postService.findHql(hql.toString());
  557. /*hql.append(" and t.parentDutiesid = ?");
  558. String str="4028e4a55f05cf9d015f05d3c55c0005";
  559. listDuties = this.postService.findHql(hql.toString(),str);*/
  560. }
  561. List<Map<String,Object>> dateList = new ArrayList<Map<String,Object>>();
  562. if(listDuties.size()>0){
  563. Map<String,Object> map = null;
  564. String sql = null;
  565. Object[] params = null;
  566. for(ZTreePostEntity postEntity:listDuties){
  567. map = new HashMap<String,Object>();
  568. map.put("id", postEntity.getId());
  569. map.put("name", postEntity.getPostName());
  570. if(StringUtils.isNotBlank(orgIds)){
  571. if(orgIds.equals(postEntity.getId())){
  572. map.put("checked", true);
  573. }
  574. }
  575. if(StringUtils.isNotBlank(parentid)){
  576. map.put("pId", parentid);
  577. } else{
  578. map.put("pId", "1");
  579. }
  580. //根据id判断是否有子节点
  581. sql = "select count(1) from t_bus_post t where t.status = '0' and t.delete_flag = '0' and t.parent_postid= ?";
  582. // sql = "select count(1) from t_bus_post t where t.parent_postid= ?";
  583. params = new Object[]{postEntity.getId()};
  584. long count = this.postService.getCountForJdbcParam(sql, params);
  585. if(count>0){
  586. map.put("isParent",true);
  587. }
  588. dateList.add(map);
  589. }
  590. }
  591. net.sf.json.JSONArray jsonArray = net.sf.json.JSONArray.fromObject(dateList);
  592. j.setMsg(jsonArray.toString());
  593. return j;
  594. }
  595. /**
  596. * 异步获取岗位名称
  597. * @author zbw
  598. * 2017-10-17
  599. * @param request
  600. * @param response
  601. * @return
  602. */
  603. @RequestMapping(params = "getPName")
  604. @ResponseBody
  605. public AjaxJson getPName(HttpServletRequest request, HttpServletResponse response) {
  606. AjaxJson j = new AjaxJson();
  607. String id = request.getParameter("id");
  608. String[] idList=id.split(",");
  609. ZTreePostEntity postEntity = systemService.getEntity(ZTreePostEntity.class, idList[0]);
  610. try {
  611. j.setMsg(postEntity.getPostName());
  612. //systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  613. } catch (Exception e) {
  614. e.printStackTrace();
  615. throw new BusinessException(e.getMessage());
  616. }
  617. return j;
  618. }
  619. /**
  620. * 逻辑删除项目岗位明细表
  621. * @author zbw
  622. * 2017-10-17
  623. * @param postEntity
  624. * @param request
  625. * @return
  626. */
  627. @RequestMapping(params = "logicDel")
  628. @ResponseBody
  629. public AjaxJson logicDel(ProjectPostDetailEntity projectPostDetail, HttpServletRequest request) {
  630. String message = null;
  631. AjaxJson j = new AjaxJson();
  632. projectPostDetail = systemService.getEntity(ProjectPostDetailEntity.class, projectPostDetail.getId());
  633. message = "项目岗位明细删除成功";
  634. try{
  635. projectPostDetail.setDeleteFlag(Globals.Delete_Forbidden.toString());
  636. projectPostDetailService.logicDel(projectPostDetail);
  637. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  638. }catch(Exception e){
  639. e.printStackTrace();
  640. message = "项目岗位明细删除失败";
  641. throw new BusinessException(e.getMessage());
  642. }
  643. j.setMsg(message);
  644. return j;
  645. }
  646. }