BwxxService.java 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. package com.cxfws.jyrxxgl.service.impl;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import javax.annotation.Resource;
  5. import javax.jws.WebMethod;
  6. import javax.jws.WebResult;
  7. import javax.jws.WebService;
  8. import javax.persistence.criteria.CriteriaBuilder;
  9. import javax.persistence.criteria.CriteriaBuilder.In;
  10. import javax.persistence.criteria.CriteriaQuery;
  11. import javax.persistence.criteria.Predicate;
  12. import javax.persistence.criteria.Root;
  13. import javax.xml.ws.WebServiceContext;
  14. import net.sf.json.JSONArray;
  15. import org.springframework.beans.BeanUtils;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.data.jpa.domain.Specification;
  18. import org.springframework.stereotype.Service;
  19. import com.cxfws.config.utils.CxfwsUtils;
  20. import com.cxfws.jyrxxgl.service.IBwxxService;
  21. import com.xt.jygl.common.BaseWebCtl;
  22. import com.xt.jygl.gkjcxx.gk.service.GkService;
  23. import com.xt.jygl.gkjcxx.gq.service.GqService;
  24. import com.xt.jygl.gkjygl.gkjyr.jyrbw.service.BwService;
  25. import com.xt.jygl.gkjygl.gkjyr.jyrjbxx.entity.BwEntity;
  26. import com.xt.jygl.gkjygl.gkjyr.jyrjbxx.service.GkjyrService;
  27. import com.xt.jygl.gkjygl.gkjyr.jyrjbxx.vo.BwVo;
  28. import com.xt.jygl.gkjygl.gkjyr.xkzxx.service.XkzglbService;
  29. import com.xtframe.sec.code.entity.CodeEntity;
  30. import com.xtframe.sec.common.BaseEntity;
  31. import com.xtframe.sec.common.QueryService;
  32. import com.xtframe.sec.user.dao.UserDao;
  33. import com.xtframe.sec.user.entity.UserEntity;
  34. import com.xtframe.util.StringUtils;
  35. /**
  36. * 泊位信息
  37. *
  38. */
  39. @Service("bwWebService")
  40. @WebService(targetNamespace = "http://service.web.jsjty.com/", portName = "bwWebServicePort", serviceName = "bwWebService")
  41. public class BwxxService extends BaseWebCtl implements IBwxxService{
  42. @Autowired
  43. private QueryService query;
  44. @Autowired
  45. private BwService bwService;
  46. @Autowired
  47. private GkService gkService;
  48. @Autowired
  49. private GqService gqService;
  50. @Autowired
  51. private GkjyrService gkjyrService;
  52. @Autowired
  53. private XkzglbService xkzglbService;
  54. @Resource
  55. private WebServiceContext wscontext;
  56. @Autowired
  57. private UserDao userdao;
  58. @Override
  59. @WebMethod(operationName = "findBw", action = "http://service.web.jsjty.com/findBw")
  60. @WebResult(name = "result", targetNamespace = "http://service.web.jsjty.com/")
  61. public String findBw(final String szdid,final String szgkid,final String szgqid, final String ssjyr, final String bwmc,final String wxpbwid,final String sfdwkfid, final String fwlxid, final String bwbwyt) {
  62. if (!this.checkUser()){
  63. return BaseWebCtl.NOLOGIN;
  64. }
  65. // 查詢條件
  66. Specification<BwEntity> spec = new Specification<BwEntity>() {
  67. @Override
  68. public Predicate toPredicate(Root<BwEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
  69. List<Predicate> list = new ArrayList<Predicate>();
  70. if (StringUtils.isNotEmpty(szdid)) {
  71. list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + szdid + "%"));
  72. }
  73. if (StringUtils.isNotEmpty(szgkid)) {
  74. list.add(cb.like(root.get("szgk").get("id").as(String.class), "%" + szgkid + "%"));
  75. }
  76. if (StringUtils.isNotEmpty(szgqid)) {
  77. list.add(cb.like(root.get("szgq").get("id").as(String.class), "%" + szgqid + "%"));
  78. }
  79. if (StringUtils.isNotEmpty(ssjyr)) {
  80. list.add(cb.like(root.get("ssjyr").get("gkjyr").as(String.class), "%" + ssjyr + "%"));
  81. }
  82. if (StringUtils.isNotEmpty(bwmc)) {
  83. list.add(cb.like(root.get("bwmc").as(String.class), "%" + bwmc + "%"));
  84. }
  85. if (StringUtils.isNotEmpty(wxpbwid)) {
  86. list.add(cb.like(root.get("wxpbw").get("id").as(String.class), "%" + wxpbwid + "%"));
  87. }
  88. if (StringUtils.isNotEmpty(fwlxid)) {
  89. list.add(cb.like(root.get("fwlx").get("id").as(String.class), "%" + fwlxid + "%"));
  90. }
  91. if (StringUtils.isNotEmpty(sfdwkfid)) {
  92. list.add(cb.like(root.get("sfdwkf").get("id").as(String.class), "%" + sfdwkfid + "%"));
  93. }
  94. if (StringUtils.isNotEmpty(bwbwyt)) {
  95. list.add(cb.like(root.get("bwyt").as(String.class), "%" + bwbwyt + "%"));
  96. }
  97. String userName=CxfwsUtils.userNameFromHeaderInfo(wscontext);
  98. UserEntity userEntity = userdao.findByUname(userName);
  99. if (userEntity.getSsjyr()!=null) {
  100. list.add(cb.like(root.get("ssjyr").get("id").as(String.class), "%" + getSsjyr().getId() + "%"));
  101. } else {
  102. In<String> in = cb.in(root.get("szgq").get("id").as(String.class));
  103. List<String> gqlist = gqService.findGqListByUserId(userEntity.getId());
  104. if (gqlist != null && gqlist.size() > 0) {
  105. for (int i = 0; i < gqlist.size(); i++) {
  106. in.value(gqlist.get(i));
  107. }
  108. list.add(in);
  109. }
  110. }
  111. // 状态为0,9,10,11不显示
  112. list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_COPY));
  113. list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_DELETE));
  114. list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_BGFLAG));
  115. list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_ZXFLAG));
  116. return cb.and(list.toArray(new Predicate[] {}));
  117. }
  118. };
  119. List<BwEntity> bwlist = query.findAll(spec, BwEntity.class);
  120. return Object2JsonStr(bwlist);
  121. }
  122. @Override
  123. public String findOne(String id) {
  124. if (!this.checkUser()){
  125. return BaseWebCtl.NOLOGIN;
  126. }
  127. BwEntity entity = bwService.findOne(id);
  128. BwVo vo = new BwVo();
  129. if (entity != null) {
  130. BeanUtils.copyProperties(entity, vo);
  131. vo.setSzdzw(entity.getSzd() != null ? entity.getSzd().getText() : "");
  132. vo.setSzgkzw(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
  133. vo.setSzgqzw(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
  134. vo.setSsjyrzw(entity.getSsjyr() != null ? entity.getSsjyr().getGkjyr() : "");
  135. vo.setSsmtzw(entity.getSsmt() != null ? entity.getSsmt().getMtmc() : "");
  136. vo.setBwsxzw(entity.getBwsx() != null ? entity.getBwsx().getText() : "");
  137. vo.setFwlxzw(entity.getFwlx() != null ? entity.getFwlx().getText() : "");
  138. vo.setWxpbwzw(entity.getWxpbw() != null ? entity.getWxpbw().getText() : "");
  139. vo.setZyhbwflzw(entity.getZyhbwfl() != null ? entity.getZyhbwfl().getText() : "");
  140. vo.setSffzzw(entity.getSffz() != null ? entity.getSffz().getText() : "");
  141. vo.setSfdwkfzw(entity.getSfdwkf() != null ? entity.getSfdwkf().getText() : "");
  142. vo.setBwszsxzw(entity.getBwszsx() != null ? entity.getBwszsx().getText() : "");
  143. vo.setSclxzw(entity.getSclx() != null ? entity.getSclx().getText() : "");
  144. vo.setJgxszw(entity.getJgxs() != null ? entity.getJgxs().getText() : "");
  145. vo.setKbcblxzw(entity.getKbcblx() != null ? entity.getKbcblx().getText() : "");
  146. vo.setSszyq(entity.getSszyq() != null ? entity.getSszyq().getId() : "");
  147. vo.setSszyqzw(entity.getSszyq() != null ? entity.getSszyq().getZyqmc() : "");
  148. vo.setZls(entity.getZls() != null ? entity.getZls().getId() : "");
  149. vo.setZlszw(entity.getZls() != null ? entity.getZls().getText() : "");
  150. vo.setXp(entity.getXp() != null ? entity.getXp().getId() : "");
  151. vo.setXpzw(entity.getXp() != null ? entity.getXp().getText() : "");
  152. vo.setBwszhd(entity.getBwszhd() != null ? entity.getBwszhd().getText() : "");
  153. if (entity.getBwyt() != null) {
  154. String bwytzw = "";
  155. String[] s = entity.getBwyt().split(",");
  156. /*
  157. * for (String string : s) { bwytzw +=
  158. * securityMgr.codeService().findOne(string).getText(); }
  159. */
  160. for (int i = 0; i < s.length; i++) {
  161. CodeEntity ce = securityMgr.codeService().findOne(s[i]);
  162. if (ce != null) {
  163. bwytzw += ce.getText();
  164. if (i != s.length - 1) {
  165. bwytzw += ",";
  166. }
  167. }
  168. }
  169. vo.setBwytzw(bwytzw);
  170. }
  171. vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
  172. vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
  173. vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
  174. vo.setSsjyr(entity.getSsjyr() != null ? entity.getSsjyr().getId() : "");
  175. vo.setSsmt(entity.getSsmt() != null ? entity.getSsmt().getId() : "");
  176. vo.setBwsx(entity.getBwsx() != null ? entity.getBwsx().getId() : "");
  177. vo.setFwlx(entity.getFwlx() != null ? entity.getFwlx().getId() : "");
  178. vo.setWxpbw(entity.getWxpbw() != null ? entity.getWxpbw().getId() : "");
  179. vo.setZyhbwfl(entity.getZyhbwfl() != null ? entity.getZyhbwfl().getId() : "");
  180. vo.setSffz(entity.getSffz() != null ? entity.getSffz().getId() : "");
  181. vo.setSfdwkf(entity.getSfdwkf() != null ? entity.getSfdwkf().getId() : "");
  182. vo.setBwszsx(entity.getBwszsx() != null ? entity.getBwszsx().getId() : "");
  183. vo.setSclx(entity.getSclx() != null ? entity.getSclx().getId() : "");
  184. vo.setJgxs(entity.getJgxs() != null ? entity.getJgxs().getId() : "");
  185. }
  186. JSONArray jsons=JSONArray.fromObject(vo);
  187. return jsons.toString();
  188. }
  189. }