| | |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.bean.dto.ProductionProductMainDto; |
| | | import com.ruoyi.production.enums.MajorCategoryEnum; |
| | | import com.ruoyi.production.enums.ProductOrderStatusEnum; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | |
| | | @AllArgsConstructor |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class ProductionProductMainServiceImpl extends ServiceImpl<ProductionProductMainMapper, ProductionProductMain> implements ProductionProductMainService { |
| | | |
| | | /** |
| | | * 生产报工大类:只区分小提琴/大提琴/贝斯,不再区分零件。 |
| | | * key为入库规范值,value为产品名称匹配别名(现场数据贝斯写作“贝司”)。 |
| | | */ |
| | | private static final Map<String, List<String>> MAJOR_CATEGORY_PATTERNS = new LinkedHashMap<>() {{ |
| | | put("小提琴", List.of("小提琴")); |
| | | put("大提琴", List.of("大提琴")); |
| | | put("贝斯", List.of("贝斯", "贝司")); |
| | | }}; |
| | | |
| | | private final ProductionProductMainMapper productionProductMainMapper; |
| | | private final SysUserMapper userMapper; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 需求:生产报工只区分产品大类(小提琴/大提琴/贝斯),不再区分零件。 |
| | | * 需求:生产报工只区分产品大类(小提琴/中提琴/大提琴/贝斯),不再区分零件。 |
| | | * 从产出产品自身名称开始沿产品树向上做关键字匹配,命中即取对应规范大类;未命中返回 null。 |
| | | * 产品树顶层为“成品/半成品/原料”等库存分类,不能直接当作大类,因此必须自底向上取第一个命中的层级。 |
| | | */ |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 按产品名称归入乐器大类。判定规则(别名表、配件排除)集中在 {@link MajorCategoryEnum}, |
| | | * 工资核算、生产核算也共用同一套规则,避免各处再写一份字符串比较。 |
| | | */ |
| | | static String matchMajorCategory(String productName) { |
| | | if (productName == null || productName.isEmpty()) { |
| | | return null; |
| | | } |
| | | // 琴盒/琴套等配件名称可能带“贝司”等字样(如 SA贝司套),排除后避免误归大类。 |
| | | if (productName.contains("琴盒") || productName.contains("琴套") || productName.contains("弓盒")) { |
| | | return null; |
| | | } |
| | | for (Map.Entry<String, List<String>> entry : MAJOR_CATEGORY_PATTERNS.entrySet()) { |
| | | for (String alias : entry.getValue()) { |
| | | if (productName.contains(alias)) { |
| | | return entry.getKey(); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | return MajorCategoryEnum.match(productName); |
| | | } |
| | | |
| | | private Boolean removeProductMainByProductionTask(ProductionProductMain productionProductMain) { |