Browse Source

git-svn-id: https://192.168.57.71/svn/lyggkj@109 1a6f6e3a-4066-fe46-b609-79c204482ece

ld_liufl 8 years ago
parent
commit
85063ee401

+ 1164 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/bagl/BaglWebService.java

@@ -0,0 +1,1164 @@
+package com.jtgh.yjpt.webService.bagl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+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 org.springframework.util.CollectionUtils;
+
+import com.jtgh.yjpt.common.Constants;
+import com.jtgh.yjpt.common.Logable;
+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.bagl.aqpjbgjzgfalsba.AqpjbgjzgfalsbaController;
+import com.jtgh.yjpt.controller.bagl.jdhxpandzdwxyba.JdhxpZdwxyBadjController;
+import com.jtgh.yjpt.controller.bagl.yjyaba.YjyabaController;
+import com.jtgh.yjpt.controller.bagl.zdsgdyhpchzlqkba.ZdsgdyhpchzlqkbaController;
+import com.jtgh.yjpt.entity.BaseEntity;
+import com.jtgh.yjpt.entity.auth.UserEntity;
+import com.jtgh.yjpt.entity.bagl.aqpjbgjzgfalsba.AqpjbgjzgfalsbaEntity;
+import com.jtgh.yjpt.entity.bagl.jdhxpandzdwxyba.GqnwxydjbabEntity;
+import com.jtgh.yjpt.entity.bagl.jdhxpandzdwxyba.GqnwxyzlbEntity;
+import com.jtgh.yjpt.entity.bagl.jdhxpandzdwxyba.ZlbzjdhxpxxEntity;
+import com.jtgh.yjpt.entity.bagl.jdhxpandzdwxyba.ZlbzzdwxyxxEntity;
+import com.jtgh.yjpt.entity.bagl.yjyaba.YjyabaEntity;
+import com.jtgh.yjpt.entity.bagl.zdsgdyhpchzlqkba.ZdsgdyhpchzlqkbaEntity;
+import com.jtgh.yjpt.entity.check.ZcyhEntity;
+import com.jtgh.yjpt.entity.jyr.JyrEntity;
+import com.jtgh.yjpt.entity.yjgl.zdwxyfb.CgEntity;
+import com.jtgh.yjpt.service.bagl.aqpjbgjzgfalsba.AqpjbgjzgfalsbaService;
+import com.jtgh.yjpt.service.bagl.jdhxpandzdwxyba.GqnwxydjbabFlowService;
+import com.jtgh.yjpt.service.bagl.jdhxpandzdwxyba.GqnwxydjbabService;
+import com.jtgh.yjpt.service.bagl.jdhxpandzdwxyba.GqnwxyzlbService;
+import com.jtgh.yjpt.service.bagl.jdhxpandzdwxyba.ZlbzjdhxpxxService;
+import com.jtgh.yjpt.service.bagl.jdhxpandzdwxyba.ZlbzzdwxyxxService;
+import com.jtgh.yjpt.service.bagl.yjyaba.YjyabaService;
+import com.jtgh.yjpt.service.bagl.zdsgdyhpchzlqkba.ZdsgdyhpchzlqkbaService;
+import com.jtgh.yjpt.service.check.ZcyhService;
+import com.jtgh.yjpt.service.common.AccessoryService;
+import com.jtgh.yjpt.service.jyr.JyrService;
+import com.jtgh.yjpt.service.yjgl.zdwxyfb.CgService;
+import com.jtgh.yjpt.webService.WsResult;
+
+/**
+ * 剧毒化学品和重大危险源备案WebService
+ * 
+ * @author chenkf
+ * 
+ */
+@Service
+@WebService(targetNamespace = "http://webService.yjpt.com/", serviceName = "baglService")
+@HandlerChain(file = "handle-chain.xml")
+public class BaglWebService extends BaseController {
+
+	@Autowired
+	private GqnwxydjbabService wxybabService;
+	@Autowired
+	private GqnwxydjbabFlowService djbaFlowService;
+	@Autowired
+	private GqnwxyzlbService zlbService;
+	@Autowired
+	private ZlbzjdhxpxxService jdhxpService;
+	@Autowired
+	private ZlbzzdwxyxxService zdwxyService;
+	@Autowired
+	private JdhxpZdwxyBadjController wxybabController;
+	@Autowired
+	private ZdsgdyhpchzlqkbaService zdsgdyhpchzlqkbaService;
+	@Autowired
+	private ZdsgdyhpchzlqkbaController zdsgdyhpchzlqkbaController;
+	@Autowired
+	private ZcyhService zcyhService;
+	@Autowired
+	private AccessoryService accessoryService;
+	@Autowired
+	private AqpjbgjzgfalsbaService aqpjbgjzgfalsbaService;
+	@Autowired
+	private AqpjbgjzgfalsbaController aqpjbgjzgfalsbaController;
+	@Autowired
+	private YjyabaService yjyabaService;
+	@Autowired
+	private YjyabaController yjyabaController;
+	@Autowired
+	private CgService cgService;
+	@Autowired
+	private JyrService jyrService;
+
+	/**
+	 * 获取重大危险源分页列表
+	 * 
+	 * @param szd
+	 * @param gq
+	 * @param gkjyr
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<GqnwxydjbabEntity> getWxybabPageListByParams(final Long szd,
+			final Long gq, final Long gkjyr, int n, int pageCount) {
+		try {
+			List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+			// 港口经营人
+			addNotEmptyModel(filterList, "dw.id", gkjyr, Operator.EQ);
+			// 所在地
+			addNotEmptyModel(filterList, "szd.id", szd, Operator.LIKE_R);
+			// 根据所在港区来查询记录
+			addNotEmptyModel(filterList, "gq.id", gq, Operator.EQ);
+			addNotEmptyModel(filterList, "recordStatus",
+					Logable.RECORD_STATE_DELETE, Operator.NEQ);
+			// 根据当前登录用户的经营人信息判断它是否为经营人
+			if (Utils.getWebServiceUser() != null) {
+				UserEntity user = Utils.getWebServiceUser();
+				// 经营人只能查自己的
+				if (Constants.YES.equals(user.getSfjyr())
+						&& user.getJyrjcxx() != null) {
+					addNotEmptyModel(filterList, "dw", user.getJyrjcxx(),
+							Operator.EQ);
+				} else {
+					// 行政人员根据权限过滤(重大危险源备案列表菜单ID=46)
+					addRecordCodeFilter(46l, filterList);
+				}
+			}
+			Specification<GqnwxydjbabEntity> spec = SpecificationCreater
+					.searchByPredicateModels(filterList);
+			SinglePageRequest pageable = new SinglePageRequest(pageCount, n,
+					"desc", "id");
+			Page<GqnwxydjbabEntity> list = wxybabService
+					.findAll(spec, pageable);
+			if (list == null || list.getTotalPages() <= pageCount) {
+				return new ArrayList<GqnwxydjbabEntity>();
+			}
+			return list.getContent();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 保存重大危险源备案
+	 * 
+	 * @param entity
+	 * @param zlb
+	 * @param jdhxpList
+	 * @param zdwxyList
+	 */
+	public GqnwxydjbabEntity saveWxybab(GqnwxydjbabEntity entity,
+			GqnwxyzlbEntity zlb, List<ZlbzjdhxpxxEntity> jdhxpList,
+			List<ZlbzzdwxyxxEntity> zdwxyList) {
+		JyrEntity jyr = null;
+		if (entity.getDw() != null) {
+			jyr = jyrService.findById(entity.getDw().getId());
+		}
+		// 备案表
+
+		if (entity.getId() == null || entity.getId().equals(0l)) {
+			if (jyr != null) {
+				entity.setSzd(jyr.getSzd());
+				entity.setGq(jyr.getSzgq());
+			}
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			entity.setRecordCode("90");
+		} else {
+			GqnwxydjbabEntity vo = wxybabService.findById(entity.getId());
+			entity.setAddDate(vo.getAddDate());
+			entity.setAddUser(vo.getAddUser());
+			entity.setRecordCode(vo.getRecordCode());
+			entity.setRecordStatus(vo.getRecordStatus());
+			entity.setSftb(vo.getSftb());
+			entity.setTbzt(vo.getTbzt());
+			entity.setQylb(vo.getQylb());
+			entity.setTbdyid(vo.getTbdyid());
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		entity = wxybabService.save(entity);
+		// 保存总览表信息
+		if(zlb == null){
+			zlb = findZlbByDjbId(entity.getId());
+		}
+		if (zlb == null || zlb.getId() == null || zlb.getId().equals(0l)) {
+			zlb = new GqnwxyzlbEntity();
+			if (jyr != null) {
+				zlb.setSzd(jyr.getSzd());
+				zlb.setGq(jyr.getSzgq());
+			}
+			zlb.setLxdh(entity.getLxdh());
+			zlb.setAddDate(new Date());
+			zlb.setAddUser(Utils.getWebServiceUser());
+			zlb.setRecordCode("90");
+		} else {
+			GqnwxyzlbEntity vo = zlbService.findById(entity.getId());
+			zlb.setAddDate(vo.getAddDate());
+			zlb.setAddUser(vo.getAddUser());
+			zlb.setRecordCode(vo.getRecordCode());
+			zlb.setRecordStatus(vo.getRecordStatus());
+			zlb.setSftb(vo.getSftb());
+			zlb.setTbzt(vo.getTbzt());
+			zlb.setQylb(vo.getQylb());
+			zlb.setTbdyid(vo.getTbdyid());
+			zlb.setUpdateDate(new Date());
+			zlb.setUpdateUser(Utils.getWebServiceUser());
+		}
+		zlb.setDjbid(entity);
+		zlb = zlbService.save(zlb);
+
+		// 保存总览表的子表信息
+		jdhxpService.deleteByZlbid(zlb.getId());
+		for (ZlbzjdhxpxxEntity jdhxp : jdhxpList) {
+			jdhxp.setZlbid(zlb);
+			// 保存总览表信息
+			if (jdhxp.getId() == null || jdhxp.getId().equals(0l)) {
+				if (jyr != null) {
+					jdhxp.setSzd(jyr.getSzd());
+					jdhxp.setGq(jyr.getSzgq());
+				}
+				jdhxp.setAddDate(new Date());
+				jdhxp.setAddUser(Utils.getWebServiceUser());
+				jdhxp.setRecordCode("90");
+			} else {
+				ZlbzjdhxpxxEntity vo = jdhxpService.findById(entity.getId());
+				jdhxp.setAddDate(vo.getAddDate());
+				jdhxp.setAddUser(vo.getAddUser());
+				jdhxp.setRecordCode(vo.getRecordCode());
+				jdhxp.setRecordStatus(vo.getRecordStatus());
+				jdhxp.setSftb(vo.getSftb());
+				jdhxp.setTbzt(vo.getTbzt());
+				jdhxp.setQylb(vo.getQylb());
+				jdhxp.setTbdyid(vo.getTbdyid());
+				jdhxp.setUpdateDate(new Date());
+				jdhxp.setUpdateUser(Utils.getWebServiceUser());
+			}
+			jdhxp.setZlbid(zlb);
+			jdhxpService.save(jdhxp);
+		}
+
+		zdwxyService.deleteByZlbid(zlb.getId());
+		for (ZlbzzdwxyxxEntity wxy : zdwxyList) {
+			wxy.setZlbid(zlb);
+			if (wxy.getId() == null || wxy.getId().equals(0l)) {
+				if (jyr != null) {
+					wxy.setSzd(jyr.getSzd());
+					wxy.setGq(jyr.getSzgq());
+				}
+				wxy.setAddDate(new Date());
+				wxy.setAddUser(Utils.getWebServiceUser());
+				wxy.setRecordCode("90");
+			} else {
+				ZlbzzdwxyxxEntity vo = zdwxyService.findById(entity.getId());
+				wxy.setAddDate(vo.getAddDate());
+				wxy.setAddUser(vo.getAddUser());
+				wxy.setRecordCode(vo.getRecordCode());
+				wxy.setRecordStatus(vo.getRecordStatus());
+				wxy.setSftb(vo.getSftb());
+				wxy.setTbzt(vo.getTbzt());
+				wxy.setQylb(vo.getQylb());
+				wxy.setTbdyid(vo.getTbdyid());
+				wxy.setUpdateDate(new Date());
+				wxy.setUpdateUser(Utils.getWebServiceUser());
+			}
+			wxy.setZlbid(zlb);
+			zdwxyService.save(wxy);
+		}
+		return entity;
+	}
+
+	/**
+	 * 提交重大危险源备案
+	 * 
+	 * @param entity
+	 * @param zlb
+	 * @param jdhxpList
+	 * @param zdwxyList
+	 */
+	public GqnwxydjbabEntity submitWxybab(GqnwxydjbabEntity entity,
+			GqnwxyzlbEntity zlb, List<ZlbzjdhxpxxEntity> jdhxpList,
+			List<ZlbzzdwxyxxEntity> zdwxyList) {
+		// 备案表
+		JyrEntity jyr = null;
+		if (entity.getDw() != null) {
+			jyr = jyrService.findById(entity.getDw().getId());
+		}
+		// 备案表
+
+		if (entity.getId() == null || entity.getId().equals(0l)) {
+			if (jyr != null) {
+				entity.setSzd(jyr.getSzd());
+				entity.setGq(jyr.getSzgq());
+			}
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			entity.setRecordCode("90");
+		} else {
+			GqnwxydjbabEntity vo = wxybabService.findById(entity.getId());
+			entity.setAddDate(vo.getAddDate());
+			entity.setAddUser(vo.getAddUser());
+			entity.setRecordCode(vo.getRecordCode());
+			entity.setRecordStatus(vo.getRecordStatus());
+			entity.setSftb(vo.getSftb());
+			entity.setTbzt(vo.getTbzt());
+			entity.setQylb(vo.getQylb());
+			entity.setTbdyid(vo.getTbdyid());
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		entity = wxybabService.submit(entity.getRecordCode(), entity);
+		// 保存总览表信息
+		if(zlb == null){
+			zlb = findZlbByDjbId(entity.getId());
+		}
+		if (zlb == null || zlb.getId() == null || zlb.getId().equals(0l)) {
+			zlb = new GqnwxyzlbEntity();
+			if (jyr != null) {
+				zlb.setSzd(jyr.getSzd());
+				zlb.setGq(jyr.getSzgq());
+			}
+			zlb.setLxdh(entity.getLxdh());
+			zlb.setAddDate(new Date());
+			zlb.setAddUser(Utils.getWebServiceUser());
+			zlb.setRecordCode("90");
+		} else {
+			GqnwxyzlbEntity vo = zlbService.findById(entity.getId());
+			zlb.setAddDate(vo.getAddDate());
+			zlb.setAddUser(vo.getAddUser());
+			zlb.setRecordCode(vo.getRecordCode());
+			zlb.setRecordStatus(vo.getRecordStatus());
+			zlb.setSftb(vo.getSftb());
+			zlb.setTbzt(vo.getTbzt());
+			zlb.setQylb(vo.getQylb());
+			zlb.setTbdyid(vo.getTbdyid());
+			zlb.setUpdateDate(new Date());
+			zlb.setUpdateUser(Utils.getWebServiceUser());
+		}
+		zlb.setDjbid(entity);
+		zlb = zlbService.save(zlb);
+
+		// 保存总览表的子表信息
+		jdhxpService.deleteByZlbid(zlb.getId());
+		for (ZlbzjdhxpxxEntity jdhxp : jdhxpList) {
+			jdhxp.setZlbid(zlb);
+			// 保存总览表信息
+			if (jdhxp.getId() == null || jdhxp.getId().equals(0l)) {
+				if (jyr != null) {
+					jdhxp.setSzd(jyr.getSzd());
+					jdhxp.setGq(jyr.getSzgq());
+				}
+				jdhxp.setAddDate(new Date());
+				jdhxp.setAddUser(Utils.getWebServiceUser());
+				jdhxp.setRecordCode("90");
+			} else {
+				ZlbzjdhxpxxEntity vo = jdhxpService.findById(entity.getId());
+				jdhxp.setAddDate(vo.getAddDate());
+				jdhxp.setAddUser(vo.getAddUser());
+				jdhxp.setRecordCode(vo.getRecordCode());
+				jdhxp.setRecordStatus(vo.getRecordStatus());
+				jdhxp.setSftb(vo.getSftb());
+				jdhxp.setTbzt(vo.getTbzt());
+				jdhxp.setQylb(vo.getQylb());
+				jdhxp.setTbdyid(vo.getTbdyid());
+				jdhxp.setUpdateDate(new Date());
+				jdhxp.setUpdateUser(Utils.getWebServiceUser());
+			}
+			jdhxp.setZlbid(zlb);
+			jdhxpService.save(jdhxp);
+		}
+
+		zdwxyService.deleteByZlbid(zlb.getId());
+		for (ZlbzzdwxyxxEntity wxy : zdwxyList) {
+			wxy.setZlbid(zlb);
+			if (wxy.getId() == null || wxy.getId().equals(0l)) {
+				if (jyr != null) {
+					wxy.setSzd(jyr.getSzd());
+					wxy.setGq(jyr.getSzgq());
+				}
+				wxy.setAddDate(new Date());
+				wxy.setAddUser(Utils.getWebServiceUser());
+				wxy.setRecordCode("90");
+			} else {
+				ZlbzzdwxyxxEntity vo = zdwxyService.findById(entity.getId());
+				wxy.setAddDate(vo.getAddDate());
+				wxy.setAddUser(vo.getAddUser());
+				wxy.setRecordCode(vo.getRecordCode());
+				wxy.setRecordStatus(vo.getRecordStatus());
+				wxy.setSftb(vo.getSftb());
+				wxy.setTbzt(vo.getTbzt());
+				wxy.setQylb(vo.getQylb());
+				wxy.setTbdyid(vo.getTbdyid());
+				wxy.setUpdateDate(new Date());
+				wxy.setUpdateUser(Utils.getWebServiceUser());
+			}
+			wxy.setZlbid(zlb);
+			zdwxyService.save(wxy);
+		}
+		return entity;
+	}
+
+	/**
+	 * 审核重大危险源
+	 * 
+	 * @param shyj
+	 * @param shsj
+	 * @param data
+	 * @param flag
+	 * @return
+	 */
+	public GqnwxydjbabEntity auditWxybab(String shyj, Date shsj,
+			GqnwxydjbabEntity data, boolean flag) {
+		data = wxybabService.findById(data.getId());
+		try {
+			wxybabController.audit(shyj, shsj, data, flag);
+			return data;
+		} catch (CloneNotSupportedException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 删除重大危险源
+	 */
+	public WsResult deleteWxybab(GqnwxydjbabEntity entity) {
+		WsResult ws = new WsResult();
+		try {
+			wxybabService.logicDelete(entity.getId());
+			ws.setResultCode(WsResult.SUCCESS);
+		} catch (Exception e) {
+			e.printStackTrace();
+			ws.setResultCode(WsResult.FAILURE);
+		}
+		return ws;
+	}
+
+	/**
+	 * 判断当前用户是否有重大危险源审批权限 之判断
+	 * 
+	 * @param id
+	 * @return 0 表示未签收,待办理,1表示已签收待办理 ,""表示 无流程
+	 */
+	public String getWxybabTaskStateByid(Long id) {
+		GqnwxydjbabEntity ba = wxybabService.findById(id);
+		if (ba.getRecordStatus() == BaseEntity.RECORD_STATE_SUBMIT) {// 申请对应的流程
+			if (wxybabService.getTaskByUserAndBusKey(Utils.getWebServiceUser()
+					.getId().toString(), ba.getId().toString()) != null) {
+				return Constants.TASK_ASSIGN;
+			} else if (wxybabService.getCandidateTaskByUserAndBusKey(Utils
+					.getWebServiceUser().getId().toString(), ba.getId()
+					.toString()) != null) {
+				return Constants.TASK_CANDIDATE;
+			}
+		} else if (ba.getRecordStatus() == BaseEntity.RECORD_STATE_QXSUBMIT) {// 核销对应的流程
+			if (djbaFlowService.getTaskByUserAndBusKey(Utils
+					.getWebServiceUser().getId().toString(), ba.getId()
+					.toString()) != null) {
+				return Constants.TASK_ASSIGN;
+			} else if (djbaFlowService.getCandidateTaskByUserAndBusKey(Utils
+					.getWebServiceUser().getId().toString(), ba.getId()
+					.toString()) != null) {
+				return Constants.TASK_CANDIDATE;
+			}
+		}
+		return "";
+	}
+
+	/**
+	 * 根据备案ID查询总览表信息
+	 * 
+	 * @param djbid
+	 * @return
+	 */
+	public GqnwxyzlbEntity findZlbByDjbId(Long djbid) {
+		try {
+			GqnwxyzlbEntity entity = zlbService.queryByDjbid(djbid);
+			return entity;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 根据总览表ID查询剧毒化学品
+	 * 
+	 * @param zlbid
+	 * @return
+	 */
+	public List<ZlbzjdhxpxxEntity> findJdhxpByZlbId(Long zlbid) {
+		try {
+			List<ZlbzjdhxpxxEntity> list = jdhxpService.queryByZlbid(zlbid);
+			return list;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 根据总览表ID查询重大危险源
+	 * 
+	 * @param zlbid
+	 * @return
+	 */
+	public List<ZlbzzdwxyxxEntity> findZdwxyByZlbId(Long zlbid) {
+		try {
+			List<ZlbzzdwxyxxEntity> list = zdwxyService.queryByZlbid(zlbid);
+			return list;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 获取重大危险源信息
+	 * 
+	 * @param djbid
+	 * @return
+	 */
+	public GqnwxydjbabEntity findWxybabById(Long djbid) {
+		return wxybabService.findById(djbid);
+	}
+
+	/**
+	 * 获取重大事故隐患排查及治理备案表
+	 * 
+	 * @param szd
+	 * @param gq
+	 * @param gkjyr
+	 * @param xmmc
+	 * @param sgyhms
+	 * @param fzr
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<ZdsgdyhpchzlqkbaEntity> getZdsgbaPageListByParams(Long szd,
+			Long gq, Long gkjyr, String xmmc, String sgyhms, String fzr, int n,
+			int pageCount) {
+		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+		// 根据填报单位过滤
+		addNotEmptyModel(filterList, "tbdw", gkjyr, Operator.EQ);
+		// 根据项目名称过滤
+		addNotEmptyModel(filterList, "xmmc", xmmc, Operator.LIKE);
+		// 根据隐患描述过滤
+		addNotEmptyModel(filterList, "sgyhms", sgyhms, Operator.LIKE);
+		// 根据项目负责人过滤
+		addNotEmptyModel(filterList, "zgfzr", fzr, Operator.LIKE);
+		addNotEmptyModel(filterList, "szd.id", szd, Operator.LIKE_R);
+		// 根据所在港区来查询记录
+		addNotEmptyModel(filterList, "gq", gq, Operator.EQ);
+		addNotEmptyModel(filterList, "recordStatus",
+				Logable.RECORD_STATE_DELETE, Operator.NEQ);
+		// 根据当前登录用户的经营人信息判断它是否为经营人
+		if (Utils.getWebServiceUser() != null) {
+			UserEntity user = Utils.getWebServiceUser();
+			// 经营人只能查自己的
+			if (Constants.YES.equals(user.getSfjyr())
+					&& user.getJyrjcxx() != null) {
+				addNotEmptyModel(filterList, "tbdw", user.getJyrjcxx(),
+						Operator.EQ);
+			} else {
+				// 行政人员根据权限过滤(重大事故备案列表菜单ID=33)
+				addRecordCodeFilter(33l, filterList);
+			}
+		}
+		Specification<ZdsgdyhpchzlqkbaEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filterList);
+		SinglePageRequest pageable = new SinglePageRequest(pageCount, n,
+				"desc", "id");
+		Page<ZdsgdyhpchzlqkbaEntity> pageList = zdsgdyhpchzlqkbaService
+				.findAll(spec, pageable);
+		if (pageList == null || pageList.getTotalPages() <= pageCount) {
+			return new ArrayList<ZdsgdyhpchzlqkbaEntity>();
+		}
+		return pageList.getContent();
+	}
+
+	/**
+	 * 保存重大事故的隐患排查和治理情况备案记录(包含修改和新增)
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public ZdsgdyhpchzlqkbaEntity saveZdsgba(ZdsgdyhpchzlqkbaEntity entity) {
+		// 判断该记录是否为新增
+		if (entity.getId() == null || entity.getId().equals(0l)) {
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			entity.setRecordCode("90");
+		} else {
+			ZdsgdyhpchzlqkbaEntity vo = zdsgdyhpchzlqkbaService.findById(entity
+					.getId());
+			entity.setAddDate(vo.getAddDate());
+			entity.setAddUser(vo.getAddUser());
+			entity.setRecordCode(vo.getRecordCode());
+			entity.setRecordStatus(vo.getRecordStatus());
+			entity.setSftb(vo.getSftb());
+			entity.setTbzt(vo.getTbzt());
+			entity.setQylb(vo.getQylb());
+			entity.setTbdyid(vo.getTbdyid());
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		// 执行save方法
+		entity = zdsgdyhpchzlqkbaService.save(entity);
+		return entity;
+	}
+
+	/**
+	 * 提交重大事故的隐患排查和治理情况备案记录(包含修改和新增)
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public ZdsgdyhpchzlqkbaEntity submitZdsgba(ZdsgdyhpchzlqkbaEntity entity) {
+		// 判断该记录是否为新增
+		if (entity.getId() == null || entity.getId().equals(0l)) {
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			entity.setRecordCode("90");
+		} else {
+			ZdsgdyhpchzlqkbaEntity vo = zdsgdyhpchzlqkbaService.findById(entity
+					.getId());
+			entity.setAddDate(vo.getAddDate());
+			entity.setAddUser(vo.getAddUser());
+			entity.setRecordCode(vo.getRecordCode());
+			entity.setRecordStatus(vo.getRecordStatus());
+			entity.setSftb(vo.getSftb());
+			entity.setTbzt(vo.getTbzt());
+			entity.setQylb(vo.getQylb());
+			entity.setTbdyid(vo.getTbdyid());
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		// 执行sumit方法
+		entity = zdsgdyhpchzlqkbaService.submit(entity.getRecordCode(), entity);
+
+		return entity;
+	}
+
+	/**
+	 * 审核重大事故备案
+	 * 
+	 * @param shyj
+	 * @param shsj
+	 * @param data
+	 * @param flag
+	 * @return
+	 */
+	public ZdsgdyhpchzlqkbaEntity auditZdsgba(String shyj, Date shsj,
+			ZdsgdyhpchzlqkbaEntity data, boolean flag) {
+		data = zdsgdyhpchzlqkbaService.findById(data.getId());
+		try {
+			zdsgdyhpchzlqkbaController.audit(shyj, shsj, data, flag);
+			return data;
+		} catch (CloneNotSupportedException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 删除重大事故备案
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public WsResult deleteZdsgba(ZdsgdyhpchzlqkbaEntity entity) {
+		WsResult ws = new WsResult();
+		try {
+			zdsgdyhpchzlqkbaService.logicDelete(entity.getId());
+			accessoryService.deleteFj(entity.getId(),
+					Constants.FJSSLX_ZDSGYHPCZGBA, 0);
+			List<ZcyhEntity> yhList = zcyhService.findBySssg(entity);
+			// 清除关联关系
+			if (!CollectionUtils.isEmpty(yhList)) {
+				for (ZcyhEntity yh : yhList) {
+					yh.setSssg(null);
+					zcyhService.save(yh);
+				}
+			}
+			ws.setResultCode(WsResult.SUCCESS);
+		} catch (Exception e) {
+			e.printStackTrace();
+			ws.setResultCode(WsResult.FAILURE);
+		}
+		return ws;
+	}
+
+	/**
+	 * 获取重大事故详细信息
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public ZdsgdyhpchzlqkbaEntity findZdsgbaById(Long id) {
+		return zdsgdyhpchzlqkbaService.findById(id);
+	}
+
+	/**
+	 * 判断当前用户是否有重大事故备案审批权限 之判断
+	 * 
+	 * @param id
+	 * @return 0 表示未签收,待办理,1表示已签收待办理 ,""表示 无流程
+	 */
+	public String getZdsgbaTaskStateByid(Long id) {
+		ZdsgdyhpchzlqkbaEntity ba = zdsgdyhpchzlqkbaService.findById(id);
+		if (ba.getRecordStatus() == BaseEntity.RECORD_STATE_SUBMIT) {// 申请对应的流程
+			if (wxybabService.getTaskByUserAndBusKey(Utils.getWebServiceUser()
+					.getId().toString(), ba.getId().toString()) != null) {
+				return Constants.TASK_ASSIGN;
+			} else if (zdsgdyhpchzlqkbaService.getCandidateTaskByUserAndBusKey(
+					Utils.getWebServiceUser().getId().toString(), ba.getId()
+							.toString()) != null) {
+				return Constants.TASK_CANDIDATE;
+			}
+		}
+		return "";
+	}
+
+	/**
+	 * 获取安全评价报告备案分页列表
+	 * 
+	 * @param szd
+	 * @param szgq
+	 * @param dwmc
+	 * @param bamc
+	 * @param beginTime
+	 * @param endTime
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<AqpjbgjzgfalsbaEntity> getAqpjbgbaPageListByParams(Long szd,
+			Long szgq, Long dwmc, String bamc, Date beginTime, Date endTime,
+			int n, int pageCount) {
+		beginTime = Utils.getDateFirstTime(beginTime);
+		endTime = Utils.getDateLastTime(endTime);
+		List<PredicateModel> filter = new ArrayList<PredicateModel>();
+		addNotEmptyModel(filter, "dwmc", dwmc, Operator.EQ);
+		addNotEmptyModel(filter, "szd.id", szd, Operator.LIKE_R);
+		addNotEmptyModel(filter, "szgq", szgq, Operator.EQ);
+		// 备案日期
+		addNotEmptyModel(filter, "bayxq", beginTime, Operator.GTE);
+		// 备案日期
+		addNotEmptyModel(filter, "bayxq", endTime, Operator.LTE);
+		addNotEmptyModel(filter, "bamc", bamc, Operator.LIKE);
+		// // 只检索非删除状态记录
+		addNotEmptyModel(filter, "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(filter, "dwmc", user.getJyrjcxx(), Operator.EQ);
+			} else {
+				// 行政人员根据权限过滤(安全评价报告备案列表菜单ID=37)
+				addRecordCodeFilter(37l, filter);
+			}
+		}
+		SinglePageRequest pageable = new SinglePageRequest(pageCount, n,
+				"desc", "id");
+		Specification<AqpjbgjzgfalsbaEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filter);
+		Page<AqpjbgjzgfalsbaEntity> page = aqpjbgjzgfalsbaService.findAll(spec,
+				pageable);
+		if (page == null || page.getTotalPages() <= pageCount) {
+			return new ArrayList<AqpjbgjzgfalsbaEntity>();
+		}
+		return page.getContent();
+	}
+
+	/**
+	 * 保存安全评价报告况备案记录(包含修改和新增)
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public AqpjbgjzgfalsbaEntity saveAqpjbgba(AqpjbgjzgfalsbaEntity entity) {
+		// 判断该记录是否为新增
+		if (entity.getId() == null || entity.getId().equals(0l)) {
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			entity.setRecordCode("90");
+		} else {
+			AqpjbgjzgfalsbaEntity vo = aqpjbgjzgfalsbaService.findById(entity
+					.getId());
+			entity.setAddDate(vo.getAddDate());
+			entity.setAddUser(vo.getAddUser());
+			entity.setRecordCode(vo.getRecordCode());
+			entity.setRecordStatus(vo.getRecordStatus());
+			entity.setSftb(vo.getSftb());
+			entity.setTbzt(vo.getTbzt());
+			entity.setQylb(vo.getQylb());
+			entity.setTbdyid(vo.getTbdyid());
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		// 执行save方法
+		entity = aqpjbgjzgfalsbaService.save(entity);
+		return entity;
+	}
+
+	/**
+	 * 提交安全评价报告备案记录(包含修改和新增)
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public AqpjbgjzgfalsbaEntity submitAqbibgba(AqpjbgjzgfalsbaEntity entity) {
+		// 判断该记录是否为新增
+		if (entity.getId() == null || entity.getId().equals(0l)) {
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			entity.setRecordCode("90");
+		} else {
+			AqpjbgjzgfalsbaEntity vo = aqpjbgjzgfalsbaService.findById(entity
+					.getId());
+			entity.setAddDate(vo.getAddDate());
+			entity.setAddUser(vo.getAddUser());
+			entity.setRecordCode(vo.getRecordCode());
+			entity.setRecordStatus(vo.getRecordStatus());
+			entity.setSftb(vo.getSftb());
+			entity.setTbzt(vo.getTbzt());
+			entity.setQylb(vo.getQylb());
+			entity.setTbdyid(vo.getTbdyid());
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		// 执行sumit方法
+		entity = aqpjbgjzgfalsbaService.submit(entity.getRecordCode(), entity);
+
+		return entity;
+	}
+
+	/**
+	 * 审核安全评价报告备案
+	 * 
+	 * @param shyj
+	 * @param shsj
+	 * @param data
+	 * @param flag
+	 * @return
+	 */
+	public AqpjbgjzgfalsbaEntity auditAqpjbgba(String shyj, Date shsj,
+			AqpjbgjzgfalsbaEntity data, boolean flag) {
+		data = aqpjbgjzgfalsbaService.findById(data.getId());
+		try {
+			aqpjbgjzgfalsbaController.audit(shyj, shsj, data, flag);
+			return data;
+		} catch (CloneNotSupportedException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 删除安全评价报告备案
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public WsResult deleteAqpjbgba(AqpjbgjzgfalsbaEntity entity) {
+		WsResult ws = new WsResult();
+		try {
+			aqpjbgjzgfalsbaService.logicDelete(Collections
+					.singletonList(entity));
+			ws.setResultCode(WsResult.SUCCESS);
+		} catch (Exception e) {
+			e.printStackTrace();
+			ws.setResultCode(WsResult.FAILURE);
+		}
+		return ws;
+	}
+
+	/**
+	 * 获取安全评价报告备案详细信息
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public AqpjbgjzgfalsbaEntity findAqpjbgbaById(Long id) {
+		return aqpjbgjzgfalsbaService.findById(id);
+	}
+
+	/**
+	 * 判断当前用户是否有重大事故备案审批权限 之判断
+	 * 
+	 * @param id
+	 * @return 0 表示未签收,待办理,1表示已签收待办理 ,""表示 无流程
+	 */
+	public String getAqpjbgbaTaskStateByid(Long id) {
+		AqpjbgjzgfalsbaEntity ba = aqpjbgjzgfalsbaService.findById(id);
+		if (ba.getRecordStatus() == BaseEntity.RECORD_STATE_SUBMIT) {// 申请对应的流程
+			if (aqpjbgjzgfalsbaService.getTaskByUserAndBusKey(Utils
+					.getWebServiceUser().getId().toString(), ba.getId()
+					.toString()) != null) {
+				return Constants.TASK_ASSIGN;
+			} else if (aqpjbgjzgfalsbaService.getCandidateTaskByUserAndBusKey(
+					Utils.getWebServiceUser().getId().toString(), ba.getId()
+							.toString()) != null) {
+				return Constants.TASK_CANDIDATE;
+			}
+		}
+		return "";
+	}
+
+	/**
+	 * 获取应急预案备案分页列表
+	 * 
+	 * @param szd
+	 * @param gq
+	 * @param dwname
+	 * @param jjtype
+	 * @param bzdate_begin
+	 * @param bzdate_end
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<YjyabaEntity> getYjyabaPageListByParams(Long szd, Long gq,
+			Long dwname, Long jjtype, Date bzdate_begin, Date bzdate_end,
+			int n, int pageCount) {
+		bzdate_begin = Utils.getDateFirstTime(bzdate_begin);
+		bzdate_end = Utils.getDateLastTime(bzdate_end);
+		List<PredicateModel> filter = new ArrayList<PredicateModel>();
+		// 查询条件-单位名称
+		addNotEmptyModel(filter, "dwname", dwname, Operator.EQ);
+		// 查询条件-经济类型
+		if (jjtype != null && !jjtype.equals(-1l)) {
+			addNotEmptyModel(filter, "jjtype", jjtype, Operator.EQ);
+		}
+		// 查询条件-编制日期范围开始
+		addNotEmptyModel(filter, "bzdate", bzdate_begin, Operator.GTE);
+
+		// 查询条件-编制日期范围结束
+		addNotEmptyModel(filter, "bzdate", bzdate_end, Operator.LTE);
+
+		// 查询条件-所在地来查询
+		if (szd != null && !szd.equals(-1l)) {
+			addNotEmptyModel(filter, "szd.id", szd, Operator.LIKE_R);
+		}
+
+		// 查询条件-所在港区
+		if (gq != null && !gq.equals(-1l)) {
+			addNotEmptyModel(filter, "gq.id", gq, Operator.EQ);
+		}
+		// // 只检索非删除状态记录
+		addNotEmptyModel(filter, "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(filter, "dwname", user.getJyrjcxx(),
+						Operator.EQ);
+			} else {
+				// 行政人员根据权限过滤(应急预案备案列表菜单ID=37)
+				addRecordCodeFilter(34l, filter);
+			}
+		}
+		SinglePageRequest pageable = new SinglePageRequest(pageCount, n,
+				"desc", "id");
+		Specification<YjyabaEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filter);
+		Page<YjyabaEntity> page = yjyabaService.findAll(spec, pageable);
+		if (page == null || page.getTotalPages() <= pageCount) {
+			return new ArrayList<YjyabaEntity>();
+		}
+		return page.getContent();
+	}
+
+	/**
+	 * 保存安全评价报告况备案记录(包含修改和新增)
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public YjyabaEntity saveYjyaba(YjyabaEntity entity) {
+		// 判断该记录是否为新增
+		if (entity.getId() == null || entity.getId().equals(0l)) {
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			entity.setRecordCode("90");
+		} else {
+			YjyabaEntity vo = yjyabaService.findById(entity.getId());
+			entity.setAddDate(vo.getAddDate());
+			entity.setAddUser(vo.getAddUser());
+			entity.setRecordCode(vo.getRecordCode());
+			entity.setRecordStatus(vo.getRecordStatus());
+			entity.setSftb(vo.getSftb());
+			entity.setTbzt(vo.getTbzt());
+			entity.setQylb(vo.getQylb());
+			entity.setTbdyid(vo.getTbdyid());
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		// 执行save方法
+		entity = yjyabaService.save(entity);
+		return entity;
+	}
+
+	/**
+	 * 提交安全评价报告备案记录(包含修改和新增)
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	public YjyabaEntity submitYjyaba(YjyabaEntity entity) {
+		// 判断该记录是否为新增
+		if (entity.getId() == null || entity.getId().equals(0l)) {
+			entity.setAddDate(new Date());
+			entity.setAddUser(Utils.getWebServiceUser());
+			entity.setRecordCode("90");
+		} else {
+			YjyabaEntity vo = yjyabaService.findById(entity.getId());
+			entity.setAddDate(vo.getAddDate());
+			entity.setAddUser(vo.getAddUser());
+			entity.setRecordCode(vo.getRecordCode());
+			entity.setRecordStatus(vo.getRecordStatus());
+			entity.setSftb(vo.getSftb());
+			entity.setTbzt(vo.getTbzt());
+			entity.setQylb(vo.getQylb());
+			entity.setTbdyid(vo.getTbdyid());
+			entity.setUpdateDate(new Date());
+			entity.setUpdateUser(Utils.getWebServiceUser());
+		}
+		// 执行sumit方法
+		entity = yjyabaService.submit(entity.getRecordCode(), entity);
+
+		return entity;
+	}
+
+	/**
+	 * 审核安全评价报告备案
+	 * 
+	 * @param shyj
+	 * @param shsj
+	 * @param data
+	 * @param flag
+	 * @return
+	 */
+	public YjyabaEntity auditYjyaba(String shyj, Date shsj, YjyabaEntity data,
+			boolean flag) {
+		data = yjyabaService.findById(data.getId());
+		try {
+			yjyabaController.aduit(shyj, shsj, flag, data);
+			return data;
+		} catch (CloneNotSupportedException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 删除安全评价报告备案
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public WsResult deleteYjyaba(YjyabaEntity entity) {
+		WsResult ws = new WsResult();
+		try {
+			yjyabaService.logicDelete(entity.getId());
+			ws.setResultCode(WsResult.SUCCESS);
+		} catch (Exception e) {
+			e.printStackTrace();
+			ws.setResultCode(WsResult.FAILURE);
+		}
+		return ws;
+	}
+
+	/**
+	 * 获取安全评价报告备案详细信息
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public YjyabaEntity findYjyababaById(Long id) {
+		return yjyabaService.findById(id);
+	}
+
+	/**
+	 * 判断当前用户是否有重大事故备案审批权限 之判断
+	 * 
+	 * @param id
+	 * @return 0 表示未签收,待办理,1表示已签收待办理 ,""表示 无流程
+	 */
+	public String getYjyabaTaskStateByid(Long id) {
+		YjyabaEntity ba = yjyabaService.findById(id);
+		if (ba.getRecordStatus() == BaseEntity.RECORD_STATE_SUBMIT) {// 申请对应的流程
+			if (yjyabaService.getTaskByUserAndBusKey(Utils.getWebServiceUser()
+					.getId().toString(), ba.getId().toString()) != null) {
+				return Constants.TASK_ASSIGN;
+			} else if (yjyabaService.getCandidateTaskByUserAndBusKey(Utils
+					.getWebServiceUser().getId().toString(), ba.getId()
+					.toString()) != null) {
+				return Constants.TASK_CANDIDATE;
+			}
+		}
+		return "";
+	}
+
+	/**
+	 * 获取重大危险源备案的重大危险源
+	 * 
+	 * @param szd
+	 * @param szgq
+	 * @param gkjyr
+	 * @param cgqmc
+	 * @param n
+	 * @param pageCount
+	 * @return
+	 */
+	public List<CgEntity> getZdwxyPageListByParams(final Long szd,
+			final Long szgq, final Long gkjyr, final String cgqmc, int n,
+			int pageCount) {
+		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
+		addNotEmptyModel(filterList, "szd", szd, Operator.EQ);
+		addNotEmptyModel(filterList, "gq", szgq, Operator.EQ);
+		addNotEmptyModel(filterList, "dwmc", gkjyr, Operator.EQ);
+		addNotEmptyModel(filterList, "cgqmc", cgqmc, Operator.LIKE);
+		addNotEmptyModel(filterList, "zdwxycggs", new Integer(1), Operator.EQ);
+		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=19)
+				addRecordCodeFilter(19l, filterList);
+			}
+		}
+		Specification<CgEntity> spec = SpecificationCreater
+				.searchByPredicateModels(filterList);
+		SinglePageRequest page = new SinglePageRequest(pageCount, n, "desc",
+				"id");
+		Page<CgEntity> list = cgService.findAll(spec, page);
+		if (list == null || list.getTotalPages() <= pageCount) {
+			return new ArrayList<CgEntity>();
+		}
+		return list.getContent();
+	}
+
+}