zoukankan      html  css  js  c++  java
  • Maven单元测试

    //         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);
        }
  • 相关阅读:
    GdiPlus[34]: IGPGraphicsPath (一)
    GdiPlus[33]: 基本绘图与填充命令
    GdiPlus[29]: IGPPen: 虚线样式
    [征询意见]博客园logo
    [公告]网站恢复正常运行
    [公告]博客园将与博文视点合作推出一系列.NET图书
    [公告]由Bruce Zhang负责博客园的出书工作
    通过Windows Live Alerts订阅博客园首页RSS
    [征询意见]博客园新logo
    [新功能]新闻管理
  • 原文地址:https://www.cnblogs.com/jwlfpzj/p/7489520.html
Copyright © 2011-2022 走看看