GqxxService.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package com.cxfws.gkjcxx.service.impl;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import javax.jws.WebMethod;
  5. import javax.jws.WebResult;
  6. import javax.jws.WebService;
  7. import javax.persistence.criteria.CriteriaBuilder;
  8. import javax.persistence.criteria.CriteriaQuery;
  9. import javax.persistence.criteria.Predicate;
  10. import javax.persistence.criteria.Root;
  11. import net.sf.json.JSONArray;
  12. import org.springframework.beans.BeanUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.data.domain.Page;
  15. import org.springframework.data.jpa.domain.Specification;
  16. import org.springframework.stereotype.Service;
  17. import com.cxfws.gkjcxx.service.IGqxxService;
  18. import com.xt.jygl.common.BaseWebCtl;
  19. import com.xt.jygl.ggfwxxgl.tzgg.ggxx.vo.GgxxVo;
  20. import com.xt.jygl.gkjcxx.gq.dao.GqDao;
  21. import com.xt.jygl.gkjcxx.gq.entity.GqEntity;
  22. import com.xt.jygl.gkjcxx.gq.vo.GqVo;
  23. import com.xtframe.sec.common.BaseEntity;
  24. import com.xtframe.sec.common.QueryService;
  25. import com.xtframe.sec.common.SimplePageRequest;
  26. import com.xtframe.util.StringUtils;
  27. /**
  28. * 港区信息查询
  29. *
  30. */
  31. @Service("gqWebService")
  32. @WebService(targetNamespace = "http://service.web.jsjty.com/", portName = "gqWebServicePort", serviceName = "gqWebService")
  33. public class GqxxService extends BaseWebCtl implements IGqxxService{
  34. @Autowired
  35. private QueryService query;
  36. @Autowired
  37. private GqDao dao;
  38. @Override
  39. @WebMethod(operationName = "findGq", action = "http://service.web.jsjty.com/excTable")
  40. @WebResult(name = "result", targetNamespace = "http://service.web.jsjty.com/")
  41. public String findGq(int pages, int rows,final String szd, final String ssgkglbm, final String szgkid, final String gqszsylx, final String gqmc) {
  42. if (!this.checkUser()){
  43. return BaseWebCtl.NOLOGIN;
  44. }
  45. SimplePageRequest page = new SimplePageRequest(pages, rows);
  46. // 查询条件
  47. Specification<GqEntity> spec = new Specification<GqEntity>() {
  48. @Override
  49. public Predicate toPredicate(Root<GqEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
  50. List<Predicate> list = new ArrayList<Predicate>();
  51. if (StringUtils.isNotEmpty(gqmc)) {
  52. list.add(cb.like(root.get("gqmc").as(String.class), "%" + gqmc + "%"));
  53. }
  54. if (StringUtils.isNotEmpty(gqszsylx)) {
  55. list.add(cb.like(root.get("gqszsylx").get("id").as(String.class), "%" + gqszsylx + "%"));
  56. }
  57. if (StringUtils.isNotEmpty(szgkid)) {
  58. list.add(cb.like(root.get("szgk").get("id").as(String.class), "%" + szgkid + "%"));
  59. }
  60. if (StringUtils.isNotEmpty(szd)) {
  61. list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + szd + "%"));
  62. }
  63. if (StringUtils.isNotEmpty(ssgkglbm)) {
  64. list.add(cb.like(root.get("ssgkglbm").get("id").as(String.class), "%" + ssgkglbm + "%"));
  65. }
  66. list.add(cb.notEqual(root.get("recordStatus").as(String.class), BaseEntity.RECORD_STATE_DELETE));
  67. return cb.and(list.toArray(new Predicate[] {}));
  68. }
  69. };
  70. if (page.getPage() < 1) {
  71. // Object xmxxpage = CacheSearchCondition.cacheSCmapVal(cacheSCmap, "xmxxpage");
  72. // if (StringUtils.isEmpty(xmxxpage) || !org.apache.commons.lang.StringUtils.isNumeric(String.valueOf(xmxxpage))) {
  73. // xmxxpage = "1";
  74. // }
  75. page.setPage(1);
  76. }
  77. page.setSort("id");
  78. page.setOrder("desc");
  79. Page<GqEntity> gqlist = query.findAll(spec, toPageRequest(page),GqEntity.class);
  80. //List<GqEntity> gqlist = query.findAll(spec, GqEntity.class);
  81. List<GqVo> voList = new ArrayList<GqVo>();
  82. for(GqEntity entity:gqlist){
  83. GqVo vo=new GqVo();
  84. if(entity!=null){
  85. BeanUtils.copyProperties(entity, vo);
  86. voList.add(vo);
  87. }
  88. }
  89. JSONArray jsons=JSONArray.fromObject(voList);
  90. return jsons.toString();
  91. }
  92. /***
  93. * 根据id
  94. */
  95. @Override
  96. public String findOne(String id) {
  97. GqEntity gq = dao.findOne(id);
  98. GqVo vo=new GqVo();
  99. BeanUtils.copyProperties(gq, vo);
  100. JSONArray jsons=JSONArray.fromObject(vo);
  101. return jsons.toString();
  102. }
  103. }