ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/BaseOnlyValController.java
@@ -45,6 +45,15 @@ BaseOnlyvalue baseOnlyvalue = baseOnlyvalueService.getOnlyCode(businessType, datequery); return AjaxResult.success(baseOnlyvalue); } /** * 获取唯一编号 */ @ApiOperation("获取序列号") @GetMapping("/getSequence") public AjaxResult getSequence( String businessType, String orgId) { return AjaxResult.success(baseOnlyvalueService.getSequence(businessType, orgId)); } } ruoyi-project/src/main/java/com/ruoyi/project/service/IBaseOnlyvalueService.java
@@ -28,4 +28,12 @@ * @return */ public BaseOnlyvalue getOnlyCode(String businessType, Boolean datequery); /** * 获取序列号 * * @param businessType * @return */ public String getSequence(String businessType, String orgId); } ruoyi-project/src/main/java/com/ruoyi/project/service/impl/BaseOnlyvalueServiceImpl.java
@@ -8,10 +8,12 @@ import com.ruoyi.project.domain.BaseOnlyvalue; import com.ruoyi.project.mapper.BaseOnlyvalueMapper; import com.ruoyi.project.service.IBaseOnlyvalueService; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.util.List; @@ -101,4 +103,39 @@ } /** * 获取序列号 * * @param businessType * @return */ @Override public String getSequence(String businessType, String orgId) { LocalDate currentDate = LocalDate.now(); int year = currentDate.getYear(); String month = currentDate.getMonthValue()+""; if(month.length()==1) month="0"+month; if(ObjectUtils.isEmpty(orgId)){ orgId=""; } //通过年月日期去查询该月份是否存在 String data =year + month+orgId; BaseOnlyvalue baseOnlyvalue = new BaseOnlyvalue(); baseOnlyvalue.setBusinesstype(businessType); List<BaseOnlyvalue> baseOnlyvalues = queryList(baseOnlyvalue); if(baseOnlyvalues.size()==0){ baseOnlyvalue.setAppentvalue(data); baseOnlyvalue.setCurrentvalue(1L); baseOnlyvalue.setBusinesstype(businessType); save(baseOnlyvalue); }else { baseOnlyvalue= baseOnlyvalues.get(0); baseOnlyvalue.setCurrentvalue(baseOnlyvalue.getCurrentvalue()+1); updateById(baseOnlyvalue); } return baseOnlyvalue.getAppentvalue() + data + baseOnlyvalue.getCurrentvalue(); } } ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceTransportServiceImpl.java
@@ -10,6 +10,7 @@ import com.ruoyi.project.mapper.ServiceTransportMapper; import com.ruoyi.project.service.IServiceTransportFileService; import com.ruoyi.project.service.IServiceTransportService; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,6 +43,7 @@ LambdaQueryWrapper<ServiceTransport> wrappers = getWrappers(serviceTransport); // 添加create_time不为空的条件 wrappers.isNotNull(ServiceTransport::getCreateTime); // 然后进行倒序排序 wrappers.orderByDesc(ServiceTransport::getCreateTime); // 创建分页对象,设置页码和每页大小 @@ -88,6 +90,9 @@ private LambdaQueryWrapper<ServiceTransport> getWrappers(ServiceTransport serviceTransport) { LambdaQueryWrapper<ServiceTransport> wrappers = Wrappers.lambdaQuery(); if (ObjectUtils.isNotEmpty(serviceTransport.getId() )) { wrappers.eq(ServiceTransport::getId, serviceTransport.getId()); } if (serviceTransport.getReportId() != null) { wrappers.eq(ServiceTransport::getReportId, serviceTransport.getReportId()); }