修改批量出入库
This commit is contained in:
@@ -13,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +52,7 @@ public class TbConsInfoController {
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
@Log("修改耗材信息")
|
@Log("修改耗材信息")
|
||||||
@ApiOperation("修改耗材信息")
|
@ApiOperation("修改耗材信息")
|
||||||
public ResponseEntity<Object> updateTbConsInfo(@Validated @RequestBody TbConsInfo resources){
|
public ResponseEntity<Object> updateTbConsInfo(@Validated @RequestBody TbConsInfo resources) throws Exception {
|
||||||
tbConsInfoService.update(resources);
|
tbConsInfoService.update(resources);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
@@ -67,7 +68,7 @@ public class TbConsInfoController {
|
|||||||
@PostMapping(value = "stockInOut")
|
@PostMapping(value = "stockInOut")
|
||||||
@Log("耗材出入库")
|
@Log("耗材出入库")
|
||||||
@ApiOperation("耗材出入库")
|
@ApiOperation("耗材出入库")
|
||||||
public ResponseEntity<Object> stockInOut(@Validated @RequestBody TbConsSuppFlow resources) throws Exception {
|
public ResponseEntity<Object> stockInOut(@Validated @RequestBody List<TbConsSuppFlow> resources) throws Exception {
|
||||||
tbConsInfoService.stockInOut(resources);
|
tbConsInfoService.stockInOut(resources);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,5 +66,5 @@ public interface TbConsInfoService {
|
|||||||
void download(List<TbConsInfoDto> all, HttpServletResponse response) throws IOException;
|
void download(List<TbConsInfoDto> all, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
|
||||||
void stockInOut(TbConsSuppFlow resources) throws Exception;
|
void stockInOut(List<TbConsSuppFlow> resources) throws Exception;
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,7 @@ import cn.ysk.cashier.cons.service.TbConsInfoService;
|
|||||||
import cn.ysk.cashier.cons.service.dto.TbConsInfoDto;
|
import cn.ysk.cashier.cons.service.dto.TbConsInfoDto;
|
||||||
import cn.ysk.cashier.cons.service.dto.TbConsInfoQueryCriteria;
|
import cn.ysk.cashier.cons.service.dto.TbConsInfoQueryCriteria;
|
||||||
import cn.ysk.cashier.cons.service.mapstruct.TbConsInfoMapper;
|
import cn.ysk.cashier.cons.service.mapstruct.TbConsInfoMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -46,6 +47,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
**/
|
**/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class TbConsInfoServiceImpl implements TbConsInfoService {
|
public class TbConsInfoServiceImpl implements TbConsInfoService {
|
||||||
|
|
||||||
private final TbConsInfoRepository tbConsInfoRepository;
|
private final TbConsInfoRepository tbConsInfoRepository;
|
||||||
@@ -103,6 +105,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
if(count>0){
|
if(count>0){
|
||||||
throw new Exception("耗材代码不允许重复");
|
throw new Exception("耗材代码不允许重复");
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.setConTypeName(tbConsType.getConTypeName());
|
resources.setConTypeName(tbConsType.getConTypeName());
|
||||||
resources.setLasterInStock(BigDecimal.ZERO);
|
resources.setLasterInStock(BigDecimal.ZERO);
|
||||||
resources.setStockNumber(BigDecimal.ZERO);
|
resources.setStockNumber(BigDecimal.ZERO);
|
||||||
@@ -150,127 +153,129 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void stockInOut(TbConsSuppFlow resources) throws Exception {
|
public void stockInOut(List<TbConsSuppFlow> resources) throws Exception {
|
||||||
TbConsInfo info= tbConsInfoRepository.getById(resources.getConInfoId());
|
if(Objects.isNull(resources)&&resources.size()<=0){
|
||||||
if(Objects.isNull(info)){
|
throw new Exception("参数错误");
|
||||||
throw new Exception("不存在的耗材信息");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (TbConsSuppFlow resource : resources) {
|
||||||
|
TbConsInfo info= tbConsInfoRepository.getById(resource.getConInfoId());
|
||||||
|
if(Objects.isNull(info)){
|
||||||
|
log.info("耗材信息不存在");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TbShopInfo tbShopInfo= tbShopInfoRepository.getById(resource.getShopId());
|
||||||
|
if(Objects.isNull(tbShopInfo)){
|
||||||
|
log.info("店铺信息不存在");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TbShopPurveyor purveyor= tbShopPurveyorRepository.getById(resource.getSupplierId());
|
||||||
|
if(Objects.isNull(purveyor)){
|
||||||
|
log.info("不存在的供应商");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
TbShopInfo tbShopInfo= tbShopInfoRepository.getById(resources.getShopId());
|
TbConsInfoFlow flow=new TbConsInfoFlow();
|
||||||
if(Objects.isNull(tbShopInfo)){
|
|
||||||
throw new Exception("店铺信息不存在");
|
|
||||||
|
TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact();
|
||||||
|
purveyorTransact.setShopId(tbShopInfo.getId().toString());
|
||||||
|
purveyorTransact.setPurveyorName(purveyor.getPurveyorName());
|
||||||
|
purveyorTransact.setPurveyorId(purveyor.getId().toString());
|
||||||
|
purveyorTransact.setRemark("");
|
||||||
|
purveyorTransact.setCreatedAt(System.currentTimeMillis());
|
||||||
|
purveyorTransact.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TbProductStockOperate stockOperate = new TbProductStockOperate();
|
||||||
|
stockOperate.setShopId(tbShopInfo.getId().toString());
|
||||||
|
stockOperate.setStockSnap("");
|
||||||
|
stockOperate.setType(resource.getType());
|
||||||
|
stockOperate.setSubType(-1);
|
||||||
|
Map<String, String> operatorSnapMap = new HashMap<>();
|
||||||
|
operatorSnapMap.put("name", tbShopInfo.getShopName());
|
||||||
|
operatorSnapMap.put("account", tbShopInfo.getAccount());
|
||||||
|
|
||||||
|
stockOperate.setOperatorSnap(JSON.toJSONString(operatorSnapMap));
|
||||||
|
stockOperate.setBatchNumber("");
|
||||||
|
stockOperate.setRemark("");
|
||||||
|
stockOperate.setStockTime(System.currentTimeMillis());
|
||||||
|
stockOperate.setCreatedAt(System.currentTimeMillis());
|
||||||
|
stockOperate.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
stockOperate.setStatus("normal");
|
||||||
|
stockOperate.setPurveyorId(resource.getSupplierId().toString());
|
||||||
|
stockOperate.setPurveyorName(purveyor.getPurveyorName());
|
||||||
|
|
||||||
|
tbProductStockOperateRepository.save(stockOperate);
|
||||||
|
|
||||||
|
if("in".equals(resource.getType())){
|
||||||
|
info.setStockNumber(info.getStockNumber().add(resource.getStockNumber()));
|
||||||
|
info.setLasterInStock(resource.getStockNumber());
|
||||||
|
resource.setType("in");
|
||||||
|
|
||||||
|
flow.setBizCode("stockIn");
|
||||||
|
flow.setBizName("耗材入库");
|
||||||
|
flow.setBizType("+");
|
||||||
|
|
||||||
|
purveyorTransact.setTotalAmount(resource.getAccountsPayable());
|
||||||
|
purveyorTransact.setPaidAmount(resource.getActualPayment());
|
||||||
|
purveyorTransact.setWaitAmount((resource.getAccountsPayable().subtract(resource.getActualPayment())));
|
||||||
|
purveyorTransact.setType("cons_in");
|
||||||
|
}else {
|
||||||
|
|
||||||
|
|
||||||
|
info.setStockNumber(info.getStockNumber().subtract(resource.getStockNumber()));
|
||||||
|
resource.setType("out");
|
||||||
|
|
||||||
|
flow.setBizCode("stockout");
|
||||||
|
flow.setBizName("耗材出库");
|
||||||
|
flow.setBizType("-");
|
||||||
|
|
||||||
|
|
||||||
|
purveyorTransact.setTotalAmount(resource.getAccountsPayable().negate());
|
||||||
|
purveyorTransact.setPaidAmount(resource.getActualPayment());
|
||||||
|
purveyorTransact.setWaitAmount((resource.getAccountsPayable().subtract(resource.getActualPayment())).negate());
|
||||||
|
purveyorTransact.setType("cons_out");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (resource.getAccountsPayable().compareTo(resource.getActualPayment()) <= 0) {
|
||||||
|
purveyorTransact.setStatus(1);
|
||||||
|
} else {
|
||||||
|
purveyorTransact.setStatus(0);
|
||||||
|
}
|
||||||
|
purveyorTransact.setPaidAt(System.currentTimeMillis());
|
||||||
|
|
||||||
|
purveyorTransactRepository.save(purveyorTransact);
|
||||||
|
if (resource.getSupplierId() != null) {
|
||||||
|
tbShopPurveyorRepository.upLastTransactAt(resource.getSupplierId().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tbConsInfoRepository.save(info);
|
||||||
|
|
||||||
|
|
||||||
|
resource.setAmount(resource.getStockNumber());
|
||||||
|
resource.setBalance(info.getStockNumber());
|
||||||
|
resource.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
|
tbConsSuppFlowRepository.save(resource);
|
||||||
|
|
||||||
|
|
||||||
|
flow.setConsId(info.getId());
|
||||||
|
flow.setShopId(info.getShopId());
|
||||||
|
flow.setConName(info.getConName());
|
||||||
|
flow.setAmount(resource.getStockNumber());
|
||||||
|
flow.setBalance(info.getStockNumber());
|
||||||
|
|
||||||
|
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
|
tbConsInfoFlowRepository.save(flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
TbShopPurveyor purveyor= tbShopPurveyorRepository.getById(resources.getSupplierId());
|
|
||||||
if(Objects.isNull(purveyor)){
|
|
||||||
throw new Exception("不存在的供应商");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TbConsInfoFlow flow=new TbConsInfoFlow();
|
|
||||||
|
|
||||||
|
|
||||||
TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact();
|
|
||||||
purveyorTransact.setShopId(tbShopInfo.getId().toString());
|
|
||||||
purveyorTransact.setPurveyorName(purveyor.getPurveyorName());
|
|
||||||
purveyorTransact.setPurveyorId(purveyor.getId().toString());
|
|
||||||
purveyorTransact.setRemark("");
|
|
||||||
purveyorTransact.setCreatedAt(System.currentTimeMillis());
|
|
||||||
purveyorTransact.setUpdatedAt(System.currentTimeMillis());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TbProductStockOperate stockOperate = new TbProductStockOperate();
|
|
||||||
stockOperate.setShopId(tbShopInfo.getId().toString());
|
|
||||||
stockOperate.setStockSnap("");
|
|
||||||
stockOperate.setType(resources.getType());
|
|
||||||
stockOperate.setSubType(-1);
|
|
||||||
Map<String, String> operatorSnapMap = new HashMap<>();
|
|
||||||
operatorSnapMap.put("name", tbShopInfo.getShopName());
|
|
||||||
operatorSnapMap.put("account", tbShopInfo.getAccount());
|
|
||||||
|
|
||||||
stockOperate.setOperatorSnap(JSON.toJSONString(operatorSnapMap));
|
|
||||||
stockOperate.setBatchNumber("");
|
|
||||||
stockOperate.setRemark("");
|
|
||||||
stockOperate.setStockTime(System.currentTimeMillis());
|
|
||||||
stockOperate.setCreatedAt(System.currentTimeMillis());
|
|
||||||
stockOperate.setUpdatedAt(System.currentTimeMillis());
|
|
||||||
stockOperate.setStatus("normal");
|
|
||||||
stockOperate.setPurveyorId(resources.getSupplierId().toString());
|
|
||||||
stockOperate.setPurveyorName(purveyor.getPurveyorName());
|
|
||||||
|
|
||||||
tbProductStockOperateRepository.save(stockOperate);
|
|
||||||
|
|
||||||
if("in".equals(resources.getType())){
|
|
||||||
info.setStockNumber(info.getStockNumber().add(resources.getStockNumber()));
|
|
||||||
info.setLasterInStock(resources.getStockNumber());
|
|
||||||
resources.setType("in");
|
|
||||||
|
|
||||||
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");
|
|
||||||
}else {
|
|
||||||
|
|
||||||
|
|
||||||
info.setStockNumber(info.getStockNumber().subtract(resources.getStockNumber()));
|
|
||||||
resources.setType("out");
|
|
||||||
|
|
||||||
flow.setBizCode("stockout");
|
|
||||||
flow.setBizName("耗材出库");
|
|
||||||
flow.setBizType("-");
|
|
||||||
|
|
||||||
|
|
||||||
purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate());
|
|
||||||
purveyorTransact.setPaidAmount(resources.getActualPayment());
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
purveyorTransact.setPaidAt(System.currentTimeMillis());
|
|
||||||
|
|
||||||
purveyorTransactRepository.save(purveyorTransact);
|
|
||||||
if (resources.getSupplierId() != null) {
|
|
||||||
tbShopPurveyorRepository.upLastTransactAt(resources.getSupplierId().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tbConsInfoRepository.save(info);
|
|
||||||
|
|
||||||
|
|
||||||
resources.setAmount(resources.getStockNumber());
|
|
||||||
resources.setBalance(info.getStockNumber());
|
|
||||||
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
|
||||||
tbConsSuppFlowRepository.save(resources);
|
|
||||||
|
|
||||||
|
|
||||||
flow.setConsId(info.getId());
|
|
||||||
flow.setShopId(info.getShopId());
|
|
||||||
flow.setConName(info.getConName());
|
|
||||||
flow.setAmount(resources.getStockNumber());
|
|
||||||
flow.setBalance(info.getStockNumber());
|
|
||||||
|
|
||||||
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
|
||||||
tbConsInfoFlowRepository.save(flow);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,14 @@ spring:
|
|||||||
port: 5672
|
port: 5672
|
||||||
username: admin
|
username: admin
|
||||||
password: Czg666888
|
password: Czg666888
|
||||||
|
redis:
|
||||||
|
#数据库索引
|
||||||
|
database: ${REDIS_DB:0}
|
||||||
|
host: ${REDIS_HOST:101.37.12.135}
|
||||||
|
port: ${REDIS_PORT:6379}
|
||||||
|
password: ${REDIS_PWD:111111}
|
||||||
|
#连接超时时间
|
||||||
|
timeout: 5000
|
||||||
|
|
||||||
|
|
||||||
# 登录相关配置
|
# 登录相关配置
|
||||||
|
|||||||
@@ -55,6 +55,14 @@ spring:
|
|||||||
port: 5672
|
port: 5672
|
||||||
username: admin
|
username: admin
|
||||||
password: Czg666888
|
password: Czg666888
|
||||||
|
redis:
|
||||||
|
#数据库索引
|
||||||
|
database: ${REDIS_DB:0}
|
||||||
|
host: ${REDIS_HOST:127.0.0.1}
|
||||||
|
port: ${REDIS_PORT:6379}
|
||||||
|
password: ${REDIS_PWD:111111}
|
||||||
|
#连接超时时间
|
||||||
|
timeout: 5000
|
||||||
|
|
||||||
# 登录相关配置
|
# 登录相关配置
|
||||||
login:
|
login:
|
||||||
|
|||||||
@@ -31,22 +31,6 @@ spring:
|
|||||||
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
||||||
show_sql: true
|
show_sql: true
|
||||||
|
|
||||||
# redisdb5:
|
|
||||||
# #数据库索引
|
|
||||||
# database: ${REDIS_DB:5}
|
|
||||||
# host: ${REDIS_HOST:127.0.0.1}
|
|
||||||
# port: ${REDIS_PORT:6379}
|
|
||||||
# password: ${REDIS_PWD:111111}
|
|
||||||
|
|
||||||
redis:
|
|
||||||
#数据库索引
|
|
||||||
database: ${REDIS_DB:0}
|
|
||||||
host: ${REDIS_HOST:127.0.0.1}
|
|
||||||
port: ${REDIS_PORT:6379}
|
|
||||||
password: ${REDIS_PWD:111111}
|
|
||||||
#连接超时时间
|
|
||||||
timeout: 5000
|
|
||||||
|
|
||||||
|
|
||||||
task:
|
task:
|
||||||
pool:
|
pool:
|
||||||
|
|||||||
Reference in New Issue
Block a user