| | |
| | | import com.fgkj.mapper.CreatClass; |
| | | import com.fgkj.mapper.UtilityFactory; |
| | | import com.fgkj.mapper.impl.*; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | public ServiceModel delete(User_task obj) { |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=true; |
| | | if (obj.getTask_type()==2){ |
| | | if (!(mapper.del(obj)>0)) { |
| | | bl=false; |
| | | Boolean bl = true; |
| | | try { |
| | | if (obj.getTask_type() == 2) { |
| | | bl = mapper.del(obj) > 0; |
| | | if (bl) bl = mapper.delsqlC(obj) > 0; //check |
| | | } else { |
| | | bl = mapper.del(obj) > 0; |
| | | if (bl) bl = mapper.delsqlT(obj) > 0; //test |
| | | } |
| | | if (!(mapper.delsqlC(obj)>0)) { |
| | | bl=false; |
| | | } |
| | | }else{ |
| | | if (!(mapper.del(obj)>0)) { |
| | | bl=false; |
| | | } |
| | | if (!(mapper.delsqlT(obj)>0)) { |
| | | bl=false; |
| | | } |
| | | } |
| | | if(bl){ |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | model.setCode(1); |
| | | model.setMsg("删除作业成功!"); |
| | | } |
| | | else{ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | model.setMsg("删除作业失败!"); |
| | | } |
| | | return model; |
| | | } |
| | | model.setMsg("删除作业失败!"); |
| | | return model; |
| | | } |
| | | if (bl) { |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | model.setCode(1); |
| | | model.setMsg("删除作业成功!"); |
| | | } else { |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | model.setMsg("删除作业失败!"); |
| | | } |
| | | return model; |
| | | } |
| | | |
| | | //4.1作业管理查询user_task所有信息 |
| | | public ServiceModel serchByCondition(Task_Batt_Test tbt){ |
| | |
| | | return model; |
| | | } |
| | | //4.1根据task_id查询user_task_test/user_task_check |
| | | public ServiceModel serchByInfo(User_task obj){ |
| | | public ServiceModel serchByInfo(User_task utask){ |
| | | ServiceModel model = new ServiceModel(); |
| | | |
| | | User_task utask=(User_task) obj; |
| | | List<Task_Batt_Test> list=null; |
| | | if(utask.getTask_type()!=2){ |
| | | list=battTestMapper.serchByCondition(utask); |
| | | //System.out.println("查询结束"); |
| | | if(list.size()>0 && list!=null){ |
| | | for (int i = 0; i < list.size(); i++) { |
| | | String uname=UtilityFactory.UidsToUnames(list.get(i).getUtest().getTask_usr_ids()); |
| | | String uname=utilityFactoryService.UidsToUnames(list.get(i).getUtest().getTask_usr_ids()); |
| | | list.get(i).getUtest().setNote(uname); |
| | | } |
| | | } |
| | |
| | | //System.out.println("查询结束"); |
| | | if(list.size()>0 && list!=null){ |
| | | for (int i = 0; i < list.size(); i++) { |
| | | String uname=UtilityFactory.UidsToUnames(list.get(i).getUcheck().getTask_usr_ids()); |
| | | String uname=utilityFactoryService.UidsToUnames(list.get(i).getUcheck().getTask_usr_ids()); |
| | | //System.out.println(uname); |
| | | list.get(i).getBinf().setStationName9(uname); //存放执行人 |
| | | } |
| | | } |
| | | } |
| | | for (Task_Batt_Test t : list) { |
| | | System.out.println("t = " + t); |
| | | // for (Task_Batt_Test t : list) { |
| | | // System.out.println("t = " + t); |
| | | // System.out.println(t.getUtest().getNote()); |
| | | } |
| | | // } |
| | | System.out.println(list.size()); |
| | | if(list!=null && list.size()>0){ |
| | | model.setCode(1); |
| | |
| | | } |
| | | //4.1查询符合条件的电池组信息(创建作业) |
| | | public List serchBattgroup(Batt_Maint_Dealarm bmd){ |
| | | // ServiceModelImpl2 model = new ServiceModelImpl2(); |
| | | User_battgroup_baojigroup_battgroup ugroup=new User_battgroup_baojigroup_battgroup(); |
| | | List<Batt_Maint_Dealarm> list = battInfMapper.serchBattgroup(bmd); //TODO 待完成 |
| | | System.out.println("list.size() = " + list.size()); |
| | | // Batt_Maint_Dealarm e = new Batt_Maint_Dealarm(); |
| | | // BattInf battInf = new BattInf(); |
| | | // battInf.setBattGroupId(1000005); |
| | | // e.setBinf(battInf); |
| | | // list.add(e);//添加测试数据 |
| | | List<Batt_Maint_Dealarm> list = battInfMapper.serchBattgroup(bmd); |
| | | // System.out.println("list.size() = " + list.size());//list.size() = 1263 |
| | | List<ServiceModel> listAll=new ArrayList<ServiceModel>(); |
| | | if(list!=null&&list.size()>=0){ |
| | | for(int i=0;i<list.size();i++){ |
| | |
| | | model.setData(list.get(i)); |
| | | if (umodel.getCode().equals(1)) { |
| | | model.setMsg(umodel.getMsg()); |
| | | //TODO perry |
| | | model.setMsgO(umodel.getMsgO()); |
| | | } |
| | | listAll.add(model); |
| | |
| | | //0.1查询指定用户的作业信息 |
| | | public ServiceModelOnce serchByUid(Task_Batt_Test tbt){ |
| | | ServiceModelOnce model = new ServiceModelOnce(); |
| | | //分页 |
| | | PageBean pageBean = tbt.getPageBean(); |
| | | PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true); |
| | | List<Task_Batt_Test> list = mapper.serchByInfo(tbt); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | list.get(i).setPageBean(new PageBean());//TODO 获取方式? |
| | | list.get(i).getPageBean().setPageAll(0); |
| | | } |
| | | // for (int i = 0; i < list.size(); i++) { |
| | | // list.get(i).setPageBean(new PageBean());//TODO 获取方式? |
| | | // list.get(i).getPageBean().setPageAll(0); |
| | | // } |
| | | //System.out.println("&&&& "+list.size()); |
| | | //未完成数量 |
| | | tbt.getUtask().setTask_complete(0); |
| | | List<Task_Batt_Test> listU = mapper.serchByInfo(tbt); |
| | | for (int i = 0; i < listU.size(); i++) { |
| | | listU.get(i).setPageBean(new PageBean()); |
| | | listU.get(i).getPageBean().setPageAll(0); |
| | | } |
| | | List<Task_Batt_Test> listUBT = mapper.serchByInfo(tbt); |
| | | System.out.println("listUBT.size = " + listUBT.size()); |
| | | //int count = 0; //统计未完成的作业数量 |
| | | if(list!=null && list.size()>0){ |
| | | for(int i=0;i<list.size();i++){ |
| | | list.get(i).setBinf(new BattInf()); |
| | | BattInf binf=new BattInf(); |
| | | User_inf user=new User_inf(); |
| | | // if(list.get(i).getUtask().getTask_complete()!=null && list.get(i).getUtask().getTask_complete()==0){ |
| | |
| | | List<BattInf> listb=battInfMapper.serchByCondition(binf); |
| | | if(listb!=null&&listb.size()>0){ |
| | | // System.out.println(listb.get(0).getBattGroupName()+" "+listb.get(0).getStationName()); |
| | | System.out.println("list.get("+i+")= " + list.get(i)); |
| | | list.get(i).setBinf(new BattInf());//测试添加 |
| | | list.get(i).getBinf().setBattGroupName(listb.get(0).getBattGroupName());//TODO 数据不足 java.lang.NullPointerException: null |
| | | // System.out.println("listb.get(0) = " + listb.get(0)); |
| | | // System.out.println("list.get(i) = " + list.get(i)); |
| | | list.get(i).getBinf().setBattGroupName(listb.get(0).getBattGroupName()); |
| | | list.get(i).getBinf().setStationName(listb.get(0).getStationName()); |
| | | // System.out.println(i+" "+list.get(i).getBinf().getBattGroupName()+" "+list.get(i).getBinf().getStationName()); |
| | | } |
| | |
| | | } |
| | | |
| | | List<User_inf> listu=userInfMapper.serchUname(user); |
| | | System.out.println("listu.size() = " + listu.size()); |
| | | if(listu!=null && listu.size()>0){ |
| | | //System.out.println(listu.get(0).getuName()); |
| | | list.get(i).getUtask().setNote(listu.get(0).getuName()); |
| | |
| | | /*for (int j=0;j<10;j++) { |
| | | System.out.println(list.get(j).getBinf()); |
| | | }*/ |
| | | |
| | | PageInfo<Task_Batt_Test> pageInfo = new PageInfo<>(list); |
| | | model.setCode(1); |
| | | model.setData(list); |
| | | model.setData(pageInfo); |
| | | // model.setSum(count); |
| | | //TODO perry |
| | | if(listU!=null && listU.size()>0){ |
| | | model.setSum(listU.get(0).getPageBean().getPageAll()); |
| | | if(listUBT!=null && listUBT.size()>0){ |
| | | // model.setSum(listU.get(0).getPageBean().getPageAll()); |
| | | model.setSum((int)pageInfo.getTotal()); |
| | | }else{ |
| | | model.setSum(0); |
| | | } |
| | |
| | | //0.1作业管理查询user_task所有信息 |
| | | public ServiceModel serchByTask(Task_Batt_Test tbt) { |
| | | ServiceModel model = new ServiceModel(); |
| | | //分页 |
| | | PageBean pageBean = tbt.getPageBean(); |
| | | PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true); |
| | | List<Task_Batt_Test> list = mapper.serchByTask(tbt); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | PageBean pageBean = new PageBean(); |
| | | list.get(i).setPageBean(pageBean); |
| | | list.get(i).setUinf(new User_inf());//封装结果集原有 |
| | | } |
| | | // System.out.println(list.size()); |
| | | |
| | | int index = 0; |
| | | if (list != null && list.size() > 0) { |
| | | System.out.println("tbt.getPageBean() = " + tbt.getPageBean()); |
| | | int i1 = (tbt.getPageBean().getPageCurr() - 1) * tbt.getPageBean().getPageSize(); |
| | | int i2 = tbt.getPageBean().getPageSize() * tbt.getPageBean().getPageCurr(); |
| | | for (int i = i1; i < i2 && i < list.size(); i++) { |
| | | list.get(index++).getPageBean().setPageAll(list.size()); |
| | | } |
| | | // System.out.println("tbt.getPageBean() = " + tbt.getPageBean()); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | list.get(i).getUinf().setuName(UtilityFactory.UidsToUnames(list.get(i).getBinf().getStationName1())); |
| | | list.get(i).setUinf(new User_inf()); |
| | | list.get(i).getUinf().setuName(utilityFactoryService.UidsToUnames(list.get(i).getBinf().getStationName1())); |
| | | } |
| | | |
| | | PageInfo<Task_Batt_Test> pageInfo = new PageInfo<>(list); |
| | | model.setCode(1); |
| | | model.setData(list); |
| | | model.setData(pageInfo); |
| | | |
| | | } else { |
| | | model.setCode(0); |