| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- éå®ä¾§ææ 页é¢ç»ä¸æ¾ç¤ºä¸ºææ 管çï¼ä¿çåèå IDãè·¯ç±åæéã |
| | | UPDATE system_menu SET name = 'ææ ç®¡ç' WHERE id = 602630; |
| | | UPDATE system_menu SET name = REPLACE(name, 'ææ ä¿è¯é', 'ææ ç®¡ç') WHERE id IN (602631, 602632, 602633, 602634); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- ææ ç»æç±ä¸é¨å¨ä½ç»è®°ï¼ä¿çæ¯æ¬¡å¼æ åéæ°ææ çæµæ°´ã |
| | | 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`); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- å·¥åºè®¾ç½®æ°å¢ 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'; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- è¡¥é½æ¥ææ£éªä¾åºåæ¹æ¬¡å·çç¼ç è§åã |
| | | 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); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- è¥é管çèåæä¸å¡æµç¨æåºï¼ä¿çåèå 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); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- åè´§ä½ç§¯åééä»
ç¨äºç©æµè®°å½ï¼ä¸åä¸è´¢å¡è®¡ç®ã |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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) |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | |
| | | 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; |
| | |
| | | .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); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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)); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | @Resource |
| | | private CrmBidBondMapper bidBondMapper; |
| | | @Resource |
| | | private CrmBidProgressMapper bidProgressMapper; |
| | | @Resource |
| | | private CrmSaleQuotationMapper saleQuotationMapper; |
| | | @Resource |
| | | private CrmCustomerService customerService; |
| | |
| | | @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()); |
| | |
| | | if (bond.getQuotationId() != null) { |
| | | saleQuotationMapper.bindBidBond(bond.getQuotationId(), bond.getId(), bond.getNo()); |
| | | } |
| | | insertProgress(bond, "CREATED", null, CrmBidResultEnum.PENDING.getResult(), null); |
| | | return bond.getId(); |
| | | } |
| | | |
| | |
| | | @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()); |
| | | // åå·ä¸å
许修æ¹ï¼ä¿æåå¼ |
| | |
| | | @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); |
| | | } |
| | |
| | | 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 |
| | |
| | | "䏿 ç»æä¸ºãæªä¸æ ãæ¶ä¸è½å
³èéå®è®¢å[" + 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(); |
| | | } |
| | |
| | | * æ ¡éªå¹¶å è½½å
³èæ¥ä»·å |
| | | */ |
| | | 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) { |
| | |
| | | }); |
| | | 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) { |
| | |
| | | } |
| | | |
| | | @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 |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | vo.setClientName(customer.getName()))); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | }); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | 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å·²å¼ç¥¨") |
| | |
| | | @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; |
| | |
| | | @ExcelProperty("å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| | | } |
| | |
| | | @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; |
| | |
| | | * ç©æµå
¬å¸ |
| | | */ |
| | | private String logisticsCompany; |
| | | /** åè´§ä½ç§¯ï¼ç«æ¹ç±³ï¼ */ |
| | | private BigDecimal deliveryVolume; |
| | | /** åè´§ééï¼åå
ï¼ */ |
| | | private BigDecimal deliveryWeight; |
| | | /** |
| | | * å¿«éè´¹ |
| | | */ |
| | |
| | | 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; |
| | |
| | | */ |
| | | 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(); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | */ |
| | | PageResult<MesProProcessDO> getProcessPage(MesProProcessPageReqVO pageReqVO); |
| | | |
| | | MesProProcessImportRespVO importProcessList(List<MesProProcessImportExcelVO> rows, boolean updateSupport); |
| | | |
| | | /** |
| | | * è·å¾æå®ç¶æçç产工åºå表 |
| | | * |
| | |
| | | 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; |
| | |
| | | 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.*; |
| | |
| | | } |
| | | |
| | | @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); |
| | | } |
| | |
| | | */ |
| | | void submitReturnSales(Long id); |
| | | |
| | | /** |
| | | * æ§è¡éè´§ï¼å¾
æ§è¡ -> å¾
䏿¶ï¼ |
| | | * |
| | | * @param id ç¼å· |
| | | */ |
| | | void finishReturnSales(Long id); |
| | | void confirmReturnSales(Long id, Long warehouseId, Long locationId, Long areaId); |
| | | |
| | | /** |
| | | * æ§è¡ä¸æ¶ï¼å¾
䏿¶ -> 已宿ï¼ï¼æ´æ°åºåå°è´¦ |
| | |
| | | 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; |
| | |
| | | |
| | | @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 |
| | |
| | | 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 |