|
@@ -5,6 +5,8 @@ import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
import com.zkqy.business.domain.ProductWarehousingRecord;
|
|
|
import com.zkqy.business.domain.vo.ProductCodeListVO;
|
|
@@ -13,6 +15,7 @@ import com.zkqy.business.mapper.ProductWarehousingRecordMapper;
|
|
|
import com.zkqy.business.service.IProductInventoryService;
|
|
|
import com.zkqy.common.core.domain.AjaxResult;
|
|
|
import com.zkqy.common.core.domain.entity.SysDictData;
|
|
|
+import com.zkqy.common.core.redis.RedisCache;
|
|
|
import com.zkqy.common.utils.DateUtils;
|
|
|
import com.zkqy.common.utils.SecurityUtils;
|
|
|
import com.zkqy.common.utils.StringUtils;
|
|
@@ -48,6 +51,9 @@ public class ProductCodeListServiceImpl implements IProductCodeListService {
|
|
|
@Autowired
|
|
|
private IProductInventoryService iProductInventoryService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询产品码单
|
|
@@ -104,8 +110,7 @@ public class ProductCodeListServiceImpl implements IProductCodeListService {
|
|
|
productCodeList.setCreateById(SecurityUtils.getUserId());
|
|
|
productCodeListMapper.insertProductCodeList(productCodeList);
|
|
|
// 直接入库--
|
|
|
- vo.getMachineTool(); // 当前机台
|
|
|
-
|
|
|
+ // vo.getMachineTool(); // 当前机台
|
|
|
String bumen = vo.getMachineToolNo().split("-")[0];
|
|
|
List<SysDictData> dictDataList = dictDataMapper.selectDictDataByType("section_stash");
|
|
|
dictDataList.forEach(item -> {
|
|
@@ -115,8 +120,6 @@ public class ProductCodeListServiceImpl implements IProductCodeListService {
|
|
|
});
|
|
|
List<ProductCodeListVO> productCodeListVOList = new ArrayList<>();
|
|
|
productCodeListVOList.add(vo);
|
|
|
-
|
|
|
-
|
|
|
iProductInventoryService.productStorage(productCodeListVOList);
|
|
|
return productCodeList.getId();
|
|
|
}
|
|
@@ -204,18 +207,36 @@ public class ProductCodeListServiceImpl implements IProductCodeListService {
|
|
|
return productCodeListMapper.selectFinishedProduct(productCodeList);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private ReentrantLock reentrantLock = new ReentrantLock();
|
|
|
|
|
|
@Override
|
|
|
public String selectMaxCodeList() {
|
|
|
- String maxCodeList = productCodeListMapper.selectMaxCodeList();
|
|
|
- LocalDate now = LocalDate.now();
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMdd");
|
|
|
- String nowCodeList = now.format(formatter) + "00001";
|
|
|
- if (StringUtils.isNotEmpty(maxCodeList) && Long.parseLong(maxCodeList) >= Long.parseLong(nowCodeList)) {
|
|
|
- return Long.parseLong(maxCodeList) + 1L + "";
|
|
|
+ try {
|
|
|
+ if (reentrantLock.tryLock(200, TimeUnit.MILLISECONDS)) {
|
|
|
+ String code = redisCache.getCacheObject("huaxianmadanweiyibianhao");
|
|
|
+ if (code == null || code.isEmpty()) {
|
|
|
+ String maxCodeList = productCodeListMapper.selectMaxCodeList();
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMdd");
|
|
|
+ String nowCodeList = now.format(formatter) + "00001";
|
|
|
+ if (StringUtils.isNotEmpty(maxCodeList) && Long.parseLong(maxCodeList) >= Long.parseLong(nowCodeList)) {
|
|
|
+ nowCodeList = Long.parseLong(maxCodeList) + 1L + "";
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject("huaxianmadanweiyibianhao", nowCodeList);
|
|
|
+ return nowCodeList;
|
|
|
+ } else {
|
|
|
+ Long nowCode = Long.valueOf(code) + 1;
|
|
|
+ redisCache.setCacheObject("huaxianmadanweiyibianhao", nowCode.toString());
|
|
|
+ return String.valueOf(nowCode);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } finally {
|
|
|
+ reentrantLock.unlock();
|
|
|
}
|
|
|
- return nowCodeList;
|
|
|
}
|
|
|
|
|
|
@Override
|