public void update(TBaseInterventionPlan model, ListtBaseRegulateInterventions){
List list = new ArrayList();
Map map = new HashMap();if(StringUtils.isNotBlank(model.getId())){
TBaseRegulateIntervention tBaseRegulateIntervention= newTBaseRegulateIntervention();
tBaseRegulateIntervention.setInterventionId(model.getId());//通过干预方案id查找关联表中的方案内容
list =tBaseRegulateInterventionMapper.select(tBaseRegulateIntervention);if (CollectionUtils.isNotEmpty(list) &&CollectionUtils.isNotEmpty(tBaseRegulateInterventions)){//将查出来的list保存到map
for(TBaseRegulateIntervention t : tBaseRegulateInterventions){
map.put(t.getRegulateId(),t.getContent());
}//将前台传进来的list和数据库的list比较,改变了就更新
for(TBaseRegulateIntervention s : list){
System.out.print("++++++++++++++" +s.getRegulateId());
System.out.print("***************" +s.getContent());if(!s.getContent().equals(map.get(s.getRegulateId()))){
System.out.print("-----------------" +map.get(s.getRegulateId()));
s.setContent(map.get(s.getRegulateId()));
tBaseRegulateInterventionMapper.updateByPrimaryKeySelective(s);
}
}
}//干预方案id不为空就更改干预方案
iTBaseInterventionPlanService.updateByPKNotNull(model);
}else{
model.setCreateTime(newDate());//干预方案id为空就保存干预方案
iTBaseInterventionPlanService.save(model);if(CollectionUtils.isNotEmpty(tBaseRegulateInterventions)){for(TBaseRegulateIntervention r : tBaseRegulateInterventions) {
TBaseRegulateIntervention tBaseRegulateIntervention= newTBaseRegulateIntervention();
tBaseRegulateIntervention.setRegulateId(r.getRegulateId());
tBaseRegulateIntervention.setInterventionId(model.getId());
tBaseRegulateIntervention.setContent(r.getContent());
tBaseRegulateIntervention.setCreateTime(newDate());this.save(tBaseRegulateIntervention);
}
}
}
}