Browse Source

webService

git-svn-id: https://192.168.57.71/svn/lyggkj@31 1a6f6e3a-4066-fe46-b609-79c204482ece
ld_liufl 9 năm trước cách đây
mục cha
commit
7a5e1d7855

+ 14 - 1
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/service/jyr/BwService.java

@@ -1,8 +1,11 @@
 package com.jtgh.yjpt.service.jyr;
 
+import java.util.List;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 
-import java.util.List;
 import com.jtgh.yjpt.client.jyr.bw.BwWebService;
 import com.jtgh.yjpt.entity.jyr.BwEntity;
 
@@ -22,6 +25,16 @@ public interface BwService {
 	 * @return
 	 */
 	public BwEntity findByTbdyid(Long tbdyid);
+	
+	/**
+	 * 分页查询所有验收申请
+	 * 
+	 * @param pageable
+	 *            分页信息
+	 * @return
+	 */
+	public Page<BwEntity> findAll(Specification<BwEntity> spec,
+			Pageable pageable);
 	/**
 	 * 查询所有的泊位
 	 * @param spec

+ 8 - 22
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/jyr/bw/BwWebService.java

@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.jtgh.yjpt.common.Constants;
-import com.jtgh.yjpt.common.GlobalData;
+import com.jtgh.yjpt.common.Utils;
 import com.jtgh.yjpt.entity.jyr.BwEntity;
 import com.jtgh.yjpt.service.jyr.BwService;
 
@@ -27,25 +27,12 @@ public class BwWebService {
 	 * 保存信息
 	 */
 	public Long save(BwEntity entity) {
-		Long entityId =entity.getId();
-		Long serverEntityId = null;
-		// 参数变更
-		if (entity.getTbdyid() != null) {
-			BwEntity tbEntity = service.findOne(entity.getTbdyid());//此同步对应id为省级的id
-			if (tbEntity != null) {
-			// 更新时
-			serverEntityId = tbEntity.getId();
-			}
-			tbEntity=entity;
-			tbEntity.setId(serverEntityId);
-			tbEntity.setSftb(Constants.NO);
-			tbEntity.setTbzt(Constants.YES);
-			tbEntity.setTbdyid(entityId);
-			tbEntity.setAddUser(GlobalData.TB_USER);
-			tbEntity.setUpdateUser(GlobalData.TB_USER);
-			entity=service.save(tbEntity);
-			 return entity.getId();
-		}
+		entity.setAddUser(Utils.getWebServiceUser());
+		entity.setUpdateUser(Utils.getWebServiceUser());
+		entity.setTbzt(Constants.NO);
+		entity=service.save(entity);
+		if(entity!=null)
+			return service.save(entity).getId();
 		return null;
 	}
 
@@ -53,8 +40,7 @@ public class BwWebService {
 	 * 删除
 	 */
 	public void delete(BwEntity entity) {
-		if(entity.getTbdyid()!=null)
 		service.logicDelete(entity.getId());
-		}
+	}
 	
 }

+ 8 - 22
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/jyr/ck/CkWebService.java

@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.jtgh.yjpt.common.Constants;
-import com.jtgh.yjpt.common.GlobalData;
+import com.jtgh.yjpt.common.Utils;
 import com.jtgh.yjpt.entity.jyrxxgl.JyrckxxEntity;
 import com.jtgh.yjpt.service.jyr.CkService;
 
@@ -27,25 +27,12 @@ public class CkWebService {
 	 * 保存信息
 	 */
 	public Long save(JyrckxxEntity entity) {
-		Long entityId =entity.getId();
-		Long serverEntityId = null;
-		// 参数变更
-		if (entity.getTbdyid() != null) {
-			JyrckxxEntity tbEntity = service.findOne(entity.getTbdyid());//此同步对应id为省级的id
-			if (tbEntity != null) {
-			// 更新时
-			serverEntityId = tbEntity.getId();
-			}
-			tbEntity=entity;
-			tbEntity.setId(serverEntityId);
-			tbEntity.setSftb(Constants.NO);
-			tbEntity.setTbzt(Constants.YES);
-			tbEntity.setTbdyid(entityId);
-			tbEntity.setAddUser(GlobalData.TB_USER);
-			tbEntity.setUpdateUser(GlobalData.TB_USER);
-			entity=service.save(tbEntity);
-			 return entity.getId();
-		}
+		entity.setAddUser(Utils.getWebServiceUser());
+		entity.setUpdateUser(Utils.getWebServiceUser());
+		entity.setTbzt(Constants.NO);
+		entity=service.save(entity);
+		if(entity!=null)
+			return service.save(entity).getId();
 		return null;
 	}
 
@@ -53,8 +40,7 @@ public class CkWebService {
 	 * 删除
 	 */
 	public void delete(JyrckxxEntity entity) {
-		if(entity.getTbdyid()!=null)
 		service.logicDelete(entity.getId());
-		}
+	}
 	
 }

+ 7 - 21
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/jyr/dc/JyrDcWebService.java

@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.jtgh.yjpt.common.Constants;
-import com.jtgh.yjpt.common.GlobalData;
+import com.jtgh.yjpt.common.Utils;
 import com.jtgh.yjpt.entity.jyrxxgl.JyrdcxxEntity;
 import com.jtgh.yjpt.service.jyr.DcService;
 
@@ -27,25 +27,12 @@ public class JyrDcWebService {
 	 * 保存信息
 	 */
 	public Long save(JyrdcxxEntity entity) {
-		Long entityId =entity.getId();
-		Long serverEntityId = null;
-		// 参数变更
-		if (entity.getTbdyid() != null) {
-			JyrdcxxEntity tbEntity = service.findOne(entity.getTbdyid());//此同步对应id为省级的id
-			if (tbEntity != null) {
-			// 更新时
-			serverEntityId = tbEntity.getId();
-			}
-			tbEntity=entity;
-			tbEntity.setId(serverEntityId);
-			tbEntity.setSftb(Constants.NO);
-			tbEntity.setTbzt(Constants.YES);
-			tbEntity.setTbdyid(entityId);
-			tbEntity.setAddUser(GlobalData.TB_USER);
-			tbEntity.setUpdateUser(GlobalData.TB_USER);
-			entity=service.save(tbEntity);
-			 return entity.getId();
-		}
+		entity.setAddUser(Utils.getWebServiceUser());
+		entity.setUpdateUser(Utils.getWebServiceUser());
+		entity.setTbzt(Constants.NO);
+		entity=service.save(entity);
+		if(entity!=null)
+			return service.save(entity).getId();
 		return null;
 	}
 
@@ -53,7 +40,6 @@ public class JyrDcWebService {
 	 * 删除
 	 */
 	public void delete(JyrdcxxEntity entity) {
-		if(entity.getTbdyid()!=null)
 		service.logicDelete(entity.getId());
 		}
 	

+ 13 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/yjgl/cg/CgxxglWebService.java

@@ -12,9 +12,11 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 
+import com.jtgh.yjpt.client.yjgl.cg.CgWebService;
 import com.jtgh.yjpt.common.Constants;
 import com.jtgh.yjpt.common.PredicateModel;
 import com.jtgh.yjpt.common.PredicateModel.Operator;
+import com.jtgh.yjpt.common.GlobalData;
 import com.jtgh.yjpt.common.SinglePageRequest;
 import com.jtgh.yjpt.common.SpecificationCreater;
 import com.jtgh.yjpt.common.Utils;
@@ -81,6 +83,17 @@ public class CgxxglWebService extends BaseController {
 			cgService.logicDelete(entity.getId());
 			zbhjjbqkService.logicDelete(zbhjjbqkService.findBySscg(entity));
 			ws.setResultCode(WsResult.SUCCESS);
+			if (Constants.YES.equals(GlobalData.JAXWS_SYNC)
+					&& GlobalData.DEPLOY_MODE.equals(Constants.DEPLOY_MODE_CITY)) {
+				CgWebService webService = cgService.getWebService();
+				if (null != webService) {
+					webService.delete(entity);
+					// 储罐的entity有clone 需要重新取
+					entity = cgService.findOne(entity.getId());
+					entity.setTbzt(Constants.YES);
+					cgService.save(entity);
+				}
+			}
 		} catch (Exception e) {
 			e.printStackTrace();
 			ws.setResultCode(WsResult.FAILURE);

+ 345 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/yjzyxxgl/YjzyxxglWebService.java

@@ -0,0 +1,345 @@
+package com.jtgh.yjpt.webService.yjzyxxgl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+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.jtgh.yjpt.common.Constants;
+import com.jtgh.yjpt.common.PredicateModel;
+import com.jtgh.yjpt.common.Utils;
+import com.jtgh.yjpt.common.PredicateModel.Operator;
+import com.jtgh.yjpt.common.SinglePageRequest;
+import com.jtgh.yjpt.common.SpecificationCreater;
+import com.jtgh.yjpt.controller.BaseController;
+import com.jtgh.yjpt.controller.yjzyxxgl.ZyyjjydwController;
+import com.jtgh.yjpt.entity.BaseEntity;
+import com.jtgh.yjpt.entity.auth.UserEntity;
+import com.jtgh.yjpt.entity.common.AccessoryEntity;
+import com.jtgh.yjpt.entity.yjzyxxgl.JzyjjydwryhzEntity;
+import com.jtgh.yjpt.entity.yjzyxxgl.YjwlEntity;
+import com.jtgh.yjpt.entity.yjzyxxgl.YjwzFlxxEntity;
+import com.jtgh.yjpt.entity.yjzyxxgl.YjwzxxEntity;
+import com.jtgh.yjpt.entity.yjzyxxgl.YjzjkEntity;
+import com.jtgh.yjpt.entity.yjzyxxgl.ZyyjjydwEntity;
+import com.jtgh.yjpt.entity.yjzyxxgl.ZyyjjydwryhzEntity;
+import com.jtgh.yjpt.service.common.AccessoryService;
+import com.jtgh.yjpt.service.yjzyxxgl.YjwlService;
+import com.jtgh.yjpt.service.yjzyxxgl.YjwzFlxxService;
+import com.jtgh.yjpt.service.yjzyxxgl.YjwzxxService;
+import com.jtgh.yjpt.service.yjzyxxgl.YjzjkService;
+import com.jtgh.yjpt.service.yjzyxxgl.ZyyjjydwService;
+
+/**
+ * 应急资源WebService
+ * 
+ * @author chenkf
+ * 
+ */
+@Service
+@WebService(targetNamespace = "http://webService.yjpt.com/", serviceName = "yjzyxxglService")
+@HandlerChain(file = "handle-chain.xml")
+public class YjzyxxglWebService extends BaseController {
+
+	@Autowired
+	private YjwzFlxxService yjwzFlxxService;
+	@Autowired
+	private YjzjkService yjzjkService;
+	@Autowired
+	private YjwzxxService yjwzxxService;
+	@Autowired
+	private YjwlService yjwlService;
+	@Autowired
+	private AccessoryService accessoryService;
+	@Autowired
+	private ZyyjjydwService zyjjydwService;
+	@Autowired
+	private ZyyjjydwController zyyjjydwController;
+
+	/**
+	 * 获取应急专家库分页信息
+	 * 
+	 * @param szd
+	 * @param sfsygkj
+	 * @param xm
+	 * @param xb
+	 * @param xjzd
+	 * @param gzdw
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<YjzjkEntity> getYjzjkPageListByParams(Long szd, String sfsygkj,
+			String xm, String xb, String xjzd, String gzdw, int n, int pageCount) {
+		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+		// 根据姓名过滤
+		addNotEmptyModel(filterList, "xm", xm, Operator.LIKE);
+		// 根据性别过滤
+		addNotEmptyModel(filterList, "xb", xb, Operator.EQ);
+		// 根据现居住地过滤
+		addNotEmptyModel(filterList, "xjzd", xjzd, Operator.LIKE);
+		// 根据工作单位过滤
+		addNotEmptyModel(filterList, "gzdw", gzdw, Operator.LIKE);
+		// 根据 所在地过滤
+		if (szd != null)
+			addNotEmptyModel(filterList, "szd.id", szd, Operator.LIKE_R);
+		// 根据是否数据港口局专家库过滤
+		addNotEmptyModel(filterList, "sfsygkj", sfsygkj, Operator.EQ);
+		addNotEmptyModel(filterList, "recordStatus",
+				BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
+		Specification<YjzjkEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filterList);
+		SinglePageRequest page = new SinglePageRequest(pageCount, n, "desc",
+				"id");
+		Page<YjzjkEntity> list = yjzjkService.findAll(spec, page);
+		if (list == null || list.getTotalPages() < pageCount) {
+			return new ArrayList<YjzjkEntity>();
+		}
+		return list.getContent();
+	}
+
+	/**
+	 * 获取应急专家库信息(返回附件)
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public YjzjkEntity findYjzjkById(Long id) {
+		YjzjkEntity entity = yjzjkService.queryYjzjk(id);
+		if (entity != null) {
+			// 检索附件
+			List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+			addNotEmptyModel(filterList, "entityType.id",
+					Constants.ACCESSORY_ENTITY_TYPE_YJZJK, Operator.EQ);
+			addNotEmptyModel(filterList, "recordStatus",
+					BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
+			addNotEmptyModel(filterList, "entityId", entity.getId(),
+					PredicateModel.Operator.EQ);
+			Specification<AccessoryEntity> accSpec = SpecificationCreater
+					.searchByPredicateModels(filterList);
+			List<AccessoryEntity> acc = accessoryService.findAll(accSpec);
+			if (acc != null && acc.size() > 0)
+				entity.setAccessory(acc.get(0));
+		}
+		return entity;
+	}
+
+	/**
+	 * 获取应急物资分页信息
+	 * 
+	 * @param szd
+	 * @param gq
+	 * @param gkdw
+	 * @param lxr
+	 * @param lxdh
+	 * @param dw
+	 * @param lb
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<YjwzxxEntity> getYjwzPageListByParams(Long szd, long gq,
+			Long gkdw, String lxr, String lxdh, String dw, String lb, int n,
+			int pageCount) {
+		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+		if (szd != 0l)
+			addNotEmptyModel(filterList, "szd.id", szd, Operator.LIKE_R);
+		if (gq != 0l) {
+			addNotEmptyModel(filterList, "gq", gq, Operator.EQ);
+		}
+		addNotEmptyModel(filterList, "gkdw", gkdw, Operator.EQ);
+		addNotEmptyModel(filterList, "lxr", lxr, Operator.LIKE);
+		addNotEmptyModel(filterList, "byzd1", lb, Operator.EQ);
+		addNotEmptyModel(filterList, "lxdh", lxdh, Operator.LIKE);
+		addNotEmptyModel(filterList, "szdgkj", dw, Operator.LIKE);
+		addNotEmptyModel(filterList, "recordStatus",
+				BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
+		Specification<YjwzxxEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filterList);
+		SinglePageRequest page = new SinglePageRequest(pageCount, n, "desc",
+				"id");
+		Page<YjwzxxEntity> list = yjwzxxService.findAll(spec, page);
+		if (list == null || list.getTotalPages() < pageCount) {
+			return new ArrayList<YjwzxxEntity>();
+		}
+		return list.getContent();
+	}
+
+	/**
+	 * 获取应急物资详细信息
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public YjwzxxEntity findYjwzById(Long id) {
+		YjwzxxEntity entity = yjwzxxService.findOne(id);
+		if (entity != null) {
+			List<YjwzFlxxEntity> yjwzFlxx = findYjwzFlxxByYjwz(entity);
+			entity.setYjwzFlxx(yjwzFlxx);
+		}
+		return entity;
+	}
+
+	/**
+	 * 根据应急物资获取应急物资设施详细信息列表
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public List<YjwzFlxxEntity> findYjwzFlxxByYjwz(YjwzxxEntity entity) {
+		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+		if (entity != null) {
+			addNotEmptyModel(filterList, "wzid", entity.getId(), Operator.EQ);
+		}
+		addNotEmptyModel(filterList, "recordStatus",
+				BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
+		Specification<YjwzFlxxEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filterList);
+		return yjwzFlxxService.findAll(spec);
+	}
+
+	/**
+	 * 获取应急物资设施详细详细
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public YjwzFlxxEntity findYjwzFlxxById(Long id) {
+		return yjwzFlxxService.findOne(id);
+	}
+
+	/**
+	 * 获取应急队伍分页信息
+	 * 
+	 * @param szd
+	 * @param gq
+	 * @param qymc
+	 * @param jyxz
+	 * @param zyfzr
+	 * @param jzfzr
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<ZyyjjydwEntity> getYjdwPageListByParams(Long szd, Long gq,
+			Long qymc, String jyxz, String zyfzr, String jzfzr, int n,
+			int pageCount) {
+		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+		addNotEmptyModel(filterList, "qymc", qymc, Operator.EQ);
+		addNotEmptyModel(filterList, "gq", gq, Operator.EQ);
+		// 只检索所在地
+		addNotEmptyModel(filterList, "szd.id", szd, Operator.LIKE_R);
+		// 只检索救援小组
+		addNotEmptyModel(filterList, "jyxz", jyxz, Operator.LIKE);
+		addNotEmptyModel(filterList, "zy_fzr", zyfzr, Operator.LIKE);
+		addNotEmptyModel(filterList, "jz_fzr", jzfzr, Operator.LIKE);
+		addNotEmptyModel(filterList, "recordStatus",
+				BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
+		Specification<ZyyjjydwEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filterList);
+		if (Utils.getWebServiceUser() != null) {
+			UserEntity user = Utils.getWebServiceUser();
+			// 经营人只能查自己的
+			if (Constants.YES.equals(user.getSfjyr())
+					&& user.getJyrjcxx() != null) {
+				addNotEmptyModel(filterList, "ssjyr", user.getJyrjcxx(),
+						Operator.EQ);
+			} else {
+				// 行政人员根据权限过滤(应急队伍列表菜单ID=12)
+				addRecordCodeFilter(12l, filterList);
+			}
+		}
+		SinglePageRequest page = new SinglePageRequest(pageCount, n, "desc",
+				"id");
+		Page<ZyyjjydwEntity> list = zyjjydwService.findAll(spec, page);
+		if (list == null || list.getTotalPages() < pageCount) {
+			return new ArrayList<ZyyjjydwEntity>();
+		}
+		return list.getContent();
+	}
+
+	/**
+	 * 获取应急队伍详细信息
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public ZyyjjydwEntity findYjdwById(Long id) {
+		ZyyjjydwEntity entity = zyjjydwService.findOne(id);
+		return entity;
+	}
+
+	/**
+	 * 根据应急队伍查询专业应急队伍人员
+	 */
+	@SuppressWarnings("unchecked")
+	public List<ZyyjjydwryhzEntity> zyrylist(Long zyyjjydwId) {
+		return (List<ZyyjjydwryhzEntity>) zyyjjydwController.zyrylist(
+				zyyjjydwId).getAttribute("list");
+	}
+
+	/**
+	 * 根据应急队伍查询兼职应急队伍人员
+	 */
+	@SuppressWarnings("unchecked")
+	public List<JzyjjydwryhzEntity> jzrylist(Long jzyjjydwId) {
+		return (List<JzyjjydwryhzEntity>) zyyjjydwController.jzrylist(
+				jzyjjydwId).getAttribute("list");
+	}
+
+	/**
+	 * 获取应急网络分页信息
+	 * 
+	 * @param szd
+	 * @param gq
+	 * @param type
+	 * @param name
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<YjwlEntity> getYjwlPageListByParams(Long szd, Long gq,
+			String type, String name, int n, int pageCount) {
+		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+		// 只检索非删除状态记录
+		addNotEmptyModel(filterList, "recordStatus",
+				BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
+		addNotEmptyModel(filterList, "name", name, PredicateModel.Operator.LIKE);
+		addNotEmptyModel(filterList, "type", type, PredicateModel.Operator.EQ);
+		if (!szd.equals(0l)) {
+			addNotEmptyModel(filterList, "szd.id", szd, Operator.LIKE);
+		}
+		addNotEmptyModel(filterList, "gq", gq, Operator.EQ);
+		Specification<YjwlEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filterList);
+		SinglePageRequest page = new SinglePageRequest(pageCount, n, "desc",
+				"id");
+		try {
+			Page<YjwlEntity> list = yjwlService.findAll(spec, page);
+			if (list == null || list.getTotalPages() < pageCount) {
+				return new ArrayList<YjwlEntity>();
+			}
+			return list.getContent();
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+		return new ArrayList<YjwlEntity>();
+	}
+
+	/**
+	 * 获取应急网络详细信息
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public YjwlEntity findYjwlById(Long id) {
+		return yjwlService.findOne(id);
+	}
+
+}

+ 389 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/zcdc/zc/ZczbWebService.java

@@ -0,0 +1,389 @@
+package com.jtgh.yjpt.webService.zcdc.zc;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+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.jtgh.yjpt.client.zcdc.zc.ZcWebService;
+import com.jtgh.yjpt.client.zcdc.zcyh.ZcyhWebService;
+import com.jtgh.yjpt.common.Constants;
+import com.jtgh.yjpt.common.GlobalData;
+import com.jtgh.yjpt.common.PredicateModel;
+import com.jtgh.yjpt.common.PredicateModel.Operator;
+import com.jtgh.yjpt.common.SinglePageRequest;
+import com.jtgh.yjpt.common.SpecificationCreater;
+import com.jtgh.yjpt.common.Utils;
+import com.jtgh.yjpt.controller.BaseController;
+import com.jtgh.yjpt.controller.check.ZcController;
+import com.jtgh.yjpt.controller.common.AccessoryController;
+import com.jtgh.yjpt.entity.BaseEntity;
+import com.jtgh.yjpt.entity.auth.UserEntity;
+import com.jtgh.yjpt.entity.check.ZcEntity;
+import com.jtgh.yjpt.entity.check.ZcyhEntity;
+import com.jtgh.yjpt.entity.common.AccessoryEntity;
+import com.jtgh.yjpt.service.check.ZcService;
+import com.jtgh.yjpt.service.check.ZcyhService;
+import com.jtgh.yjpt.service.common.AccessoryService;
+import com.jtgh.yjpt.webService.WsResult;
+
+/**
+ * 自查WebService
+ * 
+ * @author liufl
+ * 
+ */
+@Service
+@WebService(targetNamespace = "http://webService.yjpt.com/", serviceName = "zczbService")
+@HandlerChain(file = "handle-chain.xml")
+public class ZczbWebService extends BaseController {
+	@Autowired
+	private ZcService zcService;
+	@Autowired
+	private ZcyhService zcyhService;
+	@Autowired
+	private AccessoryService accessoryService;
+	@Autowired
+	private ZcController zcController;
+	@Autowired
+	private AccessoryController accessoryController;
+
+	/**
+	 * 保存
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public ZcEntity save(ZcEntity entity) {
+		if (null == entity.getId() || entity.getId().equals(0l)) {
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			// 行政人员
+			entity.setRecordCode("90");
+		} else {
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		entity.setTbzt(Constants.NO);
+		entity = zcService.save(entity);
+		return entity;
+	}
+
+	/**
+	 * 保存
+	 * 
+	 * @param entity
+	 * @param addList
+	 * @param delList
+	 * @return
+	 */
+	public ZcEntity saveEntity(ZcEntity entity, List<ZcyhEntity> addList,
+			List<ZcyhEntity> delList) {
+		boolean first = false;
+		if (null == entity.getId() || entity.getId().equals(0l)) {
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			// 行政人员
+			entity.setRecordCode("90");
+			first = true;
+		} else {
+			entity.setUpdateUser(Utils.getCurrentUser());
+			entity.setUpdateDate(new Date());
+		}
+		ZcEntity zcEntity = zcService.save(entity);// 先保存实体
+		List<ZcyhEntity> tbAddList = new ArrayList<ZcyhEntity>();// 临时存放
+		for (ZcyhEntity zcyhEntity : addList) {// for循环需要添加的自查隐患子表
+			zcyhEntity.setSszc(zcEntity);// 设置自查隐患属于的主表记录
+			zcyhEntity = zcyhService.save(zcyhEntity);
+			tbAddList.add(zcyhEntity);
+			if (first == true) {// 如果是第一次新增
+				if (null != zcyhEntity.getZgcs()) {// 但是整改措施不为空
+					for (AccessoryEntity zcyhEntity2 : zcyhEntity.getZgcs()) {
+						AccessoryEntity zgcs = accessoryService
+								.findOne(zcyhEntity2.getId());
+						if (null != zgcs) {
+							zgcs.setEntityId(zcyhEntity.getId());
+							accessoryService.save(zgcs);
+						}
+					}
+				}
+				if (null != zcyhEntity.getZgjg()) {
+					AccessoryEntity zgjg = accessoryService.findOne(zcyhEntity
+							.getZgjg().getId());
+					if (null != zgjg) {
+						zgjg.setEntityId(zcyhEntity.getId());
+						accessoryService.save(zgjg);
+					}
+				}
+			}
+		}
+		zcyhService.logicDelete(delList);
+		// 同步
+		if (Constants.YES.equals(GlobalData.JAXWS_SYNC)
+				&& GlobalData.DEPLOY_MODE.equals(Constants.DEPLOY_MODE_CITY)) {
+			try {
+				ZcWebService webService = zcService.getWebService();
+				if (webService != null) {
+					webService.save(zcEntity);
+					zcEntity.setTbzt(Constants.YES);
+					zcService.save(zcEntity);
+				} else {
+					zcEntity.setTbzt(Constants.NO);
+					zcService.save(zcEntity);
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				zcEntity.setTbzt(Constants.NO);
+				zcService.save(zcEntity);
+			}
+			List<ZcyhEntity> yhList = zcyhService.findBySszc(zcEntity);
+
+			ZcyhWebService zcyhWebService = zcyhService.getWebService();
+			if (null != zcyhWebService) {
+				for (ZcyhEntity delEntity : delList) {
+					try {
+						zcyhWebService.delete(delEntity);
+						delEntity.setTbzt(Constants.YES);
+						delEntity
+								.setRecordStatus(BaseEntity.RECORD_STATE_DELETE);
+						zcyhService.save(delEntity);
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+				for (ZcyhEntity zcyhEntity : yhList) {
+					try {
+						zcyhWebService.save(zcyhEntity);
+						zcyhEntity.setTbzt(Constants.YES);
+						zcyhService.save(zcyhEntity);
+					} catch (Exception e) {
+						e.printStackTrace();
+						zcyhEntity.setTbzt(Constants.NO);
+						zcyhService.save(zcyhEntity);
+					}
+				}
+			} else {
+				for (ZcyhEntity zcyhEntity : yhList) {
+					zcyhEntity.setTbzt(Constants.NO);
+					zcyhService.save(zcyhEntity);
+				}
+			}
+		}
+		return zcEntity;
+	}
+
+	/**
+	 * 删除
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public WsResult delete(ZcEntity entity) {
+		WsResult ws = new WsResult();
+		try {
+			List<ZcEntity> list = new ArrayList<ZcEntity>();
+			list.add(entity);
+			zcController.delete(list);
+			ws.setResultCode(WsResult.SUCCESS);
+		} catch (Exception e) {
+			e.printStackTrace();
+			ws.setResultCode(WsResult.FAILURE);
+		}
+		return ws;
+	}
+
+	/**
+	 * 分页查询
+	 * 
+	 * @param szd
+	 *            所在地
+	 * @param szgq
+	 *            所在港区
+	 * @param qymc
+	 *            企业名称
+	 * @param aqfzr
+	 *            安全负责人
+	 * @param jcsjK
+	 *            开始申报时间
+	 * @param jcsjZ
+	 *            结束时间
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<ZcEntity> getZcPageListByParams(final Long szd,
+			final Long szgq, final Long qymc, final String aqfzr, Date jcsjK,
+			Date jcsjZ, int n, int pageCount) {
+		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+		addNotEmptyModel(filterList, "szd.id", szd, Operator.LIKE_R);
+		jcsjK = Utils.getDateLastTime(jcsjK);
+		jcsjZ = Utils.getDateLastTime(jcsjZ);
+		if (null != szd) {
+			addNotEmptyModel(filterList, "szd.id", szd, Operator.LIKE_R);
+		}
+		addNotEmptyModel(filterList, "szgq", szgq, Operator.EQ);
+		addNotEmptyModel(filterList, "qymc", qymc, Operator.EQ);
+		if (jcsjK != null) {
+			addNotEmptyModel(filterList, "jcsj", jcsjK, Operator.GTE);
+		}
+		if (jcsjZ != null) {
+			addNotEmptyModel(filterList, "jcsj", jcsjZ, Operator.LTE);
+		}
+		addNotEmptyModel(filterList, "aqfzr", aqfzr, Operator.LIKE);
+		addNotEmptyModel(filterList, "recordStatus",
+				BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
+		if (Utils.getWebServiceUser() != null) {
+			UserEntity user = Utils.getWebServiceUser();
+			// 经营人只能查自己的
+			if (Constants.YES.equals(user.getSfjyr())
+					&& user.getJyrjcxx() != null) {
+				addNotEmptyModel(filterList, "dwmc", user.getJyrjcxx(),
+						Operator.EQ);
+			} else {
+				// 行政人员根据权限过滤(自查列表菜单ID=41)
+				addRecordCodeFilter(41l, filterList);
+			}
+		}
+		Specification<ZcEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filterList);
+		SinglePageRequest page = new SinglePageRequest(pageCount, n, "desc",
+				"id");
+		Page<ZcEntity> pageList = zcService.findAll(spec, page);
+		if (pageList == null || pageList.getTotalPages() < pageCount) {
+			return new ArrayList<ZcEntity>();
+		}
+		for (ZcEntity zc : pageList) {
+			List<ZcyhEntity> list = zcyhService.findBySszc(zc);
+			Double zgzj = 0d;
+			for (ZcyhEntity zcyh : list) {
+				zgzj += (null == zcyh.getZgtrzj() ? 0d : zcyh.getZgtrzj());
+				if ("-1".equals(zcyh.getMqzt()) && zcyh.getJhwcsj() != null) {
+					if (Calendar.getInstance().getTime()
+							.compareTo(zcyh.getJhwcsj()) > 0) {// 未处理超时
+						zc.setMqzt("-1");
+						break;
+					} else {// 未处理未超时
+						zc.setMqzt("1");
+						break;
+					}
+				} else {
+					zc.setMqzt("0");
+				}
+			}
+			zc.setZgzj(zgzj);
+			for (ZcyhEntity zcyh : list) {
+				if (zcyh.getYhjb().getId() == 10001138) {
+					zc.setHasSjyh("1");
+				}
+			}
+		}
+		return pageList.getContent();
+	}
+
+	/**
+	 * 获取自查详细信息
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public ZcEntity findById(Long id) {
+		ZcEntity zc = zcService.findOne(id);
+		if (zc != null) {
+			List<ZcyhEntity> list = zcyhService.findBySszc(zc);
+			Double zgzj = 0d;
+			for (ZcyhEntity zcyh : list) {
+				zgzj += (null == zcyh.getZgtrzj() ? 0d : zcyh.getZgtrzj());
+				if ("-1".equals(zcyh.getMqzt()) && zcyh.getJhwcsj() != null) {
+					if (Calendar.getInstance().getTime()
+							.compareTo(zcyh.getJhwcsj()) > 0) {// 未处理超时
+						zc.setMqzt("-1");
+						break;
+					} else {// 未处理未超时
+						zc.setMqzt("1");
+						break;
+					}
+				} else {
+					zc.setMqzt("0");
+				}
+			}
+			zc.setZgzj(zgzj);
+			for (ZcyhEntity zcyh : list) {
+				if (zcyh.getYhjb().getId() == 10001138) {
+					zc.setHasSjyh("1");
+				}
+			}
+		}
+		return zc;
+	}
+
+	/**
+	 * 获取隐患列表(不返回附件)
+	 * 
+	 * @param zc
+	 * @return
+	 */
+	public List<ZcyhEntity> findZcyhByZc(ZcEntity zc) {
+		List<ZcyhEntity> yhList = new ArrayList<ZcyhEntity>();
+		try {
+			// yhList=
+			// (List<ZcyhEntity>)zcController.getZcxxById(zc.getId()).getAttribute("list");
+			yhList = zcyhService.findBySszc(zc);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return yhList;
+	}
+
+	/**
+	 * 获取单条隐患的详细信息(包含附件)
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@SuppressWarnings("unchecked")
+	public ZcyhEntity findZcyhById(Long id) {
+		ZcyhEntity zcyh = zcyhService.findOne(id);
+		if (zcyh != null) {
+			List<AccessoryEntity> acc = new ArrayList<AccessoryEntity>();
+			List<byte[]> byteList;
+			acc = (List<AccessoryEntity>) accessoryController.listById(
+					zcyh.getId(), Long.parseLong(Constants.FJSSLX_YHZP))
+					.getAttribute("records");
+			byteList = new ArrayList<byte[]>();
+			for (AccessoryEntity ae : acc) {
+				if (ae.getContent() != null)
+					byteList.add(ae.getContent().getValue());
+			}
+			zcyh.setYhzp(byteList);
+			acc = (List<AccessoryEntity>) accessoryController.listById(
+					zcyh.getId(), Long.parseLong(Constants.FJSSLX_ZGHZP))
+					.getAttribute("records");
+			byteList = new ArrayList<byte[]>();
+			for (AccessoryEntity ae : acc) {
+				if (ae.getContent() != null)
+					byteList.add(ae.getContent().getValue());
+			}
+			zcyh.setZghzp(byteList);
+			acc = (List<AccessoryEntity>) accessoryController.listById(
+					zcyh.getId(), Long.parseLong(Constants.FJSSLX_ZGCSFJ))
+					.getAttribute("records");
+			if (acc != null && acc.size() > 0)
+				zcyh.setZgcs(acc);
+			acc = (List<AccessoryEntity>) accessoryController.listById(
+					zcyh.getId(), Long.parseLong(Constants.FJSSLX_ZGJGFJ))
+					.getAttribute("records");
+			if (acc != null && acc.size() > 0)
+				zcyh.setZgjg(acc.get(0));
+		}
+		return zcyh;
+	}
+
+}