添加耗材功能

This commit is contained in:
韩鹏辉 2024-07-03 14:31:36 +08:00
parent b32b24a608
commit 114c9917bd
30 changed files with 1304 additions and 39 deletions

View File

@ -86,6 +86,21 @@ public class TbConsInfo implements Serializable {
@ApiModelProperty(value = "店铺id")
private Integer shopId;
@Column(name = "`price`")
@ApiModelProperty(value = "单价")
private BigDecimal price;
@Column(name = "`status`")
@ApiModelProperty(value = "状态 1 启用 0 禁用")
private String status;
@Column(name = "`stock_consume`")
@ApiModelProperty(value = "消耗总量")
private BigDecimal stockConsume;
public void copy(TbConsInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -0,0 +1,122 @@
/*
* 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.cons.domain;
import cn.ysk.cashier.utils.JSONUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @author admin
* @date 2024-07-02
**/
@Entity
@Data
@Table(name="tb_cons_supp_flow")
public class TbConsSuppFlow implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "`con_info_id`",nullable = false)
@NotNull
@ApiModelProperty(value = "conInfoId")
private Integer conInfoId;
@Column(name = "`shop_id`")
@ApiModelProperty(value = "店铺id")
private Integer shopId;
@Column(name = "`sku_id`")
@ApiModelProperty(value = "skuId")
private Integer skuId;
@Column(name = "`product_id`")
@ApiModelProperty(value = "productId")
private Integer productId;
@Column(name = "`supplier_id`",nullable = false)
@NotNull
@ApiModelProperty(value = "supplierId")
private Integer supplierId;
@Column(name = "`type`",nullable = false)
@NotBlank
@ApiModelProperty(value = "出入库类型: in 入库 out 出库")
private String type;
@Column(name = "`stock_number`",nullable = false)
@NotNull
@ApiModelProperty(value = "数量")
private BigDecimal stockNumber;
@Column(name = "`price`",nullable = false)
@NotNull
@ApiModelProperty(value = "进价")
private BigDecimal price;
@Column(name = "`amount`",nullable = false)
@ApiModelProperty(value = "小计")
private BigDecimal amount;
@Column(name = "`balance`",nullable = false)
@NotNull
@ApiModelProperty(value = "剩余库存")
private BigDecimal balance;
@Column(name = "`accounts_payable`",nullable = false)
@NotNull
@ApiModelProperty(value = "应付款")
private BigDecimal accountsPayable;
@Column(name = "`actual_payment`",nullable = false)
@NotNull
@ApiModelProperty(value = "实付款")
private BigDecimal actualPayment;
@Column(name = "`payment_time`")
@ApiModelProperty(value = "paymentTime")
private Timestamp paymentTime;
@Column(name = "`create_time`")
@ApiModelProperty(value = "createTime")
private Timestamp createTime;
@Column(name = "`update_time`")
@ApiModelProperty(value = "updateTime")
private Timestamp updateTime;
public void copy(TbConsSuppFlow source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
public static void main(String[] args){
System.out.println(JSONUtil.toJSONString(new TbConsSuppFlow()));
}
}

View File

@ -44,6 +44,12 @@ public class TbProskuCon implements Serializable {
@ApiModelProperty(value = "耗材id")
private Integer conInfoId;
@Column(name = "`product_id`",nullable = false)
@ApiModelProperty(value = "商品id")
private Integer productId;
@Column(name = "`status`",nullable = false)
@NotBlank
@ApiModelProperty(value = "状态 1 启用 0 禁用")

View File

@ -89,6 +89,11 @@ public class ViewConSku implements Serializable {
@ApiModelProperty(value = "商品名称")
private String name;
@Column(name = "`price`")
@ApiModelProperty(value = "单价")
private String price;
public void copy(ViewConSku source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -0,0 +1,139 @@
/*
* 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.cons.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @author admin
* @date 2024-07-03
**/
@Entity
@Data
@Table(name="view_cons_supp_flow")
public class ViewConsSuppFlow implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "`con_info_id`",nullable = false)
@NotNull
@ApiModelProperty(value = "conInfoId")
private Integer conInfoId;
@Column(name = "`shop_id`")
@ApiModelProperty(value = "店铺id")
private Integer shopId;
@Column(name = "`sku_id`")
@ApiModelProperty(value = "skuId")
private Integer skuId;
@Column(name = "`product_id`")
@ApiModelProperty(value = "productId")
private Integer productId;
@Column(name = "`supplier_id`",nullable = false)
@NotNull
@ApiModelProperty(value = "supplierId")
private Integer supplierId;
@Column(name = "`type`",nullable = false)
@NotBlank
@ApiModelProperty(value = "出入库类型: in 入库 out 出库")
private String type;
@Column(name = "`stock_number`",nullable = false)
@NotNull
@ApiModelProperty(value = "数量")
private BigDecimal stockNumber;
@Column(name = "`price`",nullable = false)
@NotNull
@ApiModelProperty(value = "进价")
private BigDecimal price;
@Column(name = "`amount`",nullable = false)
@NotNull
@ApiModelProperty(value = "小计")
private BigDecimal amount;
@Column(name = "`balance`",nullable = false)
@NotNull
@ApiModelProperty(value = "剩余库存")
private BigDecimal balance;
@Column(name = "`accounts_payable`",nullable = false)
@NotNull
@ApiModelProperty(value = "应付款")
private BigDecimal accountsPayable;
@Column(name = "`actual_payment`",nullable = false)
@NotNull
@ApiModelProperty(value = "实付款")
private BigDecimal actualPayment;
@Column(name = "`payment_time`")
@ApiModelProperty(value = "paymentTime")
private Timestamp paymentTime;
@Column(name = "`create_time`")
@ApiModelProperty(value = "createTime")
private Timestamp createTime;
@Column(name = "`update_time`")
@ApiModelProperty(value = "updateTime")
private Timestamp updateTime;
@Column(name = "`con_name`")
@ApiModelProperty(value = "耗材名称")
private String conName;
@Column(name = "`con_code`")
@ApiModelProperty(value = "耗材代码")
private String conCode;
@Column(name = "`con_type_name`")
@ApiModelProperty(value = "耗材类型名称")
private String conTypeName;
@Column(name = "`purveyor_name`")
@ApiModelProperty(value = "联系人名字")
private String purveyorName;
@Column(name = "`address`")
@ApiModelProperty(value = "供应商地址")
private String address;
@Column(name = "`purveyor_telephone`")
@ApiModelProperty(value = "联系人电话")
private String purveyorTelephone;
public void copy(ViewConsSuppFlow source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,13 @@
package cn.ysk.cashier.cons.repository;
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author admin
* @date 2024-07-02
**/
public interface TbConsSuppFlowRepository extends JpaRepository<TbConsSuppFlow, Integer>, JpaSpecificationExecutor<TbConsSuppFlow> {
}

View File

@ -13,6 +13,15 @@ import org.springframework.data.jpa.repository.Query;
public interface TbProskuConRepository extends JpaRepository<TbProskuCon, Integer>, JpaSpecificationExecutor<TbProskuCon> {
@Query(value = "select count(0) from tb_prosku_con where con_info_id=?1 and product_sku_id=?2 and shop_id=?3",nativeQuery = true)
int countByConInfoIdAndProductSkuIdAndShopId(Integer conInfoId,Integer productSkuId,Integer shopId);
@Query(value = "select count(0) from tb_prosku_con where con_info_id=?1 and product_sku_id=?2 and shop_id=?3 and product_id=?4",nativeQuery = true)
int countByConInfoIdAndProductSkuIdAndShopId(Integer conInfoId,Integer productSkuId,Integer shopId,Integer productId);
@Query(value = "select * from tb_prosku_con where con_info_id=?1 and product_sku_id=?2 and shop_id=?3 and product_id=?4",nativeQuery = true)
TbProskuCon selectByConInfoIdAndProductSkuIdAndShopId(Integer conInfoId,Integer productSkuId,Integer shopId,Integer productId);
}

View File

@ -0,0 +1,13 @@
package cn.ysk.cashier.cons.repository;
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author admin
* @date 2024-07-03
**/
public interface ViewConsSuppFlowRepository extends JpaRepository<ViewConsSuppFlow, Integer>, JpaSpecificationExecutor<ViewConsSuppFlow> {
}

View File

@ -2,6 +2,7 @@ package cn.ysk.cashier.cons.rest;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.cons.domain.TbConsInfo;
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import cn.ysk.cashier.cons.service.TbConsInfoService;
import cn.ysk.cashier.cons.service.dto.TbConsInfoQueryCriteria;
import org.springframework.data.domain.Pageable;
@ -63,11 +64,11 @@ public class TbConsInfoController {
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping(value = "stockIn")
@Log("耗材入库")
@ApiOperation("耗材入库")
public ResponseEntity<Object> stockIn(@Validated @RequestBody TbConsInfo resources) throws Exception {
tbConsInfoService.stockIn(resources);
@PostMapping(value = "stockInOut")
@Log("耗材入库")
@ApiOperation("耗材入库")
public ResponseEntity<Object> stockInOut(@Validated @RequestBody TbConsSuppFlow resources) throws Exception {
tbConsInfoService.stockInOut(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}

View File

@ -0,0 +1,65 @@
package cn.ysk.cashier.cons.rest;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import cn.ysk.cashier.cons.service.TbConsSuppFlowService;
import cn.ysk.cashier.cons.service.dto.TbConsSuppFlowQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-07-02
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "入库记录管理")
@RequestMapping("/api/tbConsSuppFlow")
public class TbConsSuppFlowController {
private final TbConsSuppFlowService tbConsSuppFlowService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
public void exportTbConsSuppFlow(HttpServletResponse response, TbConsSuppFlowQueryCriteria criteria) throws IOException {
tbConsSuppFlowService.download(tbConsSuppFlowService.queryAll(criteria), response);
}
@GetMapping
@Log("查询入库记录")
@ApiOperation("查询入库记录")
public ResponseEntity<Object> queryTbConsSuppFlow(TbConsSuppFlowQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbConsSuppFlowService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增入库记录")
@ApiOperation("新增入库记录")
public ResponseEntity<Object> createTbConsSuppFlow(@Validated @RequestBody TbConsSuppFlow resources){
return new ResponseEntity<>(tbConsSuppFlowService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改入库记录")
@ApiOperation("修改入库记录")
public ResponseEntity<Object> updateTbConsSuppFlow(@Validated @RequestBody TbConsSuppFlow resources){
tbConsSuppFlowService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除入库记录")
@ApiOperation("删除入库记录")
public ResponseEntity<Object> deleteTbConsSuppFlow(@RequestBody Integer[] ids) {
tbConsSuppFlowService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -3,6 +3,7 @@ package cn.ysk.cashier.cons.rest;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.cons.domain.TbProskuCon;
import cn.ysk.cashier.cons.service.TbProskuConService;
import cn.ysk.cashier.cons.service.dto.ProskuInfo;
import cn.ysk.cashier.cons.service.dto.TbProskuConQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
@ -43,14 +44,14 @@ public class TbProskuConController {
@PostMapping
@Log("新增商品规格耗材信息")
@ApiOperation("新增商品规格耗材信息")
public ResponseEntity<Object> createTbProskuCon(@Validated @RequestBody TbProskuCon resources) throws Exception {
public ResponseEntity<Object> createTbProskuCon(@Validated @RequestBody ProskuInfo resources) throws Exception {
return new ResponseEntity<>(tbProskuConService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改商品规格耗材信息")
@ApiOperation("修改商品规格耗材信息")
public ResponseEntity<Object> updateTbProskuCon(@Validated @RequestBody TbProskuCon resources){
public ResponseEntity<Object> updateTbProskuCon(@Validated @RequestBody ProskuInfo resources) throws Exception {
tbProskuConService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

View File

@ -0,0 +1,65 @@
package cn.ysk.cashier.cons.rest;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
import cn.ysk.cashier.cons.service.ViewConsSuppFlowService;
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-07-03
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "出入库记录管理")
@RequestMapping("/api/viewConsSuppFlow")
public class ViewConsSuppFlowController {
private final ViewConsSuppFlowService viewConsSuppFlowService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
public void exportViewConsSuppFlow(HttpServletResponse response, ViewConsSuppFlowQueryCriteria criteria) throws IOException {
viewConsSuppFlowService.download(viewConsSuppFlowService.queryAll(criteria), response);
}
@GetMapping
@Log("查询出入库记录")
@ApiOperation("查询出入库记录")
public ResponseEntity<Object> queryViewConsSuppFlow(ViewConsSuppFlowQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(viewConsSuppFlowService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增出入库记录")
@ApiOperation("新增出入库记录")
public ResponseEntity<Object> createViewConsSuppFlow(@Validated @RequestBody ViewConsSuppFlow resources){
return new ResponseEntity<>(viewConsSuppFlowService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改出入库记录")
@ApiOperation("修改出入库记录")
public ResponseEntity<Object> updateViewConsSuppFlow(@Validated @RequestBody ViewConsSuppFlow resources){
viewConsSuppFlowService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除出入库记录")
@ApiOperation("删除出入库记录")
public ResponseEntity<Object> deleteViewConsSuppFlow(@RequestBody Integer[] ids) {
viewConsSuppFlowService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -1,6 +1,7 @@
package cn.ysk.cashier.cons.service;
import cn.ysk.cashier.cons.domain.TbConsInfo;
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import cn.ysk.cashier.cons.service.dto.TbConsInfoDto;
import cn.ysk.cashier.cons.service.dto.TbConsInfoQueryCriteria;
import org.springframework.data.domain.Pageable;
@ -65,5 +66,5 @@ public interface TbConsInfoService {
void download(List<TbConsInfoDto> all, HttpServletResponse response) throws IOException;
void stockIn(TbConsInfo resources) throws Exception;
void stockInOut(TbConsSuppFlow resources) throws Exception;
}

View File

@ -0,0 +1,66 @@
package cn.ysk.cashier.cons.service;
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import cn.ysk.cashier.cons.service.dto.TbConsSuppFlowDto;
import cn.ysk.cashier.cons.service.dto.TbConsSuppFlowQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-07-02
**/
public interface TbConsSuppFlowService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TbConsSuppFlowQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TbConsSuppFlowDto>
*/
List<TbConsSuppFlowDto> queryAll(TbConsSuppFlowQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return TbConsSuppFlowDto
*/
TbConsSuppFlowDto findById(Integer id);
/**
* 创建
* @param resources /
* @return TbConsSuppFlowDto
*/
TbConsSuppFlowDto create(TbConsSuppFlow resources);
/**
* 编辑
* @param resources /
*/
void update(TbConsSuppFlow resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<TbConsSuppFlowDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -1,6 +1,7 @@
package cn.ysk.cashier.cons.service;
import cn.ysk.cashier.cons.domain.TbProskuCon;
import cn.ysk.cashier.cons.service.dto.ProskuInfo;
import cn.ysk.cashier.cons.service.dto.TbProskuConDto;
import cn.ysk.cashier.cons.service.dto.TbProskuConQueryCriteria;
import org.springframework.data.domain.Pageable;
@ -42,13 +43,13 @@ public interface TbProskuConService {
* @param resources /
* @return TbProskuConDto
*/
TbProskuConDto create(TbProskuCon resources) throws Exception;
TbProskuConDto create(ProskuInfo resources) throws Exception;
/**
* 编辑
* @param resources /
*/
void update(TbProskuCon resources);
void update(ProskuInfo resources) throws Exception;
/**
* 多选删除

View File

@ -0,0 +1,66 @@
package cn.ysk.cashier.cons.service;
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowDto;
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-07-03
**/
public interface ViewConsSuppFlowService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(ViewConsSuppFlowQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<ViewConsSuppFlowDto>
*/
List<ViewConsSuppFlowDto> queryAll(ViewConsSuppFlowQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return ViewConsSuppFlowDto
*/
ViewConsSuppFlowDto findById(Integer id);
/**
* 创建
* @param resources /
* @return ViewConsSuppFlowDto
*/
ViewConsSuppFlowDto create(ViewConsSuppFlow resources);
/**
* 编辑
* @param resources /
*/
void update(ViewConsSuppFlow resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<ViewConsSuppFlowDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -0,0 +1,63 @@
package cn.ysk.cashier.cons.service.dto;
import cn.ysk.cashier.utils.JSONUtil;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@Data
public class ProskuInfo implements Serializable {
private Integer productId;
private Integer consInfoId;
private BigDecimal surplusStock;
private List<SkuInfo> skuInfos;
private String status;
@Data
public static class SkuInfo{
private Integer skuId;
private Integer shopId;
private Integer conInfoId;
private BigDecimal surplusStock;
private String status;
}
public static void main(String[] args){
ProskuInfo info= new ProskuInfo();
info.setConsInfoId(1);
info.setProductId(1);
info.setSurplusStock(BigDecimal.ZERO);
List<SkuInfo> skuInfos1=new ArrayList<>();
SkuInfo skuInfo=new SkuInfo();
skuInfo.setConInfoId(1);
skuInfo.setSkuId(1);
skuInfo.setShopId(1);
skuInfo.setSurplusStock(BigDecimal.ZERO);
skuInfo.setStatus("1");
skuInfos1.add(skuInfo);
info.setStatus("1");
info.setSkuInfos(skuInfos1);
System.out.println(JSONUtil.toJSONString(info));
}
}

View File

@ -15,7 +15,10 @@
*/
package cn.ysk.cashier.cons.service.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
@ -63,4 +66,14 @@ public class TbConsInfoDto implements Serializable {
/** 店铺id */
private Integer shopId;
private BigDecimal price;
private String status;
private BigDecimal stockConsume;
}

View File

@ -0,0 +1,69 @@
/*
* 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.cons.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @author admin
* @date 2024-07-02
**/
@Data
public class TbConsSuppFlowDto implements Serializable {
private Integer id;
private Integer conInfoId;
/** 店铺id */
private Integer shopId;
private Integer skuId;
private Integer productId;
private Integer supplierId;
/** 出入库类型: in 入库 out 出库 */
private String type;
/** 数量 */
private BigDecimal stockNumber;
/** 进价 */
private BigDecimal price;
/** 小计 */
private BigDecimal amount;
/** 剩余库存 */
private BigDecimal balance;
/** 应付款 */
private BigDecimal accountsPayable;
/** 实付款 */
private BigDecimal actualPayment;
private Timestamp paymentTime;
private Timestamp createTime;
private Timestamp updateTime;
}

View File

@ -0,0 +1,13 @@
package cn.ysk.cashier.cons.service.dto;
import lombok.Data;
import java.util.List;
import cn.ysk.cashier.annotation.Query;
/**
* @author admin
* @date 2024-07-02
**/
@Data
public class TbConsSuppFlowQueryCriteria{
}

View File

@ -48,4 +48,6 @@ public class TbProskuConDto implements Serializable {
/** 店铺id */
private Integer shopId;
private Integer productId;
}

View File

@ -63,4 +63,6 @@ public class ViewConSkuDto implements Serializable {
/** 商品名称 */
private String name;
}

View File

@ -0,0 +1,87 @@
/*
* 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.cons.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @author admin
* @date 2024-07-03
**/
@Data
public class ViewConsSuppFlowDto implements Serializable {
private Integer id;
private Integer conInfoId;
/** 店铺id */
private Integer shopId;
private Integer skuId;
private Integer productId;
private Integer supplierId;
/** 出入库类型: in 入库 out 出库 */
private String type;
/** 数量 */
private BigDecimal stockNumber;
/** 进价 */
private BigDecimal price;
/** 小计 */
private BigDecimal amount;
/** 剩余库存 */
private BigDecimal balance;
/** 应付款 */
private BigDecimal accountsPayable;
/** 实付款 */
private BigDecimal actualPayment;
private Timestamp paymentTime;
private Timestamp createTime;
private Timestamp updateTime;
/** 耗材名称 */
private String conName;
/** 耗材代码 */
private String conCode;
/** 耗材类型名称 */
private String conTypeName;
/** 联系人名字 */
private String purveyorName;
/** 供应商地址 */
private String address;
/** 联系人电话 */
private String purveyorTelephone;
}

View File

@ -0,0 +1,43 @@
package cn.ysk.cashier.cons.service.dto;
import cn.ysk.cashier.utils.JSONUtil;
import lombok.Data;
import java.util.List;
import cn.ysk.cashier.annotation.Query;
/**
* @author admin
* @date 2024-07-03
**/
@Data
public class ViewConsSuppFlowQueryCriteria{
/** 精确 */
@Query
private Integer conInfoId;
/** 精确 */
@Query
private String type;
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String conName;
/** 精确 */
@Query
private String conCode;
/** 精确 */
@Query
private String conTypeName;
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String purveyorName;
public static void main(String[] args){
System.out.println(JSONUtil.toJSONString(new ViewConsSuppFlowQueryCriteria()));
}
}

View File

@ -2,9 +2,16 @@ package cn.ysk.cashier.cons.service.impl;
import cn.ysk.cashier.cons.domain.TbConsInfo;
import cn.ysk.cashier.cons.domain.TbConsInfoFlow;
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import cn.ysk.cashier.cons.domain.TbConsType;
import cn.ysk.cashier.cons.repository.TbConsInfoFlowRepository;
import cn.ysk.cashier.cons.repository.TbConsSuppFlowRepository;
import cn.ysk.cashier.cons.repository.TbConsTypeRepository;
import cn.ysk.cashier.cons.service.mapstruct.TbConsSuppFlowMapper;
import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.pojo.shop.TbShopPurveyor;
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
@ -43,6 +50,11 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
public final TbConsInfoFlowRepository tbConsInfoFlowRepository;
public final TbConsSuppFlowRepository tbConsSuppFlowRepository;
private final TbShopPurveyorRepository tbShopPurveyorRepository;
private final TbShopInfoRepository tbShopInfoRepository;
@Override
public Map<String,Object> queryAll(TbConsInfoQueryCriteria criteria, Pageable pageable){
Page<TbConsInfo> page = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
@ -75,6 +87,8 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
resources.setConTypeName(tbConsType.getConTypeName());
resources.setLasterInStock(BigDecimal.ZERO);
resources.setStockNumber(BigDecimal.ZERO);
resources.setStatus("1");
resources.setStockConsume(BigDecimal.ZERO);
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
return tbConsInfoMapper.toDto(tbConsInfoRepository.save(resources));
}
@ -117,26 +131,61 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
@Override
@Transactional(rollbackFor = Exception.class)
public void stockIn(TbConsInfo resources) throws Exception {
TbConsInfo info= tbConsInfoRepository.getById(resources.getId());
public void stockInOut(TbConsSuppFlow resources) throws Exception {
TbConsInfo info= tbConsInfoRepository.getById(resources.getConInfoId());
if(Objects.isNull(info)){
throw new Exception("不存在的耗材信息");
}
info.setStockNumber(info.getStockNumber().add(resources.getStockNumber()));
info.setLasterInStock(resources.getStockNumber());
tbConsInfoRepository.save(info);
TbShopInfo tbShopInfo= tbShopInfoRepository.getById(resources.getShopId());
if(Objects.isNull(tbShopInfo)){
throw new Exception("店铺信息不存在");
}
TbShopPurveyor purveyor= tbShopPurveyorRepository.getById(resources.getSupplierId());
if(Objects.isNull(purveyor)){
throw new Exception("不存在的供应商");
}
TbConsInfoFlow flow=new TbConsInfoFlow();
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("+");
}else {
info.setStockNumber(info.getStockNumber().subtract(resources.getStockNumber()));
resources.setType("out");
flow.setBizCode("stockout");
flow.setBizName("耗材出库");
flow.setBizType("-");
}
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.setBizCode("stockIn");
flow.setBizName("耗材入库");
flow.setBizType("+");
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoFlowRepository.save(flow);

View File

@ -0,0 +1,103 @@
package cn.ysk.cashier.cons.service.impl;
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.cons.repository.TbConsSuppFlowRepository;
import cn.ysk.cashier.cons.service.TbConsSuppFlowService;
import cn.ysk.cashier.cons.service.dto.TbConsSuppFlowDto;
import cn.ysk.cashier.cons.service.dto.TbConsSuppFlowQueryCriteria;
import cn.ysk.cashier.cons.service.mapstruct.TbConsSuppFlowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author admin
* @date 2024-07-02
**/
@Service
@RequiredArgsConstructor
public class TbConsSuppFlowServiceImpl implements TbConsSuppFlowService {
private final TbConsSuppFlowRepository tbConsSuppFlowRepository;
private final TbConsSuppFlowMapper tbConsSuppFlowMapper;
@Override
public Map<String,Object> queryAll(TbConsSuppFlowQueryCriteria criteria, Pageable pageable){
Page<TbConsSuppFlow> page = tbConsSuppFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(tbConsSuppFlowMapper::toDto));
}
@Override
public List<TbConsSuppFlowDto> queryAll(TbConsSuppFlowQueryCriteria criteria){
return tbConsSuppFlowMapper.toDto(tbConsSuppFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public TbConsSuppFlowDto findById(Integer id) {
TbConsSuppFlow tbConsSuppFlow = tbConsSuppFlowRepository.findById(id).orElseGet(TbConsSuppFlow::new);
ValidationUtil.isNull(tbConsSuppFlow.getId(),"TbConsSuppFlow","id",id);
return tbConsSuppFlowMapper.toDto(tbConsSuppFlow);
}
@Override
@Transactional(rollbackFor = Exception.class)
public TbConsSuppFlowDto create(TbConsSuppFlow resources) {
return tbConsSuppFlowMapper.toDto(tbConsSuppFlowRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbConsSuppFlow resources) {
TbConsSuppFlow tbConsSuppFlow = tbConsSuppFlowRepository.findById(resources.getId()).orElseGet(TbConsSuppFlow::new);
ValidationUtil.isNull( tbConsSuppFlow.getId(),"TbConsSuppFlow","id",resources.getId());
tbConsSuppFlow.copy(resources);
tbConsSuppFlowRepository.save(tbConsSuppFlow);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
tbConsSuppFlowRepository.deleteById(id);
}
}
@Override
public void download(List<TbConsSuppFlowDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbConsSuppFlowDto tbConsSuppFlow : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put(" conInfoId", tbConsSuppFlow.getConInfoId());
map.put("店铺id", tbConsSuppFlow.getShopId());
map.put(" skuId", tbConsSuppFlow.getSkuId());
map.put(" productId", tbConsSuppFlow.getProductId());
map.put(" supplierId", tbConsSuppFlow.getSupplierId());
map.put("出入库类型: in 入库 out 出库", tbConsSuppFlow.getType());
map.put("数量", tbConsSuppFlow.getStockNumber());
map.put("进价", tbConsSuppFlow.getPrice());
map.put("小计", tbConsSuppFlow.getAmount());
map.put("剩余库存", tbConsSuppFlow.getBalance());
map.put("应付款", tbConsSuppFlow.getAccountsPayable());
map.put("实付款", tbConsSuppFlow.getActualPayment());
map.put(" paymentTime", tbConsSuppFlow.getPaymentTime());
map.put(" createTime", tbConsSuppFlow.getCreateTime());
map.put(" updateTime", tbConsSuppFlow.getUpdateTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -1,7 +1,14 @@
package cn.ysk.cashier.cons.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.ysk.cashier.cons.domain.TbConsInfo;
import cn.ysk.cashier.cons.domain.TbProskuCon;
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
import cn.ysk.cashier.cons.service.dto.ProskuInfo;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.pojo.product.TbProductSku;
import cn.ysk.cashier.repository.product.TbProductRepository;
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
@ -18,12 +25,9 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
@ -38,6 +42,12 @@ public class TbProskuConServiceImpl implements TbProskuConService {
private final TbProskuConRepository tbProskuConRepository;
private final TbProskuConMapper tbProskuConMapper;
private final TbProductRepository tbProductRepository;
private final TbProductSkuRepository tbProductSkuRepository;
private final TbConsInfoRepository tbConsInfoRepository;
@Override
public Map<String,Object> queryAll(TbProskuConQueryCriteria criteria, Pageable pageable){
Page<TbProskuCon> page = tbProskuConRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
@ -59,30 +69,112 @@ public class TbProskuConServiceImpl implements TbProskuConService {
@Override
@Transactional(rollbackFor = Exception.class)
public TbProskuConDto create(TbProskuCon resources) throws Exception {
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resources.getConInfoId(), resources.getProductSkuId(), resources.getShopId());
if(count>0){
throw new Exception("对应的商品耗材信息已存在");
public TbProskuConDto create(ProskuInfo resources) throws Exception {
TbProduct product= tbProductRepository.getById(resources.getProductId());
if(Objects.isNull(product)){
throw new Exception("对应的商品信息不存在");
}
resources.setStatus("0");
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
return tbProskuConMapper.toDto(tbProskuConRepository.save(resources));
TbConsInfo tbConsInfo= tbConsInfoRepository.getById(resources.getConsInfoId());
if(Objects.isNull(tbConsInfo)){
throw new Exception("对应的耗材信息不存在");
}
List<TbProskuCon> list=new ArrayList<>();
if(product.getIsDistribute().intValue()==1){
//查询商品对应的所有规格
List<TbProductSku> skuList= tbProductSkuRepository.searchSku(product.getId().toString());
if(Objects.nonNull(skuList)&&skuList.size()>0){
for (TbProductSku tbProductSku : skuList) {
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), tbProductSku.getId(), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId()));
if(count<=0){
TbProskuCon tbProskuCon=new TbProskuCon();
tbProskuCon.setShopId(Integer.valueOf(tbProductSku.getShopId()));
tbProskuCon.setConInfoId(resources.getConsInfoId());
tbProskuCon.setProductId(Integer.valueOf(tbProductSku.getProductId()));
tbProskuCon.setProductSkuId(tbProductSku.getId());
tbProskuCon.setSurplusStock(resources.getSurplusStock());
tbProskuCon.setStatus("1");
tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis()));
list.add(tbProskuCon);
}
}
}
}else {
for (ProskuInfo.SkuInfo skuInfo : resources.getSkuInfos()) {
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), skuInfo.getSkuId(), skuInfo.getShopId(), resources.getProductId());
if(count<=0){
TbProskuCon tbProskuCon=new TbProskuCon();
tbProskuCon.setShopId(Integer.valueOf(skuInfo.getShopId()));
tbProskuCon.setConInfoId(resources.getConsInfoId());
tbProskuCon.setProductId(resources.getProductId());
tbProskuCon.setProductSkuId(skuInfo.getSkuId());
tbProskuCon.setSurplusStock(skuInfo.getSurplusStock());
tbProskuCon.setStatus("1");
tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis()));
list.add(tbProskuCon);
}
}
}
if(Objects.nonNull(list)&&list.size()>0){
tbProskuConRepository.saveAll(list);
}
return new TbProskuConDto();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbProskuCon resources) {
TbProskuCon tbProskuCon = tbProskuConRepository.findById(resources.getId()).orElseGet(TbProskuCon::new);
ValidationUtil.isNull( tbProskuCon.getId(),"TbProskuCon","id",resources.getId());
if(ObjectUtil.isNotEmpty(resources.getStatus())){
tbProskuCon.setStatus("1");
public void update(ProskuInfo resources) throws Exception {
TbProduct product= tbProductRepository.getById(resources.getProductId());
if(Objects.isNull(product)){
throw new Exception("对应的商品信息不存在");
}
if(ObjectUtil.isNotEmpty(resources.getSurplusStock())){
tbProskuCon.setSurplusStock(resources.getSurplusStock());
TbConsInfo tbConsInfo= tbConsInfoRepository.getById(resources.getConsInfoId());
if(Objects.isNull(tbConsInfo)){
throw new Exception("对应的耗材信息不存在");
}
tbProskuConRepository.save(tbProskuCon);
List<TbProskuCon> list=new ArrayList<>();
if("1".equals(product.getIsDistribute().toString())){
//查询商品对应的所有规格
List<TbProductSku> skuList= tbProductSkuRepository.searchSku(product.getId().toString());
if(Objects.nonNull(skuList)&&skuList.size()>0){
for (TbProductSku tbProductSku : skuList) {
TbProskuCon tbProskuCon=tbProskuConRepository.selectByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), tbProductSku.getId(), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId()));
if(Objects.nonNull(tbProskuCon)){
tbProskuCon.setSurplusStock(resources.getSurplusStock());
tbProskuCon.setStatus(resources.getStatus());
tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis()));
list.add(tbProskuCon);
}
}
}
}else {
for (ProskuInfo.SkuInfo skuInfo : resources.getSkuInfos()) {
TbProskuCon tbProskuCon=tbProskuConRepository.selectByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), skuInfo.getSkuId(), skuInfo.getShopId(), resources.getProductId());
if(Objects.nonNull(tbProskuCon)){
tbProskuCon.setSurplusStock(skuInfo.getSurplusStock());
tbProskuCon.setStatus(skuInfo.getStatus());
tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis()));
list.add(tbProskuCon);
}
}
}
tbProskuConRepository.saveAll(list);
}
@Override

View File

@ -0,0 +1,109 @@
package cn.ysk.cashier.cons.service.impl;
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.cons.repository.ViewConsSuppFlowRepository;
import cn.ysk.cashier.cons.service.ViewConsSuppFlowService;
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowDto;
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowQueryCriteria;
import cn.ysk.cashier.cons.service.mapstruct.ViewConsSuppFlowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author admin
* @date 2024-07-03
**/
@Service
@RequiredArgsConstructor
public class ViewConsSuppFlowServiceImpl implements ViewConsSuppFlowService {
private final ViewConsSuppFlowRepository viewConsSuppFlowRepository;
private final ViewConsSuppFlowMapper viewConsSuppFlowMapper;
@Override
public Map<String,Object> queryAll(ViewConsSuppFlowQueryCriteria criteria, Pageable pageable){
Page<ViewConsSuppFlow> page = viewConsSuppFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(viewConsSuppFlowMapper::toDto));
}
@Override
public List<ViewConsSuppFlowDto> queryAll(ViewConsSuppFlowQueryCriteria criteria){
return viewConsSuppFlowMapper.toDto(viewConsSuppFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public ViewConsSuppFlowDto findById(Integer id) {
ViewConsSuppFlow viewConsSuppFlow = viewConsSuppFlowRepository.findById(id).orElseGet(ViewConsSuppFlow::new);
ValidationUtil.isNull(viewConsSuppFlow.getId(),"ViewConsSuppFlow","id",id);
return viewConsSuppFlowMapper.toDto(viewConsSuppFlow);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ViewConsSuppFlowDto create(ViewConsSuppFlow resources) {
return viewConsSuppFlowMapper.toDto(viewConsSuppFlowRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ViewConsSuppFlow resources) {
ViewConsSuppFlow viewConsSuppFlow = viewConsSuppFlowRepository.findById(resources.getId()).orElseGet(ViewConsSuppFlow::new);
ValidationUtil.isNull( viewConsSuppFlow.getId(),"ViewConsSuppFlow","id",resources.getId());
viewConsSuppFlow.copy(resources);
viewConsSuppFlowRepository.save(viewConsSuppFlow);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
viewConsSuppFlowRepository.deleteById(id);
}
}
@Override
public void download(List<ViewConsSuppFlowDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (ViewConsSuppFlowDto viewConsSuppFlow : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put(" conInfoId", viewConsSuppFlow.getConInfoId());
map.put("店铺id", viewConsSuppFlow.getShopId());
map.put(" skuId", viewConsSuppFlow.getSkuId());
map.put(" productId", viewConsSuppFlow.getProductId());
map.put(" supplierId", viewConsSuppFlow.getSupplierId());
map.put("出入库类型: in 入库 out 出库", viewConsSuppFlow.getType());
map.put("数量", viewConsSuppFlow.getStockNumber());
map.put("进价", viewConsSuppFlow.getPrice());
map.put("小计", viewConsSuppFlow.getAmount());
map.put("剩余库存", viewConsSuppFlow.getBalance());
map.put("应付款", viewConsSuppFlow.getAccountsPayable());
map.put("实付款", viewConsSuppFlow.getActualPayment());
map.put(" paymentTime", viewConsSuppFlow.getPaymentTime());
map.put(" createTime", viewConsSuppFlow.getCreateTime());
map.put(" updateTime", viewConsSuppFlow.getUpdateTime());
map.put("耗材名称", viewConsSuppFlow.getConName());
map.put("耗材代码", viewConsSuppFlow.getConCode());
map.put("耗材类型名称", viewConsSuppFlow.getConTypeName());
map.put("联系人名字", viewConsSuppFlow.getPurveyorName());
map.put("供应商地址", viewConsSuppFlow.getAddress());
map.put("联系人电话", viewConsSuppFlow.getPurveyorTelephone());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -0,0 +1,16 @@
package cn.ysk.cashier.cons.service.mapstruct;
import cn.ysk.cashier.base.BaseMapper;
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import cn.ysk.cashier.cons.service.dto.TbConsSuppFlowDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author admin
* @date 2024-07-02
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TbConsSuppFlowMapper extends BaseMapper<TbConsSuppFlowDto, TbConsSuppFlow> {
}

View File

@ -0,0 +1,16 @@
package cn.ysk.cashier.cons.service.mapstruct;
import cn.ysk.cashier.base.BaseMapper;
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author admin
* @date 2024-07-03
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ViewConsSuppFlowMapper extends BaseMapper<ViewConsSuppFlowDto, ViewConsSuppFlow> {
}