数据表为空时,设置自增字段为1
master
Limy 4 years ago
parent 40df46158c
commit db2a0a7a59

@ -1,5 +1,6 @@
package com.ruoyi.web.controller.nanjing;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.core.text.Convert;
@ -78,9 +79,20 @@ public class TBdProductinfoController extends BaseController
public String add(ModelMap map)
{
List<TBdProductinfo> list = tBdProductinfoService.selectTBdProductinfo();
int max = Convert.toInt(list.get(0).getProductID());
list.get(0).setProductID(max+1L);
map.addAttribute("pt",list);
int max;
if(list.size()==0){
max=0;
List<TBdProductinfo> list1 = new ArrayList<>();
TBdProductinfo tBdProductinfo = new TBdProductinfo();
tBdProductinfo.setProductID(max+1L);
list1.add(tBdProductinfo);
map.addAttribute("pt",list1);
}
else{
max = Convert.toInt(list.get(0).getProductID());
list.get(0).setProductID(max+1L);
map.addAttribute("pt",list);
}
return prefix + "/add";
}

@ -1,8 +1,10 @@
package com.ruoyi.web.controller.nanjing;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.nanjing.domain.TBdProductinfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -77,10 +79,20 @@ public class TBdProducttypeController extends BaseController
public String add(ModelMap map)
{
List<TBdProducttype> list = tBdProducttypeService.selectTBdProducttype();
int max = Convert.toInt(list.get(0).getProductTypeID());
String oper = max + 1+"";
list.get(0).setProductTypeID(oper);
map.addAttribute("pt",list);
int max ;
if(list.size()==0){
max = 0;
List<TBdProducttype> list1 = new ArrayList<>();
TBdProducttype tBdProducttype = new TBdProducttype();
tBdProducttype.setProductTypeID(max+1L+"");
map.addAttribute("pt",list1);
}else{
max = Convert.toInt(list.get(0).getProductTypeID());
String oper = max + 1+"";
list.get(0).setProductTypeID(oper);
map.addAttribute("pt",list);
}
return prefix + "/add";
}

@ -1,9 +1,6 @@
package com.ruoyi.web.controller.nanjing;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.common.core.text.Convert;
@ -108,17 +105,36 @@ public class TBdSubstationController extends BaseController
{
//工位序号+
List<TBdSubstation> list = tBdSubstationService.selectStationcode();
int max = Convert.toInt(list.get(0).getStationID());
list.get(0).setStationID(max+1L);
int max;
if(list.size()==0){
max = 0;
List<TBdSubstation> lists = new ArrayList<>();
TBdSubstation tBdSubstation = new TBdSubstation();
tBdSubstation.setStationID(max+1L);
lists.add(tBdSubstation);
map.addAttribute("si",lists);
}else{
max = Convert.toInt(list.get(0).getStationID());
list.get(0).setStationID(max+1L);
map.addAttribute("si",list);
}
//排序id+
List<TBdSubstation> list1 = tBdSubstationService.selectOrderid();
int max1 = Convert.toInt(list.get(0).getOrderID());
list.get(0).setOrderID(max1+1L);
int max1;
if(list1.size()==0){
max1 = 0;
List<TBdSubstation> list2 = new ArrayList<>();
TBdSubstation tBdSubstation = new TBdSubstation();
tBdSubstation.setOrderID(max1+1L);
list2.add(tBdSubstation);
map.addAttribute("oi",list2);
}else{
max1 = Convert.toInt(list.get(0).getOrderID());
list1.get(0).setOrderID(max1+1L);
map.addAttribute("oi",list1);
}
List<TBdLinetype> linetypes = linetypeService.selectTBdLinetypeList(new TBdLinetype());
List<TBdStationtype> stationtypes = stationtypeService.selectTBdStationtypeList(new TBdStationtype());
map.addAttribute("si",list);
map.addAttribute("oi",list);
map.addAttribute("linename",linetypes);
map.addAttribute("stationtype",stationtypes);
return prefix + "/add";

@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:sqlserver://121.36.58.109:1433;SelectMethod=cursor;DatabaseName=SecondNanjing
url: jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=FYATJ
username: sa
password: haiwei@123
password: 123456
# 从库数据源
slave:
# 从数据源开关/默认关闭

Loading…
Cancel
Save