Merge branch 'gyj' into test

This commit is contained in:
yijiegong 2024-08-27 16:00:10 +08:00
commit e9711dffe3
5 changed files with 54 additions and 39 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

@ -42,7 +42,6 @@ public class TbOrderInfoController {
@PostMapping("/date")
@ApiOperation("查询订单")
@AnonymousPostMapping
public ResponseEntity<Object> queryTbOrderInfo(@RequestBody TbOrderInfoQueryCriteria criteria){
return new ResponseEntity<>(tbOrderInfoService.queryAllPage(criteria),HttpStatus.OK);
}

View File

@ -70,6 +70,8 @@ public class TbOrderInfoQueryCriteria{
@Query(type = Query.Type.BETWEEN)
private List<Long> createdAt;
private Integer userId;
@Query
private String tableName;
@ -79,4 +81,18 @@ public class TbOrderInfoQueryCriteria{
public void setProductName(String productName) {
if(StringUtils.isNotBlank(productName)) this.productName = productName;
}
public Integer getPage() {
if (page == null) {
return 0;
}
return page;
}
public Integer getPageSize() {
if (pageSize == null) {
return 10;
}
return pageSize;
}
}

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);
}

View File

@ -108,6 +108,10 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
predicate = criteriaBuilder.and(predicate, criteriaBuilder.notEqual(root.get("orderType"), "return"));
}
if (criteria.getUserId() != null && criteria.getUserId() != 0) {
predicate = criteriaBuilder.and(predicate, criteriaBuilder.equal(root.get("userId"), criteria.getUserId()));
}
if (StringUtils.isNotBlank(criteria.getProductName())) {
Date startTime, endTime;
DateTime offsetMonth = cn.hutool.core.date.DateUtil.offsetMonth(new Date(), 3);
@ -120,11 +124,6 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
startTime = new Date(startLong);
endTime = new Date(endLong);
// 如果开始时间小于三个月前不查询
// if (startTime.before(offsetMonth)) {
// throw new BadRequestException("查询时间范围不能超过三个月");
// }
} else {
startTime = offsetMonth;
endTime = new Date();