public Result insertAndItem(Water_booklet booklet, List items) {
String[] userId = booklet.getUserId().split(","); //针对多用户进行分割
for (int i = 0;i < userId.length;i++){
booklet.setUserId(userId[i]);
if(i == 0){ //把第一个抄表人的信息存入抄表册
// 保存抄表册主信息
booklet = this.insert(booklet);
}else {
//其余抄表人信息存入关联表中
Sys_user_booklet sys_user_booklet = new Sys_user_booklet();
sys_user_booklet.setMeterId(booklet.getUserId());
sys_user_booklet.setBookletId(booklet.getId());
sys_user_booklet = dao().insert(sys_user_booklet);
}
// 保存记录信息
if (!Lang.isEmpty(items)) {
for (Water_booklet_item item : items) {
item.setBookletId(booklet.getId());
item.setCreateAt(System.currentTimeMillis() / 1000L);
item.setOpAt(item.getCreateAt());
item.setOpBy(booklet.getOpBy());
}
this.insert(items);
}
}
waterPlanService.createMonthPlan(booklet, Times.format("yyyy-MM", new Date()));
return Result.success();
}
6 回复
public Result insertAndItem(Water_booklet booklet, List<Water_booklet_item> items) {
String[] userId = booklet.getUserId().split(","); //针对多用户进行分割
for (int i = 0;i < userId.length;i++){
booklet.setUserId(userId[i]);
if(i == 0){ //把第一个抄表人的信息存入抄表册
// 保存抄表册主信息
booklet = this.insert(booklet);
}else {
//其余抄表人信息存入关联表中
Sys_user_booklet sys_user_booklet = new Sys_user_booklet();
sys_user_booklet.setMeterId(booklet.getUserId());
sys_user_booklet.setBookletId(booklet.getId());
sys_user_booklet = this.insert(sys_user_booklet);
}
}
/*// 保存记录信息
if (!Lang.isEmpty(items)) {
for (Water_booklet_item item : items) {
item.setBookletId(booklet.getId());
item.setCreateAt(System.currentTimeMillis() / 1000L);
item.setOpAt(item.getCreateAt());
item.setOpBy(booklet.getOpBy());
}
this.insert(items);
}*/
waterPlanService.createMonthPlan(booklet, Times.format("yyyy-MM", new Date()));
return Result.success();
}
添加回复
请先登陆