| | |
| | | Boolean flag = true; |
| | | if (list != null) { |
| | | Experiment experiment = null; |
| | | String realName; |
| | | try { |
| | | ExperimentWindingStep1 step1 = list.get(0); |
| | | QueryWrapper<Experiment> wrapper = new QueryWrapper<>(); |
| | |
| | | experiment = mapper.selectOne(wrapper); |
| | | if (experiment == null) { |
| | | return new Response().setMsg(0, "添加失败,试验编号不存在"); |
| | | }else { |
| | | } else { |
| | | System.out.println("wrapper = " + wrapper); |
| | | } |
| | | realName = mapper1.getRealName(step1.getExperimentId()); |
| | | if (realName == null) { |
| | | return new Response().setMsg(0, "添加失败,uid未查询到对应试验人"); |
| | | } |
| | | System.out.println("realName = " + realName); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return new Response().setMsg(0, "添加失败"); |
| | | } |
| | | |
| | | for (int i = 0; i < list.size(); i++) { |
| | | ExperimentWindingStep1 experimentWindingStep1 = list.get(i); |
| | | experimentWindingStep1.setSaveTime(new Date()); |
| | | experimentWindingStep1.setDeviceId(experiment.getDeviceId());//存设备类型 |
| | | list.set(i, experimentWindingStep1); |
| | | } |
| | | } |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | try { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | ExperimentWindingStep1 windingStep1 = list.get(i); |
| | | if (mapper1.insert(windingStep1) > 0) { |
| | | flag = true; |
| | | } else { |
| | | flag = false; |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | try { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | ExperimentWindingStep1 windingStep1 = list.get(i); |
| | | windingStep1.setSaveTime(new Date()); |
| | | windingStep1.setDeviceId(experiment.getDeviceId());//存设备类型 |
| | | windingStep1.setRealName(realName); //测试人 |
| | | windingStep1.setStatus(1); //状态:0-未开始,1-进行中,2-已完成 |
| | | |
| | | if (mapper1.insert(windingStep1) > 0) { |
| | | flag = true; |
| | | } else { |
| | | flag = false; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | dataSourceTransactionManager.rollback(transactionStatus); //事务回滚 |
| | | return new Response().setMsg(0, "添加失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | dataSourceTransactionManager.rollback(transactionStatus); //事务回滚 |
| | | return new Response().setMsg(0, "添加失败"); |
| | | } |
| | | if (flag) { |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | return new Response().setMsg(1, "添加成功"); |
| | | } else { |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | if (flag) { |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | return new Response().setMsg(1, "添加成功"); |
| | | } else { |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return new Response().setMsg(0, "添加失败"); |
| | | } |
| | | }else { |
| | | return new Response().setMsg(0, "添加失败"); |
| | | } |
| | | |