Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
bc7d3f626a
|
|
@ -30,6 +30,7 @@ public class SuppFlow implements Serializable {
|
|||
@Data
|
||||
public static class ConInfos{
|
||||
private Integer conInfoId;
|
||||
private String name;
|
||||
|
||||
private String unit;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
private final TbProductStockOperateRepository tbProductStockOperateRepository;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbConsInfoQueryCriteria criteria, Pageable pageable) {
|
||||
Page<TbConsInfo> page = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
|
|
@ -77,7 +76,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
@Override
|
||||
public Map<String, Object> queryAllAndPro(TbConsInfoQueryCriteria criteria) {
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
if(StringUtils.isNotBlank(criteria.getSort())){
|
||||
if (StringUtils.isNotBlank(criteria.getSort())) {
|
||||
String[] sortParams = criteria.getSort().split(",");
|
||||
String sortField = sortParams[0];
|
||||
Sort.Direction sortDirection = Sort.Direction.fromString(sortParams[1]);
|
||||
|
|
@ -112,7 +111,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbConsInfoDto create(List<TbConsInfo> resources){
|
||||
public TbConsInfoDto create(List<TbConsInfo> resources) {
|
||||
|
||||
|
||||
for (TbConsInfo resource : resources) {
|
||||
|
|
@ -125,8 +124,8 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
// if (count > 0) {
|
||||
// throw new Exception("耗材代码不允许重复");
|
||||
// }
|
||||
if(StringUtils.isBlank(resource.getConUnit())){
|
||||
throw new BadRequestException(resource.getConName()+ "的单位不允许为空");
|
||||
if (StringUtils.isBlank(resource.getConUnit())) {
|
||||
throw new BadRequestException(resource.getConName() + "的单位不允许为空");
|
||||
}
|
||||
resource.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER));
|
||||
resource.setConTypeName(tbConsType.getConTypeName());
|
||||
|
|
@ -150,7 +149,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
if (Objects.isNull(tbConsInfo)) {
|
||||
throw new Exception("耗材信息不存在");
|
||||
}
|
||||
BeanUtil.copyProperties(resource,tbConsInfo, CopyOptions.create().setIgnoreNullValue(true));
|
||||
BeanUtil.copyProperties(resource, tbConsInfo, CopyOptions.create().setIgnoreNullValue(true));
|
||||
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
tbConsInfoRepository.save(tbConsInfo);
|
||||
}
|
||||
|
|
@ -220,7 +219,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
|
||||
JSONArray array = new JSONArray();
|
||||
|
||||
|
||||
for (SuppFlow.ConInfos conInfos : resources.getList()) {
|
||||
JSONObject object = new JSONObject();
|
||||
|
||||
|
|
@ -229,10 +227,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
log.info("耗材信息不存在");
|
||||
continue;
|
||||
}
|
||||
conInfos.setName(info.getConName());
|
||||
BigDecimal changeStock = conInfos.getStockNumber();
|
||||
//副单位的实际修改值
|
||||
if (StringUtils.isNotBlank(conInfos.getUnit())) {
|
||||
info.setDefaultUnit(conInfos.getUnit());
|
||||
conInfos.setUnit(conInfos.getUnit());
|
||||
if (conInfos.getUnit().equals(info.getConUnitTwo())) {
|
||||
changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
|
@ -240,23 +240,13 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
&& StringUtils.isNotBlank(info.getDefaultUnit())
|
||||
&& info.getConUnitTwo().equals(info.getDefaultUnit())) {
|
||||
info.setDefaultUnit(info.getConUnitTwo());
|
||||
conInfos.setUnit(info.getConUnitTwo());
|
||||
changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TbConsSuppFlow suppFlow = new TbConsSuppFlow();
|
||||
|
||||
TbConsInfoFlow flow = new TbConsInfoFlow();
|
||||
|
||||
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.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());
|
||||
|
|
@ -265,27 +255,17 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
//实际库存
|
||||
BigDecimal amount = info.getStockNumber().subtract(info.getStockConsume());
|
||||
|
||||
|
||||
if ("in".equals(resources.getType())) {
|
||||
stockOperate.setSubType(1);
|
||||
info.setStockNumber(info.getStockNumber().add(changeStock));
|
||||
info.setLasterInStock(changeStock);
|
||||
|
||||
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).add(changeStock));
|
||||
|
||||
|
||||
flow.setBizCode("stockIn");
|
||||
flow.setBizName("耗材入库");
|
||||
flow.setBizType("+");
|
||||
|
||||
purveyorTransact.setTotalAmount(resources.getAccountsPayable());
|
||||
purveyorTransact.setPaidAmount(resources.getActualPayment());
|
||||
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())));
|
||||
purveyorTransact.setType("cons_in");
|
||||
|
||||
object.put("number", changeStock);
|
||||
}
|
||||
else if ("out".equals(resources.getType())) {
|
||||
} else if ("out".equals(resources.getType())) {
|
||||
stockOperate.setSubType(-1);
|
||||
|
||||
if (changeStock.compareTo(amount) > 0) {
|
||||
|
|
@ -293,23 +273,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
}
|
||||
|
||||
info.setStockNumber(info.getStockNumber().subtract(changeStock));
|
||||
|
||||
|
||||
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).subtract(changeStock));
|
||||
|
||||
|
||||
flow.setBizCode("stockout");
|
||||
flow.setBizName("耗材出库");
|
||||
flow.setBizType("-");
|
||||
|
||||
purveyorTransact.setPaidAmount(resources.getActualPayment());
|
||||
purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate());
|
||||
|
||||
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate());
|
||||
purveyorTransact.setType("cons_out");
|
||||
object.put("number", changeStock);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new BadRequestException("错误操作类型");
|
||||
}
|
||||
|
||||
|
|
@ -326,21 +295,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
suppFlow.setActualPayment(resources.getActualPayment());
|
||||
suppFlow.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
|
||||
if (resources.getAccountsPayable().compareTo(resources.getActualPayment()) <= 0) {
|
||||
purveyorTransact.setStatus(1);
|
||||
} else {
|
||||
purveyorTransact.setStatus(0);
|
||||
}
|
||||
|
||||
purveyorTransact.setPaidAt(System.currentTimeMillis());
|
||||
//供应商
|
||||
purveyorTransactRepository.save(purveyorTransact);
|
||||
if (resources.getSupplierId() != null) {
|
||||
tbShopPurveyorRepository.upLastTransactAt(resources.getSupplierId().toString());
|
||||
}
|
||||
|
||||
|
||||
tbConsInfoRepository.save(info);
|
||||
tbConsSuppFlowRepository.save(suppFlow);
|
||||
|
||||
|
|
@ -359,6 +313,39 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
stockOperate.setBatchNumber("");
|
||||
stockOperate.setStockSnap(array.toJSONString());
|
||||
tbProductStockOperateRepository.save(stockOperate);
|
||||
|
||||
if (resources.getSupplierId() != null) {
|
||||
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.setRemark(resources.getRemark());
|
||||
purveyorTransact.setCreatedAt(System.currentTimeMillis());
|
||||
purveyorTransact.setUpdatedAt(System.currentTimeMillis());
|
||||
purveyorTransact.setPaidAt(System.currentTimeMillis());
|
||||
purveyorTransact.setConInfos(JSONUtil.toJSONString(resources.getList()));
|
||||
if ("in".equals(resources.getType())) {
|
||||
purveyorTransact.setTotalAmount(resources.getAccountsPayable());
|
||||
purveyorTransact.setPaidAmount(resources.getActualPayment());
|
||||
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())));
|
||||
purveyorTransact.setType("cons_in");
|
||||
} else if ("out".equals(resources.getType())) {
|
||||
purveyorTransact.setPaidAmount(resources.getActualPayment());
|
||||
purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate());
|
||||
|
||||
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate());
|
||||
purveyorTransact.setType("cons_out");
|
||||
}
|
||||
|
||||
if (resources.getAccountsPayable().compareTo(resources.getActualPayment()) <= 0) {
|
||||
purveyorTransact.setStatus(1);
|
||||
} else {
|
||||
purveyorTransact.setStatus(0);
|
||||
}
|
||||
//供应商
|
||||
purveyorTransactRepository.save(purveyorTransact);
|
||||
tbShopPurveyorRepository.upLastTransactAt(resources.getSupplierId().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,20 +1,7 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.pojo.shop;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.SuppFlow;
|
||||
import cn.ysk.cashier.cons.domain.TbConsInfo;
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -23,6 +10,7 @@ import javax.persistence.*;
|
|||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -94,7 +82,14 @@ public class TbShopPurveyorTransact implements Serializable {
|
|||
@ApiModelProperty(value = "type")
|
||||
private String type;
|
||||
|
||||
@Column(name = "`con_infos`")
|
||||
private String conInfos;
|
||||
|
||||
@Transient
|
||||
private List<SuppFlow.ConInfos> conFlows;
|
||||
|
||||
@Transient
|
||||
private List<TbConsInfo> cons;
|
||||
|
||||
|
||||
public void copy(TbShopPurveyorTransact source){
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.SuppFlow;
|
||||
import cn.ysk.cashier.cons.domain.TbConsInfo;
|
||||
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
|
||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
|
|
@ -11,10 +14,12 @@ import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository;
|
|||
import cn.ysk.cashier.repository.shop.TbShopPurveyorTransactRepository;
|
||||
import cn.ysk.cashier.service.shop.TbShopPurveyorTransactService;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.utils.JSONUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import cn.ysk.cashier.vo.PurveyorTransactVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
|
@ -26,6 +31,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
|
|
@ -39,6 +45,7 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
|
|||
|
||||
private final TbShopPurveyorTransactRepository tbShopPurveyorTransactRepository;
|
||||
private final TbShopPurveyorTransactMapper tbShopPurveyorTransactMapper;
|
||||
private final TbConsInfoRepository tbConsInfoRepository;
|
||||
private final TbShopPurveyorRepository tbShopPurveyorRepository;
|
||||
private final TbShopPurveyorTransactPayService transactPayService;
|
||||
|
||||
|
|
@ -47,7 +54,15 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
|
|||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
Page<TbShopPurveyorTransact> pageShopPurveyor = tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
|
||||
for (TbShopPurveyorTransact tbShopPurveyorTransact : pageShopPurveyor.getContent()) {
|
||||
if (StringUtils.isNotBlank(tbShopPurveyorTransact.getConInfos())) {
|
||||
List<SuppFlow.ConInfos> conInfos = JSONUtil.parseJSONStrTList(tbShopPurveyorTransact.getConInfos(), SuppFlow.ConInfos.class);
|
||||
tbShopPurveyorTransact.setConFlows(conInfos);
|
||||
List<Integer> collect = conInfos.stream().map(SuppFlow.ConInfos::getConInfoId).collect(Collectors.toList());
|
||||
List<TbConsInfo> cons = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.in(root.get("id")).value(collect));
|
||||
tbShopPurveyorTransact.setCons(cons);
|
||||
}
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("content", pageShopPurveyor.getContent());
|
||||
map.put("totalElements", pageShopPurveyor.getTotalElements());
|
||||
|
|
|
|||
Loading…
Reference in New Issue