| | |
| | | import com.fgkj.mapper.UinfDaoFactory; |
| | | import com.fgkj.mapper.impl.User_infMapper; |
| | | import com.fgkj.util.ActionUtil; |
| | | 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; |
| | |
| | | //5.1用户管理(添加) |
| | | public ServiceModel add(User_inf obj) { |
| | | ServiceModel model = new ServiceModel(); |
| | | int flag=mapper.addJudge(obj); //查询,不需要开启事务 |
| | | int flag = mapper.addJudge(obj); //查询,不需要开启事务 |
| | | //System.out.println(flag); |
| | | if(flag==0){ |
| | | Boolean bl=mapper.add(obj)>0; |
| | | if(bl){ |
| | | if (flag == 0) { |
| | | Boolean bl = null; |
| | | try { |
| | | bl = mapper.add(obj) > 0; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | model.setCode(0); |
| | | model.setMsg("添加失败!"); |
| | | return model; |
| | | } |
| | | if (bl) { |
| | | model.setCode(1); |
| | | model.setMsg("添加成功!"); |
| | | } else{ |
| | | } else { |
| | | model.setCode(0); |
| | | model.setMsg("添加失败!"); |
| | | } |
| | | }else{ |
| | | } else { |
| | | model.setCode(0); |
| | | model.setMsg("用户名存在,请重新输入!"); |
| | | } |
| | |
| | | public ServiceModel update(User_inf obj) { |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl = false; |
| | | bl=mapper.update(obj); |
| | | if(bl){ |
| | | try { |
| | | bl = mapper.update(obj); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | model.setCode(0); |
| | | model.setMsg("添加失败!"); |
| | | return model; |
| | | } |
| | | if (bl) { |
| | | model.setCode(1); |
| | | model.setMsg("修改成功"); |
| | | }else{ |
| | | } else { |
| | | model.setCode(0); |
| | | model.setMsg("修改失败"); |
| | | } |
| | |
| | | return model; |
| | | } |
| | | |
| | | public ServiceModel serchByCondition(Object obj) { |
| | | public ServiceModel serchByCondition(User_inf obj) { |
| | | ServiceModel model = new ServiceModel(); |
| | | List list = mapper.serchByCondition(obj); |
| | | /* |
| | | * for (Object object : list) { System.out.println(object); } |
| | |
| | | |
| | | public ServiceModel searchAll() { |
| | | List<User_inf> list = mapper.searchAll(); |
| | | /* |
| | | * for (User_inf u : list) { System.out.println(u); } |
| | | */ |
| | | |
| | | if (list != null && list.size() > 0) { |
| | | model.setCode(1); |
| | |
| | | } |
| | | |
| | | // 根据battgroupid查对应的包机人 |
| | | public ServiceModel searchByBattGroupId(Object obj) { |
| | | model = new ServiceModel(); |
| | | public ServiceModelImpl2 searchByBattGroupId(User_battgroup_baojigroup_battgroup obj) { |
| | | ServiceModelImpl2 model = new ServiceModelImpl2(); |
| | | List<User_inf> list = mapper.searchByBattGroupId(obj); |
| | | // System.out.println(list.size()); |
| | | /* |
| | |
| | | } |
| | | uStrN = uStrN.substring(1, uStrN.length()); |
| | | uStrI = uStrI.substring(1, uStrI.length()); |
| | | //TODO perry |
| | | /*model.setMsg(uStrN); |
| | | model.setMsgO(uStrI);*/ |
| | | model.setMsg(uStrN); |
| | | model.setMsgO(uStrI); |
| | | } else { |
| | | model.setCode(0); |
| | | } |
| | | // System.out.println(model.getMsg()); |
| | | // System.out.println(model); |
| | | // System.out.println(model.getMsg()); |
| | | // System.out.println(model); |
| | | return model; |
| | | } |
| | | |
| | | // 3.1根据uid查用户信息(uname) |
| | | public ServiceModel serchuName(User_inf inf) { |
| | | model = new ServiceModel(); |
| | | ServiceModel model = new ServiceModel(); |
| | | List list = mapper.serchUname(inf); |
| | | if (list != null && list.size() > 0) { |
| | | model.setCode(1); |
| | |
| | | } |
| | | |
| | | // 5.1查询员工的所有信息 |
| | | public ServiceModel searchAll2(Batt_User_Permit bup) { |
| | | // System.out.println((Batt_User_Permit)obj); |
| | | public ServiceModel searchAll(Batt_User_Permit bup) { |
| | | ServiceModel model = new ServiceModel(); |
| | | //分页 |
| | | PageBean pageBean = bup.getPageBean(); |
| | | PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true); |
| | | List<Batt_User_Permit> list = mapper.searchAll2(bup);// 存放的是员工信息 |
| | | List<Batt_User_Permit> listd =new ArrayList<>(); |
| | | int index=0; |
| | | for(int i=(bup.getPageBean().getPageCurr()-1)*bup.getPageBean().getPageSize();i<bup.getPageBean().getPageSize()*bup.getPageBean().getPageCurr()&&i<list.size();i++){ |
| | | |
| | | // listd.add((Batt_User_Permit) list.get(i)); |
| | | Batt_User_Permit batt_user_permit = list.get(i); |
| | | batt_user_permit.setPageBean(new PageBean()); |
| | | listd.add(batt_user_permit); |
| | | System.out.println(list.get(i)); |
| | | ((Batt_User_Permit)listd.get(index++)).getPageBean().setPageAll(list.size()); |
| | | } |
| | | list=listd; |
| | | |
| | | if (list != null && list.size() > 0) { |
| | | model.setCode(1); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | ServiceModelImpl model1 = upservice.serchByCondition(list.get(i).getUinf());// 存放权限 |
| | | // System.out.println(model1.getMsgN()); |
| | | if (model1.getCode() > 0) { |
| | | //TODO perry |
| | | list.get(i).getUinf().setPermitgroupName(model1.getMsgN()); |
| | | } else { |
| | | list.get(i).getUinf().setPermitgroupName(""); |
| | | } |
| | | } |
| | | model.setData(list); |
| | | PageInfo<Batt_User_Permit> pageInfo = new PageInfo<>(list); |
| | | model.setData(pageInfo); |
| | | } |
| | | // System.out.println(model); |
| | | return model; |
| | |
| | | } |
| | | |
| | | //修改用户密码 |
| | | public ServiceModel updatePassword(User_inf obj){ |
| | | public ServiceModel updatePassword(User_inf uinf){ |
| | | ServiceModel model = new ServiceModel(); |
| | | User_inf uinf=(User_inf) obj; |
| | | uinf.setUpassword((String)ActionUtil.EncryptionMD5(uinf.getuSnId())); |
| | | //System.out.println(uinf); |
| | | Boolean bl=mapper.updatePassword(uinf); |
| | |
| | | } |
| | | |
| | | //根据员工信息和员工编号去匹配合适的员工 |
| | | public ServiceModel searchByNameOrId(Batt_User_Permit obj){ |
| | | PageBean pageBean = obj.getPageBean(); |
| | | int curr = (pageBean.getPageCurr() - 1) * pageBean.getPageSize(); |
| | | obj.getPageBean().setPageCurr(curr); |
| | | List<User_inf> list=mapper.searchByNameOrId(obj); |
| | | public ServiceModel searchByNameOrId(Batt_User_Permit bup){ |
| | | |
| | | //分页 |
| | | PageBean pageBean = bup.getPageBean(); |
| | | PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true); |
| | | List<User_inf> list=mapper.searchByNameOrId(bup); |
| | | |
| | | if(list!=null&&list.size()>0){ |
| | | //去掉limit条件后的总数 |
| | | int number=mapper.getLimtitNumber(); |
| | | System.out.println("number = " + number); |
| | | list.get(list.size()-1).setuNote(String.valueOf(number)); |
| | | list.get(list.size()-1).setuNote(""+pageBean.getPageAll()); |
| | | PageInfo<User_inf> pageInfo = new PageInfo<>(list); |
| | | model.setCode(1); |
| | | model.setData(list); |
| | | model.setData(pageInfo); |
| | | model.setMsg("查询成功!"); |
| | | } |
| | | else{ |
| | |
| | | |
| | | //包机组重做(穿梭框)查询所有的用户 |
| | | public ServiceModel searchCS_All() { |
| | | ServiceModel model = new ServiceModel(); |
| | | List list=mapper.searchCS_All(); |
| | | if(list!=null&&list.size()>0){ |
| | | model.setCode(1); |