|
@@ -0,0 +1,348 @@
|
|
|
+package com.cxfws.jyrxxgl.service.impl;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+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 javax.persistence.criteria.Subquery;
|
|
|
+import javax.persistence.criteria.CriteriaBuilder.In;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+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 org.springframework.ui.Model;
|
|
|
+
|
|
|
+import com.cxfws.jyrxxgl.service.IXkzxxWebService;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.xt.jygl.accessory.entity.AccessoryEntity;
|
|
|
+import com.xt.jygl.accessory.service.AccessoryService;
|
|
|
+import com.xt.jygl.common.BaseWebCtl;
|
|
|
+import com.xt.jygl.common.Constants;
|
|
|
+import com.xt.jygl.common.GlobalData;
|
|
|
+import com.xt.jygl.common.SearchCondition;
|
|
|
+import com.xt.jygl.common.Utils;
|
|
|
+import com.xt.jygl.ftp.Ftp;
|
|
|
+import com.xt.jygl.ftp.FtpUtil;
|
|
|
+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.entity.GkjyrEntity;
|
|
|
+import com.xt.jygl.gkjygl.gkjyr.jyrjbxx.service.GkjyrService;
|
|
|
+import com.xt.jygl.gkjygl.gkjyr.xkzxx.entity.XkzxxEntity;
|
|
|
+import com.xt.jygl.gkjygl.gkjyr.xkzxx.service.XkzxxService;
|
|
|
+import com.xt.jygl.gkjygl.gkjyr.xkzxx.vo.XkzxxVo;
|
|
|
+import com.xt.jygl.set.user.client.UserService;
|
|
|
+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 cache.CacheSearchCondition;
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+
|
|
|
+@Service
|
|
|
+@WebService(targetNamespace = "http://service.web.jsjty.com/", portName = "xkzxxWebServicePort", serviceName = "xkzxxWebService")
|
|
|
+public class XkzxxWebService extends BaseWebCtl implements IXkzxxWebService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QueryService query;
|
|
|
+ @Autowired
|
|
|
+ private GqService gqService;
|
|
|
+ @Autowired
|
|
|
+ private GkService gkService;
|
|
|
+ @Autowired
|
|
|
+ private GkjyrService gkjyrService;
|
|
|
+ @Autowired
|
|
|
+ private XkzxxService xkzxxService;
|
|
|
+ @Autowired
|
|
|
+ private AccessoryService accessoryService;
|
|
|
+ //列表
|
|
|
+ public String findXkzxx(int pages, int rows,final String gkjyr, final String szgqid, final String gkjyxkzh, final String szdid, final String yxqz, final String szgkid, final String yxq1, final String yxq2, final String sfyx, final String xkzsfdq){
|
|
|
+ if (!this.checkUser()){
|
|
|
+ return BaseWebCtl.NOLOGIN;
|
|
|
+ }
|
|
|
+ SimplePageRequest page = new SimplePageRequest(pages, rows);
|
|
|
+ final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ // 查询条件
|
|
|
+ Specification<XkzxxEntity> spec = new Specification<XkzxxEntity>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<XkzxxEntity> 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(gkjyr)) {
|
|
|
+ Subquery<GkjyrEntity> subquery = query.subquery(GkjyrEntity.class);
|
|
|
+ Root<GkjyrEntity> dpRoot = subquery.from(GkjyrEntity.class);
|
|
|
+ subquery.select(dpRoot);
|
|
|
+ List<Predicate> subQueryPredicates = new ArrayList<Predicate>();
|
|
|
+ subQueryPredicates.add(cb.equal(root.get("gkjyr").as(String.class), dpRoot.get("id").as(String.class)));
|
|
|
+ subQueryPredicates.add(cb.like(dpRoot.get("gkjyr").as(String.class), "%" + gkjyr + "%"));
|
|
|
+ subquery.where(subQueryPredicates.toArray(new Predicate[] {}));
|
|
|
+ list.add(cb.exists(subquery));
|
|
|
+ }
|
|
|
+ // else if (StringUtils.isNotEmpty(SearchCondition.xkzgkjyr) &&
|
|
|
+ // isGET(request)) {
|
|
|
+ // list.add(cb.like(root.get("gkjyr").as(String.class), "%" +
|
|
|
+ // SearchCondition.xkzgkjyr + "%"));
|
|
|
+ // }
|
|
|
+ if (StringUtils.isNotEmpty(gkjyxkzh)) {
|
|
|
+ list.add(cb.like(root.get("gkjyxkzh").as(String.class), "%" + gkjyxkzh + "%"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(sfyx)) {
|
|
|
+ list.add(cb.equal(root.get("sfyx").as(String.class), sfyx));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(yxq1)) {
|
|
|
+ Date yxq1_time;
|
|
|
+ try {
|
|
|
+ yxq1_time = sdf.parse(yxq1);
|
|
|
+ list.add(cb.greaterThanOrEqualTo(root.get("yxqz").as(Date.class), yxq1_time));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // else if (SearchCondition.yxq1 != null && isGET(request)) {
|
|
|
+ // list.add(cb.greaterThanOrEqualTo(root.get("yxqz").as(Date.class),
|
|
|
+ // SearchCondition.yxq1));
|
|
|
+ // }
|
|
|
+ if (StringUtils.isNotEmpty(yxq2)) {
|
|
|
+ Date yxq2_time;
|
|
|
+ try {
|
|
|
+ yxq2_time = sdf.parse(yxq2);
|
|
|
+ list.add(cb.lessThanOrEqualTo(root.get("yxqz").as(Date.class), yxq2_time));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // else if (SearchCondition.yxq2 != null && isGET(request)) {
|
|
|
+ // list.add(cb.lessThanOrEqualTo(root.get("yxqz").as(Date.class),
|
|
|
+ // SearchCondition.yxq2));
|
|
|
+ // }
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+ if (StringUtils.isNotEmpty(xkzsfdq)) {
|
|
|
+ if ((xkzsfdq).equals("6103")) {
|
|
|
+ list.add(cb.lessThanOrEqualTo(root.get("yxqz").as(Date.class), now));
|
|
|
+ } else if ((xkzsfdq).equals("6101")) {
|
|
|
+ list.add(cb.greaterThan(root.get("yxqz").as(Date.class), now));
|
|
|
+ } else {
|
|
|
+ list.add(cb.lessThanOrEqualTo(root.get("yxqz").as(Date.class), DateTime.addDays(now, 30)));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 经营人只能查看自己企业下的数据,非经营人只能查看自己所在港区的数据
|
|
|
+ if (isJyr()) {
|
|
|
+ list.add(cb.like(root.get("gkjyr").as(String.class), "%" + getSsjyr().getId() + "%"));
|
|
|
+ } else {
|
|
|
+ In<String> in = cb.in(root.get("ssgq").as(String.class));
|
|
|
+ //List<String> gqlist = (List<String>) Utils.getSession().getAttribute("gqList");
|
|
|
+ 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.like(root.get("szd").get("id").as(String.class),
|
|
|
+ // "%" + SecUtils.getCurrUser().getSzd().getId() + "%"));
|
|
|
+ }
|
|
|
+ // 状态为0,9,10,11不显示
|
|
|
+ list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_COPY));
|
|
|
+ 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_BGFLAG));
|
|
|
+ list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_ZXFLAG));
|
|
|
+ return cb.and(list.toArray(new Predicate[] {}));
|
|
|
+ }
|
|
|
+ };
|
|
|
+// String user1 = (String) Utils.getSession().getAttribute("user");
|
|
|
+//
|
|
|
+// String user2 = SecUtils.getCurrUser().getId();
|
|
|
+// if (user2 != null) {
|
|
|
+// if (!user2.equals(user1)) {
|
|
|
+// SearchCondition.xkzpage = 1;
|
|
|
+// SearchCondition.xkzgkjyr = "";
|
|
|
+// SearchCondition.xkzszdid = "";
|
|
|
+// SearchCondition.xkzszgqid = "";
|
|
|
+// SearchCondition.xkzszgkid = "";
|
|
|
+// SearchCondition.xkzgkjyxkzh = "";
|
|
|
+// SearchCondition.sfyx = "";
|
|
|
+// SearchCondition.yxq1 = null;
|
|
|
+// SearchCondition.yxq2 = null;
|
|
|
+// SearchCondition.xkzsfdq = "";
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// Utils.getSession().setAttribute("user", user2);
|
|
|
+
|
|
|
+ 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.setOrder("asc");
|
|
|
+ Page<XkzxxEntity> list = query.findAll(spec, toPageRequest(page),XkzxxEntity.class);
|
|
|
+ List<XkzxxVo> voList = new ArrayList<XkzxxVo>();
|
|
|
+ for (XkzxxEntity entity : list) {
|
|
|
+ XkzxxVo vo = new XkzxxVo();
|
|
|
+ if (entity != null && entity.getRecordStatus() != 9) {
|
|
|
+ BeanUtils.copyProperties(entity, vo);
|
|
|
+ Date date = new Date();
|
|
|
+ /*
|
|
|
+ * SimpleDateFormat formatter = new
|
|
|
+ * SimpleDateFormat("yyyy-MM-dd"); String
|
|
|
+ * dqrq=formatter.format(date);
|
|
|
+ */
|
|
|
+ long day = (entity.getYxqz().getTime() - date.getTime()) / (24 * 60 * 60 * 1000);
|
|
|
+ if (day < 30 || day == 30) {
|
|
|
+ vo.setSfred("1");
|
|
|
+ } else {
|
|
|
+ vo.setSfred("2");
|
|
|
+ }
|
|
|
+ // 为所属港区中文赋值
|
|
|
+ // 先获取所属港区id
|
|
|
+ if (vo.getSsgq() != null) {
|
|
|
+ GqEntity gq = gqService.findOne(vo.getSsgq());
|
|
|
+ if (null != gq) {
|
|
|
+ vo.setSsgqzw(gq.getGqmc());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (vo.getSzgk() != null) {
|
|
|
+ GkEntity gk = gkService.findOne(vo.getSzgk());
|
|
|
+ if (null != gk) {
|
|
|
+ vo.setSzgkzw(gk.getGkmc());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vo.getGkjyr() != null) {
|
|
|
+
|
|
|
+ GkjyrEntity jyr = gkjyrService.findOne(vo.getGkjyr());
|
|
|
+ if (null != jyr) {
|
|
|
+ vo.setGkjyrzw(jyr.getGkjyr());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ voList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return JSONArray.fromObject(voList).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //详情
|
|
|
+ public String findOne(String id) {
|
|
|
+ if (!this.checkUser()){
|
|
|
+ return BaseWebCtl.NOLOGIN;
|
|
|
+ }
|
|
|
+ XkzxxEntity entity = xkzxxService.findOne(id);
|
|
|
+ XkzxxVo vo = new XkzxxVo();
|
|
|
+
|
|
|
+ if (entity != null) {
|
|
|
+ BeanUtils.copyProperties(entity, vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vo.getGkjyr() != null) {
|
|
|
+ GkjyrEntity gkjyr = gkjyrService.findOne(vo.getGkjyr());
|
|
|
+ if (null != gkjyr) {
|
|
|
+ vo.setGkjyrzw(gkjyr.getGkjyr());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vo.getSsgq() != null) {
|
|
|
+ GqEntity gq = gqService.findOne(vo.getSsgq());
|
|
|
+ if (null != gq) {
|
|
|
+ vo.setSsgqzw(gq.getGqmc());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("1".equals(vo.getStype())) {
|
|
|
+ if (GlobalData.DEPLOY_MODE.equals(Constants.DEPLOY_MODE_CITY)) {
|
|
|
+ if (!StringUtils.isEmpty(entity.getZmpicid())) {
|
|
|
+ AccessoryEntity acc = accessoryService.findOne(entity.getZmpicid());
|
|
|
+ ftpDown(acc);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(entity.getFmpicid())) {
|
|
|
+ AccessoryEntity acc = accessoryService.findOne(entity.getFmpicid());
|
|
|
+ ftpDown(acc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return JSONArray.fromObject(vo).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ftpDown(AccessoryEntity acc) {
|
|
|
+ try {
|
|
|
+ Ftp f = new Ftp();
|
|
|
+ f.setIpAddr(GlobalData.FTP_IP);
|
|
|
+ f.setPort(Integer.parseInt(GlobalData.FTP_PORT));
|
|
|
+ f.setUserName(GlobalData.FTP_XK_USER);
|
|
|
+ f.setPwd(GlobalData.FTP_XK_USER);
|
|
|
+ f.setPath("");
|
|
|
+ // 本地目录
|
|
|
+ String localBaseDir = GlobalData.VIEW_FILE_PATH + acc.getFilepath();
|
|
|
+ File newfile = new File(localBaseDir);
|
|
|
+ // 如果文件夹不存在则创建
|
|
|
+ if (!newfile.exists() && !newfile.isDirectory()) {
|
|
|
+ newfile.mkdirs();
|
|
|
+ }
|
|
|
+ // 远程目录
|
|
|
+ String remoteBaseDir = acc.getFilepath();
|
|
|
+ // 下载ftp文件
|
|
|
+ boolean downflag = FtpUtil.startDown(f, localBaseDir, remoteBaseDir, acc.getFilename());
|
|
|
+ if (downflag) {
|
|
|
+ System.out.println("ok");
|
|
|
+ acc.setFjbz("1");
|
|
|
+ accessoryService.save(acc);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|