gaoluyang
3 小时以前 7a923e32e55e9c34830690341469cc170f65092e
feat: 完善销售和投标业务流程
已添加11个文件
已修改19个文件
545 ■■■■■ 文件已修改
sql/mysql/20261112_crm_bid_management_menu.sql 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/mysql/20261112_crm_bid_progress.sql 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/mysql/20261113_mes_process_import_menu.sql 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/mysql/20261113_qc_iqc_vendor_batch_code_rule.sql 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/mysql/20261113_sales_menu_order.sql 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/mysql/20261114_sales_notice_delivery_metrics.sql 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bidbond/CrmBidBondController.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bidbond/vo/CrmBidProgressReqVO.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/bidbond/CrmBidProgressDO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/bidbond/CrmBidBondMapper.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/bidbond/CrmBidProgressMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/bidbond/CrmBidBondService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/bidbond/CrmBidBondServiceImpl.java 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/bidbond/CrmBidBondQuotationBindingTest.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/MesProProcessController.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/MesProProcessImportExcelVO.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/MesProProcessImportRespVO.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/MesWmReturnSalesController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/MesWmSalesNoticeController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticeLedgerRespVO.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticeRespVO.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticeSaveReqVO.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/salesnotice/MesWmSalesNoticeDO.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/mps/MesProMpsServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessService.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/salesnotice/MesWmSalesNoticeServiceImpl.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
yudao-module-mes/src/main/resources/templates/wm/sales-delivery.docx 补丁 | 查看 | 原始文档 | blame | 历史
sql/mysql/20261112_crm_bid_management_menu.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,3 @@
-- é”€å”®ä¾§æŠ•标页面统一显示为投标管理,保留原菜单 ID、路由和权限。
UPDATE system_menu SET name = '投标管理' WHERE id = 602630;
UPDATE system_menu SET name = REPLACE(name, '投标保证金', '投标管理') WHERE id IN (602631, 602632, 602633, 602634);
sql/mysql/20261112_crm_bid_progress.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
-- æŠ•标结果由专门动作登记,保留每次开标及重新投标的流水。
CREATE TABLE IF NOT EXISTS `crm_bid_progress` (
  `id` BIGINT NOT NULL AUTO_INCREMENT,
  `bid_bond_id` BIGINT NOT NULL,
  `action` VARCHAR(20) NOT NULL COMMENT 'CREATED/FOLLOW_UP/WON/LOST/REBID',
  `from_result` TINYINT DEFAULT NULL,
  `to_result` TINYINT NOT NULL,
  `quotation_round` INT DEFAULT NULL,
  `remark` VARCHAR(500) DEFAULT NULL,
  `creator` VARCHAR(64) DEFAULT '',
  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updater` VARCHAR(64) DEFAULT '',
  `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `deleted` BIT(1) NOT NULL DEFAULT b'0',
  PRIMARY KEY (`id`),
  KEY `idx_bid_bond_id` (`bid_bond_id`, `id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='投标过程流水';
-- æ—§å•据只补一条导入快照,不伪造历史跟进动作。
INSERT INTO `crm_bid_progress` (`bid_bond_id`, `action`, `from_result`, `to_result`, `quotation_round`, `remark`, `creator`, `create_time`)
SELECT b.`id`, 'IMPORTED', NULL, b.`bid_result`, b.`quotation_round`, '历史单据导入时的状态快照', b.`creator`, b.`create_time`
FROM `crm_bid_bond` b
WHERE b.`deleted` = b'0' AND NOT EXISTS (SELECT 1 FROM `crm_bid_progress` p WHERE p.`bid_bond_id` = b.`id`);
sql/mysql/20261113_mes_process_import_menu.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
-- å·¥åºè®¾ç½®æ–°å¢ž Excel å¯¼å…¥æƒé™ï¼Œæ²¿ç”¨çŽ°æœ‰å·¥åºèœå•ã€‚
INSERT INTO system_menu (id, name, permission, type, sort, parent_id, path, icon,
                         component, component_name, status, visible, keep_alive, always_show,
                         creator, create_time, updater, update_time, deleted)
VALUES (5716, '工序导入', 'mes:pro-process:import', 3, 6, 5710, '', '',
        '', '', 0, b'1', b'1', b'1', '1', NOW(), '1', NOW(), b'0')
ON DUPLICATE KEY UPDATE name = VALUES(name), permission = VALUES(permission),
                        parent_id = VALUES(parent_id), deleted = b'0';
sql/mysql/20261113_qc_iqc_vendor_batch_code_rule.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
-- è¡¥é½æ¥æ–™æ£€éªŒä¾›åº”商批次号的编码规则。
INSERT INTO mes_md_auto_code_rule
    (code, name, description, max_length, padded, status, creator, create_time, updater, update_time, deleted)
SELECT 'QC_IQC_VENDOR_BATCH_CODE', '来料检验供应商批次号', '来料检验供应商批次号自动编码',
       14, b'0', 0, '1', NOW(), '1', NOW(), b'0'
WHERE NOT EXISTS (
    SELECT 1 FROM mes_md_auto_code_rule WHERE code = 'QC_IQC_VENDOR_BATCH_CODE' AND deleted = 0
);
SET @vendor_batch_rule_id = (
    SELECT id FROM mes_md_auto_code_rule
    WHERE code = 'QC_IQC_VENDOR_BATCH_CODE' AND deleted = 0 LIMIT 1
);
INSERT INTO mes_md_auto_code_part
    (rule_id, sort, type, length, fix_character, serial_start_no, serial_step,
     cycle_flag, cycle_method, creator, create_time, updater, update_time, deleted)
SELECT @vendor_batch_rule_id, 1, 3, 3, 'VB_', NULL, NULL, NULL, NULL,
       '1', NOW(), '1', NOW(), b'0'
WHERE NOT EXISTS (SELECT 1 FROM mes_md_auto_code_part WHERE rule_id = @vendor_batch_rule_id AND sort = 1 AND deleted = 0);
INSERT INTO mes_md_auto_code_part
    (rule_id, sort, type, length, date_format, serial_start_no, serial_step,
     cycle_flag, cycle_method, creator, create_time, updater, update_time, deleted)
SELECT @vendor_batch_rule_id, 2, 2, 8, 'yyyyMMdd', NULL, NULL, NULL, NULL,
       '1', NOW(), '1', NOW(), b'0'
WHERE NOT EXISTS (SELECT 1 FROM mes_md_auto_code_part WHERE rule_id = @vendor_batch_rule_id AND sort = 2 AND deleted = 0);
INSERT INTO mes_md_auto_code_part
    (rule_id, sort, type, length, serial_start_no, serial_step,
     cycle_flag, cycle_method, creator, create_time, updater, update_time, deleted)
SELECT @vendor_batch_rule_id, 3, 4, 3, 1, 1, b'1', 3,
       '1', NOW(), '1', NOW(), b'0'
WHERE NOT EXISTS (SELECT 1 FROM mes_md_auto_code_part WHERE rule_id = @vendor_batch_rule_id AND sort = 3 AND deleted = 0);
sql/mysql/20261113_sales_menu_order.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
-- è¥é”€ç®¡ç†èœå•按业务流程排序;保留原菜单 ID、组件和权限。
UPDATE system_menu SET sort = CASE id
  WHEN 2701 THEN 10 WHEN 1075495 THEN 20 WHEN 1075496 THEN 30
  WHEN 1075497 THEN 40 WHEN 1075498 THEN 50 WHEN 2524 THEN 90
  WHEN 2404 THEN 10 WHEN 2546 THEN 20 WHEN 2391 THEN 30
  WHEN 2416 THEN 40 WHEN 2618 THEN 50
  WHEN 2410 THEN 10 WHEN 602512 THEN 20 WHEN 602630 THEN 30
  WHEN 2398 THEN 40 WHEN 2638 THEN 50
  WHEN 2428 THEN 10 WHEN 2422 THEN 20 WHEN 1063093 THEN 30
  WHEN 1075660 THEN 40
  WHEN 1065000 THEN 10 WHEN 1065100 THEN 20 WHEN 2560 THEN 30
  ELSE sort END,
  parent_id = CASE WHEN id = 602630 THEN 1075496 ELSE parent_id END
WHERE id IN (2701,1075495,1075496,1075497,1075498,2524,
  2404,2546,2391,2416,2618,2410,602512,602630,2398,2638,
  2428,2422,1063093,1075660,1065000,1065100,2560);
sql/mysql/20261114_sales_notice_delivery_metrics.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,4 @@
-- å‘货体积和重量仅用于物流记录,不参与财务计算。
ALTER TABLE mes_wm_sales_notice
    ADD COLUMN delivery_volume DECIMAL(18,3) NULL COMMENT '发货体积(立方米)' AFTER logistics_company,
    ADD COLUMN delivery_weight DECIMAL(18,3) NULL COMMENT '发货重量(千克)' AFTER delivery_volume;
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bidbond/CrmBidBondController.java
@@ -9,6 +9,8 @@
import cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo.CrmBidBondRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo.CrmBidBondSaleOrderRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo.CrmBidBondSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo.CrmBidProgressReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.bidbond.CrmBidProgressDO;
import cn.iocoder.yudao.module.crm.service.bidbond.CrmBidBondService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -50,6 +52,21 @@
        return success(true);
    }
    @PostMapping("/progress")
    @Operation(summary = "登记投标过程")
    @PreAuthorize("@ss.hasPermission('crm:bid-bond:update')")
    public CommonResult<Boolean> recordProgress(@Valid @RequestBody CrmBidProgressReqVO reqVO) {
        bidBondService.recordProgress(reqVO.getId(), reqVO.getAction(), reqVO.getRemark());
        return success(true);
    }
    @GetMapping("/progress-list")
    @Operation(summary = "投标过程流水")
    @PreAuthorize("@ss.hasPermission('crm:bid-bond:query')")
    public CommonResult<List<CrmBidProgressDO>> getProgressList(@RequestParam("id") Long id) {
        return success(bidBondService.getProgressList(id));
    }
    @DeleteMapping("/delete")
    @Operation(summary = "删除投标保证金记录")
    @Parameter(name = "id", description = "编号", required = true)
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bidbond/vo/CrmBidProgressReqVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class CrmBidProgressReqVO {
    @NotNull(message = "投标编号不能为空")
    private Long id;
    @NotBlank(message = "过程动作不能为空")
    private String action;
    private String remark;
}
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/bidbond/CrmBidProgressDO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.bidbond;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@TableName("crm_bid_progress")
@Data
@EqualsAndHashCode(callSuper = true)
public class CrmBidProgressDO extends BaseDO {
    @TableId
    private Long id;
    private Long bidBondId;
    private String action;
    private Integer fromResult;
    private Integer toResult;
    private Integer quotationRound;
    private String remark;
}
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/bidbond/CrmBidBondMapper.java
@@ -7,6 +7,7 @@
import cn.iocoder.yudao.module.crm.dal.dataobject.bidbond.CrmBidBondDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.Collection;
import java.util.List;
@@ -29,6 +30,9 @@
                .orderByDesc(CrmBidBondDO::getId));
    }
    @Select("SELECT * FROM crm_bid_bond WHERE id = #{id} AND deleted = 0 FOR UPDATE")
    CrmBidBondDO selectByIdForUpdate(Long id);
    default CrmBidBondDO selectByNo(String no) {
        return selectOne(CrmBidBondDO::getNo, no);
    }
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/bidbond/CrmBidProgressMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.crm.dal.mysql.bidbond;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.dal.dataobject.bidbond.CrmBidProgressDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface CrmBidProgressMapper extends BaseMapperX<CrmBidProgressDO> {
    default List<CrmBidProgressDO> selectByBidBondId(Long bidBondId) {
        return selectList(new LambdaQueryWrapperX<CrmBidProgressDO>()
                .eq(CrmBidProgressDO::getBidBondId, bidBondId)
                .orderByAsc(CrmBidProgressDO::getId));
    }
}
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/bidbond/CrmBidBondService.java
@@ -6,6 +6,7 @@
import cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo.CrmBidBondSaleOrderRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo.CrmBidBondSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.bidbond.CrmBidBondDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.bidbond.CrmBidProgressDO;
import jakarta.validation.Valid;
import java.util.List;
@@ -21,6 +22,10 @@
    void deleteBidBond(Long id);
    void recordProgress(Long id, String action, String remark);
    List<CrmBidProgressDO> getProgressList(Long id);
    CrmBidBondDO getBidBond(Long id);
    CrmBidBondRespVO getBidBondDetail(Long id);
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/bidbond/CrmBidBondServiceImpl.java
@@ -10,9 +10,11 @@
import cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo.CrmBidBondSaleOrderRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.bidbond.vo.CrmBidBondSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.bidbond.CrmBidBondDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.bidbond.CrmBidProgressDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationDO;
import cn.iocoder.yudao.module.crm.dal.mysql.bidbond.CrmBidBondMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.bidbond.CrmBidProgressMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.quotation.CrmSaleQuotationMapper;
import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.crm.enums.bidbond.CrmBidBondRefundStatusEnum;
@@ -51,6 +53,8 @@
    @Resource
    private CrmBidBondMapper bidBondMapper;
    @Resource
    private CrmBidProgressMapper bidProgressMapper;
    @Resource
    private CrmSaleQuotationMapper saleQuotationMapper;
    @Resource
    private CrmCustomerService customerService;
@@ -60,6 +64,9 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long createBidBond(CrmBidBondSaveReqVO createReqVO) {
        if (!CrmBidResultEnum.PENDING.getResult().equals(createReqVO.getBidResult())) {
            throw new ServiceException(400, "新投标必须先登记为待开标,请在过程跟进中登记结果");
        }
        CrmBidBondDO bond = validateAndBuild(createReqVO);
        bond.setId(null);
        bond.setNo(generateBondNo());
@@ -68,6 +75,7 @@
        if (bond.getQuotationId() != null) {
            saleQuotationMapper.bindBidBond(bond.getQuotationId(), bond.getId(), bond.getNo());
        }
        insertProgress(bond, "CREATED", null, CrmBidResultEnum.PENDING.getResult(), null);
        return bond.getId();
    }
@@ -75,6 +83,13 @@
    @Transactional(rollbackFor = Exception.class)
    public void updateBidBond(CrmBidBondSaveReqVO updateReqVO) {
        CrmBidBondDO oldBond = validateBidBondExists(updateReqVO.getId());
        if (!Objects.equals(oldBond.getBidResult(), updateReqVO.getBidResult())) {
            throw new ServiceException(400, "中标结果只能通过投标过程跟进登记");
        }
        if (CrmBidResultEnum.WON.getResult().equals(oldBond.getBidResult())
                && !Objects.equals(oldBond.getQuotationId(), updateReqVO.getQuotationId())) {
            throw new ServiceException(400, "已中标投标不能更换报价单");
        }
        CrmBidBondDO updateObj = validateAndBuild(updateReqVO);
        updateObj.setId(updateReqVO.getId());
        // å•号不允许修改,保持原值
@@ -93,6 +108,10 @@
    @Transactional(rollbackFor = Exception.class)
    public void deleteBidBond(Long id) {
        CrmBidBondDO bond = validateBidBondExists(id);
        if (!CrmBidResultEnum.PENDING.getResult().equals(bond.getBidResult())
                || bidProgressMapper.selectByBidBondId(id).size() > 1) {
            throw new ServiceException(400, "已有投标过程记录,不能删除");
        }
        if (CrmBidResultEnum.WON.getResult().equals(bond.getBidResult()) && bond.getQuotationId() != null) {
            throw ServiceExceptionUtil.exception(ErrorCodeConstants.BID_BOND_DELETE_FAIL_WON);
        }
@@ -101,6 +120,72 @@
            saleQuotationMapper.bindBidBond(bond.getQuotationId(), null, null);
        }
        bidBondMapper.deleteById(id);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void recordProgress(Long id, String action, String remark) {
        CrmBidBondDO bond = bidBondMapper.selectByIdForUpdate(id);
        if (bond == null) throw new ServiceException(400, "投标记录不存在");
        int from = bond.getBidResult();
        int target;
        switch (action) {
            case "FOLLOW_UP" -> {
                if (from == CrmBidResultEnum.WON.getResult()) throw new ServiceException(400, "已中标投标不能继续跟进开标过程");
                target = from;
            }
            case "WON" -> {
                if (from != CrmBidResultEnum.PENDING.getResult()) throw new ServiceException(400, "只有待开标投标可以登记中标");
                target = CrmBidResultEnum.WON.getResult();
            }
            case "LOST" -> {
                if (from != CrmBidResultEnum.PENDING.getResult()) throw new ServiceException(400, "只有待开标投标可以登记未中标");
                target = CrmBidResultEnum.LOST.getResult();
            }
            case "REBID" -> {
                if (from != CrmBidResultEnum.LOST.getResult()) throw new ServiceException(400, "只有未中标投标可以重新投标");
                CrmSaleQuotationDO quotation = saleQuotationMapper.selectById(bond.getQuotationId());
                List<CrmBidProgressDO> history = bidProgressMapper.selectByBidBondId(id);
                int lastRound = history.stream().filter(e -> "LOST".equals(e.getAction())
                                || ("IMPORTED".equals(e.getAction()) && Objects.equals(e.getToResult(), CrmBidResultEnum.LOST.getResult())))
                        .map(CrmBidProgressDO::getQuotationRound).filter(Objects::nonNull)
                        .max(Integer::compareTo).orElse(0);
                if (quotation == null || quotation.getRevisionNo() == null || quotation.getRevisionNo() <= lastRound) {
                    throw new ServiceException(400, "请先完成下一轮报价,再重新投标");
                }
                target = CrmBidResultEnum.PENDING.getResult();
            }
            default -> throw new ServiceException(400, "不支持的投标过程动作");
        }
        if (remark == null || remark.isBlank()) throw new ServiceException(400, "请填写本次跟进说明");
        if (remark.length() > 500) throw new ServiceException(400, "跟进说明不能超过500字");
        CrmSaleQuotationDO quotation = saleQuotationMapper.selectById(bond.getQuotationId());
        bond.setBidResult(target);
        bond.setQuotationRound(quotation != null ? quotation.getRevisionNo() : bond.getQuotationRound());
        if (target == CrmBidResultEnum.WON.getResult()) {
            bond.setRefundStatus(CrmBidBondRefundStatusEnum.NO_NEED.getStatus());
            bond.setRefundAmount(null);
            bond.setRefundDate(null);
        }
        bidBondMapper.updateByIdIncludingNulls(bond);
        insertProgress(bond, action, from, target, remark);
    }
    @Override
    public List<CrmBidProgressDO> getProgressList(Long id) {
        validateBidBondExists(id);
        return bidProgressMapper.selectByBidBondId(id);
    }
    private void insertProgress(CrmBidBondDO bond, String action, Integer from, Integer to, String remark) {
        CrmBidProgressDO event = new CrmBidProgressDO();
        event.setBidBondId(bond.getId());
        event.setAction(action);
        event.setFromResult(from);
        event.setToResult(to);
        event.setQuotationRound(bond.getQuotationRound());
        event.setRemark(remark);
        bidProgressMapper.insert(event);
    }
    @Override
@@ -194,9 +279,9 @@
                        "中标结果为【未中标】时不能关联销售订单[" + order.getNo()
                                + "]。如已中标,请先将中标结果改为【已中标】;如确未中标,请清空关联销售订单。");
            }
            // é€‰ä¸­é”€å”®è®¢å•说明已中标,待开标时自动置为已中标
            if (CrmBidResultEnum.PENDING.getResult().equals(bidResult)) {
                bidResult = CrmBidResultEnum.WON.getResult();
                throw new ServiceException(ErrorCodeConstants.BID_BOND_SALE_ORDER_NOT_APPROVE.getCode(),
                        "待开标时不能关联销售订单,请先明确中标结果。");
            }
            saleOrderNo = order.getNo();
        }
@@ -223,14 +308,10 @@
     * æ ¡éªŒå¹¶åŠ è½½å…³è”æŠ¥ä»·å•
     */
    private CrmSaleQuotationDO validateQuotation(CrmBidBondSaveReqVO reqVO, Integer bidResult) {
        // ä¸­æ ‡æ—¶æŠ¥ä»·å•必填,保证中标后可以据此转合同
        if (CrmBidResultEnum.WON.getResult().equals(bidResult) && reqVO.getQuotationId() == null) {
            throw new ServiceException(ErrorCodeConstants.BID_BOND_WON_QUOTATION_REQUIRED.getCode(),
                    "中标结果为【已中标】时必须关联报价单,否则无法凭该报价单转合同。"
                            + "请选择本次中标的销售报价单后重新保存。");
        }
        // æŠ•标记录必须绑定本次报价,待开标与未中标也需要保留报价关联。
        if (reqVO.getQuotationId() == null) {
            return null;
            throw new ServiceException(ErrorCodeConstants.BID_BOND_WON_QUOTATION_REQUIRED.getCode(),
                    "投标记录必须关联本次销售报价单,请选择报价单后重新保存。");
        }
        CrmSaleQuotationDO quotation = saleQuotationMapper.selectById(reqVO.getQuotationId());
        if (quotation == null) {
yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/bidbond/CrmBidBondQuotationBindingTest.java
@@ -51,6 +51,12 @@
        });
        ReflectionTestUtils.setField(service, "customerService", customerService);
        ReflectionTestUtils.setField(service, "bidBondMapper", bondMapper);
        ReflectionTestUtils.setField(service, "bidProgressMapper",
                stub(cn.iocoder.yudao.module.crm.dal.mysql.bidbond.CrmBidProgressMapper.class,
                        (proxy, method, args) -> {
                            if ("insert".equals(method.getName())) return 1;
                            throw new AssertionError(method.getName());
                        }));
    }
    private void bindQuotation(CrmSaleQuotationDO quotation) {
@@ -98,13 +104,13 @@
    }
    @Test
    void wonRequiresQuotation() {
    void createCannotSetResultDirectly() {
        bindQuotation(new CrmSaleQuotationDO().setId(5L).setNo("BJ5").setCustomerId(1L).setStatus(2));
        CrmBidBondSaveReqVO req = baseReq();
        req.setBidResult(1);
        ServiceException ex = assertThrows(ServiceException.class, () -> service.createBidBond(req));
        assertEquals(BID_BOND_WON_QUOTATION_REQUIRED.getCode(), ex.getCode());
        assertEquals(400, ex.getCode());
    }
    @Test
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/MesProProcessController.java
@@ -10,6 +10,8 @@
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportExcelVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO;
import cn.iocoder.yudao.module.mes.service.pro.process.MesProProcessService;
import io.swagger.v3.oas.annotations.Operation;
@@ -21,6 +23,7 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
@@ -98,4 +101,26 @@
        ExcelUtils.write(response, "生产工序.xls", "数据", MesProProcessRespVO.class, data);
    }
    @GetMapping("/get-import-template")
    @Operation(summary = "下载工序导入模板")
    @PreAuthorize("@ss.hasPermission('mes:pro-process:import')")
    public void importTemplate(HttpServletResponse response) throws IOException {
        MesProProcessImportExcelVO example = new MesProProcessImportExcelVO();
        example.setCode("PROCESS001");
        example.setName("示例工序");
        example.setBillingType(2);
        example.setWageRate(new java.math.BigDecimal("12.50"));
        example.setStdTimeModeName("未启用");
        example.setStatus(CommonStatusEnum.ENABLE.getStatus());
        ExcelUtils.write(response, "工序导入模板.xls", "工序设置", MesProProcessImportExcelVO.class, List.of(example));
    }
    @PostMapping("/import")
    @Operation(summary = "导入工序")
    @PreAuthorize("@ss.hasPermission('mes:pro-process:import')")
    public CommonResult<MesProProcessImportRespVO> importProcess(@RequestParam("file") MultipartFile file,
            @RequestParam(value = "updateSupport", defaultValue = "false") boolean updateSupport) throws IOException {
        return success(processService.importProcessList(ExcelUtils.read(file, MesProProcessImportExcelVO.class), updateSupport));
    }
}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/MesProProcessImportExcelVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class MesProProcessImportExcelVO {
    @ExcelProperty("工序编码(必填)") private String code;
    @ExcelProperty("工序名称(必填)") private String name;
    @ExcelProperty("计费类型(必填:1计时/2计件)") private Integer billingType;
    @ExcelProperty("工资定额(必填)") private BigDecimal wageRate;
    @ExcelProperty("辅助工时小时工资") private BigDecimal auxHourlyRate;
    // å›ºå®šåˆ—序号以兼容旧模板:旧列标题为“标准工时计算方式(0/1/2/3)”。
    @ExcelProperty(value = "标准工时计算方式(未启用/转速×节距/线速度直取/满速百分比×节距)", index = 5) private String stdTimeModeName;
    @ExcelProperty("标准工时折算系数") private BigDecimal stdTimeFactor;
    @ExcelProperty("机台满转速") private BigDecimal maxRpm;
    @ExcelProperty("转速参数编码") private String stdRpmParamCode;
    @ExcelProperty("节距参数编码") private String stdPitchParamCode;
    @ExcelProperty("线速度参数编码") private String stdSpeedParamCode;
    @ExcelProperty("转速百分比参数编码") private String stdPercentParamCode;
    @ExcelProperty("状态(0启用/1停用;留空默认启用)") private Integer status;
    @ExcelProperty("工艺要求") private String attention;
    @ExcelProperty("备注") private String remark;
}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/MesProProcessImportRespVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo;
import lombok.Builder;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
@Builder
public class MesProProcessImportRespVO {
    private List<String> createCodes;
    private List<String> updateCodes;
    private Map<String, String> failureCodes;
}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/MesWmReturnSalesController.java
@@ -109,21 +109,14 @@
        return success(true);
    }
    @PutMapping("/finish")
    @Operation(summary = "执行退货")
    @Parameter(name = "id", description = "编号", required = true)
    @PutMapping("/confirm-inbound")
    @Operation(summary = "质检后确认退货入库")
    @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:finish')")
    public CommonResult<Boolean> finishReturnSales(@RequestParam("id") Long id) {
        returnSalesService.finishReturnSales(id);
        return success(true);
    }
    @PutMapping("/stock")
    @Operation(summary = "执行上架")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:stock')")
    public CommonResult<Boolean> stockReturnSales(@RequestParam("id") Long id) {
        returnSalesService.stockReturnSales(id);
    public CommonResult<Boolean> confirmReturnSales(@RequestParam("id") Long id,
            @RequestParam("warehouseId") Long warehouseId,
            @RequestParam("locationId") Long locationId,
            @RequestParam("areaId") Long areaId) {
        returnSalesService.confirmReturnSales(id, warehouseId, locationId, areaId);
        return success(true);
    }
@@ -158,4 +151,4 @@
                        vo.setClientName(customer.getName())));
    }
}
}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/MesWmSalesNoticeController.java
@@ -162,6 +162,8 @@
                row.setRecipientName(notice.getRecipientName());
                row.setRecipientAddress(notice.getRecipientAddress());
                row.setLogisticsCompany(notice.getLogisticsCompany());
                row.setDeliveryVolume(notice.getDeliveryVolume());
                row.setDeliveryWeight(notice.getDeliveryWeight());
                row.setExpressFee(notice.getExpressFee());
                row.setInvoiceStatus(notice.getInvoiceStatus());
                row.setStatus(notice.getStatus());
@@ -233,6 +235,8 @@
        fields.put("recipientTelephone", notice.getRecipientTelephone());
        fields.put("recipientAddress", notice.getRecipientAddress());
        fields.put("logisticsCompany", notice.getLogisticsCompany());
        fields.put("deliveryVolume", notice.getDeliveryVolume() == null ? "" : notice.getDeliveryVolume().toPlainString());
        fields.put("deliveryWeight", notice.getDeliveryWeight() == null ? "" : notice.getDeliveryWeight().toPlainString());
        fields.put("expressFee", notice.getExpressFee() == null ? "0.00" : notice.getExpressFee().toPlainString());
        fields.put("creator", resolveCreatorName(notice.getCreator()));
        fields.put("remark", notice.getRemark());
@@ -332,4 +336,4 @@
        });
    }
}
}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticeLedgerRespVO.java
@@ -33,6 +33,10 @@
    private String recipientAddress;
    @Schema(description = "物流公司")
    private String logisticsCompany;
    @Schema(description = "发货体积(立方米)")
    private BigDecimal deliveryVolume;
    @Schema(description = "发货重量(千克)")
    private BigDecimal deliveryWeight;
    @Schema(description = "快递费")
    private BigDecimal expressFee;
    @Schema(description = "开票状态:0未开票 1部分开票 2已开票")
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticeRespVO.java
@@ -59,6 +59,14 @@
    @ExcelProperty("物流公司")
    private String logisticsCompany;
    @Schema(description = "发货体积(立方米)")
    @ExcelProperty("发货体积(m³)")
    private BigDecimal deliveryVolume;
    @Schema(description = "发货重量(千克)")
    @ExcelProperty("发货重量(kg)")
    private BigDecimal deliveryWeight;
    @Schema(description = "快递费", example = "25.00")
    @ExcelProperty("快递费")
    private BigDecimal expressFee;
@@ -83,4 +91,4 @@
    @ExcelProperty("创建时间")
    private LocalDateTime createTime;
}
}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticeSaveReqVO.java
@@ -52,6 +52,14 @@
    @Size(max = 128, message = "物流公司名称不能超过 128 ä¸ªå­—符")
    private String logisticsCompany;
    @Schema(description = "发货体积(立方米)")
    @DecimalMin(value = "0", message = "发货体积不能小于 0")
    private BigDecimal deliveryVolume;
    @Schema(description = "发货重量(千克)")
    @DecimalMin(value = "0", message = "发货重量不能小于 0")
    private BigDecimal deliveryWeight;
    @Schema(description = "快递费", example = "25.00")
    @DecimalMin(value = "0", message = "快递费不能小于 0")
    private BigDecimal expressFee;
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/salesnotice/MesWmSalesNoticeDO.java
@@ -70,6 +70,10 @@
     * ç‰©æµå…¬å¸
     */
    private String logisticsCompany;
    /** å‘货体积(立方米) */
    private BigDecimal deliveryVolume;
    /** å‘货重量(千克) */
    private BigDecimal deliveryWeight;
    /**
     * å¿«é€’è´¹
     */
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/mps/MesProMpsServiceImpl.java
@@ -17,6 +17,7 @@
import cn.iocoder.yudao.module.mes.dal.mysql.pro.mps.MesProMpsMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.pro.feedback.MesProFeedbackMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
import cn.iocoder.yudao.module.mes.enums.md.autocode.MesMdAutoCodeRuleCodeEnum;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.feedback.MesProFeedbackDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.route.MesProRouteProductBomDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.route.MesProRouteProductDO;
@@ -597,9 +598,9 @@
     */
    private String generateWorkOrderCode() {
        try {
            return autoCodeRecordService.generateAutoCode("WO");
            return autoCodeRecordService.generateAutoCode(MesMdAutoCodeRuleCodeEnum.PRO_WORK_ORDER_CODE.getCode());
        } catch (Exception e) {
            log.warn("[generateWorkOrderCode] ç¼–码规则 WO ä¸å­˜åœ¨ï¼Œä½¿ç”¨æ—¶é—´æˆ³ç”Ÿæˆ");
            log.warn("[generateWorkOrderCode] ç”Ÿäº§å·¥å•编码生成失败,使用时间戳生成", e);
            return "WO" + System.currentTimeMillis();
        }
    }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessService.java
@@ -3,6 +3,8 @@
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportExcelVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO;
import jakarta.validation.Valid;
@@ -66,6 +68,8 @@
     */
    PageResult<MesProProcessDO> getProcessPage(MesProProcessPageReqVO pageReqVO);
    MesProProcessImportRespVO importProcessList(List<MesProProcessImportExcelVO> rows, boolean updateSupport);
    /**
     * èŽ·å¾—æŒ‡å®šçŠ¶æ€çš„ç”Ÿäº§å·¥åºåˆ—è¡¨
     *
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java
@@ -7,6 +7,8 @@
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportExcelVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO;
import cn.iocoder.yudao.module.mes.dal.mysql.pro.process.MesProProcessMapper;
import cn.iocoder.yudao.module.mes.enums.pro.MesProProcessBillingTypeEnum;
@@ -20,6 +22,11 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
@@ -159,6 +166,65 @@
    }
    @Override
    public MesProProcessImportRespVO importProcessList(List<MesProProcessImportExcelVO> rows, boolean updateSupport) {
        if (CollUtil.isEmpty(rows)) {
            throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400, "导入文件没有工序数据");
        }
        MesProProcessImportRespVO result = MesProProcessImportRespVO.builder()
                .createCodes(new ArrayList<>()).updateCodes(new ArrayList<>())
                .failureCodes(new LinkedHashMap<>()).build();
        Set<String> seenCodes = new HashSet<>();
        for (int index = 0; index < rows.size(); index++) {
            MesProProcessImportExcelVO row = rows.get(index);
            String code = row.getCode() == null ? "" : row.getCode().trim();
            String key = code.isEmpty() ? "第 " + (index + 2) + " è¡Œ" : code;
            try {
                if (code.isEmpty() || row.getName() == null || row.getName().isBlank()) {
                    throw new IllegalArgumentException("工序编码和名称不能为空");
                }
                if (!seenCodes.add(code)) throw new IllegalArgumentException("文件内工序编码重复");
                if (row.getBillingType() == null || row.getWageRate() == null) {
                    throw new IllegalArgumentException("计费类型和工资定额不能为空");
                }
                if (row.getStatus() != null && row.getStatus() != 0 && row.getStatus() != 1) {
                    throw new IllegalArgumentException("状态只能填写 0 æˆ– 1");
                }
                MesProProcessSaveReqVO save = BeanUtils.toBean(row, MesProProcessSaveReqVO.class);
                save.setStdTimeMode(parseStdTimeMode(row.getStdTimeModeName()));
                save.setCode(code);
                save.setName(row.getName().trim());
                save.setStatus(row.getStatus() == null ? 0 : row.getStatus());
                MesProProcessDO existing = processMapper.selectByCode(code);
                if (existing == null) {
                    createProcess(save);
                    result.getCreateCodes().add(code);
                } else if (updateSupport) {
                    save.setId(existing.getId());
                    updateProcess(save);
                    result.getUpdateCodes().add(code);
                } else {
                    throw new IllegalArgumentException("工序编码已存在,勾选覆盖后可更新");
                }
            } catch (RuntimeException ex) {
                result.getFailureCodes().put(key, ex.getMessage());
            }
        }
        return result;
    }
    private Integer parseStdTimeMode(String value) {
        if (value == null || value.isBlank()) return null;
        String normalized = value.trim().replace(" ", "").replace("*", "×").replace("*", "×");
        return switch (normalized) {
            case "0", "未启用" -> 0;
            case "1", "转速×节距" -> 1;
            case "2", "线速度直取" -> 2;
            case "3", "满速百分比×节距" -> 3;
            default -> throw new IllegalArgumentException("标准工时计算方式请填写:未启用、转速×节距、线速度直取、满速百分比×节距");
        };
    }
    @Override
    public List<MesProProcessDO> getProcessListByStatus(Integer status) {
        return processMapper.selectListByStatus(status);
    }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesService.java
@@ -74,12 +74,7 @@
     */
    void submitReturnSales(Long id);
    /**
     * æ‰§è¡Œé€€è´§ï¼ˆå¾…执行 -> å¾…上架)
     *
     * @param id ç¼–号
     */
    void finishReturnSales(Long id);
    void confirmReturnSales(Long id, Long warehouseId, Long locationId, Long areaId);
    /**
     * æ‰§è¡Œä¸Šæž¶ï¼ˆå¾…上架 -> å·²å®Œæˆï¼‰ï¼Œæ›´æ–°åº“存台账
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java
@@ -12,6 +12,7 @@
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail.MesWmReturnSalesDetailSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.mdm.MesMdmItemDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDetailDO;
@@ -147,20 +148,40 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void finishReturnSales(Long id) {
        // 1.1 æ ¡éªŒå­˜åœ¨ + å¾…执行状态
        MesWmReturnSalesDO returnSales = validateReturnSalesExists(id);
    public void confirmReturnSales(Long id, Long warehouseId, Long locationId, Long areaId) {
        if (warehouseId == null || locationId == null || areaId == null) {
            throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400, "请选择入库仓库、库区和库位");
        }
        MesWmReturnSalesDO returnSales = returnSalesMapper.selectByIdForUpdate(id);
        if (returnSales == null) throw exception(WM_RETURN_SALES_NOT_EXISTS);
        if (ObjUtil.notEqual(MesWmReturnSalesStatusEnum.APPROVING.getStatus(), returnSales.getStatus())) {
            throw exception(WM_RETURN_SALES_STATUS_NOT_APPROVING);
        }
        // 1.2 æ ¡éªŒè‡³å°‘有一条行
        List<MesWmReturnSalesLineDO> lines = returnSalesLineService.getReturnSalesLineListByReturnId(id);
        if (CollUtil.isEmpty(lines)) {
            throw exception(WM_RETURN_SALES_NO_LINE);
        if (CollUtil.isEmpty(lines)) throw exception(WM_RETURN_SALES_NO_LINE);
        if (CollUtil.isNotEmpty(returnSalesDetailService.getReturnSalesDetailListByReturnId(id))) {
            throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400, "退货单已有上架明细,请按原流程完成");
        }
        // 2. æ‰§è¡Œé€€è´§ï¼ˆå¾…执行 -> å¾…上架)
        // æ˜Žç»†æœåŠ¡ä¼šæ ¡éªŒè´¨æ£€ç»“æžœã€åº“ä½å±‚çº§ã€æ··æ”¾è§„åˆ™å’Œæ‰¹æ¬¡ã€‚
        returnSalesMapper.updateById(new MesWmReturnSalesDO()
                .setId(id).setStatus(MesWmReturnSalesStatusEnum.APPROVED.getStatus()));
        for (MesWmReturnSalesLineDO line : lines) {
            if (line.getNcrDispositionId() != null
                    && Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())) continue;
            if (ObjUtil.notEqual(line.getQualityStatus(), MesWmQualityStatusEnum.PASS.getStatus())) {
                throw exception(WM_RETURN_SALES_LINE_NOT_QUALIFIED);
            }
            MesWmReturnSalesDetailSaveReqVO detail = new MesWmReturnSalesDetailSaveReqVO();
            detail.setReturnId(id);
            detail.setLineId(line.getId());
            detail.setItemId(line.getItemId());
            detail.setQuantity(line.getQuantity());
            detail.setWarehouseId(warehouseId);
            detail.setLocationId(locationId);
            detail.setAreaId(areaId);
            returnSalesDetailService.createReturnSalesDetail(detail);
        }
        stockReturnSales(id);
    }
    @Override
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/salesnotice/MesWmSalesNoticeServiceImpl.java
@@ -153,38 +153,11 @@
            throw exception(WM_SALES_NOTICE_LINE_EMPTY);
        }
        // 2. å…¨å±€å…å®¡æ‰¹ï¼šç›´æŽ¥è¿›å…¥å¾…出库
        if (bpmProcessInstanceApi.isGlobalAutoApprove()) {
            salesNoticeMapper.updateById(new MesWmSalesNoticeDO()
                    .setId(id).setProcessInstanceId("").setStatus(APPROVED.getStatus()));
            reserveSaleOrderOutStatus(notice);
            return;
        }
        // 3. å¿…须选择流程,且分类下存在激活的流程定义
        if (StrUtil.isBlank(processDefinitionKey)) {
            throw exception(WM_SALES_NOTICE_SUBMIT_PROCESS_KEY_REQUIRED);
        }
        validateSalesNoticeApproveCategoryAndProcessDefinition();
        ProcessDefinition processDefinition = bpmProcessDefinitionService.getActiveProcessDefinition(processDefinitionKey);
        // åŒºåˆ†ã€ŒKey ä¸å­˜åœ¨/已停用」与「流程存在但不属于发货审批分类」,分别给出可执行的提示
        if (processDefinition == null) {
            throw exception(WM_SALES_NOTICE_BPM_PROCESS_KEY_INVALID, processDefinitionKey);
        }
        boolean inDeliveryCategory = bpmProcessDefinitionService
                .getProcessDefinitionInfoListByCategory(SALES_DELIVERY_APPROVE_CATEGORY_CODE).stream()
                .anyMatch(info -> Objects.equals(info.getProcessDefinitionId(), processDefinition.getId()));
        if (!inDeliveryCategory) {
            throw exception(WM_SALES_NOTICE_BPM_PROCESS_DEFINITION_NOT_IN_CATEGORY,
                    StrUtil.blankToDefault(processDefinition.getName(), processDefinitionKey));
        }
        // 4. åˆ›å»ºå®¡æ‰¹æµç¨‹å®žä¾‹ï¼Œè¿›å…¥å®¡æ‰¹ä¸­
        String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO()
                .setProcessDefinitionKey(processDefinitionKey).setBusinessKey(String.valueOf(id))
                .setVariables(Map.of("businessNo", notice.getCode())));
        // å‘货通知由仓库确认后直接出库,不再启动审批流程。
        salesNoticeMapper.updateById(new MesWmSalesNoticeDO()
                .setId(id).setProcessInstanceId(processInstanceId).setStatus(APPROVING.getStatus()));
                .setId(id).setProcessInstanceId("").setStatus(APPROVED.getStatus()));
        reserveSaleOrderOutStatus(notice);
    }
    @Override
yudao-module-mes/src/main/resources/templates/wm/sales-delivery.docx
Binary files differ