//         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. 如何写好一个vue组件,老夫的一年经验全在这了【转】 v-bind="$attrs" 和 v-on="$listeners"

    如何写好一个vue组件,老夫的一年经验全在这了 一个适用性良好的组件,一种是可配置项很多,另一种就是容易覆写,从而扩展功能 Vue 组件的 API 来自三部分——prop.事件和插槽: prop 允许 ...

  2. 关于CSS3三角的实现

    1,向上的三角 ;;           ;;           </html> 3,向左的三角 ;;           </html> 4,向右的三角 ;;        ...

  3. python读取.mat文件

    可以先看一下.mat中存了些什么: import scipy.io as sio box_file = '/home/bnrc/formatm/test/1479504458876408533_box ...

  4. Ubuntu下Hyperledger Fabric v0.6安装部署

    系统环境:虚拟机VMware Workstation中的Ubuntu 16.04LTS 1.环境准备 1.1安装Docker Docker安装命令: curl –fsSL https://get.do ...

  5. 多数据源连接Oracle报错,linux熵池耗尽问题

    最近碰到了个很有意思的问题,springboot加载多数据源,遇到了在启动时数据库连接报错的问题. 报错信息: The error occurred while executing a query 然 ...

  6. shelll脚本,根据软链接,找到真实路径

    [root@localhost tmp]# ls -l total lrwxrwxrwx root root Sep : abc -> /etc/passwd lrwxrwxrwx root r ...

  7. iOS HmacSHA1加密 和 MD5 Base64加密 --iOS开发系列---项目中成长的知识五

    项目中开发中需要对一些数据进行加密后和服务器验证是否是我们客户端发出的请求! 方案是服务器定的,使用HmacSHA1加密和MD5 Base64加密 加密过程比较复杂 1.获取格林威治时间 2.用bas ...

  8. proto_ops和proto区别

    **proto_ops:**该结构体包含了某个特定的"protocol family"的一系列functions. 其包含的functions和struct proto很类似,但是 ...

  9. modprode

    modprobe命令 1.modprobe 命令是根据depmod -a的输出/lib/modules/version/modules.dep来加载全部的所需要模块. 2.删除模块的命令是:modpr ...

  10. clock gate

    clock gate 这个专题,比较复杂设计DC  PT PR.下面仅仅从RTL行为级说明一下.