📄 contractmanageaction.java
字号:
* @param idocService
* @param pagedlist 要筛选的列表pageList
* @param state 传入的状态
* @return
* @throws OsmException
* @throws LicenseException
*/
private List getFilertDocument(IBoInstanceService iboinstance,IDocumentService idocService,PagedList pagedlist,String state,boolean flag) throws LicenseException, OsmException
{
List document_List =new ArrayList();//
List examineList = new ArrayList();//审批中合同
List performing_NomarlList = new ArrayList();//履行中合同正常履行
List performing_LaterlList = new ArrayList();//履行中合同延期履行
List performedList = new ArrayList();//已履行合同
if(!pagedlist.isEmpty()){
for (Iterator iter = pagedlist.iterator(); iter.hasNext();) {
Map document = (Map) iter.next();
try {
String boinsid=(String)document.get("BO_INSTANCE_ID");//获得业务流程实例id
IBoInstance iBoIns = iboinstance.getBizObjectInstance(boinsid);//根据业务流程实例id得到业务流程实例
String create_id = iBoIns.getCreaterID();//获得起草人id
//获得起草时间
long start_time = (Long.parseLong((document.get("START_TIME") == null ? "0" :
(document.get("START_TIME") == "" ? "0" : document.get("START_TIME")).toString())));
if(iBoIns != null){
IDocument idocument = iBoIns.getDocument();//得到文档实例
if(idocument != null){
if(C_EXAMINE.equals(state) && flag){//审批中
examineList.add(setContractBean(start_time, idocument,create_id,iBoIns,boinsid));
}else if(isCorpsContract(idocument)){//履行中或已履行合同中的特殊的11种合同
if(C_FINASH.equals(state) && isPerformingContract(1,idocument)){//特殊的11种合同履行中合同(正常履行)
performing_NomarlList.add(setContractBean(start_time, idocument,create_id,iBoIns,boinsid));
}else if(C_PERFORMED.equals(state)){//特殊的11种合同已履行合同
performedList.add(setContractBean(start_time, idocument,create_id,iBoIns,boinsid));
}
}else{//履行中合同或已履行合同(正常)
if(isPerformingContract(0,idocument)){//普通合同履行中合同
if(C_DEFER.equals(state) && isPerformingContract(1,idocument)){//延期合同
performing_LaterlList.add(setContractBean(start_time, idocument,create_id,iBoIns,boinsid));
}else if(C_FINASH.equals(state) && !isPerformingContract(1,idocument)){//正常结束合同
performing_NomarlList.add(setContractBean(start_time, idocument,create_id,iBoIns,boinsid));
}
}else if(C_PERFORMED.equals(state)){//普通合同已履行合同
performedList.add(setContractBean(start_time, idocument,create_id,iBoIns,boinsid));
}
}
}
}
} catch (BoInsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//确定返回的list对象
if(C_EXAMINE.equals(state)){//审批中合同
document_List = examineList;
}else if(C_FINASH.equals(state)){//履行中正常合同
document_List = performing_NomarlList;
}else if(C_DEFER.equals(state)){//履行中延期合同
document_List = performing_LaterlList;
}else if(C_PERFORMED.equals(state)){//已履行合同
document_List = performedList;
}
return document_List;
}
/**
* 是否是特殊的四种合同 :SP合同、技术服务合同、广告合同、租赁合同 合作合同 互联合同 知识产权转让合同 保密合同 土地使用权卖出合同
* 房产卖出合同 其他合同 11中合同
* @param map pageList中的Map对象
* @return true :是 false 否
*/
private boolean isCorpsContract(IDocument idocument){
boolean flag = false;
String smalUnit_id = idocument.getContent(C_HTXL)==null ? "" : idocument.getContent(C_HTXL).getItemValue();
if(Contract_SP.equals(smalUnit_id) || Contract_JSFW.equals(smalUnit_id)
|| Contract_GG.equals(smalUnit_id) || Contract_ZL.equals(smalUnit_id)
|| Contract_HZ.equals(smalUnit_id) || Contract_HL.equals(smalUnit_id)
|| Contract_ZSCQZR.equals(smalUnit_id) || Contract_BM.equals(smalUnit_id)
|| Contract_TDSYQ.equals(smalUnit_id) || Contract_FCMC.equals(smalUnit_id)
|| Contract_QT.equals(smalUnit_id)){
flag = true;
}
return flag;
}
/**
* 判断是否是履行中合同
* @param state 0 普通的合同 1 特殊的四种合同 或者是判断 正常合同的 正常结束或者是延期(true 延期 false正常结束)
* @param idocument
* @return true :履行中合同 false 已履行合同
*/
private boolean isPerformingContract(int state,IDocument idocument)
{
boolean flag =false;
if(idocument != null){
if(state == 0 ){//普通合同 如果 付款金额 < 合同总额 则是 履行中的合同
double fukuanzonge = Double.parseDouble(idocument.getContent(C_FKZE) == null ? "0" : (idocument.getContent(C_FKZE).getItemValue() == null ? "0" : idocument.getContent(C_FKZE).getItemValue()));
double hetongjine = Double.parseDouble(idocument.getContent(C_HTJE) == null ? "0" : (idocument.getContent(C_HTJE).getItemValue() == null ? "0" : idocument.getContent(C_HTJE).getItemValue()));
if(fukuanzonge < hetongjine){
flag =true;
}
}else if(state == 1 &&
compareDate(idocument.getContent(C_HTJSSJ) == null ? null : idocument.getContent(C_HTJSSJ).getItemValue(),null) >= 0){//特殊合同(或正常合同的正常和延期) 如果 合同预计履行期限 > 当前时间 则是 履行中的合同
//(不存在延期情况) 否则则是已履行的情况
flag = true;
}
}
return flag;
}
/**
* 比较两个日期的大小 >0 : date1 > date2 <0: date1 < date2
* @param date1
* @param date2 如果为 null 则 与当前日期比较
*/
private int compareDate(String date1,String date2)
{
if(date1 != null && !"".equals(date1)){
Date date_second = new Date();
SimpleDateFormat sdf = new SimpleDateFormat();
try {
Date date_frist = sdf.parse(date1);
if( null != date2 && !"".equals(date2)){
date_second = sdf.parse(date2);
}
return date_frist.compareTo(date_second);
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return 0;
}
/**把数据装载到 ContractManageBean 中
* @param start_time 起草时间
* @param idocument IDocument对象
* @param create_id 起草人id
* @param iBoIns IBoInstance对象
* @return ContractManageBean
* @throws LicenseException
* @throws OsmException
*/
private ContractManageBean setContractBean(long start_time,IDocument idocument ,String create_id,IBoInstance iBoIns,String boinsid) throws LicenseException, OsmException
{
ContractManageBean contractBean = new ContractManageBean();
contractBean.setTitle(idocument.getDocTitle() == null ? "" : idocument.getDocTitle());//标题
contractBean.setState(idocument.getContent("state") == null ? "" :idocument.getContent("state").getItemValue());//合同状态
contractBean.setCreaterName(getCreateName(create_id));//起草人姓名
contractBean.setCreateTime(getDateFarmat(start_time));//起草时间
contractBean.setCurrent_state(iBoIns.getSpread1());//当前环节
contractBean.setBoinsid(boinsid);//业务流程实例id
return contractBean;
}
/**格式化时间格式
* @param Long Long
* @return
*/
private String getDateFarmat(long dateValue)
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(dateValue);
String start_time = sdf.format(cal.getTime());
return start_time;
}
/**根据起草人id得到起草人姓名
* @param create_id
* @return
* @throws LicenseException
* @throws OsmException
*/
private String getCreateName(String create_id) throws LicenseException, OsmException
{
// 获取起草人姓名
String createName = null;
try {
if(create_id != null && !"".equals(create_id)){
IAccountsMgmtService iAccountservice =null;
iAccountservice = (IAccountsMgmtService) getBusinessService(IAccountsMgmtService.class.getName());
AccountsBean accountsbean =iAccountservice.getAccountsById(create_id);
createName = accountsbean.getEmpinfo().getEmpname();
}
} catch (NotFoundModuleException e) {
S_LOGGER.error(e);
throw e;
} catch (ExpiryException e) {
S_LOGGER.error(e);
throw e;
} catch (LicenseException e) {
S_LOGGER.error(e);
throw e;
} catch (OsmException e) {
S_LOGGER.error(e);
throw e;
}
return createName;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -