ProvidentFundStrategyController.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. package cn.com.lzt.providentfundstrategy.controller;
  2. import java.io.IOException;
  3. import java.math.BigDecimal;
  4. import java.net.URI;
  5. import java.text.ParseException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.HashMap;
  9. import java.util.List;
  10. import java.util.Map;
  11. import java.util.Set;
  12. import javax.servlet.http.HttpServletRequest;
  13. import javax.servlet.http.HttpServletResponse;
  14. import javax.validation.ConstraintViolation;
  15. import javax.validation.Validator;
  16. import org.apache.commons.lang.StringUtils;
  17. import org.apache.log4j.Logger;
  18. import org.jeecgframework.core.beanvalidator.BeanValidators;
  19. import org.jeecgframework.core.common.controller.BaseController;
  20. import org.jeecgframework.core.common.exception.BusinessException;
  21. import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
  22. import org.jeecgframework.core.common.model.json.AjaxJson;
  23. import org.jeecgframework.core.common.model.json.DataGrid;
  24. import org.jeecgframework.core.constant.Globals;
  25. import org.jeecgframework.core.util.DateUtils;
  26. import org.jeecgframework.core.util.ExceptionUtil;
  27. import org.jeecgframework.core.util.MyBeanUtils;
  28. import org.jeecgframework.core.util.ResourceUtil;
  29. import org.jeecgframework.core.util.StringUtil;
  30. import org.jeecgframework.p3.core.util.oConvertUtils;
  31. import org.jeecgframework.poi.excel.ExcelImportUtil;
  32. import org.jeecgframework.poi.excel.entity.ExportParams;
  33. import org.jeecgframework.poi.excel.entity.ImportParams;
  34. import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
  35. import org.jeecgframework.tag.core.easyui.TagUtil;
  36. import org.jeecgframework.web.system.service.SystemService;
  37. import org.springframework.beans.factory.annotation.Autowired;
  38. import org.springframework.http.HttpHeaders;
  39. import org.springframework.http.HttpStatus;
  40. import org.springframework.http.MediaType;
  41. import org.springframework.http.ResponseEntity;
  42. import org.springframework.stereotype.Controller;
  43. import org.springframework.ui.ModelMap;
  44. import org.springframework.web.bind.annotation.PathVariable;
  45. import org.springframework.web.bind.annotation.RequestBody;
  46. import org.springframework.web.bind.annotation.RequestMapping;
  47. import org.springframework.web.bind.annotation.RequestMethod;
  48. import org.springframework.web.bind.annotation.ResponseBody;
  49. import org.springframework.web.bind.annotation.ResponseStatus;
  50. import org.springframework.web.multipart.MultipartFile;
  51. import org.springframework.web.multipart.MultipartHttpServletRequest;
  52. import org.springframework.web.servlet.ModelAndView;
  53. import org.springframework.web.util.UriComponentsBuilder;
  54. import cn.com.lzt.providentfundstrategy.entity.ProvidentFundStrategyEntity;
  55. import cn.com.lzt.providentfundstrategy.service.ProvidentFundStrategyServiceI;
  56. import cn.com.lzt.socialsecuritystrategy.entity.SocialSecurityStrategyEntity;
  57. /**
  58. * @Title: Controller
  59. * @Description: 公积金策略表
  60. * @author onlineGenerator
  61. * @date 2017-09-26 16:39:32
  62. * @version V1.0
  63. *
  64. */
  65. @Controller
  66. @RequestMapping("/providentFundStrategyController")
  67. public class ProvidentFundStrategyController extends BaseController {
  68. /**
  69. * Logger for this class
  70. */
  71. private static final Logger logger = Logger.getLogger(ProvidentFundStrategyController.class);
  72. @Autowired
  73. private ProvidentFundStrategyServiceI providentFundStrategyService;
  74. @Autowired
  75. private SystemService systemService;
  76. @Autowired
  77. private Validator validator;
  78. /**
  79. * 公积金策略表列表 页面跳转
  80. *
  81. * @return
  82. */
  83. @RequestMapping(params = "list")
  84. public ModelAndView list(HttpServletRequest request) {
  85. return new ModelAndView("cn/com/lzt/providentfundstrategy/providentFundStrategyList");
  86. }
  87. /**
  88. * easyui AJAX请求数据
  89. *
  90. * @param request
  91. * @param response
  92. * @param dataGrid
  93. * @param user
  94. */
  95. @RequestMapping(params = "datagrid")
  96. public void datagrid(ProvidentFundStrategyEntity providentFundStrategy,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  97. CriteriaQuery cq = new CriteriaQuery(ProvidentFundStrategyEntity.class, dataGrid);
  98. //查询条件组装器
  99. // org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, providentFundStrategy, request.getParameterMap());
  100. // cq.add();
  101. try{
  102. // String[] status = new String[]{Globals.Enabled_Status.toString(), Globals.Disabled_Status.toString()};
  103. // cq.in("status", status);
  104. cq.eq("deleteFlag", Globals.Delete_Normal.toString());
  105. //缴费基数查询
  106. String basePay_begin = request.getParameter("basePay_begin");
  107. String basePay_end = request.getParameter("basePay_end");
  108. if(oConvertUtils.isNotEmpty(basePay_begin)){
  109. cq.ge("basePay", new BigDecimal(basePay_begin).setScale(2, BigDecimal.ROUND_DOWN));
  110. cq.add();
  111. }
  112. if(oConvertUtils.isNotEmpty(basePay_end)){
  113. cq.le("basePay", new BigDecimal(basePay_end).setScale(2, BigDecimal.ROUND_DOWN));
  114. cq.add();
  115. }
  116. //自定义追加查询条件
  117. //适用时间查询
  118. String startTime = request.getParameter("startTime");
  119. String endTime = request.getParameter("endTime");
  120. if(oConvertUtils.isNotEmpty(startTime)){
  121. cq.ge("endTime", DateUtils.parseDate(startTime, "yyyy-MM-dd"));
  122. cq.add();
  123. }
  124. if(oConvertUtils.isNotEmpty(endTime)){
  125. cq.le("startTime", DateUtils.parseDate(endTime, "yyyy-MM-dd"));
  126. cq.add();
  127. }
  128. //状态
  129. String status = request.getParameter("status");
  130. if(oConvertUtils.isNotEmpty(status)){
  131. cq.eq("status", status);
  132. cq.add();
  133. }
  134. //排序
  135. Map map = new HashMap();
  136. map.put("createDate", "desc");
  137. cq.setOrder(map);
  138. }catch (Exception e) {
  139. throw new BusinessException(e.getMessage());
  140. }
  141. cq.add();
  142. this.providentFundStrategyService.getDataGridReturn(cq, true);
  143. TagUtil.datagrid(response, dataGrid);
  144. }
  145. /**
  146. * 删除公积金策略
  147. *
  148. * @return
  149. */
  150. @RequestMapping(params = "doDel")
  151. @ResponseBody
  152. public AjaxJson doDel(ProvidentFundStrategyEntity providentFundStrategy, HttpServletRequest request) {
  153. String message = null;
  154. AjaxJson j = new AjaxJson();
  155. providentFundStrategy = systemService.getEntity(ProvidentFundStrategyEntity.class, providentFundStrategy.getId());
  156. message = "公积金策略表删除成功";
  157. try{
  158. providentFundStrategyService.delete(providentFundStrategy);
  159. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  160. }catch(Exception e){
  161. e.printStackTrace();
  162. message = "公积金策略表删除失败";
  163. throw new BusinessException(e.getMessage());
  164. }
  165. j.setMsg(message);
  166. return j;
  167. }
  168. /**
  169. * 逻辑删除公积金策略
  170. *
  171. * @return
  172. */
  173. @RequestMapping(params = "logicDel")
  174. @ResponseBody
  175. public AjaxJson logicDel(ProvidentFundStrategyEntity providentFundStrategy, HttpServletRequest request) {
  176. String message = null;
  177. AjaxJson j = new AjaxJson();
  178. providentFundStrategy = systemService.getEntity(ProvidentFundStrategyEntity.class, providentFundStrategy.getId());
  179. message = "公积金策略 删除成功";
  180. try{
  181. providentFundStrategy.setDeleteFlag(Globals.Delete_Forbidden.toString());
  182. providentFundStrategyService.logicDel(providentFundStrategy);
  183. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  184. }catch(Exception e){
  185. e.printStackTrace();
  186. message = "公积金策略 删除失败";
  187. throw new BusinessException(e.getMessage());
  188. }
  189. j.setMsg(message);
  190. return j;
  191. }
  192. /**
  193. * 批量删除公积金策略表
  194. *
  195. * @return
  196. */
  197. @RequestMapping(params = "doBatchDel")
  198. @ResponseBody
  199. public AjaxJson doBatchDel(String ids,HttpServletRequest request){
  200. String message = null;
  201. AjaxJson j = new AjaxJson();
  202. message = "公积金策略表删除成功";
  203. try{
  204. for(String id:ids.split(",")){
  205. ProvidentFundStrategyEntity providentFundStrategy = systemService.getEntity(ProvidentFundStrategyEntity.class,
  206. id
  207. );
  208. providentFundStrategyService.delete(providentFundStrategy);
  209. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  210. }
  211. }catch(Exception e){
  212. e.printStackTrace();
  213. message = "公积金策略表删除失败";
  214. throw new BusinessException(e.getMessage());
  215. }
  216. j.setMsg(message);
  217. return j;
  218. }
  219. /**
  220. * 添加公积金策略表
  221. *
  222. * @param ids
  223. * @return
  224. */
  225. @RequestMapping(params = "doAdd")
  226. @ResponseBody
  227. public AjaxJson doAdd(ProvidentFundStrategyEntity providentFundStrategy, HttpServletRequest request) {
  228. String message = null;
  229. AjaxJson j = new AjaxJson();
  230. message = "公积金策略表添加成功";
  231. try{
  232. SimpleDateFormat date_sdf = new SimpleDateFormat("yyyy-MM-dd");
  233. String startTime = request.getParameter("startTime");
  234. String endTime = request.getParameter("endTime");
  235. if(oConvertUtils.isNotEmpty(startTime)){
  236. providentFundStrategy.setStartTime(date_sdf.parse(startTime));
  237. }
  238. if(oConvertUtils.isNotEmpty(endTime)){
  239. providentFundStrategy.setEndTime(date_sdf.parse(endTime));
  240. }
  241. providentFundStrategy.setStatus(Globals.Enabled_Status.toString());
  242. providentFundStrategy.setDeleteFlag(Globals.Delete_Normal.toString());
  243. providentFundStrategyService.save(providentFundStrategy);
  244. systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
  245. }catch(Exception e){
  246. e.printStackTrace();
  247. message = "公积金策略表添加失败";
  248. throw new BusinessException(e.getMessage());
  249. }
  250. j.setMsg(message);
  251. return j;
  252. }
  253. /**
  254. * 更新公积金策略表
  255. *
  256. * @param ids
  257. * @return
  258. */
  259. @RequestMapping(params = "doUpdate")
  260. @ResponseBody
  261. public AjaxJson doUpdate(ProvidentFundStrategyEntity providentFundStrategy, HttpServletRequest request) {
  262. String message = null;
  263. AjaxJson j = new AjaxJson();
  264. message = "公积金策略表更新成功";
  265. ProvidentFundStrategyEntity t = providentFundStrategyService.get(ProvidentFundStrategyEntity.class, providentFundStrategy.getId());
  266. try {
  267. MyBeanUtils.copyBeanNotNull2Bean(providentFundStrategy, t);
  268. providentFundStrategyService.saveOrUpdate(t);
  269. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  270. } catch (Exception e) {
  271. e.printStackTrace();
  272. message = "公积金策略表更新失败";
  273. throw new BusinessException(e.getMessage());
  274. }
  275. j.setMsg(message);
  276. return j;
  277. }
  278. /**
  279. * 公积金策略表新增页面跳转
  280. *
  281. * @return
  282. */
  283. @RequestMapping(params = "goAdd")
  284. public ModelAndView goAdd(ProvidentFundStrategyEntity providentFundStrategy, HttpServletRequest req) {
  285. if (StringUtil.isNotEmpty(providentFundStrategy.getId())) {
  286. providentFundStrategy = providentFundStrategyService.getEntity(ProvidentFundStrategyEntity.class, providentFundStrategy.getId());
  287. req.setAttribute("providentFundStrategyPage", providentFundStrategy);
  288. }
  289. return new ModelAndView("cn/com/lzt/providentfundstrategy/providentFundStrategy-add");
  290. }
  291. /**
  292. * 公积金策略表编辑页面跳转
  293. *
  294. * @return
  295. */
  296. @RequestMapping(params = "goUpdate")
  297. public ModelAndView goUpdate(ProvidentFundStrategyEntity providentFundStrategy, HttpServletRequest req) {
  298. if (StringUtil.isNotEmpty(providentFundStrategy.getId())) {
  299. providentFundStrategy = providentFundStrategyService.getEntity(ProvidentFundStrategyEntity.class, providentFundStrategy.getId());
  300. req.setAttribute("providentFundStrategyPage", providentFundStrategy);
  301. }
  302. return new ModelAndView("cn/com/lzt/providentfundstrategy/providentFundStrategy-update");
  303. }
  304. /**
  305. * 导入功能跳转
  306. *
  307. * @return
  308. */
  309. @RequestMapping(params = "upload")
  310. public ModelAndView upload(HttpServletRequest req) {
  311. req.setAttribute("controller_name","providentFundStrategyController");
  312. return new ModelAndView("common/upload/pub_excel_upload");
  313. }
  314. /**
  315. * 导出excel
  316. *
  317. * @param request
  318. * @param response
  319. */
  320. @RequestMapping(params = "exportXls")
  321. public String exportXls(ProvidentFundStrategyEntity providentFundStrategy,HttpServletRequest request,HttpServletResponse response
  322. , DataGrid dataGrid,ModelMap modelMap) {
  323. CriteriaQuery cq = new CriteriaQuery(ProvidentFundStrategyEntity.class, dataGrid);
  324. try{
  325. // String[] status = new String[]{Globals.Enabled_Status.toString(), Globals.Disabled_Status.toString()};
  326. // cq.in("status", status);
  327. cq.eq("deleteFlag", Globals.Delete_Normal.toString());
  328. //缴费基数查询
  329. String basePay_begin = request.getParameter("basePay_begin");
  330. String basePay_end = request.getParameter("basePay_end");
  331. if(oConvertUtils.isNotEmpty(basePay_begin)){
  332. cq.ge("basePay", new BigDecimal(basePay_begin).setScale(2, BigDecimal.ROUND_DOWN));
  333. cq.add();
  334. }
  335. if(oConvertUtils.isNotEmpty(basePay_end)){
  336. cq.le("basePay", new BigDecimal(basePay_end).setScale(2, BigDecimal.ROUND_DOWN));
  337. cq.add();
  338. }
  339. //自定义追加查询条件
  340. //适用时间查询
  341. String startTime = request.getParameter("startTime");
  342. String endTime = request.getParameter("endTime");
  343. if(oConvertUtils.isNotEmpty(startTime)){
  344. cq.ge("endTime", DateUtils.parseDate(startTime, "yyyy-MM-dd"));
  345. cq.add();
  346. }
  347. if(oConvertUtils.isNotEmpty(endTime)){
  348. cq.le("startTime", DateUtils.parseDate(endTime, "yyyy-MM-dd"));
  349. cq.add();
  350. }
  351. //状态
  352. String status = request.getParameter("status");
  353. if(oConvertUtils.isNotEmpty(status)){
  354. cq.eq("status", status);
  355. cq.add();
  356. }
  357. //排序
  358. Map map = new HashMap();
  359. map.put("createDate", "desc");
  360. cq.setOrder(map);
  361. }catch (Exception e) {
  362. throw new BusinessException(e.getMessage());
  363. }
  364. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, providentFundStrategy, request.getParameterMap());
  365. List<ProvidentFundStrategyEntity> providentFundStrategys = this.providentFundStrategyService.getListByCriteriaQuery(cq,false);
  366. modelMap.put(NormalExcelConstants.FILE_NAME,"公积金策略表");
  367. modelMap.put(NormalExcelConstants.CLASS,ProvidentFundStrategyEntity.class);
  368. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("公积金策略表列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  369. "导出信息"));
  370. modelMap.put(NormalExcelConstants.DATA_LIST,providentFundStrategys);
  371. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  372. }
  373. /**
  374. * 导出excel 使模板
  375. *
  376. * @param request
  377. * @param response
  378. */
  379. @RequestMapping(params = "exportXlsByT")
  380. public String exportXlsByT(ProvidentFundStrategyEntity providentFundStrategy,HttpServletRequest request,HttpServletResponse response
  381. , DataGrid dataGrid,ModelMap modelMap) {
  382. modelMap.put(NormalExcelConstants.FILE_NAME,"公积金策略表");
  383. modelMap.put(NormalExcelConstants.CLASS,ProvidentFundStrategyEntity.class);
  384. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("公积金策略表列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  385. "导出信息"));
  386. modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
  387. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  388. }
  389. @SuppressWarnings("unchecked")
  390. @RequestMapping(params = "importExcel", method = RequestMethod.POST)
  391. @ResponseBody
  392. public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
  393. AjaxJson j = new AjaxJson();
  394. MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
  395. Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
  396. for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
  397. MultipartFile file = entity.getValue();// 获取上传文件对象
  398. ImportParams params = new ImportParams();
  399. params.setTitleRows(2);
  400. params.setHeadRows(1);
  401. params.setNeedSave(true);
  402. try {
  403. List<ProvidentFundStrategyEntity> listProvidentFundStrategyEntitys = ExcelImportUtil.importExcel(file.getInputStream(),ProvidentFundStrategyEntity.class,params);
  404. for (ProvidentFundStrategyEntity providentFundStrategy : listProvidentFundStrategyEntitys) {
  405. providentFundStrategyService.save(providentFundStrategy);
  406. }
  407. j.setMsg("文件导入成功!");
  408. } catch (Exception e) {
  409. j.setMsg("文件导入失败!");
  410. logger.error(ExceptionUtil.getExceptionMessage(e));
  411. }finally{
  412. try {
  413. file.getInputStream().close();
  414. } catch (IOException e) {
  415. e.printStackTrace();
  416. }
  417. }
  418. }
  419. return j;
  420. }
  421. @RequestMapping(method = RequestMethod.GET)
  422. @ResponseBody
  423. public List<ProvidentFundStrategyEntity> list() {
  424. List<ProvidentFundStrategyEntity> listProvidentFundStrategys=providentFundStrategyService.getList(ProvidentFundStrategyEntity.class);
  425. return listProvidentFundStrategys;
  426. }
  427. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  428. @ResponseBody
  429. public ResponseEntity<?> get(@PathVariable("id") String id) {
  430. ProvidentFundStrategyEntity task = providentFundStrategyService.get(ProvidentFundStrategyEntity.class, id);
  431. if (task == null) {
  432. return new ResponseEntity(HttpStatus.NOT_FOUND);
  433. }
  434. return new ResponseEntity(task, HttpStatus.OK);
  435. }
  436. @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
  437. @ResponseBody
  438. public ResponseEntity<?> create(@RequestBody ProvidentFundStrategyEntity providentFundStrategy, UriComponentsBuilder uriBuilder) {
  439. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  440. Set<ConstraintViolation<ProvidentFundStrategyEntity>> failures = validator.validate(providentFundStrategy);
  441. if (!failures.isEmpty()) {
  442. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  443. }
  444. //保存
  445. try{
  446. providentFundStrategyService.save(providentFundStrategy);
  447. } catch (Exception e) {
  448. e.printStackTrace();
  449. return new ResponseEntity(HttpStatus.NO_CONTENT);
  450. }
  451. //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
  452. String id = providentFundStrategy.getId();
  453. URI uri = uriBuilder.path("/rest/providentFundStrategyController/" + id).build().toUri();
  454. HttpHeaders headers = new HttpHeaders();
  455. headers.setLocation(uri);
  456. return new ResponseEntity(headers, HttpStatus.CREATED);
  457. }
  458. @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
  459. public ResponseEntity<?> update(@RequestBody ProvidentFundStrategyEntity providentFundStrategy) {
  460. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  461. Set<ConstraintViolation<ProvidentFundStrategyEntity>> failures = validator.validate(providentFundStrategy);
  462. if (!failures.isEmpty()) {
  463. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  464. }
  465. //保存
  466. try{
  467. providentFundStrategyService.saveOrUpdate(providentFundStrategy);
  468. } catch (Exception e) {
  469. e.printStackTrace();
  470. return new ResponseEntity(HttpStatus.NO_CONTENT);
  471. }
  472. //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
  473. return new ResponseEntity(HttpStatus.NO_CONTENT);
  474. }
  475. @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  476. @ResponseStatus(HttpStatus.NO_CONTENT)
  477. public void delete(@PathVariable("id") String id) {
  478. providentFundStrategyService.deleteEntityById(ProvidentFundStrategyEntity.class, id);
  479. }
  480. /**
  481. * 启用
  482. *
  483. * @author zhijia.wang
  484. */
  485. @RequestMapping(params = "enable")
  486. @ResponseBody
  487. public AjaxJson enable(String id, HttpServletRequest req) {
  488. AjaxJson j = new AjaxJson();
  489. String message = null;
  490. ProvidentFundStrategyEntity providentFundStrategy = providentFundStrategyService.getEntity(ProvidentFundStrategyEntity.class, id);
  491. try{
  492. providentFundStrategy.setStatus(Globals.Enabled_Status.toString());
  493. providentFundStrategyService.updateEntitie(providentFundStrategy);
  494. message = "公积金策略:" + "" + "启用成功!";
  495. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  496. }catch(Exception e){
  497. message = "操作失败!";
  498. }
  499. j.setMsg(message);
  500. return j;
  501. }
  502. /**
  503. * 停用
  504. *
  505. * @author zhijia.wang
  506. */
  507. @RequestMapping(params = "disable")
  508. @ResponseBody
  509. public AjaxJson disable(String id, HttpServletRequest req) {
  510. AjaxJson j = new AjaxJson();
  511. String message = null;
  512. ProvidentFundStrategyEntity providentFundStrategy = providentFundStrategyService.getEntity(ProvidentFundStrategyEntity.class, id);
  513. try{
  514. providentFundStrategy.setStatus(Globals.Disabled_Status.toString());
  515. providentFundStrategyService.updateEntitie(providentFundStrategy);
  516. message = "公积金策略:" + "" + "停用成功!";
  517. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  518. }catch(Exception e){
  519. message = "操作失败!";
  520. }
  521. j.setMsg(message);
  522. return j;
  523. }
  524. /**
  525. * 判断公积金名称是否重复
  526. *
  527. * @return
  528. * @throws ParseException
  529. */
  530. @RequestMapping(params = "isCorrection")
  531. @ResponseBody
  532. public AjaxJson isCorrection(HttpServletRequest request) throws ParseException {
  533. AjaxJson j = new AjaxJson();
  534. String id = request.getParameter("id");
  535. String providentFundName = request.getParameter("providentFundName");
  536. j.setSuccess(true);
  537. j.setMsg("无重复");
  538. if(StringUtils.isNotEmpty(providentFundName)){
  539. List<ProvidentFundStrategyEntity> per= providentFundStrategyService.findByQueryString(" FROM ProvidentFundStrategyEntity where providentFundName = '"+providentFundName+"'");
  540. //ProvidentFundStrategyEntity per = providentFundStrategyService.findUniqueByProperty(ProvidentFundStrategyEntity.class, "providentFundName", providentFundName);
  541. if(per != null && !per.isEmpty()){
  542. if(oConvertUtils.isEmpty(id)){
  543. j.setSuccess(false);
  544. j.setMsg("公积金策略名称重复,请重新输入!");
  545. return j;
  546. }else{
  547. if(per.size() > 1){
  548. j.setSuccess(false);
  549. j.setMsg("公积金策略名称重复,请重新输入!");
  550. return j;
  551. }
  552. }
  553. }
  554. }
  555. return j;
  556. }
  557. }