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

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

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

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

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

Loading…
Cancel
Save