//         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);
}

Maven单元测试的更多相关文章

  1. maven单元测试设置代理

    背景 环境需要设置代理才能够访问外部网络,如果只是运行java程序来访问网络,我们可以通过java -jar test.jar -DproxyHost=proxy_ip -DproxyPort=pro ...

  2. maven 单元测试 ( http://www.cnblogs.com/qinpengming/p/5225380.html )

     对junit单元测试的报告:类似这样的结果 ------------------------------------------------------- T E S T S ----------- ...

  3. junit+maven单元测试

    一.概念 junit是一个专门测试的框架 集合maven进行单元测试,可批量测试类中的大量方法是否符合预期 二.作用:单元测试:测试的内容是类中的方法,每一个方法都是独立测试的.方法是测试的基本单位. ...

  4. maven单元测试报java.lang.IllegalStateException: Failed to load ApplicationContext

    报这个异常java.lang.IllegalStateException: Failed to load ApplicationContext的时候,通常是因为applicationContent.x ...

  5. [转]利用maven的surefire插件实现单元测试与集成测试

    原文链接 http://my.oschina.net/dlpinghailinfeng/blog/301136 maven单元测试与集成测试 通过maven的Profile 配置生命周期 通过mave ...

  6. 工程化管理--maven

    mavne模型 可以看出 maven构件都是由插件支撑的 maven的插件位置在:F:\MavenRepository\org\apache\maven\plugins Maven仓库布局 本地仓库 ...

  7. Maven运行JUnit测试(http://www.360doc.com/content/13/0927/15/7304817_317455642.shtml)

    Maven单元测试 分类: maven 2012-05-09 15:17 1986人阅读 评论(1) 收藏 举报 maven测试junit单元测试javarandom   目录(?)[-] maven ...

  8. Quartz学习——SSMM(Spring+SpringMVC+Mybatis+Mysql)和Quartz集成详解(四)

    当任何时候觉你得难受了,其实你的大脑是在进化,当任何时候你觉得轻松,其实都在使用以前的坏习惯. 通过前面的学习,你可能大致了解了Quartz,本篇博文为你打开学习SSMM+Quartz的旅程!欢迎上车 ...

  9. (转) Quartz学习——SSMM(Spring+SpringMVC+Mybatis+Mysql)和Quartz集成详解(四)

    http://blog.csdn.net/u010648555/article/details/60767633 当任何时候觉你得难受了,其实你的大脑是在进化,当任何时候你觉得轻松,其实都在使用以前的 ...

随机推荐

  1. 理想路径——双向BFS

    题目 给n个点m条边(2 ≤ n ≤ 100000,1 ≤ m ≤ 200000)的无向图,每条边上都涂有一种颜色.求从结点1到结点n的一条路径,使得经过的边数尽量的少,在此前提下,经过边的颜色序列的 ...

  2. vue2.0的变化

    1. 在每个组件模板,不在支持片段代码 组件中模板: 之前: <template> <h3>我是组件</h3><strong>我是加粗标签</st ...

  3. Vue项目经验

    Vue项目经验 setInterval路由跳转继续运行并没有及时进行销毁比如一些弹幕,走马灯文字,这类需要定时调用的,路由跳转之后,因为组件已经销毁了,但是setInterval还没有销毁,还在继续后 ...

  4. Synchronized关键字整理

    Synchronized关键字整理 作用:能够保证在同一时刻最多只有一个线程执行该段代码,以达到保证并发安全效果. 两个用法: 1.对象锁: 包括方法锁(默认锁对象为this当前实例对象)和同步代码块 ...

  5. 冒泡法排序参考(Java)

    package com.swift; public class Maopao { //冒泡法 public static void main(String[] args) { int[] arr= { ...

  6. 随机生成一份试卷,试卷的种类分为单选、多选、判断三种题型。nodejs6.0 mysql

    背景:从数据库中,随机生成一份试卷,试卷的种类分为单选.多选.判断三种题型. 首先我需要生成随机数id(在这之前我需要知道数据库中各个题型的题数,这样我才能设置随机数),并依据生成的随机数id,去查找 ...

  7. C++_STL基础案例

    C++ C++三种容器:list.vector和deque的区别:https://blog.csdn.net/gogokongyin/article/details/51178378 一.容器 小常识 ...

  8. c++ 计算彩票中奖概率

    操作方法: 输入两个数字,第一个数字是备选总数,第二个数字是选择总数,然后返回中将概率. 可以投注多次,结束的时候返回总的中将概率. #include <iostream> using n ...

  9. python--第一类对象,函数名,变量名

    一 . 第一类对象 函数对象可以像变量一样进行赋值 , 还可以作为列表的元素进行使用 可以作为返回值返回 , 可以作为参数进行传递 def func(): def people(): print('金 ...

  10. Makefile文件中的sed介绍

    haoxin$ sed --helpUsage: sed [OPTION]... {script-only-if-no-other-script} [input-file]... -n, --quie ...