//         SKU码:系列前3位+6位年月日+3位序号(自动生产,取数据库中当天最大的,没有就赋值位001)

//        订单编号:BRD+6位年月日+5位序号
//
// 退单号:BRT+6位年月日+3位序号 @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/spring/applicationContext-dao.xml")
public class CodeGenerateServiceImplTest { private final Logger logger = Logger.getLogger(this.getClass());
@Autowired
private CodeGenerateMapper codeGenerateMapper; @Test
public void insertOne() throws Exception {
BMUtil bmUtil = new BMUtil();
//参数s
String firstCode = "BRG";
String generateType = bmUtil.BRG;
// String generateType = "BRG";
int indexSize = 3;
//参数e
String zero = "";
for (int i = 0; i < indexSize; i++) {
zero += "0";
}
Date dt = new Date();
SimpleDateFormat matter1 = new SimpleDateFormat("yyyyMMdd");
String secondCode = matter1.format(dt); // 当天的日期六位格式化 CodeGenerate codeGenerate = new CodeGenerate();
codeGenerate.setFirstCode(firstCode);
codeGenerate.setSecondCode(secondCode);
codeGenerate.setGenerateType(generateType); String maxLastCode = codeGenerateMapper.getMaxLastCode(codeGenerate);
String newLastCode = "";
if (maxLastCode != "" && maxLastCode != null) {
int maxLastCodeNum = Integer.valueOf(maxLastCode);
maxLastCodeNum++;
Format f = new DecimalFormat(zero);
newLastCode = f.format(maxLastCodeNum);
System.out.println(newLastCode); } else {
int num = 1;
Format ff = new DecimalFormat(zero);
newLastCode = ff.format(num);
System.out.println(newLastCode);
}
codeGenerate.setLastCode(newLastCode);
// 插入数据库
int t = codeGenerateMapper.insertOne(codeGenerate); //通过插入后返回的主见,查询编码信息
System.out.println(codeGenerate.getId());
List<CodeGenerate> codeGenerateList = codeGenerateMapper.getCodeGenerateById(codeGenerate.getId());
String bm = codeGenerateList.get(0).getFirstCode() + codeGenerateList.get(0).getSecondCode() + codeGenerateList.get(0).getLastCode();
logger.info(JSON.toJSONStringWithDateFormat(codeGenerateList, "yyyy-MM-dd HH:mm:ss"));
System.out.println(bm);
}

最新文章

  1. BZOJ1303 [CQOI2009]中位数图
  2. loadrunner怎么将变量保存到参数中
  3. linux常识以及常用命令和参数
  4. html-php深入理解
  5. hibernateUtils
  6. [ActionScript] AS3代码实现曝光过度效果
  7. eclipse优化(部分)
  8. 在非UI线程中更改UI(Delphi使用隐藏窗口来处理,QT使用信号槽)
  9. hdu 1175 连连看 DFS
  10. git 20181119
  11. 渐变UI
  12. Python3.7 dataclass 介绍
  13. virtualbox 在物理机是无线网卡的时候做桥接配置
  14. 吴裕雄 python 熵权法确定特征权重
  15. TZOJ 3481 Highway Construction(树的直径+最短路)
  16. cookie 组成结构
  17. 【LeetCode】74. Search a 2D Matrix
  18. 已知(x,y,z,yaw,pitch,roll)如何得到4*4的转换矩阵?
  19. virtualbox 错误解决记录
  20. 剑指 Offer——数字在排序数组中出现的次数

热门文章

  1. vue2.0的变化
  2. Vue之父子组件的通信
  3. javaEE(9)_在线支付
  4. javascript基础知识 (八) BOM学习笔记
  5. P2261 bzoj1257 [CQOI2007]余数求和
  6. nginx + 一个端口 部署多个单页应用(history模式)
  7. verilog random使用
  8. Django初学及mvt模型理解
  9. 学习Python第一天,命令很多跟Linux还有脚本语言相似。
  10. 解决windows管理员已阻止你运行此应用问题