XkzfzWebService.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. package com.cxfws.jyrxxgl.service.impl;
  2. import java.text.SimpleDateFormat;
  3. import java.util.ArrayList;
  4. import java.util.Calendar;
  5. import java.util.Date;
  6. import java.util.List;
  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.Expression;
  12. import javax.persistence.criteria.Predicate;
  13. import javax.persistence.criteria.Root;
  14. import org.springframework.beans.BeanUtils;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.data.domain.Page;
  17. import org.springframework.data.jpa.domain.Specification;
  18. import org.springframework.stereotype.Service;
  19. import com.cxfws.jyrxxgl.service.IXkzfzWebService;
  20. import com.xt.jygl.accessory.service.AccessoryService;
  21. import com.xt.jygl.common.BaseWebCtl;
  22. import com.xt.jygl.common.SearchCondition;
  23. import com.xt.jygl.common.Utils;
  24. import com.xt.jygl.gkjcxx.gk.entity.GkEntity;
  25. import com.xt.jygl.gkjcxx.gk.service.GkService;
  26. import com.xt.jygl.gkjcxx.gq.entity.GqEntity;
  27. import com.xt.jygl.gkjcxx.gq.service.GqService;
  28. import com.xt.jygl.gkjygl.gkjyr.jyrjbxx.service.GkjyrService;
  29. import com.xt.jygl.gkjygl.gkjyr.xkzfz.entity.XkzfzEntity;
  30. import com.xt.jygl.gkjygl.gkjyr.xkzfz.service.XkzfzService;
  31. import com.xt.jygl.gkjygl.gkjyr.xkzfz.vo.XkzfzVo;
  32. import com.xt.jygl.gkjygl.gkjyr.xkzxx.service.XkzxxService;
  33. import com.xtframe.sec.code.entity.CodeEntity;
  34. import com.xtframe.sec.common.BaseEntity;
  35. import com.xtframe.sec.common.QueryService;
  36. import com.xtframe.sec.common.SimplePageRequest;
  37. import com.xtframe.sec.utils.SecUtils;
  38. import com.xtframe.util.DateTime;
  39. import com.xtframe.util.StringUtils;
  40. import net.sf.json.JSONArray;
  41. @Service
  42. @WebService(targetNamespace = "http://service.web.jsjty.com/", portName = "xkzfzWebServicePort", serviceName = "xkzfzWebService")
  43. public class XkzfzWebService extends BaseWebCtl implements IXkzfzWebService {
  44. @Autowired
  45. private QueryService query;
  46. @Autowired
  47. private GqService gqService;
  48. @Autowired
  49. private GkService gkService;
  50. @Autowired
  51. private GkjyrService gkjyrService;
  52. @Autowired
  53. private XkzxxService xkzxxService;
  54. @Autowired
  55. private AccessoryService accessoryService;
  56. @Autowired
  57. private XkzfzService xkzfzService;
  58. //列表
  59. @Override
  60. public String findXkzfz(int pages, int rows,final String ssjyr, final String szdid, final String szgkid, final String szgqid, final String fzsqh, final String fzsfyx, final String wxhwpm, final String fzsfdq){
  61. if (!this.checkUser()){
  62. return BaseWebCtl.NOLOGIN;
  63. }
  64. SimplePageRequest page = new SimplePageRequest(pages, rows);
  65. final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  66. // 查询条件
  67. Specification<XkzfzEntity> spec = new Specification<XkzfzEntity>() {
  68. @Override
  69. public Predicate toPredicate(Root<XkzfzEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
  70. List<Predicate> list = new ArrayList<Predicate>();
  71. if (StringUtils.isNotEmpty(szdid)) {
  72. list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + szdid + "%"));
  73. }
  74. // else if (StringUtils.isNotEmpty(SearchCondition.xkzszdid) &&
  75. // isGET(request)) {
  76. // list.add(cb.like(root.get("szd").get("id").as(String.class),
  77. // "%" + SearchCondition.xkzszdid + "%"));
  78. // }
  79. if (StringUtils.isNotEmpty(szgkid)) {
  80. list.add(cb.like(root.get("szgk").as(String.class), "%" + szgkid + "%"));
  81. }
  82. // else if (StringUtils.isNotEmpty(SearchCondition.xkzszgkid) &&
  83. // isGET(request)) {
  84. // list.add(cb.like(root.get("szgk").as(String.class), "%" +
  85. // SearchCondition.xkzszgkid + "%"));
  86. // }
  87. if (StringUtils.isNotEmpty(szgqid)) {
  88. list.add(cb.like(root.get("ssgq").as(String.class), "%" + szgqid + "%"));
  89. }
  90. // else if (StringUtils.isNotEmpty(SearchCondition.xkzszgqid) &&
  91. // isGET(request)) {
  92. // list.add(cb.like(root.get("ssgq").as(String.class), "%" +
  93. // SearchCondition.xkzszgqid + "%"));
  94. // }
  95. if (StringUtils.isNotEmpty(ssjyr)) {
  96. list.add(cb.like(root.get("ssjyr").get("gkjyr").as(String.class), "%" + ssjyr + "%"));
  97. }
  98. // else if (StringUtils.isNotEmpty(SearchCondition.xkzgkjyr) &&
  99. // isGET(request)) {
  100. // list.add(cb.like(root.get("gkjyr").as(String.class), "%" +
  101. // SearchCondition.xkzgkjyr + "%"));
  102. // }
  103. if (StringUtils.isNotEmpty(fzsqh)) {
  104. list.add(cb.like(root.get("fzsqh").as(String.class), "%" + fzsqh + "%"));
  105. }
  106. if (StringUtils.isNotEmpty(wxhwpm)) {
  107. list.add(cb.like(root.get("wxhwpm").as(String.class), wxhwpm));
  108. }
  109. if (StringUtils.isNotEmpty(fzsfyx)) {
  110. if (("是").equals(fzsfyx)) {
  111. list.add(cb.equal(root.get("recordStatus").as(String.class), "1"));
  112. } else {
  113. list.add(cb.notEqual(root.get("recordStatus").as(String.class), "1"));
  114. }
  115. }
  116. Date now = new Date();
  117. if (StringUtils.isNotEmpty(fzsfdq)) {
  118. if ((fzsfdq).equals("6103")) {
  119. list.add(cb.lessThanOrEqualTo(root.get("yxqjssj").as(Date.class), now));
  120. } else if ((fzsfdq).equals("6101")) {
  121. list.add(cb.greaterThan(root.get("yxqjssj").as(Date.class), now));
  122. } else {
  123. list.add(cb.lessThanOrEqualTo(root.get("yxqjssj").as(Date.class), DateTime.addDays(now, 30)));
  124. }
  125. }
  126. // 经营人只能查看自己企业下的数据,非经营人只能查看自己所在地的数据
  127. if (isJyr()) {
  128. list.add(cb.like(root.get("ssjyr").get("id").as(String.class), "%" + getSsjyr().getId() + "%"));
  129. } else {
  130. In<String> in = cb.in(root.get("szgq").get("id").as(String.class));
  131. @SuppressWarnings("unchecked")
  132. List<String> gqlist = gqService.findGqListByUserId(SecUtils.getCurrUser().getId());
  133. if (gqlist != null && gqlist.size() > 0) {
  134. for (int i = 0; i < gqlist.size(); i++) {
  135. in.value(gqlist.get(i));
  136. }
  137. list.add(in);
  138. }
  139. }
  140. list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_DELETE));
  141. list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_COPY));
  142. return cb.and(list.toArray(new Predicate[] {}));
  143. }
  144. };
  145. if (page.getPage() < 1) {
  146. // Object xmxxpage = CacheSearchCondition.cacheSCmapVal(cacheSCmap, "xmxxpage");
  147. // if (StringUtils.isEmpty(xmxxpage) || !org.apache.commons.lang.StringUtils.isNumeric(String.valueOf(xmxxpage))) {
  148. // xmxxpage = "1";
  149. // }
  150. page.setPage(1);
  151. }
  152. page.setSort("yxqjssj");
  153. page.setOrder("desc");
  154. Page<XkzfzEntity> list = query.findAll(spec, toPageRequest(page),XkzfzEntity.class);
  155. List<XkzfzVo> voList = new ArrayList<XkzfzVo>();
  156. for (XkzfzEntity entity : list) {
  157. XkzfzVo vo = new XkzfzVo();
  158. if (entity != null) {
  159. BeanUtils.copyProperties(entity, vo);
  160. if (null != entity.getFzsj()) {
  161. vo.setFzsjfmt(DateTime.toString(DateTime.toDate(entity.getFzsj())));
  162. }
  163. if (null != entity.getYxqkssj()) {
  164. vo.setYxqkssjfmt(DateTime.toString(DateTime.toDate(entity.getYxqkssj())));
  165. }
  166. if (null != entity.getYxqjssj()) {
  167. vo.setYxqjssjfmt(DateTime.toString(DateTime.toDate(entity.getYxqjssj())));
  168. }
  169. vo.setSzdzw(entity.getSzd() != null ? entity.getSzd().getText() : "");
  170. vo.setSzgkzw(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
  171. vo.setSzgqzw(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
  172. vo.setSsjyrzw(entity.getSsjyr() != null ? entity.getSsjyr().getGkjyr() : "");
  173. vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
  174. vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
  175. vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
  176. vo.setSsjyr(entity.getSsjyr() != null ? entity.getSsjyr().getId() : "");
  177. Calendar time = Calendar.getInstance();
  178. time.set(Calendar.HOUR_OF_DAY, 0);
  179. time.set(Calendar.MINUTE, 0);
  180. time.set(Calendar.SECOND, 0);
  181. if (vo.getYxqjssjfmt() != null && DateTime.toDate(entity.getYxqjssj()).getTime() > time.getTimeInMillis()) {
  182. vo.setRecordStatus(1);
  183. } else {
  184. vo.setRecordStatus(9);
  185. }
  186. voList.add(vo);
  187. }
  188. }
  189. return JSONArray.fromObject(voList).toString();
  190. }
  191. //详情查询
  192. public String findOne(String id) {
  193. if (!this.checkUser()){
  194. return BaseWebCtl.NOLOGIN;
  195. }
  196. XkzfzEntity entity = xkzfzService.findOne(id);
  197. XkzfzVo vo = new XkzfzVo();
  198. BeanUtils.copyProperties(entity, vo);
  199. vo.setSzdzw(entity.getSzd() != null ? entity.getSzd().getText() : "");
  200. vo.setSzgkzw(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
  201. vo.setSzgqzw(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
  202. vo.setSsjyrzw(entity.getSsjyr() != null ? entity.getSsjyr().getGkjyr() : "");
  203. vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
  204. vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
  205. vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
  206. vo.setSsjyr(entity.getSsjyr() != null ? entity.getSsjyr().getId() : "");
  207. if (null != entity.getFzsj()) {
  208. vo.setFzsjfmt(DateTime.toString(DateTime.toDate(entity.getFzsj())));
  209. }
  210. if (null != entity.getYxqkssj()) {
  211. vo.setYxqkssjfmt(DateTime.toString(DateTime.toDate(entity.getYxqkssj())));
  212. }
  213. if (null != entity.getYxqjssj()) {
  214. vo.setYxqjssjfmt(DateTime.toString(DateTime.toDate(entity.getYxqjssj())));
  215. }
  216. // zycs cq whdj
  217. if (vo.getZycs() != null) {
  218. CodeEntity zycs = securityMgr.codeService().findOne(vo.getZycs());
  219. if (null != zycs) {
  220. vo.setZycszw(zycs.getText());
  221. }
  222. }
  223. if (vo.getCq() != null) {
  224. CodeEntity cq = securityMgr.codeService().findOne(vo.getCq());
  225. if (null != cq) {
  226. vo.setCqzw(cq.getText());
  227. }
  228. }
  229. if (vo.getWhdj() != null) {
  230. CodeEntity whdj = securityMgr.codeService().findOne(vo.getWhdj());
  231. if (null != whdj) {
  232. vo.setWhdjzw(whdj.getText());
  233. }
  234. }
  235. List<CodeEntity> listZycs = securityMgr.codeService().findValidCodesByGroupCode("ZYCS");
  236. List<GqEntity> listgq = gqService.findGq();
  237. List<GkEntity> listgk = gkService.findGk();
  238. return JSONArray.fromObject(vo).toString();
  239. }
  240. }