package com.cxfws.gkjcxx.service.impl; import java.util.ArrayList; import java.util.List; import javax.jws.WebMethod; import javax.jws.WebResult; import javax.jws.WebService; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import net.sf.json.JSONArray; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import com.cxfws.gkjcxx.service.IGqxxService; import com.xt.jygl.common.BaseWebCtl; import com.xt.jygl.ggfwxxgl.tzgg.ggxx.vo.GgxxVo; import com.xt.jygl.gkjcxx.gq.dao.GqDao; import com.xt.jygl.gkjcxx.gq.entity.GqEntity; import com.xt.jygl.gkjcxx.gq.vo.GqVo; import com.xtframe.sec.common.BaseEntity; import com.xtframe.sec.common.QueryService; import com.xtframe.sec.common.SimplePageRequest; import com.xtframe.util.StringUtils; /** * 港区信息查询 * */ @Service("gqWebService") @WebService(targetNamespace = "http://service.web.jsjty.com/", portName = "gqWebServicePort", serviceName = "gqWebService") public class GqxxService extends BaseWebCtl implements IGqxxService{ @Autowired private QueryService query; @Autowired private GqDao dao; @Override @WebMethod(operationName = "findGq", action = "http://service.web.jsjty.com/excTable") @WebResult(name = "result", targetNamespace = "http://service.web.jsjty.com/") public String findGq(int pages, int rows,final String szd, final String ssgkglbm, final String szgkid, final String gqszsylx, final String gqmc) { if (!this.checkUser()){ return BaseWebCtl.NOLOGIN; } SimplePageRequest page = new SimplePageRequest(pages, rows); // 查询条件 Specification spec = new Specification() { @Override public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) { List list = new ArrayList(); if (StringUtils.isNotEmpty(gqmc)) { list.add(cb.like(root.get("gqmc").as(String.class), "%" + gqmc + "%")); } if (StringUtils.isNotEmpty(gqszsylx)) { list.add(cb.like(root.get("gqszsylx").get("id").as(String.class), "%" + gqszsylx + "%")); } if (StringUtils.isNotEmpty(szgkid)) { list.add(cb.like(root.get("szgk").get("id").as(String.class), "%" + szgkid + "%")); } if (StringUtils.isNotEmpty(szd)) { list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + szd + "%")); } if (StringUtils.isNotEmpty(ssgkglbm)) { list.add(cb.like(root.get("ssgkglbm").get("id").as(String.class), "%" + ssgkglbm + "%")); } list.add(cb.notEqual(root.get("recordStatus").as(String.class), BaseEntity.RECORD_STATE_DELETE)); return cb.and(list.toArray(new Predicate[] {})); } }; if (page.getPage() < 1) { // Object xmxxpage = CacheSearchCondition.cacheSCmapVal(cacheSCmap, "xmxxpage"); // if (StringUtils.isEmpty(xmxxpage) || !org.apache.commons.lang.StringUtils.isNumeric(String.valueOf(xmxxpage))) { // xmxxpage = "1"; // } page.setPage(1); } page.setSort("id"); page.setOrder("desc"); Page gqlist = query.findAll(spec, toPageRequest(page),GqEntity.class); //List gqlist = query.findAll(spec, GqEntity.class); List voList = new ArrayList(); for(GqEntity entity:gqlist){ GqVo vo=new GqVo(); if(entity!=null){ BeanUtils.copyProperties(entity, vo); voList.add(vo); } } JSONArray jsons=JSONArray.fromObject(voList); return jsons.toString(); } /*** * 根据id */ @Override public String findOne(String id) { GqEntity gq = dao.findOne(id); GqVo vo=new GqVo(); BeanUtils.copyProperties(gq, vo); JSONArray jsons=JSONArray.fromObject(vo); return jsons.toString(); } }