Browse Source

feat: [编号生成] 增加分装编号逻辑

master
memorylkf 2 months ago
parent
commit
8b801fb370
3 changed files with 23 additions and 7 deletions
  1. +5
    -4
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java
  2. +9
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISnGenService.java
  3. +9
    -3
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SnGenServiceImpl.java

+ 5
- 4
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java View File

@ -70,17 +70,18 @@ public class PublicController extends BaseController {
/**
* 获取编号
*
* @param count
* @param my 母液编号分装用
* @return
*/
@GetMapping("/getSn")
public AjaxResult getSn(Integer count) {
public AjaxResult getSn(Integer count,String my) {
if (count == null || count.intValue() <= 1) {
return AjaxResult.success("操作成功",snGenService.getNewSn(SnTypeEnum.wz.getValue()));
return AjaxResult.success("操作成功",snGenService.getNewSn(SnTypeEnum.wz.getValue(),my));
}else{
List<String> list = new ArrayList<>();
for (int i = 0; i < count;i++){
list.add(snGenService.getNewSn(SnTypeEnum.wz.getValue()));
list.add(snGenService.getNewSn(SnTypeEnum.wz.getValue(),my));
}
return AjaxResult.success(list);
}

+ 9
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISnGenService.java View File

@ -14,6 +14,15 @@ public interface ISnGenService extends IService
{
/**
* 获取新编号
* @param type
* @param my 母液编号分装用
* @return
*/
String getNewSn(Integer type, String my);
/**
* 获取新编号
* @param type
* @return
*/
String getNewSn(Integer type);

+ 9
- 3
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SnGenServiceImpl.java View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.core.utils.SpringUtils;
import com.hxhq.common.core.utils.StringUtils;
import com.hxhq.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -31,11 +32,11 @@ public class SnGenServiceImpl extends ServiceImpl implements
private final Lock lock = new ReentrantLock(true);
@Override
public String getNewSn(Integer type) {
public String getNewSn(Integer type, String my) {
lock.lock();
try {
Integer sort = 1;
String date = DateUtils.dateTimeNow("yyMMdd");
String date = StringUtils.isBlank(my)? DateUtils.dateTimeNow("yyMMdd"):my;
QueryWrapper<SnGen> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("date",date);
queryWrapper.eq("type",type);
@ -49,7 +50,7 @@ public class SnGenServiceImpl extends ServiceImpl implements
baseMapper.addSn(date,type);
sort = getOne(queryWrapper,false).getSn();
}
return date+"-"+String.format("%03d", sort);
return (StringUtils.isBlank(my)?(date+"-"):"")+String.format("%03d", sort);
} catch (Exception e) {
log.error("getNewSn执行被中断", e);
} finally {
@ -57,4 +58,9 @@ public class SnGenServiceImpl extends ServiceImpl implements
}
return null;
}
@Override
public String getNewSn(Integer type) {
return getNewSn(type,null);
}
}

Loading…
Cancel
Save