1、项目中对用户操作的结果进行审核时候,出现一个问题,如果对省份,和城市审核,出现四条数据,分别为province,city,province,city.
但是我提供给手机端的数据必须是省份城市一起显示,不是四条而是2条。
// get user_verification data
int issyn = 0;// 0未同步,1为同步
/*
* List<UserVerificationVO> verificationid =
* userVerificationDaoImpl.queryUserVerification();
*/
List<String> typelist = new ArrayList<String>();
typelist.add("province");
typelist.add("city");
typelist.add("company");
typelist.add("name");
StringBuffer completed = new StringBuffer();
completed.append(" and vc.status in(1,-1)");
VerificationContentVO provinceValue = null;
VerificationContentVO cityValue = null;
// 1。为用户信息审核
List<VerificationContentVO> getVerificationContent = verificationDaoImpl.queryVerificationContent(1, completed.toString(), issyn);
/**
* 1、注意:当连续数据库中存在两次修改地区,数据库存在四条数据,province,city等
* 按照如下遍历方式会处理最后的province和city,之后是倒数第二个province,city (non-Javadoc)
*
* @see com.bitbao.cm.service.VerificationService#sendCommentStreamMessage()
*/
for (VerificationContentVO verificationContentVO : getVerificationContent) {
SystemMessage message = new SystemMessage();
if ("province".equals(verificationContentVO.getName())) {
provinceValue = verificationContentVO;
continue;
}
if ("city".equals(verificationContentVO.getName())) {
cityValue = verificationContentVO;
continue;
}
if (typelist.contains(verificationContentVO.getName().trim())) {
// basic info
message.setType(SystemMessageType.BASIC_MESSAGE);
}
else {
// industry info
message.setType(SystemMessageType.INDUSTRY_MESSAGE);
}
message.setUid(verificationContentVO.getUid());
message.setVerificationContentVO(verificationContentVO);
// save message to database
if (messageServiceImpl.add(message)) {
// update sendmessage status
verificationDaoImpl.updateVerificationForSyn(verificationContentVO.getId(), issyn + 1);
}
}
// process province and city
if (provinceValue != null && cityValue != null) {
SystemMessage message = new SystemMessage();
message.setType(SystemMessageType.BASIC_MESSAGE);
message.setProvinceValue(provinceValue.getNewValue());
message.setCityValue(cityValue.getNewValue());
message.setUid(provinceValue.getUid());
message.setVerificationContentVO(provinceValue);
if (messageServiceImpl.add(message)) {
// update sendmessage status
verificationDaoImpl.updateVerificationForSyn(provinceValue.getId(), issyn + 1);
verificationDaoImpl.updateVerificationForSyn(cityValue.getId(), issyn + 1);
}
}
以上处理发生的问题是:导致每次处理都会先处理最后一条数据,之后是倒数第二条。。。,处理完之后才会插入到common_message表中。
虽说每次都从最后一条开始插入数据,但是不免有些小问题。
可以在处理city时候将province 和city一起弄成一条数据。