diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/controller/ProductCategoryController.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/controller/ProductCategoryController.java index e2e454d..9f7b181 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/controller/ProductCategoryController.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/controller/ProductCategoryController.java @@ -1,7 +1,13 @@ package com.lframework.xingyun.basedata.controller; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.BooleanUtil; import com.lframework.starter.common.exceptions.impl.DefaultClientException; import com.lframework.starter.common.utils.CollectionUtil; +import com.lframework.starter.web.components.excel.ExcelMultipartWriterSheetBuilder; +import com.lframework.starter.web.resp.PageResult; +import com.lframework.xingyun.basedata.excel.product.category.ProductCategoryExportModel; +import com.lframework.xingyun.basedata.excel.product.category.ProductCategoryExportModelVo; import com.lframework.xingyun.template.core.service.RecursionMappingService; import com.lframework.starter.web.annotations.security.HasPermission; import com.lframework.starter.web.common.utils.ApplicationUtil; @@ -199,4 +205,29 @@ public class ProductCategoryController extends DefaultBaseController { return InvokeResultBuilder.success(); } + + @ApiOperation("导出") + @HasPermission({"base-data:product:category:export"}) + @PostMapping(value = "/export") + public void exportExcel(@Valid ProductCategoryExportModelVo vo) { + ExcelMultipartWriterSheetBuilder builder = ExcelUtil.multipartExportXls("商品类目", ProductCategoryExportModel.class); + try { + int pageIndex = 1; + while (true) { + PageResult pageResult = productCategoryService.query(pageIndex, getExportSize(), vo); + List models = BeanUtil.copyToList(pageResult.getDatas(), ProductCategoryExportModel.class); + models.forEach(e -> e.setAvailable(BooleanUtil.toBoolean(e.getAvailable()) ? "启用" : "停用")); + builder.doWrite(models); + + if (!pageResult.isHasNext()) { + break; + } + pageIndex++; + } + } finally { + builder.finish(); + } + } + + } diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/category/ProductCategoryExportModel.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/category/ProductCategoryExportModel.java new file mode 100644 index 0000000..7049812 --- /dev/null +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/category/ProductCategoryExportModel.java @@ -0,0 +1,37 @@ +package com.lframework.xingyun.basedata.excel.product.category; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.lframework.starter.web.annotations.excel.ExcelRequired; +import com.lframework.starter.web.components.excel.ExcelModel; +import lombok.Data; + +@Data +public class ProductCategoryExportModel implements ExcelModel { + + /** + * 编号 + */ + @ExcelRequired + @ExcelProperty("编号") + private String code; + + /** + * 名称 + */ + @ExcelRequired + @ExcelProperty("名称") + private String name; + + /** + * 状态 + */ + @ExcelProperty("状态") + private String available; + + /** + * 备注 + */ + @ExcelProperty("备注") + private String description; + +} diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/category/ProductCategoryExportModelVo.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/category/ProductCategoryExportModelVo.java new file mode 100644 index 0000000..bb5b06b --- /dev/null +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/category/ProductCategoryExportModelVo.java @@ -0,0 +1,26 @@ +package com.lframework.xingyun.basedata.excel.product.category; + +import com.lframework.starter.web.vo.BaseVo; +import com.lframework.starter.web.vo.SortPageVo; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ProductCategoryExportModelVo extends SortPageVo implements BaseVo, Serializable { + + /** + * 编号 + */ + private String code; + + /** + * 名称 + */ + private String name; + + /** + * 状态 + */ + private String available; +} diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/product/ProductCategoryServiceImpl.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/product/ProductCategoryServiceImpl.java index 7b59837..317bc7b 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/product/ProductCategoryServiceImpl.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/product/ProductCategoryServiceImpl.java @@ -1,12 +1,19 @@ package com.lframework.xingyun.basedata.impl.product; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; import com.lframework.starter.common.constants.StringPool; import com.lframework.starter.common.exceptions.impl.DefaultClientException; +import com.lframework.starter.common.utils.Assert; import com.lframework.starter.common.utils.CollectionUtil; import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.common.utils.StringUtil; +import com.lframework.starter.web.resp.PageResult; +import com.lframework.starter.web.utils.PageHelperUtil; +import com.lframework.starter.web.utils.PageResultUtil; +import com.lframework.xingyun.basedata.excel.product.category.ProductCategoryExportModelVo; import com.lframework.xingyun.template.core.annotations.OpLog; import com.lframework.xingyun.basedata.enums.BaseDataOpLogType; import com.lframework.starter.web.impl.BaseMpServiceImpl; @@ -39,6 +46,22 @@ public class ProductCategoryServiceImpl extends @Autowired private RecursionMappingService recursionMappingService; + @Override + public PageResult query(Integer pageIndex, Integer pageSize, ProductCategoryExportModelVo vo) { + Assert.greaterThanZero(pageIndex); + Assert.greaterThanZero(pageSize); + + PageHelperUtil.startPage(pageIndex, pageSize); + List datas = this.list(Wrappers.lambdaQuery(ProductCategory.class) + .like(StrUtil.isNotBlank(vo.getName()), ProductCategory::getName,vo.getName()) + .like(StrUtil.isNotBlank(vo.getCode()), ProductCategory::getCode,vo.getCode()) + .eq(StrUtil.isNotBlank(vo.getAvailable()), ProductCategory::getAvailable,Boolean.TRUE) + .orderByAsc(ProductCategory::getCode).orderByDesc(ProductCategory::getAvailable) + ); + + return PageResultUtil.convert(new PageInfo<>(datas)); + } + @Override public List getAllProductCategories() { diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/service/product/ProductCategoryService.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/service/product/ProductCategoryService.java index ca2f418..9b08397 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/service/product/ProductCategoryService.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/service/product/ProductCategoryService.java @@ -1,7 +1,9 @@ package com.lframework.xingyun.basedata.service.product; +import com.lframework.starter.web.resp.PageResult; import com.lframework.starter.web.service.BaseMpService; import com.lframework.xingyun.basedata.entity.ProductCategory; +import com.lframework.xingyun.basedata.excel.product.category.ProductCategoryExportModelVo; import com.lframework.xingyun.basedata.vo.product.category.CreateProductCategoryVo; import com.lframework.xingyun.basedata.vo.product.category.QueryProductCategorySelectorVo; import com.lframework.xingyun.basedata.vo.product.category.UpdateProductCategoryVo; @@ -10,6 +12,16 @@ import java.util.List; public interface ProductCategoryService extends BaseMpService { + /** + * 查询列表 + * + * @param pageIndex + * @param pageSize + * @param vo + * @return + */ + PageResult query(Integer pageIndex, Integer pageSize, ProductCategoryExportModelVo vo); + /** * 查询全部类目信息 * diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/purchase/QueryPurchaseOrderBo.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/purchase/QueryPurchaseOrderBo.java index 72c6784..b84558a 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/purchase/QueryPurchaseOrderBo.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/purchase/QueryPurchaseOrderBo.java @@ -1,5 +1,6 @@ package com.lframework.xingyun.sc.bo.purchase; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.fasterxml.jackson.annotation.JsonFormat; import com.lframework.starter.common.constants.StringPool; import com.lframework.starter.common.utils.StringUtil; @@ -9,12 +10,21 @@ import com.lframework.xingyun.basedata.entity.StoreCenter; import com.lframework.xingyun.basedata.entity.Supplier; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; import com.lframework.xingyun.basedata.service.supplier.SupplierService; +import com.lframework.xingyun.sc.dto.purchase.PurchaseOrderWithReceiveDto; import com.lframework.xingyun.sc.entity.PurchaseOrder; +import com.lframework.xingyun.sc.entity.ReceiveSheet; +import com.lframework.xingyun.sc.enums.OrderStatus; +import com.lframework.xingyun.sc.enums.PurchaseOrderStatus; +import com.lframework.xingyun.sc.service.purchase.PurchaseOrderService; +import com.lframework.xingyun.sc.service.purchase.ReceiveSheetService; import com.lframework.xingyun.template.core.service.UserService; import io.swagger.annotations.ApiModelProperty; + import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; + import lombok.Data; @Data @@ -125,6 +135,12 @@ public class QueryPurchaseOrderBo extends BaseBo { @ApiModelProperty("状态") private Integer status; + /** + * 订单状态 + */ + @ApiModelProperty("订单状态") + private Integer orderStatus; + /** * 拒绝原因 */ @@ -164,6 +180,25 @@ public class QueryPurchaseOrderBo extends BaseBo { this.approveBy = userService.findById(dto.getApproveBy()).getName(); } + PurchaseOrderService purchaseOrderService = ApplicationUtil.getBean(PurchaseOrderService.class); + PurchaseOrderWithReceiveDto data = purchaseOrderService.getWithReceive(id); + PurchaseOrderWithReceiveBo result = new PurchaseOrderWithReceiveBo(data); + + ReceiveSheetService receiveSheetService = ApplicationUtil.getBean(ReceiveSheetService.class); + List receiveSheetList = receiveSheetService.list(Wrappers.lambdaQuery(ReceiveSheet.class).eq(ReceiveSheet::getPurchaseOrderId, id).eq(ReceiveSheet::getStatus, PurchaseOrderStatus.APPROVE_PASS.getCode())); + if (receiveSheetList.isEmpty()) { + this.orderStatus = OrderStatus.IN_LOGISTICS.getCode(); + } else { + if (result.getDetails() == null) { + this.orderStatus = OrderStatus.COMPLETE_RECEIPT_OF_GOODS.getCode(); + } else { + int reduce = result.getDetails().stream().mapToInt(PurchaseOrderWithReceiveBo.DetailBo::getRemainNum).sum(); + if (reduce > 0) { + this.orderStatus = OrderStatus.PARTIAL_RECEIPT_OF_GOODS.getCode(); + } + } + } + this.status = dto.getStatus().getCode(); } } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/sale/QuerySaleOrderBo.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/sale/QuerySaleOrderBo.java index f73c042..066db8e 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/sale/QuerySaleOrderBo.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/sale/QuerySaleOrderBo.java @@ -9,7 +9,10 @@ import com.lframework.xingyun.basedata.entity.Customer; import com.lframework.xingyun.basedata.entity.StoreCenter; import com.lframework.xingyun.basedata.service.customer.CustomerService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; +import com.lframework.xingyun.sc.dto.sale.SaleOrderWithOutDto; import com.lframework.xingyun.sc.entity.SaleOrder; +import com.lframework.xingyun.sc.enums.OrderStatus; +import com.lframework.xingyun.sc.service.sale.SaleOrderService; import com.lframework.xingyun.template.core.service.UserService; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; @@ -117,6 +120,12 @@ public class QuerySaleOrderBo extends BaseBo { @ApiModelProperty("状态") private Integer status; + /** + * 订单状态 + */ + @ApiModelProperty("订单状态") + private Integer orderStatus; + /** * 拒绝原因 */ @@ -156,6 +165,12 @@ public class QuerySaleOrderBo extends BaseBo { this.approveBy = userService.findById(dto.getApproveBy()).getName(); } + SaleOrderService saleOrderService = ApplicationUtil.getBean(SaleOrderService.class); + SaleOrderWithOutDto data = saleOrderService.getWithOut(id); + SaleOrderWithOutBo result = new SaleOrderWithOutBo(data); + + this.orderStatus = result.getDetails() != null ? OrderStatus.NOT_SHIPPED_YET.getCode() : OrderStatus.ALREADY_SHIPPED.getCode(); + this.status = dto.getStatus().getCode(); } } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/enums/OrderStatus.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/enums/OrderStatus.java new file mode 100644 index 0000000..a4898ce --- /dev/null +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/enums/OrderStatus.java @@ -0,0 +1,37 @@ +package com.lframework.xingyun.sc.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.lframework.starter.web.enums.BaseEnum; + +public enum OrderStatus implements BaseEnum { + + IN_LOGISTICS(0, "物流中"), + PARTIAL_RECEIPT_OF_GOODS(1, "部分收货"), + COMPLETE_RECEIPT_OF_GOODS(2, "完全收货"), + + ALREADY_SHIPPED(3, "已发货"), + NOT_SHIPPED_YET(4, "未发货"); + + @EnumValue + private Integer code; + + private String desc; + + OrderStatus(Integer code, String desc) { + + this.code = code; + this.desc = desc; + } + + @Override + public Integer getCode() { + + return this.code; + } + + @Override + public String getDesc() { + + return this.desc; + } +}