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