master:生产需求单功能完善;

pull/1121/head
liujiang 2025-07-06 23:43:26 +08:00
parent c18b6a1879
commit 7416c6f50b
25 changed files with 346 additions and 103 deletions

View File

@ -32,6 +32,13 @@ public class ShoppingCartController extends XktBaseController {
final IShoppingCartService shopCartService;
@PreAuthorize("@ss.hasRole('seller')")
@ApiOperation(value = "获取用户进货车各状态数量", httpMethod = "GET", response = R.class)
@GetMapping("/status/num")
public R<ShopCartStatusCountResVO> getStatusNum() {
return R.ok(BeanUtil.toBean(shopCartService.getStatusNum(), ShopCartStatusCountResVO.class));
}
@PreAuthorize("@ss.hasRole('seller')")
@ApiOperation(value = "电商卖家添加商品到进货车", httpMethod = "POST", response = R.class)
@Log(title = "电商卖家添加商品到进货车", businessType = BusinessType.INSERT)

View File

@ -6,6 +6,8 @@ import com.ruoyi.common.core.controller.XktBaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.Page;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.xkt.vo.storeProductDemand.*;
import com.ruoyi.xkt.dto.storeProductDemand.*;
import com.ruoyi.xkt.service.IStoreProductDemandService;
@ -16,6 +18,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
/**
@ -69,11 +74,6 @@ public class StoreProductDemandController extends XktBaseController {
@PutMapping
public R<Integer> updateWorkingStatus(@Validated @RequestBody StoreProdDemandWorkingVO workingVO) {
return R.ok(storeProdDemandService.updateWorkingStatus(BeanUtil.toBean(workingVO, StoreProdDemandWorkingDTO.class)));
// TODO 是否需要导出excel表格
// TODO 是否需要导出excel表格
// TODO 是否需要导出excel表格
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
@ -84,4 +84,18 @@ public class StoreProductDemandController extends XktBaseController {
return R.ok(storeProdDemandService.deleteByStoreProdDemandIds(BeanUtil.toBean(deleteVO, StoreProdDemandDeleteDTO.class)));
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
@ApiOperation(value = "导出生产需求", httpMethod = "POST", response = R.class)
@Log(title = "导出生产需求", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, @Validated @RequestBody StoreProdDemandExportVO exportVO) throws UnsupportedEncodingException {
List<StoreProdDemandDownloadDTO> downloadList = storeProdDemandService.export(BeanUtil.toBean(exportVO, StoreProdDemandExportDTO.class));
ExcelUtil<StoreProdDemandDownloadDTO> util = new ExcelUtil<>(StoreProdDemandDownloadDTO.class);
// 设置下载excel名
String encodedFileName = URLEncoder.encode("生产需求" + DateUtils.getDate(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename=" + encodedFileName + ".xlsx");
util.exportExcel(response, downloadList, "生产需求记录");
}
}

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@ -39,6 +40,7 @@ public class StoreCertVO {
@NotBlank(message = "身份证号不能为空")
@Pattern(regexp = "(^\\d{15}$)|(^\\d{17}([0-9]|X|x)$)", message = "身份证号格式不正确请输入有效的15位或18位身份证号")
private String idCard;
@Valid
@ApiModelProperty(value = "认证文件列表", required = true)
@NotNull(message = "认证文件列表不能为空")
private List<StoreFileVO> fileList;

View File

@ -0,0 +1,26 @@
package com.ruoyi.web.controller.xkt.vo.storeProductDemand;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreProdDemandExportVO {
@ApiModelProperty(value = "档口ID", required = true)
@NotNull(message = "档口ID不能为空")
private Long storeId;
@NotNull(message = "档口需求明细ID不能为空")
@ApiModelProperty(value = "档口需求明细ID", required = true)
private List<Long> storeProdDemandDetailIdList;
}

View File

@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
@ -24,6 +25,7 @@ public class StoreProdDemandVO {
@ApiModelProperty(value = "档口工厂ID", required = true)
private Long storeFactoryId;
@NotNull(message = "需求列表不能为空")
@Valid
@ApiModelProperty(value = "新增需求列表", required = true)
private List<DetailVO> detailList;
@ -41,10 +43,11 @@ public class StoreProdDemandVO {
@NotBlank(message = "颜色不能为空")
@ApiModelProperty(value = "颜色", required = true)
private String colorName;
@NotBlank(message = "是否紧急单不能为空")
@ApiModelProperty(value = "是否紧急单:2=正常,1=紧急", required = true)
@NotNull(message = "是否紧急单不能为空")
@ApiModelProperty(value = "是否紧急单:0=正常,1=紧急", required = true)
private Integer emergency;
@ApiModelProperty(value = "总的数量")
@ApiModelProperty(value = "总的数量", required = true)
@NotNull(message = "总数量不能为空")
private Integer quantity;
@ApiModelProperty(value = "尺码30")
private Integer size30;

View File

@ -17,11 +17,11 @@ public class StoreProdDemandWorkingVO {
@ApiModelProperty(value = "档口ID", required = true)
@NotNull(message = "档口ID不能为空")
private Long storeId;
@NotNull(message = "档口需求明细ID不能为空")
@ApiModelProperty(value = "档口需求明细ID", required = true)
@NotNull(message = "档口需求明细ID列表不能为空")
@ApiModelProperty(value = "档口需求明细ID列表", required = true)
private List<Long> storeProdDemandDetailIdList;
@NotNull(message = "是否导出生产单不能为空")
@ApiModelProperty(value = "是否导出生产单", required = true)
private Boolean download;
@NotNull(message = "档口需求ID列表不能为空")
@ApiModelProperty(value = "档口需求ID列表", required = true)
private List<Long> storeProdDemandIdList;
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.web.controller.xkt.vo.userShoppingCart;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ShopCartStatusCountResVO {
@ApiModelProperty(value = "在售数量")
private Integer onSaleNum;
@ApiModelProperty(value = "已失效数量")
private Integer expiredNum;
}

View File

@ -516,6 +516,36 @@ create table gen_table_column (
) engine=innodb auto_increment=1 comment = '代码生成业务表字段';
DROP TABLE IF EXISTS `voucher_sequence`;
CREATE TABLE `voucher_sequence` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '单据编号ID',
`store_id` bigint UNSIGNED NOT NULL COMMENT '档口ID',
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '单据类型',
`date_format` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '单据格式化类型',
`next_sequence` int NOT NULL COMMENT '下一个单据编号',
`prefix` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '单据编号前缀',
`sequence_format` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '格式化类型',
`version` bigint UNSIGNED NOT NULL COMMENT '版本号',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '删除标志0代表存在 2代表删除',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统code生成规则' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of voucher_sequence
-- ----------------------------
INSERT INTO `voucher_sequence` VALUES (1, 1, 'STORE_SALE', 'yyyy-MM-dd', 1, 'SD', '%04d', 0, '0', '', '2025-03-30 16:09:23', '', '2025-03-30 16:09:26');
INSERT INTO `voucher_sequence` VALUES (2, 1, 'STORAGE', 'yyyy-MM-dd', 1, 'RK', '%04d', 0, '0', '', '2025-03-30 16:09:23', '', '2025-03-30 16:09:26');
INSERT INTO `voucher_sequence` VALUES (3, 1, 'DEMAND', 'yyyy-MM-dd', 1, 'XQ', '%04d', 0, '0', '', '2025-03-30 16:09:23', '', '2025-03-30 16:09:26');
INSERT INTO `voucher_sequence` VALUES (4, 1, 'STORE_ORDER', 'yyyy-MM-dd', 1, 'DF', '%04d', 0, '0', '', '2025-03-30 16:09:23', '', '2025-05-15 01:54:15');
SET FOREIGN_KEY_CHECKS = 1;
DROP TABLE IF EXISTS `sys_product_category`;
CREATE TABLE `sys_product_category` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '商品分类ID',

View File

@ -9,6 +9,8 @@ import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* store_product_demand
*
@ -48,13 +50,11 @@ public class StoreProductDemand extends XktBaseEntity {
*/
@Excel(name = "需求状态")
private Integer demandStatus;
/**
*
*/
private String remark;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

View File

@ -62,9 +62,9 @@ public class StoreProductDemandDetail extends XktBaseEntity {
private Long storeProdId;
/**
* 2 1
* 0 1
*/
@Excel(name = "是否紧急单", readConverterExp = "2=正常,1=紧急")
@Excel(name = "是否紧急单", readConverterExp = "0=正常,1=紧急")
private Integer emergency;
/**

View File

@ -0,0 +1,55 @@
package com.ruoyi.xkt.dto.storeProductDemand;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreProdDemandDownloadDTO {
@Excel(name = "序号", cellType = Excel.ColumnType.NUMERIC, needMerge = true)
private Integer orderNum;
@Excel(name = "货号", needMerge = true)
private String prodArtNum;
@Excel(name = "颜色", needMerge = true)
private String colorName;
@Excel(name = "30")
private Integer size30Quantity;
@Excel(name = "31")
private Integer size31Quantity;
@Excel(name = "32")
private Integer size32Quantity;
@Excel(name = "33")
private Integer size33Quantity;
@Excel(name = "34")
private Integer size34Quantity;
@Excel(name = "35")
private Integer size35Quantity;
@Excel(name = "36")
private Integer size36Quantity;
@Excel(name = "37")
private Integer size37Quantity;
@Excel(name = "38")
private Integer size38Quantity;
@Excel(name = "39")
private Integer size39Quantity;
@Excel(name = "40")
private Integer size40Quantity;
@Excel(name = "41")
private Integer size41Quantity;
@Excel(name = "42")
private Integer size42Quantity;
@Excel(name = "43")
private Integer size43Quantity;
@Excel(name = "合计")
private Integer totalQuantity;
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.xkt.dto.storeProductDemand;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreProdDemandExportDTO {
@ApiModelProperty(value = "档口ID")
private Long storeId;
@ApiModelProperty(value = "档口需求明细ID")
private List<Long> storeProdDemandDetailIdList;
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.xkt.dto.storeProductDemand;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
@ -17,6 +18,8 @@ public class StoreProdDemandWorkingDTO {
private Long storeId;
@ApiModelProperty(value = "档口需求明细ID")
private List<Long> storeProdDemandDetailIdList;
@ApiModelProperty(value = "档口需求ID列表")
private List<Long> storeProdDemandIdList;
@ApiModelProperty(value = "是否导出生产单")
private Boolean download;

View File

@ -0,0 +1,21 @@
package com.ruoyi.xkt.dto.userShoppingCart;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ShopCartStatusCountResDTO {
@ApiModelProperty(value = "在售数量")
private Integer onSaleNum;
@ApiModelProperty(value = "已失效数量")
private Integer expiredNum;
}

View File

@ -12,7 +12,7 @@ import lombok.Getter;
public enum EmergencyType {
PROD_STORAGE(1, "紧急单"),
OTHER_STORAGE(2, "正常单");
OTHER_STORAGE(0, "正常单");
private final Integer value;
private final String label;

View File

@ -5,6 +5,7 @@ import com.ruoyi.xkt.domain.ShoppingCart;
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageDTO;
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageDetailResDTO;
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageResDTO;
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartStatusCountResDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -19,6 +20,7 @@ public interface ShoppingCartMapper extends BaseMapper<ShoppingCart> {
/**
*
*
* @param pageDTO
* @return List<ShopCartPageResDTO>
*/
@ -27,9 +29,18 @@ public interface ShoppingCartMapper extends BaseMapper<ShoppingCart> {
/**
* ID
*
* @param shoppingCartIdList ID
* @return
*/
List<ShopCartPageDetailResDTO> selectDetailList(@Param("shoppingCartIdList") List<Long> shoppingCartIdList);
/**
*
*
* @param userId ID
* @return ShopCartStatusCountResDTO
*/
ShopCartStatusCountResDTO getStatusNum(@Param("userId") Long userId);
}

View File

@ -13,53 +13,6 @@ import java.util.List;
* @date 2025-03-26
*/
public interface StoreProductDemandMapper extends BaseMapper<StoreProductDemand> {
/**
*
*
* @param id
* @return
*/
public StoreProductDemand selectStoreProductDemandByStoreProdDemandId(Long id);
/**
*
*
* @param storeProductDemand
* @return
*/
public List<StoreProductDemand> selectStoreProductDemandList(StoreProductDemand storeProductDemand);
/**
*
*
* @param storeProductDemand
* @return
*/
public int insertStoreProductDemand(StoreProductDemand storeProductDemand);
/**
*
*
* @param storeProductDemand
* @return
*/
public int updateStoreProductDemand(StoreProductDemand storeProductDemand);
/**
*
*
* @param id
* @return
*/
public int deleteStoreProductDemandByStoreProdDemandId(Long id);
/**
*
*
* @param storeProdDemandIds
* @return
*/
public int deleteStoreProductDemandByStoreProdDemandIds(Long[] storeProdDemandIds);
/**
*
@ -68,10 +21,9 @@ public interface StoreProductDemandMapper extends BaseMapper<StoreProductDemand>
*/
void updateStatusByIds(@Param("demandIdList") List<Long> demandIdList);
/**
*
*
* <p>
* ID
* IDID
*

View File

@ -61,4 +61,11 @@ public interface IShoppingCartService {
*/
List<ShoppingCartDTO> getList(ShopCartListDTO listDTO);
/**
*
*
* @return ShopCartStatusCountResDTO
*/
ShopCartStatusCountResDTO getStatusNum();
}

View File

@ -19,7 +19,7 @@ public interface IStoreProductDemandService {
* @param deleteDTO
* @return
*/
public int deleteByStoreProdDemandIds(StoreProdDemandDeleteDTO deleteDTO);
int deleteByStoreProdDemandIds(StoreProdDemandDeleteDTO deleteDTO);
/**
*
@ -68,5 +68,12 @@ public interface IStoreProductDemandService {
* @return DTO
*/
StoreProdDemandVerifyResDTO verifyDemandExist(StoreProdDemandVerifyDTO demandVerifyDTO);
/**
*
*
* @param exportDTO
* @return List<StoreProdDemandDownloadDTO>
*/
List<StoreProdDemandDownloadDTO> export(StoreProdDemandExportDTO exportDTO);
}

View File

@ -13,6 +13,7 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.xkt.domain.*;
import com.ruoyi.xkt.dto.storeProductFile.StoreProdMainPicDTO;
import com.ruoyi.xkt.dto.userShoppingCart.*;
import com.ruoyi.xkt.enums.EProductStatus;
import com.ruoyi.xkt.enums.FileType;
import com.ruoyi.xkt.enums.ProductSizeStatus;
import com.ruoyi.xkt.mapper.*;
@ -304,6 +305,17 @@ public class ShoppingCartServiceImpl implements IShoppingCartService {
}).collect(Collectors.toList());
}
/**
*
*
* @return ShopCartStatusCountResDTO
*/
@Override
@Transactional(readOnly = true)
public ShopCartStatusCountResDTO getStatusNum() {
return this.shopCartMapper.getStatusNum(SecurityUtils.getUserId());
}
/**
*
*

View File

@ -75,7 +75,8 @@ public class StoreProductDemandServiceImpl implements IStoreProductDemandService
List<Long> storeProdColorIdList = prodColorList.stream().map(StoreProductColor::getId).collect(Collectors.toList());
// 根据各个颜色查询库存信息
List<StoreProductStock> prodStockList = this.storeProdStockMapper.selectList(new LambdaQueryWrapper<StoreProductStock>()
.in(StoreProductStock::getStoreProdColorId, storeProdColorIdList).eq(StoreProductStock::getDelFlag, Constants.UNDELETED).eq(StoreProductStock::getStoreId, storeId));
.in(StoreProductStock::getStoreProdColorId, storeProdColorIdList).eq(StoreProductStock::getDelFlag, Constants.UNDELETED)
.eq(StoreProductStock::getStoreId, storeId));
// 将库存信息封装成Map
Map<Long, StoreProdStockDTO> stockMap = prodStockList.stream().collect(Collectors
.toMap(StoreProductStock::getStoreProdColorId, x -> BeanUtil.toBean(x, StoreProdStockDTO.class)));
@ -144,32 +145,21 @@ public class StoreProductDemandServiceImpl implements IStoreProductDemandService
StoreProductDemand demand = new StoreProductDemand();
// 生成code
demand.setCode(this.sequenceService.generateCode(demandDTO.getStoreId(), EVoucherSequenceType.DEMAND.getValue(), DateUtils.parseDateToStr(DateUtils.YYYYMMDD, new Date())))
.setDemandStatus(1).setStoreId(demandDTO.getStoreId()).setStoreFactoryId(demandDTO.getStoreFactoryId());
.setDemandStatus(1).setStoreId(demandDTO.getStoreId()).setStoreFactoryId(demandDTO.getStoreFactoryId()).setCreateBy(SecurityUtils.getUsername());
int count = this.storeProdDemandMapper.insert(demand);
// 生产需求详情
List<StoreProductDemandDetail> detailList = demandDTO.getDetailList().stream()
.map(x -> BeanUtil.toBean(x, StoreProductDemandDetail.class).setStoreId(demandDTO.getStoreId())
.setStoreProdDemandId(demand.getId()).setDetailStatus(1)).collect(Collectors.toList());
List<StoreProductDemandDetail> detailList = demandDTO.getDetailList().stream().map(x -> {
StoreProductDemandDetail detail = BeanUtil.toBean(x, StoreProductDemandDetail.class).setStoreId(demandDTO.getStoreId())
.setStoreProdDemandId(demand.getId()).setDetailStatus(1);
detail.setCreateBy(SecurityUtils.getUsername());
return detail;
}).collect(Collectors.toList());
this.storeProdDemandDetailMapper.insert(detailList);
return count;
}
/**
*
*
* 便
*
* @param pageDTO DTO
* @return
*/
@Override
@Transactional(readOnly = true)
/**
*
*
* @param pageDTO
* @return
*/
public Page<StoreProdDemandPageResDTO> selectPage(StoreProdDemandPageDTO pageDTO) {
// 用户是否为档口管理者或子账户
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(pageDTO.getStoreId())) {
@ -202,8 +192,6 @@ public class StoreProductDemandServiceImpl implements IStoreProductDemandService
/**
*
* DTO
*
*
* @param workingDTO
* @return
@ -217,10 +205,22 @@ public class StoreProductDemandServiceImpl implements IStoreProductDemandService
}
List<StoreProductDemandDetail> demandDetailList = Optional.ofNullable(this.storeProdDemandDetailMapper.selectList(new LambdaQueryWrapper<StoreProductDemandDetail>()
.eq(StoreProductDemandDetail::getStoreId, workingDTO.getStoreId()).eq(StoreProductDemandDetail::getDelFlag, Constants.UNDELETED)
.in(StoreProductDemandDetail::getId, workingDTO.getStoreProdDemandDetailIdList())))
.in(StoreProductDemandDetail::getStoreProdDemandId, workingDTO.getStoreProdDemandIdList())))
.orElseThrow(() -> new ServiceException("需求单明细不存在!", HttpStatus.ERROR));
demandDetailList.forEach(x -> x.setDetailStatus(DemandStatus.IN_PRODUCTION.getValue()));
// 更新需求明细单的状态为 生产中
demandDetailList.stream().filter(x -> workingDTO.getStoreProdDemandDetailIdList().contains(x.getId()))
.forEach(x -> x.setDetailStatus(DemandStatus.IN_PRODUCTION.getValue()));
List<BatchResult> list = this.storeProdDemandDetailMapper.updateById(demandDetailList);
Map<Long, List<StoreProductDemandDetail>> detailMap = demandDetailList.stream().collect(Collectors.groupingBy(StoreProductDemandDetail::getStoreProdDemandId));
// 所有的需求单
List<StoreProductDemand> demandList = this.storeProdDemandMapper.selectByIds(workingDTO.getStoreProdDemandIdList());
demandList.forEach(demand -> {
List<StoreProductDemandDetail> detailList = detailMap.get(demand.getId());
if (CollectionUtils.isNotEmpty(detailList) && detailList.stream().allMatch(x -> Objects.equals(x.getDetailStatus(), DemandStatus.IN_PRODUCTION.getValue()))) {
demand.setDemandStatus(DemandStatus.IN_PRODUCTION.getValue());
}
});
this.storeProdDemandMapper.updateById(demandList);
return list.size();
}
@ -368,6 +368,31 @@ public class StoreProductDemandServiceImpl implements IStoreProductDemandService
}};
}
/**
*
*
* @param exportDTO
* @return List<StoreProdDemandDownloadDTO>
*/
@Override
@Transactional(readOnly = true)
public List<StoreProdDemandDownloadDTO> export(StoreProdDemandExportDTO exportDTO) {
List<StoreProductDemandDetail> demandDetailList = this.storeProdDemandDetailMapper.selectList(new LambdaQueryWrapper<StoreProductDemandDetail>()
.eq(StoreProductDemandDetail::getStoreId, exportDTO.getStoreId()).eq(StoreProductDemandDetail::getDelFlag, Constants.UNDELETED)
.in(StoreProductDemandDetail::getId, exportDTO.getStoreProdDemandDetailIdList()));
List<StoreProdDemandDownloadDTO> downLoadList = demandDetailList.stream().sorted(Comparator.comparing(StoreProductDemandDetail::getProdArtNum))
.map(x -> new StoreProdDemandDownloadDTO()
.setProdArtNum(x.getProdArtNum()).setColorName(x.getColorName()).setSize30Quantity(x.getSize30()).setSize31Quantity(x.getSize31())
.setSize32Quantity(x.getSize32()).setSize33Quantity(x.getSize33()).setSize34Quantity(x.getSize34()).setSize35Quantity(x.getSize35())
.setSize36Quantity(x.getSize36()).setSize37Quantity(x.getSize37()).setSize38Quantity(x.getSize38()).setSize39Quantity(x.getSize39())
.setSize40Quantity(x.getSize40()).setSize41Quantity(x.getSize41()).setSize42Quantity(x.getSize42()).setSize43Quantity(x.getSize43()))
.collect(Collectors.toList());
for (int i = 0; i < downLoadList.size(); i++) {
downLoadList.get(i).setOrderNum(i + 1);
}
return downLoadList;
}
/**
*
*
@ -381,10 +406,12 @@ public class StoreProductDemandServiceImpl implements IStoreProductDemandService
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(deleteDTO.getStoreId())) {
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
}
List<StoreProductDemandDetail> demandDetailList = Optional.ofNullable(this.storeProdDemandDetailMapper.selectList(new LambdaQueryWrapper<StoreProductDemandDetail>()
.eq(StoreProductDemandDetail::getStoreId, deleteDTO.getStoreId()).eq(StoreProductDemandDetail::getDelFlag, Constants.UNDELETED)
.in(StoreProductDemandDetail::getId, deleteDTO.getStoreProdDemandDetailIdList())))
.orElseThrow(() -> new ServiceException("需求单明细不存在!", HttpStatus.ERROR));
List<StoreProductDemandDetail> demandDetailList = this.storeProdDemandDetailMapper.selectList(new LambdaQueryWrapper<StoreProductDemandDetail>()
.eq(StoreProductDemandDetail::getStoreId, deleteDTO.getStoreId()).eq(StoreProductDemandDetail::getDelFlag, Constants.UNDELETED)
.in(StoreProductDemandDetail::getId, deleteDTO.getStoreProdDemandDetailIdList()));
if (CollectionUtils.isEmpty(demandDetailList)) {
throw new ServiceException("需求单明细不存在!", HttpStatus.ERROR);
}
// 根据需求明细ID能否找到对应的入库与需求抵扣关系数据
List<StoreProductStorageDemandDeduct> deductList = this.storageDemandDeductMapper.selectList(new LambdaQueryWrapper<StoreProductStorageDemandDeduct>()
.in(StoreProductStorageDemandDeduct::getStoreProdDemandDetailId, deleteDTO.getStoreProdDemandDetailIdList())

View File

@ -948,11 +948,18 @@ public class StoreProductServiceImpl implements IStoreProductService {
* @throws IOException
*/
private void deleteESDoc(List<Long> storeProdIdList) throws IOException {
List<BulkOperation> list = storeProdIdList.stream().map(x -> new BulkOperation.Builder().delete(
d -> d.id(String.valueOf(x)).index(Constants.ES_IDX_PRODUCT_INFO)).build()).collect(Collectors.toList());
// 调用bulk方法执行批量插入操作
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(Constants.ES_IDX_PRODUCT_INFO).operations(list));
System.out.println("bulkResponse.items() = " + bulkResponse.items());
try {
// 删除ES索引文档
List<BulkOperation> list = storeProdIdList.stream().map(x -> new BulkOperation.Builder().delete(
d -> d.id(String.valueOf(x)).index(Constants.ES_IDX_PRODUCT_INFO)).build()).collect(Collectors.toList());
// 调用bulk方法执行批量插入操作
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(Constants.ES_IDX_PRODUCT_INFO).operations(list));
log.info("bulkResponse.items() = {}", bulkResponse.items());
} catch (IOException | RuntimeException e) {
// 记录日志并抛出或处理异常
log.error("删除ES文档失败商品ID: {}, 错误信息: {}", storeProdIdList, e.getMessage(), e);
throw e; // 或者做其他补偿处理,比如异步重试
}
}
/**

View File

@ -66,5 +66,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sc.id DESC
</select>
<select id="getStatusNum">
SELECT
sc.id,
IFNULL( SUM( CASE WHEN sp.prod_status IN ( 2, 3 ) THEN 1 ELSE 0 END ), 0 ) AS onSaleNum,
IFNULL( SUM( CASE WHEN sp.prod_status IN ( 4, 5 ) THEN 1 ELSE 0 END ), 0 ) AS expiredNum
FROM
shopping_cart sc
LEFT JOIN store_product sp ON sc.store_prod_id = sp.id
WHERE
sc.del_flag = 0
AND sp.prod_status IN ( 2, 3, 4, 5 )
AND sc.user_id = #{userId}
GROUP BY
sc.id
</select>
</mapper>

View File

@ -36,9 +36,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spc.create_time AS createTime,
sf.file_url AS mainPicUrl,
CONCAT(
( SELECT MIN( size ) FROM store_product_color_size WHERE store_color_id = spc.id AND del_flag = 0 AND standard = 1 ),
( SELECT MIN( size ) FROM store_product_color_size WHERE store_color_id = spc.store_color_id AND store_prod_id = spc.store_prod_id AND del_flag = 0 AND standard = 1 ),
'-',
( SELECT MAX( size ) FROM store_product_color_size WHERE store_color_id = spc.id AND del_flag = 0 AND standard = 1 )
( SELECT MAX( size ) FROM store_product_color_size WHERE store_color_id = spc.store_color_id AND store_prod_id = spc.store_prod_id AND del_flag = 0 AND standard = 1 )
) AS standard
FROM
store_product_color spc

View File

@ -281,7 +281,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sp.id AS storeProdId,
sp.store_id,
s.store_name,
sp.prod_name,
sp.prod_art_num,
sp.prod_title,
sp.create_time,