123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- package com.cxfws.jyrxxgl.service.impl;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.List;
- import javax.jws.WebService;
- import javax.persistence.criteria.CriteriaBuilder;
- import javax.persistence.criteria.CriteriaBuilder.In;
- import javax.persistence.criteria.CriteriaQuery;
- import javax.persistence.criteria.Expression;
- import javax.persistence.criteria.Predicate;
- import javax.persistence.criteria.Root;
- 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.jyrxxgl.service.IXkzfzWebService;
- import com.xt.jygl.accessory.service.AccessoryService;
- import com.xt.jygl.common.BaseWebCtl;
- import com.xt.jygl.common.SearchCondition;
- import com.xt.jygl.common.Utils;
- import com.xt.jygl.gkjcxx.gk.entity.GkEntity;
- import com.xt.jygl.gkjcxx.gk.service.GkService;
- import com.xt.jygl.gkjcxx.gq.entity.GqEntity;
- import com.xt.jygl.gkjcxx.gq.service.GqService;
- import com.xt.jygl.gkjygl.gkjyr.jyrjbxx.service.GkjyrService;
- import com.xt.jygl.gkjygl.gkjyr.xkzfz.entity.XkzfzEntity;
- import com.xt.jygl.gkjygl.gkjyr.xkzfz.service.XkzfzService;
- import com.xt.jygl.gkjygl.gkjyr.xkzfz.vo.XkzfzVo;
- import com.xt.jygl.gkjygl.gkjyr.xkzxx.service.XkzxxService;
- import com.xtframe.sec.code.entity.CodeEntity;
- import com.xtframe.sec.common.BaseEntity;
- import com.xtframe.sec.common.QueryService;
- import com.xtframe.sec.common.SimplePageRequest;
- import com.xtframe.sec.utils.SecUtils;
- import com.xtframe.util.DateTime;
- import com.xtframe.util.StringUtils;
- import net.sf.json.JSONArray;
- @Service
- @WebService(targetNamespace = "http://service.web.jsjty.com/", portName = "xkzfzWebServicePort", serviceName = "xkzfzWebService")
- public class XkzfzWebService extends BaseWebCtl implements IXkzfzWebService {
-
- @Autowired
- private QueryService query;
- @Autowired
- private GqService gqService;
- @Autowired
- private GkService gkService;
- @Autowired
- private GkjyrService gkjyrService;
- @Autowired
- private XkzxxService xkzxxService;
- @Autowired
- private AccessoryService accessoryService;
- @Autowired
- private XkzfzService xkzfzService;
- //列表
- @Override
- 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){
-
- if (!this.checkUser()){
- return BaseWebCtl.NOLOGIN;
- }
- SimplePageRequest page = new SimplePageRequest(pages, rows);
- final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- // 查询条件
- Specification<XkzfzEntity> spec = new Specification<XkzfzEntity>() {
-
- @Override
- public Predicate toPredicate(Root<XkzfzEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
- List<Predicate> list = new ArrayList<Predicate>();
- if (StringUtils.isNotEmpty(szdid)) {
- list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + szdid + "%"));
- }
- // else if (StringUtils.isNotEmpty(SearchCondition.xkzszdid) &&
- // isGET(request)) {
- // list.add(cb.like(root.get("szd").get("id").as(String.class),
- // "%" + SearchCondition.xkzszdid + "%"));
- // }
- if (StringUtils.isNotEmpty(szgkid)) {
- list.add(cb.like(root.get("szgk").as(String.class), "%" + szgkid + "%"));
- }
- // else if (StringUtils.isNotEmpty(SearchCondition.xkzszgkid) &&
- // isGET(request)) {
- // list.add(cb.like(root.get("szgk").as(String.class), "%" +
- // SearchCondition.xkzszgkid + "%"));
- // }
- if (StringUtils.isNotEmpty(szgqid)) {
- list.add(cb.like(root.get("ssgq").as(String.class), "%" + szgqid + "%"));
- }
- // else if (StringUtils.isNotEmpty(SearchCondition.xkzszgqid) &&
- // isGET(request)) {
- // list.add(cb.like(root.get("ssgq").as(String.class), "%" +
- // SearchCondition.xkzszgqid + "%"));
- // }
- if (StringUtils.isNotEmpty(ssjyr)) {
- list.add(cb.like(root.get("ssjyr").get("gkjyr").as(String.class), "%" + ssjyr + "%"));
- }
- // else if (StringUtils.isNotEmpty(SearchCondition.xkzgkjyr) &&
- // isGET(request)) {
- // list.add(cb.like(root.get("gkjyr").as(String.class), "%" +
- // SearchCondition.xkzgkjyr + "%"));
- // }
- if (StringUtils.isNotEmpty(fzsqh)) {
- list.add(cb.like(root.get("fzsqh").as(String.class), "%" + fzsqh + "%"));
- }
- if (StringUtils.isNotEmpty(wxhwpm)) {
- list.add(cb.like(root.get("wxhwpm").as(String.class), wxhwpm));
- }
- if (StringUtils.isNotEmpty(fzsfyx)) {
- if (("是").equals(fzsfyx)) {
- list.add(cb.equal(root.get("recordStatus").as(String.class), "1"));
- } else {
- list.add(cb.notEqual(root.get("recordStatus").as(String.class), "1"));
- }
- }
-
- Date now = new Date();
- if (StringUtils.isNotEmpty(fzsfdq)) {
- if ((fzsfdq).equals("6103")) {
- list.add(cb.lessThanOrEqualTo(root.get("yxqjssj").as(Date.class), now));
- } else if ((fzsfdq).equals("6101")) {
- list.add(cb.greaterThan(root.get("yxqjssj").as(Date.class), now));
- } else {
- list.add(cb.lessThanOrEqualTo(root.get("yxqjssj").as(Date.class), DateTime.addDays(now, 30)));
- }
- }
- // 经营人只能查看自己企业下的数据,非经营人只能查看自己所在地的数据
- if (isJyr()) {
- list.add(cb.like(root.get("ssjyr").get("id").as(String.class), "%" + getSsjyr().getId() + "%"));
- } else {
- In<String> in = cb.in(root.get("szgq").get("id").as(String.class));
- @SuppressWarnings("unchecked")
- List<String> gqlist = gqService.findGqListByUserId(SecUtils.getCurrUser().getId());
- if (gqlist != null && gqlist.size() > 0) {
- for (int i = 0; i < gqlist.size(); i++) {
- in.value(gqlist.get(i));
- }
- list.add(in);
- }
- }
- list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_DELETE));
- list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_COPY));
- 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("yxqjssj");
- page.setOrder("desc");
- Page<XkzfzEntity> list = query.findAll(spec, toPageRequest(page),XkzfzEntity.class);
- List<XkzfzVo> voList = new ArrayList<XkzfzVo>();
- for (XkzfzEntity entity : list) {
- XkzfzVo vo = new XkzfzVo();
- if (entity != null) {
- BeanUtils.copyProperties(entity, vo);
- if (null != entity.getFzsj()) {
- vo.setFzsjfmt(DateTime.toString(DateTime.toDate(entity.getFzsj())));
- }
- if (null != entity.getYxqkssj()) {
- vo.setYxqkssjfmt(DateTime.toString(DateTime.toDate(entity.getYxqkssj())));
- }
- if (null != entity.getYxqjssj()) {
- vo.setYxqjssjfmt(DateTime.toString(DateTime.toDate(entity.getYxqjssj())));
- }
- vo.setSzdzw(entity.getSzd() != null ? entity.getSzd().getText() : "");
- vo.setSzgkzw(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
- vo.setSzgqzw(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
- vo.setSsjyrzw(entity.getSsjyr() != null ? entity.getSsjyr().getGkjyr() : "");
- vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
- vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
- vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
- vo.setSsjyr(entity.getSsjyr() != null ? entity.getSsjyr().getId() : "");
- Calendar time = Calendar.getInstance();
- time.set(Calendar.HOUR_OF_DAY, 0);
- time.set(Calendar.MINUTE, 0);
- time.set(Calendar.SECOND, 0);
- if (vo.getYxqjssjfmt() != null && DateTime.toDate(entity.getYxqjssj()).getTime() > time.getTimeInMillis()) {
- vo.setRecordStatus(1);
- } else {
- vo.setRecordStatus(9);
- }
- voList.add(vo);
- }
- }
- return JSONArray.fromObject(voList).toString();
- }
-
- //详情查询
- public String findOne(String id) {
- if (!this.checkUser()){
- return BaseWebCtl.NOLOGIN;
- }
-
- XkzfzEntity entity = xkzfzService.findOne(id);
- XkzfzVo vo = new XkzfzVo();
- BeanUtils.copyProperties(entity, vo);
- vo.setSzdzw(entity.getSzd() != null ? entity.getSzd().getText() : "");
- vo.setSzgkzw(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
- vo.setSzgqzw(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
- vo.setSsjyrzw(entity.getSsjyr() != null ? entity.getSsjyr().getGkjyr() : "");
- vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
- vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
- vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
- vo.setSsjyr(entity.getSsjyr() != null ? entity.getSsjyr().getId() : "");
- if (null != entity.getFzsj()) {
- vo.setFzsjfmt(DateTime.toString(DateTime.toDate(entity.getFzsj())));
- }
- if (null != entity.getYxqkssj()) {
- vo.setYxqkssjfmt(DateTime.toString(DateTime.toDate(entity.getYxqkssj())));
- }
- if (null != entity.getYxqjssj()) {
- vo.setYxqjssjfmt(DateTime.toString(DateTime.toDate(entity.getYxqjssj())));
- }
- // zycs cq whdj
- if (vo.getZycs() != null) {
- CodeEntity zycs = securityMgr.codeService().findOne(vo.getZycs());
- if (null != zycs) {
- vo.setZycszw(zycs.getText());
- }
- }
- if (vo.getCq() != null) {
- CodeEntity cq = securityMgr.codeService().findOne(vo.getCq());
- if (null != cq) {
- vo.setCqzw(cq.getText());
- }
- }
- if (vo.getWhdj() != null) {
- CodeEntity whdj = securityMgr.codeService().findOne(vo.getWhdj());
- if (null != whdj) {
- vo.setWhdjzw(whdj.getText());
- }
- }
- List<CodeEntity> listZycs = securityMgr.codeService().findValidCodesByGroupCode("ZYCS");
- List<GqEntity> listgq = gqService.findGq();
- List<GkEntity> listgk = gkService.findGk();
- return JSONArray.fromObject(vo).toString();
- }
- }
|