当findById(Integer id)变成String类型

时间:2021-07-04 22:04:44

1、原Action

// 添加跳转
    @RequiresPermissions("pdaManager:v_add")
    @RequestMapping("/pdaManager/v_add.do")
    public String add(HttpServletRequest request, ModelMap model) {
        List<BeanDataDictionary> sbztList = dataMng.findByPid(128);
        List<BeanEquipmentModel> list = equipMng.getList();
        List<BeanEquipmentModel> zdxhList = new ArrayList<BeanEquipmentModel>();
        for(BeanEquipmentModel equip : list){
             BeanFacturer facture = facMng.findById(equip.getFacturerId());
             BeanEquipmentModel bean = new BeanEquipmentModel();
             bean.setModel_code(equip.getModel_code()+"("+facture.getFacturer_short()+")"); bean.setId(equip.getId()); zdxhList.add(bean); }
        
        model.addAttribute("zdxhList", zdxhList);
        model.addAttribute("sbztList", sbztList);
        return "pdaManager/add";
    }

2、新action

// 添加跳转
    @RequiresPermissions("pdaManager:v_add")
    @RequestMapping("/pdaManager/v_add.do")
    public String add(HttpServletRequest request, ModelMap model) {
        List<BeanDataDictionary> sbztList = dataMng.findByPid(128);
        List<BeanEquipmentModel> list = equipMng.getList();
        List<BeanEquipmentModel> zdxhList = new ArrayList<BeanEquipmentModel>();
        for(BeanEquipmentModel equip : list){
            String ids = equip.getFacturerId();
            String id[] =  ids.split(",");
            for (int i = 0; i < id.length; i++) {
             BeanFacturer facture = facMng.findById(Integer.parseInt(id[i]));
             BeanEquipmentModel bean = new BeanEquipmentModel();
             bean.setModel_code(equip.getModel_code()+"("+facture.getFacturer_short()+")");
             bean.setId(equip.getId());
             zdxhList.add(bean);            
        }
        }
        model.addAttribute("zdxhList", zdxhList);
        model.addAttribute("sbztList", sbztList);
        return "pdaManager/add";
    }