CheckHeaderService.java
1.26 KB
package com.huaheng.pc.check.checkHeader.service;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.check.checkHeader.domain.CheckHeader;
import com.huaheng.pc.check.checkHeader.mapper.CheckHeaderMapper;
@Service
public class CheckHeaderService extends ServiceImpl<CheckHeaderMapper, CheckHeader> {
@Resource
private CheckHeaderMapper checkHeaderMapper;
//根据单据类型建单据号
public String createCode(String checkType)
{
String code = null;
Date now = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
String maxCode = checkHeaderMapper.createCode(checkType);
if (maxCode != null && maxCode.length() > 13 && maxCode.substring(maxCode.length() - 13, maxCode.length() - 5).equals(df.format(now)))
{
Integer Count = Integer.valueOf(maxCode.substring(maxCode.length() - 5, maxCode.length()));
code = checkType + df.format(now) + String.format("%05d", Count + 1);
}
else
{
code = checkType + df.format(now) + "00001";
}
return code;
}
}