diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java index 3195f87..7adc751 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java @@ -11,17 +11,24 @@ import com.hxhq.business.form.study.StudyFormPreSearchForm; import com.hxhq.business.form.study.StudySearchForm; import com.hxhq.business.form.zcg.ZcgSearchForm; import com.hxhq.business.service.*; +import com.hxhq.common.core.constant.CacheConstants; import com.hxhq.common.core.exception.ServiceException; +import com.hxhq.common.core.utils.DateUtils; import com.hxhq.common.core.web.controller.BaseController; import com.hxhq.common.core.web.domain.AjaxResult; import com.hxhq.common.core.web.page.TableDataInfo; +import com.hxhq.common.redis.service.RedisService; import com.hxhq.common.security.annotation.RequiresPermissions; import org.apache.commons.lang3.StringUtils; import org.aspectj.weaver.loadtime.Aj; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.concurrent.TimeUnit; /** @@ -32,8 +39,7 @@ import java.util.List; */ @RestController @RequestMapping("/business/public") -public class PublicController extends BaseController -{ +public class PublicController extends BaseController { @Autowired private ITemplateService templateService; @Autowired @@ -46,14 +52,45 @@ public class PublicController extends BaseController private IAnimalSpeciesService animalSpeciesService; @Autowired private IZcgService zcgService; + @Autowired + private RedisService redisService; + + /** + * 获取编号 + * + * @return + */ + @GetMapping("/getSn") + public AjaxResult getSn(Integer count) { + if (count == null || count.intValue() <= 0) { + return AjaxResult.error("参数错误"); + } + Integer start = 1; + SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd"); + String today = sdf.format(new Date()); + //获取当前最大编号 + String maxNum = redisService.getCacheObject(today); + if (StringUtils.isNoneBlank(maxNum)) { + start = Integer.parseInt(maxNum)+1; + } + HashMap map = new HashMap(count); + for (int i = 0; i < count;i++){ + map.put("sn"+i,today+String.format("%04d", start)); + start++; + } + //更新当前最大编号 + redisService.setCacheObject(today,start,60*60*24L, TimeUnit.SECONDS); + return AjaxResult.success(map); + } /** * 试验区域-饲养间列表 + * * @return */ @GetMapping("/roomList") public AjaxResult getRoomList(String syqy) { - if(StringUtils.isNotEmpty(syqy)) { + if (StringUtils.isNotEmpty(syqy)) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Room::getSyqy, syqy); List list = roomService.list(queryWrapper); @@ -66,11 +103,12 @@ public class PublicController extends BaseController /** * 动物种属-笼具列表 + * * @return */ @GetMapping("/animalSpeciesList") public AjaxResult getAnimalSpeciesList(String animalSpecies) { - if(StringUtils.isNotEmpty(animalSpecies)) { + if (StringUtils.isNotEmpty(animalSpecies)) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(AnimalSpecies::getAnimalSpecies, animalSpecies); List list = animalSpeciesService.list(queryWrapper); @@ -86,8 +124,7 @@ public class PublicController extends BaseController * 查询模板列表 */ @GetMapping("/templateList") - public TableDataInfo list(Template template) - { + public TableDataInfo list(Template template) { startPage(); List