|
|
|
@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
@ -64,29 +65,15 @@ public class PublicController extends BaseController { |
|
|
|
*/ |
|
|
|
@GetMapping("/getSn") |
|
|
|
public AjaxResult getSn(Integer count) { |
|
|
|
if (count == null || count.intValue() <= 0) { |
|
|
|
return AjaxResult.error("参数错误"); |
|
|
|
if (count == null || count.intValue() <= 1) { |
|
|
|
return AjaxResult.success("操作成功",snGenService.getNewSn()); |
|
|
|
}else{ |
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
for (int i = 0; i < count;i++){ |
|
|
|
list.add(snGenService.getNewSn()); |
|
|
|
} |
|
|
|
return AjaxResult.success(list); |
|
|
|
} |
|
|
|
// Integer start = 1; |
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd"); |
|
|
|
// String today = sdf.format(new Date()); |
|
|
|
// //获取当前最大编号 |
|
|
|
// String maxNum = redisService.getCacheObject(today); |
|
|
|
// if (StringUtils.isNoneBlank(maxNum)) { |
|
|
|
// start = Integer.parseInt(maxNum)+1; |
|
|
|
// } |
|
|
|
// HashMap<String, Object> map = new HashMap<String, Object>(count); |
|
|
|
// for (int i = 0; i < count;i++){ |
|
|
|
// map.put("sn"+i,today+String.format("%04d", start)); |
|
|
|
// start++; |
|
|
|
// } |
|
|
|
// //更新当前最大编号 |
|
|
|
// redisService.setCacheObject(today,start,60*60*24L, TimeUnit.SECONDS); |
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>(count); |
|
|
|
for (int i = 0; i < count;i++){ |
|
|
|
map.put("sn"+i,snGenService.getNewSn()); |
|
|
|
} |
|
|
|
return AjaxResult.success(map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|