|
@@ -144,6 +144,75 @@ public class SerialnumTplService {
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
|
|
@Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
|
|
|
|
+ public String genSerialNumNoSort(String companyId, String bizCode) throws Exception {
|
|
|
|
+ //获取当前登录人信息
|
|
|
|
+ UserDTO dto = UserUtils.getCurrentUserDTO();
|
|
|
|
+ Office office = officeMapper.selectById(companyId);
|
|
|
|
+ if (StringUtils.isBlank(bizCode)){
|
|
|
|
+ throw new Exception("生成编号失败,业务类型不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (office != null) {
|
|
|
|
+ SysSerialnumTpl numTpl = this.querySerialTpl(office, bizCode);
|
|
|
|
+ if (numTpl == null) {
|
|
|
|
+ //查询编号模板 {brspnm}DZ-{year}-{serialNum}
|
|
|
|
+ SysSerialnumTpl serialNumTpl = serialnumTplMapper.queryByComAndBizCode(companyId, bizCode);
|
|
|
|
+ serialNumTpl.setCompanyId(companyId);
|
|
|
|
+ serialNumTpl.setSerialNum(0);
|
|
|
|
+ serialNumTpl.setCreateBy(dto.getId());
|
|
|
|
+ serialNumTpl.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+ serialnumTplMapper.insert(serialNumTpl);
|
|
|
|
+ numTpl = serialNumTpl;
|
|
|
|
+ }
|
|
|
|
+ if (numTpl == null) {
|
|
|
|
+ throw new Exception("生成编号失败,请先设置相关业务编号模板");
|
|
|
|
+ }
|
|
|
|
+ String year = DateUtils.formatDate(new Date(), "yyyy");
|
|
|
|
+ if (!year.equals(numTpl.getYearBuilt())) {
|
|
|
|
+ serialnumTplMapper.resetSerialNum(numTpl.getId(), numTpl.getYearBuilt(), year);
|
|
|
|
+ }
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ String serialTpl = numTpl.getSerialTpl();
|
|
|
|
+ int i = serialnumTplMapper.updateSerialNum(numTpl);
|
|
|
|
+ if (i != 1) {
|
|
|
|
+ throw new Exception("生成编号失败,请稍后重试");
|
|
|
|
+ }
|
|
|
|
+ String num = String.valueOf(numTpl.getSerialNum() + 1);
|
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
|
+ sb.append(num);
|
|
|
|
+ //查询公司简称
|
|
|
|
+ if (serialTpl.contains("spnm")) {
|
|
|
|
+ String companyShortname = UserUtils.getSysParam("company_shortname");
|
|
|
|
+ map.put("spnm", StringUtils.isBlank(companyShortname) ? "" : companyShortname);
|
|
|
|
+ }
|
|
|
|
+ //查询分公司简称
|
|
|
|
+ if (serialTpl.contains("brspnm")) {
|
|
|
|
+ String branchShortname = UserUtils.getSysParam("branch_shortname");
|
|
|
|
+ map.put("brspnm", StringUtils.isBlank(branchShortname) ? "" : branchShortname);
|
|
|
|
+ }
|
|
|
|
+ //年份
|
|
|
|
+ if (serialTpl.contains("year")) {
|
|
|
|
+ map.put("year", year);
|
|
|
|
+ }
|
|
|
|
+ //月份
|
|
|
|
+ if (serialTpl.contains("month")) {
|
|
|
|
+ int month = new Date().getMonth() + 1;
|
|
|
|
+ map.put("month", month + "");
|
|
|
|
+ }
|
|
|
|
+ //序列号
|
|
|
|
+ if (serialTpl.contains("serialNum")) {
|
|
|
|
+ map.put("serialNum", sb.toString());
|
|
|
|
+ }
|
|
|
|
+ //日期
|
|
|
|
+ if (serialTpl.contains("day")) {
|
|
|
|
+ map.put("day", new Date().getDate() + "");
|
|
|
|
+ }
|
|
|
|
+ String serNum = StringUtils.renderString(serialTpl, map);
|
|
|
|
+ return serNum;
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
|
|
public String genSerialReviewNum(String companyId, String bizCode) throws Exception {
|
|
public String genSerialReviewNum(String companyId, String bizCode) throws Exception {
|
|
//获取当前登录人信息
|
|
//获取当前登录人信息
|
|
UserDTO dto = UserUtils.getCurrentUserDTO();
|
|
UserDTO dto = UserUtils.getCurrentUserDTO();
|