下面这里代码中的所有变量都在for循环之外创建,对于对象的创建我还是有点不明白,如果按照下面的“(1)”的写法,
如果list的集合中的数据超过1条数据,当for循环第二次进入系统时下面"(2)"中的do{}方法内,对象竟然取得的内容是重复的,不知道什么原因,
最后我将“(1)”的方法修改成 先 new 对象,再给对象赋值,才把问题解决。在此记录一下
for (int i =0;i<querySocialSecurityS.size();i++ ) {
//处理同一张点单
//判断下一条订单id是否与上一条数据id一致,不一致则循环下一张订单
securityVo= querySocialSecurityS.get(i);// <span style="color:#FF0000;">(1)</span>
tempSecurityVo= querySocialSecurityS.get(i);
securityId=securityVo.getCesId();
empSecurityId = String.valueOf(Helper.requestOID(CS_EMP_SECURITY).longValue());
System.out.println("securityId=="+securityId);
do{//<span style="color:#FF0000;">(2)</span>
securityVo= querySocialSecurityS.get(i);
if(securityId.equals(securityVo.getCesId())){
//把原办理记录对应的社保公积金办理明细赋给新的办理记录
insertSecurityItemValues=new StringBuffer("");
insertSecurityItemValues.append("values('"+String.valueOf(Helper.requestOID(CS_EMP_SECURITY_ITEM).longValue())+"',")
.append("'"+empSecurityId+"',").append("'"+securityVo.getProduct_id()+"',").append(securityVo.getBase()+",")
.append(securityVo.getE_ratio()+",").append(securityVo.getP_ratio()+",").append(securityVo.getMoney()+",")
.append(securityVo.getE_money()+",").append(securityVo.getP_money()+",").append(securityVo.getE_add_money()+",")
.append(securityVo.getP_add_money()+",").append("'"+securityVo.getSecurity_product_id()+"',");
if(securityVo.getIs_join_bd()!=null){
insertSecurityItemValues.append("'"+securityVo.getIs_join_bd() +"',");
}else{
insertSecurityItemValues.append("null,");
}
insertSecurityItemValues.append("'"+securityVo.getCreate_user_id()+"',")
.append(" sysdate ,").append("'0',").append(securityVo.getExact_e_money()+",")
.append(securityVo.getExact_p_money()+",").append(securityVo.getBase1()+",").append(securityVo.getBase_salary()+")");
tempSql=new StringBuffer();
list_sql.add(tempSql.append(insertSecurityItem).append(insertSecurityItemValues).toString());
++i;
if(i==querySocialSecurityS.size()){
break;
}
}else{
//同一张订单明细循环完成。
bool=false;
--i;
}
}while(bool);
bool = true ;
//新增新的办理记录
insertSecurityValues=new StringBuffer("values('"+empSecurityId+"',")
.append("'"+tempSecurityVo.getCompany_id()+"',").append("'"+tempSecurityVo.getEmp_post_id()+"',")
.append("'"+tempSecurityVo.getCust_code()+"',").append("'"+tempSecurityVo.getCust_name()+"',")
.append("'"+tempSecurityVo.getEmp_service_item_id()+"',").append("'"+tempSecurityVo.getEmp_service_id()+"',")
.append("'"+tempSecurityVo.getSocial_unit_id()+"',").append("'"+tempSecurityVo.getApply_man()+"',")
.append("to_date('"+UtilsDate.getDateTimesStr(tempSecurityVo.getApply_date())+"','yyyy-mm-dd,hh24:mi:ss'),");
if(tempSecurityVo.getApply_remark()!=null){
insertSecurityValues.append("'"+tempSecurityVo.getApply_remark()+"',");
}else{
insertSecurityValues.append("null,");
}
insertSecurityValues.append("'"+tempSecurityVo.getTransact_man()+"',").append("to_date('"+UtilsDate.getDateTimesStr(tempSecurityVo.getTransact_date())+"','yyyy-mm-dd,hh24:mi:ss'),")
.append("'"+tempSecurityVo.getTransact_type_id()+"',");
if(tempSecurityVo.getTransact_remarks()!=null){
insertSecurityValues.append("'"+tempSecurityVo.getTransact_remarks()+"',");
}else{
insertSecurityValues.append("null,");
}
insertSecurityValues.append("'"+nianfen+"06',").append("null,")
.append("'"+tempSecurityVo.getFund_month()+"',");
if(tempSecurityVo.getBack_reason()!=null){
insertSecurityValues.append("'"+tempSecurityVo.getBack_reason()+"',");
}else{
insertSecurityValues.append("null,");
}
insertSecurityValues.append("'"+tempSecurityVo.getAgent_id()+"',").append("'"+tempSecurityVo.getSecurity_status_bd()+"',")
.append("'"+tempSecurityVo.getSerial_no()+"',").append("'"+tempSecurityVo.getCreate_user_id()+"',")
.append(" sysdate ,").append("'0',")
.append("'"+tempSecurityVo.getSecurity_group_id()+"',").append("'"+tempSecurityVo.getEmp_account_id()+"',");
if(tempSecurityVo.getPre_id()!=null){
insertSecurityValues.append("'"+tempSecurityVo.getPre_id()+"',");
}else{
insertSecurityValues.append("null,");
}
if(tempSecurityVo.getTransact_reason_bd()!=null){
insertSecurityValues.append("'"+tempSecurityVo.getTransact_reason_bd()+"' )") ;
}else{
insertSecurityValues.append("null )") ;
}
tempSql = new StringBuffer();
list_sql.add(tempSql.append(insertSecurity).append(insertSecurityValues).toString());
//--修改原记录的结束日期、状态为停办
updateSecurity = new StringBuffer("update cs_emp_security set end_month='"+nianfen+"05',security_status_bd='5',stop_remarks='补差金额计算后调整',last_update_user_id='"+user_id+"',last_update_date=sysdate where id='"+securityId+"' ");
list_sql.add(updateSecurity.toString());
}
List for循环与对象的问题
最新推荐文章于 2024-06-05 14:26:44 发布