/* *

ClassName: LPContBL

*

Description: LLClaimSchemaBL类文件

*

Copyright: Copyright (c) 2002

*

Company: sinosoft

* @Database: * @CreateDate:2002-07-25 */ package com.sinosoft.lis.bl; import com.sinosoft.lis.db.LCContDB; import com.sinosoft.lis.db.LPContDB; import com.sinosoft.lis.i18n.I18nMessage; import com.sinosoft.lis.pubfun.PubFun; import com.sinosoft.lis.schema.LCContSchema; import com.sinosoft.lis.schema.LPContSchema; import com.sinosoft.lis.schema.LPEdorItemSchema; import com.sinosoft.lis.sql.repository.LPEdorItemSQL; import com.sinosoft.lis.vschema.LCContSet; import com.sinosoft.lis.vschema.LPContSet; import com.sinosoft.lis.vschema.LPEdorItemSet; import com.sinosoft.persistence.SQLProxy; import com.sinosoft.utility.CError; import com.sinosoft.utility.Reflections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class LPContBL{ private static final Logger logger = LoggerFactory.getLogger(LPContBL.class); private static LPEdorItemSQL lPEdorItemSQL = SQLProxy.getInstance(LPEdorItemSQL.class); // @Constructor public LPContBL() { } public void setDefaultFields(LPContSchema schema) { schema.setMakeDate(PubFun.getCurrentDate()); schema.setMakeTime(PubFun.getCurrentTime()); schema.setModifyDate(PubFun.getCurrentDate()); schema.setModifyTime(PubFun.getCurrentTime()); } public static boolean queryLPCont(LPContSchema schema, LPEdorItemSchema aLPEdorItemSchema) { LPEdorItemSchema tLPEdorItemSchema = new LPEdorItemSchema(); LPEdorItemSet tLPEdorItemSet = new LPEdorItemSet(); Reflections tReflections = new Reflections(); LPContSet tLPContSet = new LPContSet(); LPContSchema tLPContSchema = new LPContSchema(); LPContSchema aLPContSchema = new LPContSchema(); LCContSchema tLCContSchema = new LCContSchema(); String sql; int m; // 查找本次申请的保单批改信息 LPEdorItemSet mLPEdorItemSet = lPEdorItemSQL.findAllByEdorNoAndContNoOrderByMakeDateAndMakeTimeDesc( aLPEdorItemSchema.getEdorNo(), aLPEdorItemSchema.getContNo()); if (mLPEdorItemSet != null && mLPEdorItemSet.size() >= 1) { tLPEdorItemSet = lPEdorItemSQL.findAllByEdorNoAndContNoAndMakeDateBetweenAndMakeTimeOrderByMakeDateAndMakeTime( aLPEdorItemSchema.getEdorNo(),aLPEdorItemSchema.getContNo(),aLPEdorItemSchema.getMakeDate(), aLPEdorItemSchema.getMakeDate(),aLPEdorItemSchema.getMakeTime()); } else if (mLPEdorItemSet == null) { CError.buildErr(schema, new I18nMessage("查询保全项目错误!", "LIS-07778")); return false; } if (tLPEdorItemSet == null) { CError.buildErr(schema, new I18nMessage("查询保全项目错误!", "LIS-07778")); return false; } m = tLPEdorItemSet.size(); for (int i = 1; i <= m; i++) { tLPEdorItemSchema = tLPEdorItemSet.get(i); LPContDB tLPContDB = new LPContDB(); tLPContSchema.setEdorNo(tLPEdorItemSchema.getEdorNo()); tLPContSchema.setContNo(tLPEdorItemSchema.getContNo()); tLPContSchema.setEdorType(tLPEdorItemSchema.getEdorType()); tLPContDB.setSchema(tLPContSchema); if (!tLPContDB.getInfo()) { continue; } aLPContSchema = tLPContDB.getSchema(); aLPContSchema.setEdorNo(aLPEdorItemSchema.getEdorNo()); aLPContSchema.setEdorType(aLPEdorItemSchema.getEdorType()); // 增加退保限制 schema.setSchema(aLPContSchema); return true; } // 查找已经申请确认的保单批改信息(没有保全确认) tLPEdorItemSet.clear(); m = 0; tLPEdorItemSet = lPEdorItemSQL.findAllByEdorStateAndContNoOrderByMakeDateDescAndMakeTimeDesc("2",aLPEdorItemSchema.getContNo()); if (tLPEdorItemSet == null) { CError.buildErr(schema, new I18nMessage("查询已经申请确认的保单保全项目错误!", "LIS-09546")); return false; } m = tLPEdorItemSet.size(); for (int i = 1; i <= m; i++) { tLPEdorItemSchema = tLPEdorItemSet.get(i); LPContDB tLPContDB = new LPContDB(); tLPContSchema.setEdorNo(tLPEdorItemSchema.getEdorNo()); tLPContSchema.setContNo(tLPEdorItemSchema.getContNo()); tLPContSchema.setEdorType(tLPEdorItemSchema.getEdorType()); tLPContDB.setSchema(tLPContSchema); if (!tLPContDB.getInfo()) { continue; } aLPContSchema = tLPContDB.getSchema(); aLPContSchema.setEdorNo(aLPEdorItemSchema.getEdorNo()); aLPContSchema.setEdorType(aLPEdorItemSchema.getEdorType()); // 增加退保限制 schema.setSchema(aLPContSchema); return true; } // 如果是第一次申请,得到承保保单信息。 LCContDB tLCContDB = new LCContDB(); tLCContDB.setContNo(aLPEdorItemSchema.getContNo()); if (!tLCContDB.getInfo()) { return false; } tLCContSchema = tLCContDB.getSchema(); // 转换Schema tReflections.transFields(aLPContSchema, tLCContSchema); aLPContSchema.setEdorNo(aLPEdorItemSchema.getEdorNo()); aLPContSchema.setEdorType(aLPEdorItemSchema.getEdorType()); schema.setSchema(aLPContSchema); return true; } /** * 取得附加险保单信息 * * @param aLPEdorItemSchema * @return */ // public static LPContSet queryAppendLPCont(LPContSchema schema, LPEdorItemSchema aLPEdorItemSchema) // { // //得到承保附险保单信息。 // LCContSet tLCContSet = new LCContSet(); // LPContSet tLPContSet = new LPContSet(); // LPEdorItemSchema tLPEdorItemSchema = new LPEdorItemSchema(); // tLPEdorItemSchema.setSchema(aLPEdorItemSchema); // LCContDB tLCContDB = new LCContDB(); // String tSql = "Select * from LCCont where mainContNo='" + // aLPEdorItemSchema.getContNo() + "' and MainContNo<>ContNo"; // tLCContSet = tLCContDB.executeQuery(tSql); // if (tLCContDB.mErrors.needDealError()) // { // CError.buildErr(schema, new I18nMessage("查询承保附险保单信息错误!", "LIS-13035")); // } // // if (tLCContSet.size() > 0) // { // for (int i = 1; i <= tLCContSet.size(); i++) // { // tLPEdorItemSchema.setContNo(tLCContSet.get(i).getContNo()); // if (queryLPCont(schema, tLPEdorItemSchema)) // { // tLPContSet.add(schema.getSchema()); // } // } // } // return tLPContSet; // } /** * 取得主险和附加险保单信息 * * @param aLPEdorItemSchema * @return */ // public static LPContSet queryAllLPCont2(LPContSchema schema,LPEdorItemSchema aLPEdorItemSchema) // { // logger.debug("start queryAll Main retail Pol ....."); // // //得到承保附险保单信息。 // LCContSet tLCContSet = new LCContSet(); // LPContSet tLPContSet = new LPContSet(); // // LPEdorItemSchema tLPEdorItemSchema = new LPEdorItemSchema(); // tLPEdorItemSchema.setSchema(aLPEdorItemSchema); // // LCContDB tLCContDB = new LCContDB(); // // String tSql1 = " select * from LCCont where ContNo = '" + // aLPEdorItemSchema.getContNo() + "'"; // LCContSet primPolSet = tLCContDB.executeQuery(tSql1); // if (tLCContDB.mErrors.needDealError()) // { // CError.buildErr(schema, new I18nMessage("查询主险和附加险保单信息错误!", "LIS-13036")); // } // // if (primPolSet.size() == 0) // return tLPContSet; // String mainContNo = primPolSet.get(1).getMainContNo(); // // String tSql = "Select * from LCCont where mainContNo='" + mainContNo + // "'"; // logger.debug("tSql : " + tSql); // tLCContSet = tLCContDB.executeQuery(tSql); // if (tLCContDB.mErrors.needDealError()) // { // CError.buildErr(schema, new I18nMessage("查询主险和附加险保单信息错误!", "LIS-13036")); // } // // logger.debug("tLCContSet size :" + tLCContSet.size()); // if (tLCContSet.size() > 0) // { // for (int i = 1; i <= tLCContSet.size(); i++) // { // tLPEdorItemSchema.setContNo(tLCContSet.get(i).getContNo()); // if (queryLPCont(schema, tLPEdorItemSchema)) // { // logger.debug(">>>>>>>>> :" + // schema.getSchema().getContNo()); // logger.debug("sumPrem :" + // schema.getSchema().getSumPrem()); // tLPContSet.add(schema.getSchema()); // } // } // } // return tLPContSet; // } /** * 取得附加险保单信息 * * @param aLPEdorItemSchema * @return */ // public static LPContSet queryAllLPCont(LPContSchema schema, LPEdorItemSchema aLPEdorItemSchema) // { // logger.debug("start queryAllLPCont ....."); // //得到承保附险保单信息。 // LCContSet tLCContSet = new LCContSet(); // LPContSet tLPContSet = new LPContSet(); // // LPEdorItemSchema tLPEdorItemSchema = new LPEdorItemSchema(); // tLPEdorItemSchema.setSchema(aLPEdorItemSchema); // // LCContDB tLCContDB = new LCContDB(); // String tSql = "Select * from LCCont where mainContNo='" + // aLPEdorItemSchema.getContNo() + "' or ContNo ='" + // aLPEdorItemSchema.getContNo() + "'"; // logger.debug("tSql : " + tSql); // tLCContSet = tLCContDB.executeQuery(tSql); // logger.debug("tLCContSet size :" + tLCContSet.size()); // if (tLCContSet.size() > 0) // { // for (int i = 1; i <= tLCContSet.size(); i++) // { // tLPEdorItemSchema.setContNo(tLCContSet.get(i).getContNo()); // if (queryLPCont(schema, tLPEdorItemSchema)) // { // logger.debug(">>>>>>>>> :" + // schema.getSchema().getContNo()); // logger.debug("sumPrem :" + // schema.getSchema().getSumPrem()); // tLPContSet.add(schema.getSchema()); // } // } // } // return tLPContSet; // } // 查询上次保全被保险人变动信息 public static boolean queryLastLPCont(LPContSchema schema, LPEdorItemSchema aLPEdorItemSchema, LPContSchema aLPContSchema) { LPContSchema tLPContSchema = new LPContSchema(); LPContSet aLPContSet = new LPContSet(); LCContSchema tLCContSchema = new LCContSchema(); LCContSet tLCContSet = new LCContSet(); LPEdorItemSchema tLPEdorItemSchema = new LPEdorItemSchema(); LPEdorItemSet tLPEdorItemSet = new LPEdorItemSet(); String sql; int m, n; m = 0; n = 0; // 查找最近申请的保单批改信息 tLPEdorItemSet = lPEdorItemSQL.findAllByContNoAndEdorStateAndMakeDateAndMakeTimeOrderByMakeDateAndMakeTime( aLPEdorItemSchema.getContNo(),"0",aLPEdorItemSchema.getMakeDate(),aLPEdorItemSchema.getMakeDate(), aLPEdorItemSchema.getMakeTime()); if (tLPEdorItemSet == null ) { CError.buildErr(schema, new I18nMessage("查询最近申请的保单批改信息错误!", "LIS-13037")); return false; } m = tLPEdorItemSet.size(); for (int i = 1; i <= m; i++) { tLPEdorItemSchema = new LPEdorItemSchema(); tLPEdorItemSchema = tLPEdorItemSet.get(i); LPContDB tLPContDB = new LPContDB(); tLPContSchema.setEdorNo(tLPEdorItemSchema.getEdorNo()); tLPContSchema.setContNo(tLPEdorItemSchema.getContNo()); tLPContSchema.setEdorType(tLPEdorItemSchema.getEdorType()); logger.debug(tLPEdorItemSchema.getEdorType()); tLPContDB.setSchema(tLPContSchema); if (!tLPContDB.getInfo()) { continue; } else { tLPContDB.setEdorNo(aLPContSchema.getEdorNo()); tLPContDB.setEdorType(aLPContSchema.getEdorType()); schema.setSchema(tLPContDB.getSchema()); return true; } } // 如果是第一次申请,得到承保保单的客户信息 LCContDB tLCContDB = new LCContDB(); tLCContDB.setContNo(aLPEdorItemSchema.getContNo()); tLCContSet = tLCContDB.query(); n = tLCContSet.size(); logger.debug("------n:" + n); for (int i = 1; i <= n; i++) { tLCContSchema = tLCContSet.get(i); logger.debug("ContNo:" + aLPContSchema.getContNo()); // 转换Schema Reflections tReflections = new Reflections(); tReflections.transFields(tLPContSchema, tLCContSchema); tLPContSchema.setEdorNo(aLPEdorItemSchema.getEdorNo()); tLPContSchema.setEdorType(aLPEdorItemSchema.getEdorType()); schema.setSchema(tLPContSchema); return true; } return false; } }