Merge remote-tracking branch 'origin/dev' into test

This commit is contained in:
SongZhang 2024-08-27 15:59:11 +08:00
commit 543d770d98
2 changed files with 34 additions and 33 deletions

View File

@ -1,6 +1,7 @@
package cn.ysk.cashier.cons.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.cons.domain.*;
import cn.ysk.cashier.cons.repository.TbConsInfoFlowRepository;
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
@ -81,9 +82,9 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
@Override
public List<TbConsInfoDto> queryAll(TbConsInfoQueryCriteria criteria) {
List<TbConsInfoDto> list= tbConsInfoMapper.toDto(tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
if(Objects.nonNull(list)&&list.size()>0){
list.parallelStream().forEach(it->{
List<TbConsInfoDto> list = tbConsInfoMapper.toDto(tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
if (Objects.nonNull(list) && list.size() > 0) {
list.parallelStream().forEach(it -> {
it.setContypeCode(tbConsTypeRepository.findById(it.getConTypeId()).orElseGet(TbConsType::new).getConTypeCode());
});
}
@ -115,14 +116,14 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
// }
resource.setConCode(StringCodeUtil.getRandom(8,LETTER_CAPITAL_NUMBER));
resource.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER));
resource.setConTypeName(tbConsType.getConTypeName());
resource.setLasterInStock(BigDecimal.ZERO);
resource.setStockNumber(BigDecimal.ZERO);
resource.setStatus("1");
resource.setStockConsume(BigDecimal.ZERO);
resource.setCreateTime(new Timestamp(System.currentTimeMillis()));
resource=tbConsInfoRepository.save(resource);
resource = tbConsInfoRepository.save(resource);
TbConsInfoFlow flow = new TbConsInfoFlow();
@ -140,7 +141,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
tbConsInfoFlowRepository.save(flow);
}
return tbConsInfoMapper.toDto(new TbConsInfo());
}
@ -184,9 +184,9 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
map.put("耗材名称", tbConsInfo.getConName());
map.put("耗材类型代码", tbConsInfo.getContypeCode());
map.put("单位", tbConsInfo.getConUnit());
map.put("价格",tbConsInfo.getPrice());
map.put("耗材预警值",tbConsInfo.getConWarning());
map.put("库存",tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
map.put("价格", tbConsInfo.getPrice());
map.put("耗材预警值", tbConsInfo.getConWarning());
map.put("库存", tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
list.add(map);
}
FileUtil.downloadExcel(list, response);
@ -195,7 +195,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
@Override
@Transactional(rollbackFor = Exception.class)
public void stockInOut(SuppFlow resources) throws Exception {
log.info("resources:{}",JSON.toJSONString(resources));
log.info("resources:{}", JSON.toJSONString(resources));
if (Objects.isNull(resources)) {
throw new Exception("参数错误");
}
@ -205,9 +205,9 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
throw new Exception("店铺信息不存在");
}
TbShopPurveyor purveyor=null;
TbShopPurveyor purveyor = null;
TbProductStockOperate stockOperate = new TbProductStockOperate();
if(Objects.nonNull(resources.getSupplierId())){
if (Objects.nonNull(resources.getSupplierId())) {
purveyor = tbShopPurveyorRepository.getById(resources.getSupplierId());
if (Objects.nonNull(purveyor)) {
stockOperate.setPurveyorId(resources.getSupplierId().toString());
@ -217,7 +217,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
stockOperate.setShopId(tbShopInfo.getId().toString());
stockOperate.setStockSnap("");
stockOperate.setType(resources.getType().equals("in")?"cons_in":"cons_out");
stockOperate.setType(resources.getType().equals("in") ? "cons_in" : "cons_out");
Map<String, String> operatorSnapMap = new HashMap<>();
operatorSnapMap.put("name", tbShopInfo.getShopName());
operatorSnapMap.put("account", tbShopInfo.getAccount());
@ -229,11 +229,11 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
stockOperate.setUpdatedAt(System.currentTimeMillis());
stockOperate.setStatus("normal");
JSONArray array=new JSONArray();
JSONArray array = new JSONArray();
for (SuppFlow.ConInfos conInfos : resources.getList()) {
JSONObject object=new JSONObject();
JSONObject object = new JSONObject();
TbConsInfo info = tbConsInfoRepository.getById(conInfos.getConInfold());
if (Objects.isNull(info)) {
@ -247,19 +247,19 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact();
purveyorTransact.setShopId(tbShopInfo.getId().toString());
purveyorTransact.setPurveyorName(Objects.isNull(purveyor)?"":purveyor.getPurveyorName());
purveyorTransact.setPurveyorId(Objects.isNull(purveyor)?"":purveyor.getId().toString());
purveyorTransact.setPurveyorName(Objects.isNull(purveyor) ? "" : purveyor.getPurveyorName());
purveyorTransact.setPurveyorId(Objects.isNull(purveyor) ? "" : purveyor.getId().toString());
purveyorTransact.setRemark(resources.getRemark());
purveyorTransact.setCreatedAt(System.currentTimeMillis());
purveyorTransact.setUpdatedAt(System.currentTimeMillis());
suppFlow.setConInfoId(info.getConTypeId());
suppFlow.setShopId(resources.getShopId());
suppFlow.setSupplierId(Objects.isNull(resources.getSupplierId())?0: resources.getSupplierId());
suppFlow.setSupplierId(Objects.isNull(resources.getSupplierId()) ? 0 : resources.getSupplierId());
suppFlow.setType(resources.getType());
suppFlow.setStockNumber(conInfos.getStockNumber());
BigDecimal amount=info.getStockNumber().subtract(info.getStockConsume());
BigDecimal amount = info.getStockNumber().subtract(info.getStockConsume());
if ("in".equals(resources.getType())) {
@ -279,19 +279,17 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())));
purveyorTransact.setType("cons_in");
object.put("number",conInfos.getStockNumber());
} else if("out".equals(resources.getType())) {
object.put("number", conInfos.getStockNumber());
} else if ("out".equals(resources.getType())) {
stockOperate.setSubType(-1);
if(conInfos.getStockNumber().compareTo(info.getStockNumber())>0){
if (conInfos.getStockNumber().compareTo(info.getStockNumber()) > 0) {
throw new BadRequestException("出库数量大于现有的库存数量");
}
info.setStockNumber(info.getStockNumber().subtract(conInfos.getStockNumber()));
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).subtract(conInfos.getStockNumber()));
@ -304,16 +302,16 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate());
purveyorTransact.setType("cons_out");
object.put("number",conInfos.getStockNumber());
}else {
object.put("number", conInfos.getStockNumber());
} else {
throw new BadRequestException("错误操作类型");
}
object.put("stockNumber",amount);
object.put("stockNumber", amount);
object.put("name",info.getConName());
object.put("unitName",info.getConUnit());
object.put("name", info.getConName());
object.put("unitName", info.getConUnit());
array.add(object);
suppFlow.setPrice(conInfos.getPrice());
@ -367,7 +365,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
XSSFRow row = null;
List<TbConsInfo> consInfos=new ArrayList<>();
List<TbConsInfo> consInfos = new ArrayList<>();
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
row = sheet.getRow(i);
if (row != null) {
@ -431,7 +429,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
TbConsInfo consInfo = tbConsInfoRepository.findByConCode(cell0.toString());
if (ObjectUtil.isEmpty(consInfo) || ObjectUtil.isNull(consInfo)) {
consInfo = new TbConsInfo();
consInfo.setConCode(StringCodeUtil.getRandom(8,LETTER_CAPITAL_NUMBER));
consInfo.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER));
consInfo.setShopId(Integer.valueOf(shopId));
consInfo.setConTypeId(tbConsType.getId());
consInfo.setConTypeName(tbConsType.getConTypeName());
@ -487,7 +485,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
}
} else {
TbConsInfo consInfo = new TbConsInfo();
consInfo.setConCode(StringCodeUtil.getRandom(8,LETTER_CAPITAL_NUMBER));
consInfo.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER));
consInfo.setShopId(Integer.valueOf(shopId));
consInfo.setConTypeId(tbConsType.getId());
consInfo.setConTypeName(tbConsType.getConTypeName());
@ -523,7 +521,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
}
public static void main(String[] args){
public static void main(String[] args) {
System.out.println(UUID.randomUUID().toString());
}

View File

@ -66,4 +66,7 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
@Query(value = "select b.* from tb_product_sku as a left join tb_product as b on a.product_id=b.id where a.id=:skuId", nativeQuery = true)
TbProduct selectBySkuId(@Param("skuId") Integer skuId);
@Query(value = "select * from tb_product as a where a.id=:skuId", nativeQuery = true)
TbProduct selectById(@Param("skuId") Integer skuId);
}