已添加17个文件
已重命名1个文件
已修改36个文件
| | |
| | | |
| | | ALTER TABLE `product-inventory-management-zsjc`.`production_plan` |
| | | DROP COLUMN `data_sync_type`, |
| | | MODIFY COLUMN `data_source_type` tinyint NULL DEFAULT 1 COMMENT 'æ°æ®æ¥æºç±»åï¼1=éé忥 2=æå¨æ°å¢' AFTER `form_modified_time`; |
| | | MODIFY COLUMN `data_source_type` tinyint NULL DEFAULT 1 COMMENT 'æ°æ®æ¥æºç±»åï¼1=éé忥 2=æå¨æ°å¢' AFTER `form_modified_time`; |
| | | |
| | | -- å 餿§è¡¨ |
| | | DROP TABLE IF EXISTS `base_param`; |
| | | DROP TABLE IF EXISTS `product_process_param`; |
| | | |
| | | CREATE TABLE `base_param` |
| | | ( |
| | | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主é®ID', |
| | | `param_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'åæ°å¯ä¸æ è¯', |
| | | `param_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'åæ°åç§°', |
| | | `param_type` tinyint NOT NULL COMMENT 'åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)', |
| | | `param_format` varchar(255) DEFAULT NULL COMMENT 'åæ°æ ¼å¼', |
| | | `value_mode` tinyint DEFAULT '1' COMMENT '弿¨¡å¼(1åå¼ 2åºé´)', |
| | | `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'åä½', |
| | | `is_required` tinyint DEFAULT '0' COMMENT 'æ¯å¦å¿
å¡«', |
| | | `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '夿³¨', |
| | | `create_user` varchar(64) DEFAULT NULL COMMENT 'å建人', |
| | | `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'å建æ¶é´', |
| | | `update_user` varchar(64) DEFAULT NULL COMMENT 'ä¿®æ¹äºº', |
| | | `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'ä¿®æ¹æ¶é´', |
| | | `tenant_id` bigint DEFAULT NULL COMMENT 'ç§æ·ID', |
| | | PRIMARY KEY (`id`) USING BTREE |
| | | ) ENGINE = InnoDB |
| | | AUTO_INCREMENT = 10 |
| | | DEFAULT CHARSET = utf8mb4 |
| | | COLLATE = utf8mb4_0900_ai_ci COMMENT ='åºç¡åæ°å®ä¹è¡¨'; |
| | | |
| | | CREATE TABLE `product_process_param` |
| | | ( |
| | | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主é®ID', |
| | | `process_id` bigint NOT NULL COMMENT 'æå±å·¥åºID (product_process.id)', |
| | | `param_id` bigint NOT NULL COMMENT 'å
³èåºç¡åæ°ID (base_param.id)', |
| | | `standard_value` varchar(200) DEFAULT NULL COMMENT '卿¤å·¥åºè®¾å®çæ åå¼(å弿¨¡å¼)', |
| | | `min_value` decimal(10, 2) DEFAULT NULL COMMENT '卿¤å·¥åºè®¾å®çæ åæå°å¼(åºé´æ¨¡å¼)', |
| | | `max_value` decimal(10, 2) DEFAULT NULL COMMENT '卿¤å·¥åºè®¾å®çæ åæå¤§å¼(åºé´æ¨¡å¼)', |
| | | `is_required` tinyint NOT NULL DEFAULT '0' COMMENT '卿¤å·¥åºä¸æ¯å¦å¿
å¡«(0-å¦, 1-æ¯)', |
| | | `sort` int NOT NULL DEFAULT '0' COMMENT 'æåºå·', |
| | | `tenant_id` bigint DEFAULT NULL COMMENT 'ç§æ·ID', |
| | | `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'å建æ¶é´', |
| | | `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'æ´æ°æ¶é´', |
| | | PRIMARY KEY (`id`) USING BTREE, |
| | | KEY `idx_process_id` (`process_id`) USING BTREE, |
| | | KEY `idx_param_id` (`param_id`) USING BTREE |
| | | ) ENGINE = InnoDB |
| | | AUTO_INCREMENT = 1 |
| | | DEFAULT CHARSET = utf8mb4 |
| | | COLLATE = utf8mb4_0900_ai_ci COMMENT ='å·¥åºç»å®åæ°è¡¨'; |
| | | |
| | | ALTER TABLE `product_process` MODIFY COLUMN `name` varchar(255) COMMENT 'å·¥åºåç§°'; |
| | | ALTER TABLE `product_process` MODIFY COLUMN `no` varchar(255) COMMENT 'å·¥åºç¼å·'; |
| | | ALTER TABLE `product_process` ADD COLUMN `status` tinyint(1) DEFAULT '1' COMMENT 'ç¶æï¼0-åç¨ï¼1-å¯ç¨' AFTER `no`; |
| | | ALTER TABLE `product_process` MODIFY COLUMN `type` bigint COMMENT 'ç±»åï¼0-计æ¶ï¼1-计件'; |
| | | ALTER TABLE `product_process` MODIFY COLUMN `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'å建æ¶é´'; |
| | | ALTER TABLE `product_process` MODIFY COLUMN `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'ä¿®æ¹æ¶é´'; |
| | | |
| | | ALTER TABLE `product-inventory-management-zsjc`.`customer` |
| | | ADD COLUMN `form_instance_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'å®æè¡¨åå®ä¾ID' AFTER `customer_type`, |
| | | ADD COLUMN `form_modified_time` datetime(0) NULL DEFAULT NULL COMMENT 'å®æä¿®æ¹æ¶é´' AFTER `form_instance_id`; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.controller; |
| | | |
| | | import com.ruoyi.basic.pojo.BaseParam; |
| | | import com.ruoyi.basic.service.BaseParamService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * åºç¡åæ°å®ä¹æ§å¶å± |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/13 16:42 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/baseParam") |
| | | public class BaseParamController extends BaseController { |
| | | |
| | | @Autowired |
| | | private BaseParamService baseParamService; |
| | | |
| | | @GetMapping("list") |
| | | @Log(title = "åºç¡åæ°æ°æ®éå", businessType = BusinessType.OTHER) |
| | | @ApiOperation("åºç¡åæ°æ°æ®éå") |
| | | public AjaxResult baseParamList(BaseParam baseParam) { |
| | | List<BaseParam> list = baseParamService.baseParamList(baseParam); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @Log(title = "æ°å¢åºç¡åæ°", businessType = BusinessType.INSERT) |
| | | @ApiOperation("æ°å¢åºç¡åæ°") |
| | | public AjaxResult baseParamAdd(@RequestBody BaseParam baseParam) { |
| | | return toAjax(baseParamService.addBaseParam(baseParam)); |
| | | } |
| | | |
| | | @PutMapping("/edit") |
| | | @Log(title = "ä¿®æ¹åºç¡åæ°", businessType = BusinessType.UPDATE) |
| | | @ApiOperation("ä¿®æ¹åºç¡åæ°") |
| | | public AjaxResult baseParamEdit(@RequestBody BaseParam baseParam) { |
| | | return toAjax(baseParamService.updateBaseParam(baseParam)); |
| | | } |
| | | |
| | | @DeleteMapping("/remove/{ids}") |
| | | @Log(title = "å é¤åºç¡åæ°", businessType = BusinessType.DELETE) |
| | | @ApiOperation("å é¤åºç¡åæ°") |
| | | public AjaxResult baseParamRemove(@PathVariable Long[] ids) { |
| | | return toAjax(baseParamService.deleteBaseParamByIds(ids)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <br> |
| | | * åºç¡åæ°å®ä¹Dto |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/13 17:40 |
| | | */ |
| | | @Data |
| | | @Api("åºç¡åæ°å®ä¹Dto") |
| | | public class BaseParamDto { |
| | | |
| | | @ApiModelProperty("主é®ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("åæ°å¯ä¸æ è¯") |
| | | private String paramKey; |
| | | |
| | | @ApiModelProperty("åæ°åç§°") |
| | | private String paramName; |
| | | |
| | | @ApiModelProperty("åæ°ç±»å(1æ°å 2ææ¬)") |
| | | private Integer paramType; |
| | | |
| | | @ApiModelProperty("åæ°æ ¼å¼") |
| | | private String paramFormat; |
| | | |
| | | @ApiModelProperty("弿¨¡å¼(1åå¼ 2åºé´)") |
| | | private Integer valueMode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("é»è®¤å¼(åå¼åæ°)") |
| | | private String defaultValue; |
| | | |
| | | @ApiModelProperty("é»è®¤æå°å¼(åºé´åæ°)") |
| | | private BigDecimal defaultMin; |
| | | |
| | | @ApiModelProperty("é»è®¤æå¤§å¼(åºé´åæ°)") |
| | | private BigDecimal defaultMax; |
| | | |
| | | @ApiModelProperty("æ¯å¦å¿
å¡«(0å¦ 1æ¯)") |
| | | private Integer isRequired; |
| | | |
| | | @ApiModelProperty("产åç±»å表IDåç§°") |
| | | private String baseProductTypeName; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("å建人") |
| | | private String createUser; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | private String updateUser; |
| | | |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.basic.pojo.BaseParam; |
| | | |
| | | /** |
| | | * <br> |
| | | * åºç¡åæ°å®ä¹Mapper |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/13 16:39 |
| | | */ |
| | | public interface BaseParamMapper extends BaseMapper<BaseParam> { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <br> |
| | | * åºç¡åæ°å®ä¹è¡¨ |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/13 16:33 |
| | | */ |
| | | @Data |
| | | @TableName("base_param") |
| | | @Api("åºç¡åæ°å®ä¹") |
| | | public class BaseParam { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | @ApiModelProperty("主é®ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("åæ°å¯ä¸æ è¯") |
| | | private String paramKey; |
| | | |
| | | @ApiModelProperty("åæ°åç§°") |
| | | private String paramName; |
| | | |
| | | @ApiModelProperty("åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)") |
| | | private Integer paramType; |
| | | |
| | | @ApiModelProperty("åæ°æ ¼å¼") |
| | | private String paramFormat; |
| | | |
| | | @ApiModelProperty("弿¨¡å¼(1åå¼ 2åºé´)") |
| | | private Integer valueMode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("æ¯å¦å¿
å¡«(0å¦ 1æ¯)") |
| | | private Integer isRequired; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("å建人") |
| | | private String createUser; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | private String updateUser; |
| | | |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("ç§æ·ID") |
| | | private Long tenantId; |
| | | } |
| | |
| | | @ApiModelProperty(value = "弿·è¡å·") |
| | | @Excel(name = "弿·è¡å·") |
| | | private String bankCode; |
| | | |
| | | @ApiModelProperty("å®æè¡¨åå®ä¾ID") |
| | | private String formInstanceId; |
| | | |
| | | @ApiModelProperty("å®æä¿®æ¹æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime formModifiedTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.basic.pojo.BaseParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * åºç¡åæ°å®ä¹æ¥å£ |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/13 16:40 |
| | | */ |
| | | public interface BaseParamService extends IService<BaseParam> { |
| | | List<BaseParam> baseParamList(BaseParam baseParam); |
| | | |
| | | int addBaseParam(BaseParam baseParam); |
| | | |
| | | int updateBaseParam(BaseParam baseParam); |
| | | |
| | | int deleteBaseParamByIds(Long[] ids); |
| | | } |
| | |
| | | List<Customer> selectCustomerLists(Customer customer); |
| | | |
| | | AjaxResult importData(MultipartFile file); |
| | | |
| | | //åæ¥å®¢æ·æ°æ® |
| | | void syncCustomerJob(); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.mapper.BaseParamMapper; |
| | | import com.ruoyi.basic.pojo.BaseParam; |
| | | import com.ruoyi.basic.service.BaseParamService; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * åºç¡åæ°å®ä¹æ¥å£å®ç°ç±» |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/13 16:41 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @Api("åºç¡åæ°å®ä¹æ¥å£å®ç°ç±»") |
| | | public class BaseParamServiceImpl extends ServiceImpl<BaseParamMapper, BaseParam> implements BaseParamService { |
| | | |
| | | @Override |
| | | public List<BaseParam> baseParamList(BaseParam baseParam) { |
| | | LambdaQueryWrapper<BaseParam> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.isNotEmpty(baseParam.getParamName())) { |
| | | queryWrapper.like(BaseParam::getParamName, baseParam.getParamName()); |
| | | } |
| | | List<BaseParam> list = list(queryWrapper); |
| | | if (list == null || list.isEmpty()) { |
| | | return new ArrayList<>(0); |
| | | } |
| | | |
| | | // å¤çæ¥ææ ¼å¼å±ç¤º |
| | | list.forEach(item -> { |
| | | if (Integer.valueOf(4).equals(item.getParamType()) && StringUtils.isNotEmpty(item.getParamFormat())) { |
| | | item.setParamFormat(toUpperCasePattern(item.getParamFormat())); |
| | | } |
| | | }); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public int addBaseParam(BaseParam baseParam) { |
| | | if (baseParam == null) { |
| | | throw new RuntimeException("æ°å¢åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | // åæ°æ ¡éª |
| | | checkBaseParam(baseParam); |
| | | // èªå¨çæparamKey |
| | | baseParam.setParamKey(generateParamKey()); |
| | | baseParam.setCreateUser(SecurityUtils.getUsername()); |
| | | baseParam.setCreateTime(LocalDateTime.now()); |
| | | // 设置é»è®¤å¼ |
| | | if (baseParam.getIsRequired() == null) baseParam.setIsRequired(0); |
| | | if (baseParam.getValueMode() == null) baseParam.setValueMode(1); |
| | | |
| | | return baseMapper.insert(baseParam); |
| | | } |
| | | |
| | | @Override |
| | | public int updateBaseParam(BaseParam baseParam) { |
| | | if (baseParam == null || baseParam.getId() == null) { |
| | | throw new RuntimeException("ä¿®æ¹åæ°IDä¸è½ä¸ºç©º"); |
| | | } |
| | | // åæ°æ ¡éª |
| | | checkBaseParam(baseParam); |
| | | baseParam.setUpdateUser(SecurityUtils.getUsername()); |
| | | baseParam.setUpdateTime(LocalDateTime.now()); |
| | | |
| | | return baseMapper.updateById(baseParam); |
| | | } |
| | | |
| | | /** |
| | | * åæ°å®ä¹åæ³æ ¡éª |
| | | */ |
| | | private void checkBaseParam(BaseParam baseParam) { |
| | | if (StringUtils.isEmpty(baseParam.getParamName())) { |
| | | throw new RuntimeException("åæ°åç§°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | // ç±»åæ ¡éª (1:æ°å, 2:ææ¬, 3:䏿鿩, 4:æ¥ææ¶é´) |
| | | List<Integer> validTypes = Arrays.asList(1, 2, 3, 4); |
| | | if (baseParam.getParamType() == null || !validTypes.contains(baseParam.getParamType())) { |
| | | throw new RuntimeException("éæ³åæ°ç±»å"); |
| | | } |
| | | |
| | | // å¦ææ¯æ¥æç±»åï¼æ ¡éªæ¥ææ ¼å¼é
ç½® |
| | | if (Integer.valueOf(4).equals(baseParam.getParamType())) { |
| | | if (StringUtils.isEmpty(baseParam.getParamFormat())) { |
| | | throw new RuntimeException("æ¥æç±»åå¿
é¡»é
ç½®åæ°æ ¼å¼(å¦: yyyy-MM-dd)"); |
| | | } |
| | | try { |
| | | String standardPattern = normalizePattern(baseParam.getParamFormat()); |
| | | DateTimeFormatter.ofPattern(standardPattern); |
| | | baseParam.setParamFormat(standardPattern); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("æ¥ææ ¼å¼éæ³: " + baseParam.getParamFormat()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * çæåæ°å¯ä¸key (PARAM_XXX) |
| | | */ |
| | | private String generateParamKey() { |
| | | String prefix = "PARAM_"; |
| | | LambdaQueryWrapper<BaseParam> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(BaseParam::getParamKey) |
| | | .likeRight(BaseParam::getParamKey, prefix) |
| | | .orderByDesc(BaseParam::getParamKey) |
| | | .last("limit 1"); |
| | | |
| | | BaseParam last = baseMapper.selectOne(wrapper); |
| | | int nextNum = 1; |
| | | if (last != null && StringUtils.isNotEmpty(last.getParamKey())) { |
| | | try { |
| | | String numStr = last.getParamKey().replace(prefix, ""); |
| | | nextNum = Integer.parseInt(numStr) + 1; |
| | | } catch (Exception e) { |
| | | log.error("è§£æParamKeyå¼å¸¸", e); |
| | | } |
| | | } |
| | | return prefix + String.format("%04d", nextNum); |
| | | } |
| | | |
| | | /** |
| | | * æ¥ææ ¼å¼å |
| | | */ |
| | | private String normalizePattern(String pattern) { |
| | | if (StringUtils.isEmpty(pattern)) return "yyyy-MM-dd"; |
| | | return pattern.replace("YYYY", "yyyy") |
| | | .replace("DD", "dd") |
| | | .replace("SS", "ss"); |
| | | } |
| | | |
| | | /** |
| | | * 转æ¢ä¸ºå
¨å¤§åæ¾ç¤º |
| | | */ |
| | | private String toUpperCasePattern(String pattern) { |
| | | if (StringUtils.isEmpty(pattern)) return ""; |
| | | return pattern.replace("yyyy", "YYYY") |
| | | .replace("dd", "DD") |
| | | .replace("ss", "SS"); |
| | | } |
| | | |
| | | @Override |
| | | public int deleteBaseParamByIds(Long[] ids) { |
| | | if (ids == null || ids.length == 0) { |
| | | throw new RuntimeException("å é¤IDä¸è½ä¸ºç©º"); |
| | | } |
| | | return baseMapper.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.util.AliDingUtils; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.production.enums.MaterialConfigTypeEnum; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.productionPlan.enums.DataSourceTypeEnum; |
| | | import com.ruoyi.productionPlan.pojo.ProductionPlan; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | |
| | | private CustomerFollowUpFileService customerFollowUpFileService; |
| | | |
| | | private CustomerReturnVisitService customerReturnVisitService; |
| | | |
| | | private AliDingConfig aliDingConfig; |
| | | |
| | | /** |
| | | * 忥éï¼é²æ¢æå¨å宿¶ä»»å¡åæ¶æ§è¡ |
| | | */ |
| | | private final ReentrantLock syncLock = new ReentrantLock(); |
| | | |
| | | /** |
| | | * æ¥è¯¢å®¢æ·æ¡£æ¡ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void syncCustomerJob() { |
| | | syncCustomerData(2); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> customerList(Customer customer) { |
| | | LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber); |
| | |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * åæ¥æ°æ® |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void syncCustomerData(Integer dataSyncType) { |
| | | if (!syncLock.tryLock()) { |
| | | log.warn("忥æ£å¨è¿è¡ä¸ï¼æ¬æ¬¡ {} åæ¥è¯·æ±è¢«è·³è¿", dataSyncType == 1 ? "æå¨" : "宿¶ä»»å¡"); |
| | | return; |
| | | } |
| | | try { |
| | | JSONArray searchConditions = new JSONArray(); |
| | | JSONObject statusCondition = new JSONObject(); |
| | | statusCondition.put("key", "processInstanceStatus"); |
| | | JSONArray statusValueArray = new JSONArray(); |
| | | statusValueArray.add("COMPLETED"); |
| | | statusCondition.put("value", statusValueArray); |
| | | statusCondition.put("type", "ARRAY"); |
| | | statusCondition.put("operator", "in"); |
| | | statusCondition.put("componentName", "SelectField"); |
| | | searchConditions.add(statusCondition); |
| | | |
| | | JSONObject resultCondition = new JSONObject(); |
| | | resultCondition.put("key", "processApprovedResult"); |
| | | JSONArray resultValueArray = new JSONArray(); |
| | | resultValueArray.add("agree"); |
| | | resultCondition.put("value", resultValueArray); |
| | | resultCondition.put("type", "ARRAY"); |
| | | resultCondition.put("operator", "in"); |
| | | resultCondition.put("componentName", "SelectField"); |
| | | searchConditions.add(resultCondition); |
| | | |
| | | String searchFieldJson = searchConditions.toJSONString(); |
| | | |
| | | JSONArray dataArr = AliDingUtils.getFormDataList(aliDingConfig, aliDingConfig.getCustomerCodeFormUuid(), searchFieldJson, this, Customer::getFormModifiedTime); |
| | | |
| | | if (dataArr.isEmpty()) { |
| | | log.info("æ²¡ææ´å¤æ°æ°æ®éè¦åæ¥"); |
| | | return; |
| | | } |
| | | |
| | | // è§£æå¹¶ä¿åæ°æ® |
| | | List<Customer> list = parseCustomer(dataArr); |
| | | if (!list.isEmpty()) { |
| | | // å¤çæ´æ°ææ°å¢ |
| | | int affected = processSaveOrUpdate(list); |
| | | log.info("å®¢æ·æ°æ®åæ¥å®æï¼å
±åæ¥ {} æ¡æ°æ®", affected); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("忥客æ·ä¿¡æ¯å¼å¸¸", e); |
| | | } finally { |
| | | // éæ¾é |
| | | syncLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | private List<Customer> parseCustomer(JSONArray dataArr) { |
| | | List<Customer> list = new ArrayList<>(); |
| | | for (int i = 0; i < dataArr.size(); i++) { |
| | | JSONObject item = dataArr.getJSONObject(i); |
| | | String formInstanceId = item.getString("formInstanceId"); |
| | | JSONObject formData = item.getJSONObject("formData"); |
| | | Customer customer = new Customer(); |
| | | customer.setCustomerName(formData.getString("textField_l7fwg8uh")); |
| | | customer.setTaxpayerIdentificationNumber(formData.getString("textField_l88df8ae")); |
| | | customer.setCompanyAddress(formData.getString("textField_l7fwg8uj")); |
| | | customer.setCompanyPhone(formData.getString("textField_lb38bng2")); |
| | | customer.setContactPerson(formData.getString("textField_l7fwg8ut")); |
| | | customer.setContactPhone(formData.getString("textField_l7fwg8uu")); |
| | | customer.setMaintainer("管çåè´¦å·"); |
| | | LocalDateTime dateTime = AliDingUtils.parseUtcTime(item.getString("modifiedTimeGMT")); |
| | | ZoneId zoneId = ZoneId.of("Asia/Shanghai"); |
| | | Date date = Date.from(dateTime.atZone(zoneId).toInstant()); |
| | | customer.setMaintenanceTime(date); |
| | | customer.setFormInstanceId(formInstanceId); |
| | | customer.setFormModifiedTime(dateTime); |
| | | list.add(customer); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private int processSaveOrUpdate(List<Customer> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return 0; |
| | | } |
| | | int affected = 0; |
| | | |
| | | for (Customer customer : list) { |
| | | |
| | | LambdaQueryWrapper<Customer> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Customer::getFormInstanceId, customer.getFormInstanceId()); |
| | | |
| | | Customer exist = this.getOne(wrapper); |
| | | if (exist == null) { |
| | | this.save(customer); |
| | | affected++; |
| | | log.info("æ°å¢å®¢æ·ä¿¡æ¯ {}", customer.getCustomerName()); |
| | | } else { |
| | | if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(customer.getFormModifiedTime())) { |
| | | customer.setId(exist.getId()); |
| | | this.updateById(customer); |
| | | affected++; |
| | | log.info("æ´æ°å®¢æ·ä¿¡æ¯ {}", customer.getCustomerName()); |
| | | } |
| | | } |
| | | } |
| | | return affected; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.task; |
| | | |
| | | import com.ruoyi.basic.service.ICustomerService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | public class CustomerTask { |
| | | |
| | | @Autowired |
| | | private ICustomerService customerService; |
| | | |
| | | @Scheduled(cron = "0 0 * * * ?") |
| | | public void syncCustomerDataJob() { |
| | | customerService.syncCustomerJob(); |
| | | } |
| | | } |
| | |
| | | private String materialCodeFormUuid; |
| | | |
| | | /** |
| | | * 客æ·ä¿¡æ¯-å®æè¡¨åID |
| | | */ |
| | | private String customerCodeFormUuid; |
| | | |
| | | /** |
| | | * 宿åºç¨å¯é¥ |
| | | * ç¨äºè®¿é®å®æè¡¨å API |
| | | */ |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.util; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| | | import com.baomidou.mybatisplus.core.toolkit.support.SerializedLambda; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.time.LocalDateTime; |
| | | import java.time.OffsetDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.format.DateTimeParseException; |
| | | |
| | | /** |
| | | * <br> |
| | | * æ ¹æ®å®æè¡¨å ID è·åæ°æ® |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/14 11:11 |
| | | */ |
| | | @Slf4j |
| | | public class AliDingUtils { |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®è¡¨å ID è·åå®ææ°æ® |
| | | * |
| | | * @param aliDingConfig éé宿æ¥å£é
ç½® |
| | | * @param formUuid è·åæ°æ®ç表åID |
| | | * @param searchFieldJson éè¦æºå¸¦çæ¥è¯¢æ¡ä»¶ |
| | | * @param service è·åæè¿è¡¨åæ´æ°çæ¥æService |
| | | * @param timeField 表åä¿®æ¹æ¥æ |
| | | * @param <T> å®ä½ç±» |
| | | * @return 对åºè¡¨åçæ°æ® |
| | | */ |
| | | public static <T> JSONArray getFormDataList(AliDingConfig aliDingConfig, String formUuid, String searchFieldJson, IService<T> service, SFunction<T, ?> timeField) { |
| | | // è·å accessToken |
| | | String accessToken = getAccessToken(aliDingConfig); |
| | | // è·åæå忥æ¶é´ |
| | | LocalDateTime lastSyncTime = getLastSyncTime(service, timeField); |
| | | log.info("å¼å§åæ¥æ°æ®ï¼æ¬å°æåä¿®æ¹æ¶é´: {}", lastSyncTime); |
| | | |
| | | JSONArray allData = new JSONArray(); |
| | | int pageNumber = 1; |
| | | int pageSize = 50; |
| | | boolean hasMore = true; |
| | | |
| | | while (hasMore) { |
| | | JSONObject searchParam = new JSONObject(); |
| | | searchParam.put("appType", aliDingConfig.getAppType()); |
| | | searchParam.put("systemToken", aliDingConfig.getSystemToken()); |
| | | searchParam.put("userId", aliDingConfig.getUserId()); |
| | | searchParam.put("formUuid", formUuid); |
| | | searchParam.put("currentPage", pageNumber); |
| | | searchParam.put("pageSize", pageSize); |
| | | |
| | | if (StringUtils.isNotEmpty(searchFieldJson)) { |
| | | searchParam.put("searchFieldJson", searchFieldJson); |
| | | } |
| | | |
| | | searchParam.put("orderConfigJson", "{\"gmt_modified\":\"+\"}"); |
| | | |
| | | if (lastSyncTime != null) { |
| | | String startTime = lastSyncTime.plusSeconds(1) |
| | | .atZone(ZoneId.systemDefault()) |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | searchParam.put("modifiedFromTimeGMT", startTime); |
| | | } |
| | | |
| | | String endTime = LocalDateTime.now() |
| | | .atZone(ZoneId.systemDefault()) |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | searchParam.put("modifiedToTimeGMT", endTime); |
| | | |
| | | String dataRes = HttpUtils.sendPostJson( |
| | | aliDingConfig.getSearchFormDataUrl(), |
| | | searchParam.toJSONString(), |
| | | StandardCharsets.UTF_8.name(), |
| | | null, |
| | | accessToken |
| | | ); |
| | | |
| | | if (StringUtils.isEmpty(dataRes)) { |
| | | log.warn("第 {} 页æåæ°æ®ä¸ºç©º", pageNumber); |
| | | break; |
| | | } |
| | | |
| | | JSONObject resultObj = JSON.parseObject(dataRes); |
| | | JSONArray dataArr = resultObj.getJSONArray("data"); |
| | | Integer totalCount = resultObj.getInteger("totalCount"); |
| | | |
| | | if (dataArr == null || dataArr.isEmpty()) { |
| | | log.info("æ²¡ææ´å¤æ°æ°æ®éè¦åæ¥"); |
| | | break; |
| | | } |
| | | allData.addAll(dataArr); |
| | | hasMore = (pageNumber * pageSize) < totalCount; |
| | | pageNumber++; |
| | | |
| | | log.info("æ£å¨æå宿åé¡µæ°æ®ï¼ç¬¬ {} 页已å¤çï¼å½åæåæ°: {}/{}", pageNumber - 1, allData.size(), totalCount); |
| | | } |
| | | |
| | | return allData; |
| | | } |
| | | |
| | | /** |
| | | * è·åéé AccessToken |
| | | */ |
| | | private static String getAccessToken(AliDingConfig aliDingConfig) { |
| | | String params = "appkey=" + aliDingConfig.getAppKey() + "&appsecret=" + aliDingConfig.getAppSecret(); |
| | | String tokenRes = HttpUtils.sendGet(aliDingConfig.getAccessTokenUrl(), params); |
| | | JSONObject tokenObj = JSON.parseObject(tokenRes); |
| | | String accessToken = tokenObj.getString("access_token"); |
| | | if (StringUtils.isEmpty(accessToken)) { |
| | | log.error("è·åééAccessToken失败: {}", tokenRes); |
| | | } |
| | | return accessToken; |
| | | } |
| | | |
| | | /** |
| | | * æ¥ææ ¼å¼å |
| | | * |
| | | * @param utcString æ¥æ |
| | | * @return LocalDateTime |
| | | */ |
| | | public static LocalDateTime parseUtcTime(String utcString) { |
| | | if (StringUtils.isEmpty(utcString)) { |
| | | return null; |
| | | } |
| | | try { |
| | | OffsetDateTime odt = OffsetDateTime.parse(utcString); |
| | | return odt.toLocalDateTime(); |
| | | } catch (DateTimeParseException ex) { |
| | | log.warn("è§£ææ¶é´ {} 失败: {}", utcString, ex.getMessage()); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private static <T> LocalDateTime getLastSyncTime(IService<T> service, SFunction<T, ?> timeField) { |
| | | LambdaQueryWrapper<T> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.orderByDesc(timeField).last("LIMIT 1"); |
| | | T lastRecord = service.getOne(queryWrapper); |
| | | if (lastRecord == null) { |
| | | return null; |
| | | } |
| | | try { |
| | | Method writeReplace = timeField.getClass().getDeclaredMethod("writeReplace"); |
| | | writeReplace.setAccessible(true); |
| | | SerializedLambda lambda = (SerializedLambda) writeReplace.invoke(timeField); |
| | | // è·åæ¹æ³å |
| | | String methodName = lambda.getImplMethodName(); |
| | | // è½¬åæ®µå |
| | | String fieldName = methodName.substring(3, 4).toLowerCase() + methodName.substring(4); |
| | | Field field = lastRecord.getClass().getDeclaredField(fieldName); |
| | | field.setAccessible(true); |
| | | return (LocalDateTime) field.get(lastRecord); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("è·åæå忥æ¶é´å¤±è´¥", e); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.production.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.production.dto.ProductMaterialSkuDto; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.pojo.ProductMaterialSkuImportDto; |
| | | import com.ruoyi.production.dto.ProductMaterialSkuImportDto; |
| | | import com.ruoyi.production.service.ProductMaterialSkuService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @GetMapping("/list") |
| | | @ApiOperation("ç©æè§æ ¼æ°æ®éå") |
| | | @Log(title = "ç©æè§æ ¼æ°æ®éå", businessType = BusinessType.OTHER) |
| | | public AjaxResult productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto) { |
| | | Page<ProductMaterialSkuDto> list = productMaterialSkuService.productMaterialSkuList(page, dto); |
| | | public AjaxResult productMaterialSkuList(Page<ProductMaterialSkuDto> page, ProductMaterialSkuDto dto, @RequestParam(value = "type", required = false) Integer type) { |
| | | Page<ProductMaterialSkuDto> list = productMaterialSkuService.productMaterialSkuList(page, dto, type); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.controller; |
| | | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.production.dto.ProductProcessParamSortDTO; |
| | | import com.ruoyi.production.pojo.ProductProcessParam; |
| | | import com.ruoyi.production.service.ProductProcessParamService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * å·¥åºç»å®åæ°æ§å¶å± |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/14 13:33 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/productProcessParam") |
| | | @Api(tags = "å·¥åºåæ°ç»å®ç®¡ç") |
| | | public class ProductProcessParamController { |
| | | |
| | | @Autowired |
| | | private ProductProcessParamService productProcessParamService; |
| | | |
| | | @GetMapping("/list/{productProcessId}") |
| | | @Log(title = "æ ¹æ®å·¥åºIDæ¥è¯¢å¯¹åºçåæ°", businessType = BusinessType.OTHER) |
| | | @ApiOperation("æ ¹æ®å·¥åºIDæ¥è¯¢å¯¹åºçåæ°") |
| | | public AjaxResult listByProcessId(@PathVariable("productProcessId") Long productProcessId) { |
| | | return AjaxResult.success(productProcessParamService.listByProcessId(productProcessId)); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @Log(title = "æ°å¢å·¥åºç»å®åæ°", businessType = BusinessType.INSERT) |
| | | @ApiOperation("æ°å¢å·¥åºç»å®åæ°") |
| | | public AjaxResult add(@RequestBody ProductProcessParam productProcessParam) { |
| | | productProcessParamService.add(productProcessParam); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PutMapping("/edit") |
| | | @Log(title = "ä¿®æ¹å·¥åºç»å®åæ°", businessType = BusinessType.UPDATE) |
| | | @ApiOperation("ä¿®æ¹å·¥åºç»å®åæ°") |
| | | public AjaxResult edit(@RequestBody ProductProcessParam productProcessParam) { |
| | | productProcessParamService.edit(productProcessParam); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/{ids}") |
| | | @Log(title = "å é¤å·¥åºç»å®åæ°", businessType = BusinessType.DELETE) |
| | | @ApiOperation("å é¤å·¥åºç»å®åæ°") |
| | | public AjaxResult remove(@PathVariable List<Long> ids) { |
| | | productProcessParamService.deleteByIds(ids); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PutMapping("/sort") |
| | | @Log(title = "æ´æ°å·¥åºåæ°æåº", businessType = BusinessType.UPDATE) |
| | | @ApiOperation("æ´æ°å·¥åºåæ°æåº") |
| | | public AjaxResult updateSort(@RequestBody ProductProcessParamSortDTO dto) { |
| | | productProcessParamService.updateSort(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
| | |
| | | |
| | | @ApiOperation("BOMæ¥çåé详æ
") |
| | | @GetMapping("/listBybomId/{bomId}") |
| | | public R listBybomId( @PathVariable("bomId") Integer bomId){ |
| | | return R.ok(productStructureService.listBybomId(bomId)); |
| | | public R listByBomId( @PathVariable("bomId") Integer bomId){ |
| | | return R.ok(productStructureService.listByBomId(bomId)); |
| | | } |
| | | } |
| | |
| | | private Integer inventoryCategoryId; |
| | | |
| | | @ApiModelProperty("ç©æåç§°") |
| | | private String materialName; |
| | | private String productName; |
| | | |
| | | |
| | | } |
| | |
| | | public class ProductMaterialSkuDto { |
| | | |
| | | @ApiModelProperty("ç©æID") |
| | | private Long materialId; |
| | | private Long productId; |
| | | |
| | | @ApiModelProperty("ç©æåç§°") |
| | | private String materialName; |
| | | private String productName; |
| | | |
| | | @ApiModelProperty("ç©æç¼ç ") |
| | | private String materialCode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String baseUnit; |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("è§æ ¼ID") |
| | | private Long skuId; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("è§æ ¼åå·") |
| | | private String specification; |
| | | private String model; |
| | | |
| | | @ApiModelProperty("ä¾åºæ¹å¼") |
| | | private String supplyType; |
| ÎļþÃû´Ó src/main/java/com/ruoyi/production/pojo/ProductMaterialSkuImportDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.production.pojo; |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | |
| | | |
| | | @ApiModelProperty("è§æ ¼åå·") |
| | | @Excel(name = "è§æ ¼åå·") |
| | | private String specification; |
| | | private String model; |
| | | |
| | | @ApiModelProperty("ä¾åºæ¹å¼ï¼èªå¶ï¼å¤è´ï¼") |
| | | @Excel(name = "ä¾åºæ¹å¼") |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <br> |
| | | * å·¥åºç»å®åæ°Dto |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/14 15:33 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ProductProcessParamDto对象", description = "å·¥åºç»å®åæ°Dto") |
| | | public class ProductProcessParamDto { |
| | | |
| | | @ApiModelProperty("主é®ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("æå±å·¥åºID (product_process.id)") |
| | | private Long processId; |
| | | |
| | | @ApiModelProperty("å
³èåºç¡åæ°ID (base_param.id)") |
| | | private Long paramId; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åå¼(å弿¨¡å¼ä½¿ç¨)") |
| | | private String standardValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åæå°å¼(åºé´æ¨¡å¼ä½¿ç¨)") |
| | | private BigDecimal minValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åæå¤§å¼(åºé´æ¨¡å¼ä½¿ç¨)") |
| | | private BigDecimal maxValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºä¸æ¯å¦å¿
å¡«(0-å¦, 1-æ¯)") |
| | | private Integer isRequired; |
| | | |
| | | @ApiModelProperty("æåºå·") |
| | | private Integer sort; |
| | | |
| | | @ApiModelProperty("åæ°åç§°") |
| | | private String paramName; |
| | | |
| | | @ApiModelProperty("åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)") |
| | | private Integer paramType; |
| | | |
| | | @ApiModelProperty("åæ°æ ¼å¼") |
| | | private String paramFormat; |
| | | |
| | | @ApiModelProperty("弿¨¡å¼(1åå¼ 2åºé´)") |
| | | private Integer valueMode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * å·¥åºåæ°æåº DTO |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/14 14:25 |
| | | */ |
| | | @Data |
| | | @ApiModel("å·¥åºåæ°æåºå
¥å") |
| | | public class ProductProcessParamSortDTO { |
| | | |
| | | @ApiModelProperty("æåºé¡¹å表") |
| | | private List<SortItem> items; |
| | | |
| | | @Data |
| | | @ApiModel("æåºé¡¹") |
| | | public static class SortItem { |
| | | |
| | | @ApiModelProperty("è®°å½ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("æåºå·") |
| | | private Integer sort; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.production.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.production.dto.ProductMaterialSkuDto; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | * @since 2026/03/12 10:04 |
| | | */ |
| | | public interface ProductMaterialSkuMapper extends BaseMapper<ProductMaterialSku> { |
| | | } |
| | | |
| | | /** |
| | | * è¿è¡¨æ¥è¯¢ç©æåè§æ ¼ |
| | | */ |
| | | Page<ProductMaterialSkuDto> selectSkuWithMaterialPage(@Param("page") Page<ProductMaterialSkuDto> page, @Param("dto") ProductMaterialSkuDto dto, @Param("type") Integer type); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.production.dto.ProductProcessParamDto; |
| | | import com.ruoyi.production.pojo.ProductProcessParam; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * å·¥åºç»å®åæ° Mapper æ¥å£ |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/14 13:16 |
| | | */ |
| | | public interface ProductProcessParamMapper extends BaseMapper<ProductProcessParam> { |
| | | |
| | | List<ProductProcessParamDto> selectDtoListByProcessId(@Param("processId") Long processId); |
| | | |
| | | |
| | | } |
| | |
| | | @Mapper |
| | | public interface ProductStructureMapper extends BaseMapper<ProductStructure> { |
| | | |
| | | List<ProductStructureDto> listBybomId(@Param("bomId") Integer bomId); |
| | | List<ProductStructureDto> listByBomId(@Param("bomId") Integer bomId); |
| | | |
| | | List<ProductStructureDto> listBybomAndProcess(@Param("bomId") Integer bomId, @Param("processId") Long processId); |
| | | List<ProductStructureDto> listByBomAndProcess(@Param("bomId") Integer bomId, @Param("processId") Long processId); |
| | | } |
| | |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "产åID") |
| | | //product_model |
| | | //å®å¤-ä¸ç建æä½¿ç¨æ°ç产å表å
³èproduct_material_sku |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty(value = "æè¿°") |
| | |
| | | private Long processId; |
| | | |
| | | @ApiModelProperty(value ="产åid") |
| | | //å®å¤-ä¸ç建æä½¿ç¨æ°ç产å表å
³èproduct_material_sku |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | |
| | | private String bomNo; |
| | | |
| | | @ApiModelProperty("产åè§æ ¼id") |
| | | //å®å¤-ä¸ç建æä½¿ç¨æ°ç产å表å
³èproduct_material_sku |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | |
| | | private Integer inventoryCategoryId; |
| | | |
| | | @ApiModelProperty("ç©æåç§°") |
| | | private String materialName; |
| | | private String productName; |
| | | |
| | | @ApiModelProperty("åºæ¬åä½") |
| | | private String baseUnit; |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("ç©æID") |
| | | private Long materialId; |
| | | private Long productId; |
| | | |
| | | @ApiModelProperty("æ è¯ç¼ç ") |
| | | private String identifierCode; |
| | |
| | | private String materialCode; |
| | | |
| | | @ApiModelProperty("è§æ ¼åå·") |
| | | private String specification; |
| | | private String model; |
| | | |
| | | @ApiModelProperty("ä¾åºæ¹å¼ï¼èªå¶ï¼å¤è´ï¼") |
| | | private String supplyType; |
| | |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * ç¶æï¼0-åç¨ï¼1-å¯ç¨ |
| | | */ |
| | | private Boolean status; |
| | | |
| | | |
| | | /** |
| | | * å·¥èµå®é¢ |
| | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @ApiModelProperty(value ="æ¯å¦è´¨æ£") |
| | | @ApiModelProperty(value = "æ¯å¦è´¨æ£") |
| | | private Boolean isQuality; |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * å·¥åºç»å®åæ°å®ä½ç±» |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/14 13:14 |
| | | */ |
| | | @Data |
| | | @TableName("product_process_param") |
| | | @ApiModel(value = "ProductProcessParam对象", description = "å·¥åºç»å®åæ°è¡¨") |
| | | public class ProductProcessParam implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty("主é®ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("æå±å·¥åºID (product_process.id)") |
| | | private Long processId; |
| | | |
| | | @ApiModelProperty("å
³èåºç¡åæ°ID (base_param.id)") |
| | | private Long paramId; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åå¼(å弿¨¡å¼ä½¿ç¨)") |
| | | private String standardValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åæå°å¼(åºé´æ¨¡å¼ä½¿ç¨)") |
| | | private BigDecimal minValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åæå¤§å¼(åºé´æ¨¡å¼ä½¿ç¨)") |
| | | private BigDecimal maxValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºä¸æ¯å¦å¿
å¡«(0-å¦, 1-æ¯)") |
| | | private Integer isRequired; |
| | | |
| | | @ApiModelProperty("æåºå·") |
| | | private Integer sort; |
| | | |
| | | @ApiModelProperty("ç§æ·ID") |
| | | private Long tenantId; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | } |
| | |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("产åid") |
| | | //product_model |
| | | //å®å¤-ä¸ç建æä½¿ç¨æ°ç产å表å
³èproduct_material_sku |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty("æè¿°") |
| | |
| | | private Long processId; |
| | | |
| | | @ApiModelProperty(value ="产åid") |
| | | //å®å¤-ä¸ç建æä½¿ç¨æ°ç产å表å
³èproduct_material_sku |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | |
| | | /** |
| | | * 产ååç§° |
| | | */ |
| | | //å®å¤-ä¸ç建æä½¿ç¨æ°ç产å表å
³èproduct_material_sku |
| | | private Long productModelId; |
| | | |
| | | /** |
| | |
| | | * @since 2026/03/12 10:04 |
| | | */ |
| | | public interface ProductMaterialSkuService extends IService<ProductMaterialSku> { |
| | | Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto); |
| | | Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSkuDto> page, ProductMaterialSkuDto dto, Integer type); |
| | | |
| | | void addProductMaterialSku(ProductMaterialSku productMaterialSku); |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.production.dto.ProductProcessParamDto; |
| | | import com.ruoyi.production.dto.ProductProcessParamSortDTO; |
| | | import com.ruoyi.production.pojo.ProductProcessParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * å·¥åºç»å®åæ°æ¥å£ |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/14 13:17 |
| | | */ |
| | | public interface ProductProcessParamService extends IService<ProductProcessParam> { |
| | | |
| | | List<ProductProcessParamDto> listByProcessId(Long processId); |
| | | |
| | | void add(ProductProcessParam productProcessParam); |
| | | |
| | | void edit(ProductProcessParam productProcessParam); |
| | | |
| | | void deleteByIds(List<Long> ids); |
| | | |
| | | void updateSort(ProductProcessParamSortDTO dto); |
| | | } |
| | |
| | | |
| | | Boolean addProductStructureDto(ProductStructureDto productStructureDto); |
| | | |
| | | List<ProductStructureDto> listBybomId(Integer bomId); |
| | | List<ProductStructureDto> listByBomId(Integer bomId); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.IProductModelService; |
| | | import com.ruoyi.basic.service.IProductService; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | import com.ruoyi.production.pojo.ProductBom; |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | import com.ruoyi.production.service.ProductBomService; |
| | | import com.ruoyi.production.service.ProductProcessService; |
| | | import com.ruoyi.production.service.ProductStructureService; |
| | | import com.ruoyi.production.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | public class ProductBomServiceImpl extends ServiceImpl<ProductBomMapper, ProductBom> implements ProductBomService { |
| | | |
| | | @Autowired |
| | | private IProductService productService; |
| | | |
| | | @Autowired |
| | | private ProductBomMapper productBomMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private IProductModelService productModelService; |
| | | |
| | | @Autowired |
| | | private ProductStructureService productStructureService; |
| | | |
| | | @Autowired |
| | | private ProductProcessService productProcessService; |
| | | |
| | | @Autowired |
| | | private ProductMaterialService productMaterialService; |
| | | |
| | | @Autowired |
| | | private ProductMaterialSkuService productMaterialSkuService; |
| | | |
| | | @Override |
| | | public IPage<ProductBomDto> listPage(Page page, ProductBomDto productBomDto) { |
| | |
| | | throw new ServiceException("è¯·éæ©äº§åæ¨¡å"); |
| | | } |
| | | |
| | | ProductModel productModel = productModelService.getById(productBom.getProductModelId()); |
| | | ProductMaterialSku productModel = productMaterialSkuService.getById(productBom.getProductModelId()); |
| | | if (productModel == null) { |
| | | throw new ServiceException("éæ©çäº§åæ¨¡åä¸åå¨"); |
| | | } |
| | | ProductMaterial productMaterial = productMaterialService.getById(productModel.getProductId()); |
| | | |
| | | // æ·»å åå§ç产åç»æ |
| | | ProductStructure productStructure = new ProductStructure(); |
| | | productStructure.setProductModelId(productBom.getProductModelId()); |
| | | productStructure.setUnit(productModel.getUnit()); |
| | | productStructure.setUnit(productMaterial != null ? productMaterial.getUnit() : null); |
| | | productStructure.setUnitQuantity(BigDecimal.valueOf(1)); |
| | | productStructure.setBomId(productBom.getId()); |
| | | |
| | |
| | | |
| | | // å建 BOM æ°æ® |
| | | BomImportDto first = list.get(0); |
| | | ProductModel rootModel = findModel(first.getParentName(), first.getParentSpec()); |
| | | ProductMaterialSku rootModel = findModel(first.getParentName(), first.getParentSpec()); |
| | | ProductBom bom = new ProductBom(); |
| | | bom.setProductModelId(rootModel.getId()); |
| | | bom.setVersion("1.0"); |
| | |
| | | rootNode.setParentId(null); // 顶屿²¡æç¶èç¹ |
| | | rootNode.setProductModelId(rootModel.getId()); |
| | | rootNode.setUnitQuantity(BigDecimal.ONE); |
| | | rootNode.setUnit(rootModel.getUnit()); |
| | | ProductMaterial rootMaterial = productMaterialService.getById(rootModel.getProductId()); |
| | | rootNode.setUnit(rootMaterial != null ? rootMaterial.getUnit() : null); |
| | | productStructureService.save(rootNode); |
| | | |
| | | treePathMap.put(parentKey, rootNode.getId()); |
| | |
| | | } |
| | | |
| | | // è·åå项模åä¿¡æ¯ |
| | | ProductModel childModel = findModel(dto.getChildName(), dto.getChildSpec()); |
| | | ProductMaterialSku childModel = findModel(dto.getChildName(), dto.getChildSpec()); |
| | | |
| | | // æå
¥ç»æè¡¨ |
| | | ProductStructure node = new ProductStructure(); |
| | |
| | | node.setParentId(parentStructureId); // ç¶èç¹ID |
| | | node.setProductModelId(childModel.getId()); |
| | | node.setUnitQuantity(dto.getUnitQty()); |
| | | node.setUnit(childModel.getUnit()); |
| | | ProductMaterial childMaterial = productMaterialService.getById(childModel.getProductId()); |
| | | node.setUnit(childMaterial != null ? childMaterial.getUnit() : null); |
| | | if (processMap.containsKey(dto.getProcess())) { |
| | | node.setProcessId(processMap.get(dto.getProcess())); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | List<ProductStructureDto> treeData = productStructureService.listBybomId(bomId); |
| | | List<ProductStructureDto> treeData = productStructureService.listByBomId(bomId); |
| | | if (treeData == null || treeData.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private ProductModel findModel(String name, String spec) { |
| | | Product product = productService.getOne(new LambdaQueryWrapper<Product>() |
| | | .eq(Product::getProductName, name).last("limit 1")); |
| | | private ProductMaterialSku findModel(String name, String spec) { |
| | | ProductMaterial product = productMaterialService.getOne(new LambdaQueryWrapper<ProductMaterial>() |
| | | .eq(ProductMaterial::getProductName, name).last("limit 1")); |
| | | if (product == null) throw new ServiceException("äº§åæªç»´æ¤ï¼" + name); |
| | | |
| | | ProductModel model = productModelService.getOne(new LambdaQueryWrapper<ProductModel>() |
| | | .eq(ProductModel::getProductId, product.getId()) |
| | | .eq(ProductModel::getModel, spec).last("limit 1")); |
| | | ProductMaterialSku model = productMaterialSkuService.getOne(new LambdaQueryWrapper<ProductMaterialSku>() |
| | | .eq(ProductMaterialSku::getProductId, product.getId()) |
| | | .eq(ProductMaterialSku::getModel, spec).last("limit 1")); |
| | | if (model == null) throw new ServiceException("è§æ ¼æªç»´æ¤ï¼" + name + "[" + spec + "]"); |
| | | return model; |
| | | } |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.framework.util.AliDingUtils; |
| | | import com.ruoyi.production.dto.ProductMaterialDto; |
| | | import com.ruoyi.production.dto.ProductMaterialGroupDto; |
| | | import com.ruoyi.production.enums.MaterialConfigTypeEnum; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.time.LocalDateTime; |
| | | import java.time.OffsetDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.format.DateTimeParseException; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | } |
| | | |
| | | try { |
| | | // è·å AccessToken |
| | | String accessToken = getAccessToken(); |
| | | if (StringUtils.isEmpty(accessToken)) { |
| | | |
| | | |
| | | JSONArray searchConditions = new JSONArray(); |
| | | JSONObject statusCondition = new JSONObject(); |
| | | statusCondition.put("key", "processInstanceStatus"); |
| | | JSONArray statusValueArray = new JSONArray(); |
| | | statusValueArray.add("COMPLETED"); |
| | | statusCondition.put("value", statusValueArray); |
| | | statusCondition.put("type", "ARRAY"); |
| | | statusCondition.put("operator", "in"); |
| | | statusCondition.put("componentName", "SelectField"); |
| | | searchConditions.add(statusCondition); |
| | | |
| | | JSONObject resultCondition = new JSONObject(); |
| | | resultCondition.put("key", "processApprovedResult"); |
| | | JSONArray resultValueArray = new JSONArray(); |
| | | resultValueArray.add("agree"); |
| | | resultCondition.put("value", resultValueArray); |
| | | resultCondition.put("type", "ARRAY"); |
| | | resultCondition.put("operator", "in"); |
| | | resultCondition.put("componentName", "SelectField"); |
| | | searchConditions.add(resultCondition); |
| | | |
| | | String searchFieldJson = searchConditions.toJSONString(); |
| | | |
| | | JSONArray dataArr = AliDingUtils.getFormDataList(aliDingConfig, aliDingConfig.getMaterialCodeFormUuid(), searchFieldJson, productMaterialSkuService, ProductMaterialSku::getFormModifiedTime); |
| | | |
| | | if (dataArr.isEmpty()) { |
| | | log.info("æ²¡ææ´å¤æ°æ°æ®éè¦åæ¥"); |
| | | return; |
| | | } |
| | | |
| | | // è·åæ¬å°æå忥æ¶é´ |
| | | LocalDateTime lastSyncTime = getLastSyncTime(); |
| | | log.info("å¼å§ç©æç¼ç å¢éåæ¥ï¼æ¬å°æåä¿®æ¹æ¶é´: {}", lastSyncTime); |
| | | |
| | | int pageNumber = 1; |
| | | int pageSize = 50; |
| | | boolean hasMore = true; |
| | | int totalSynced = 0; |
| | | |
| | | while (hasMore) { |
| | | // æ¥è¯¢åæ° |
| | | JSONObject searchParam = buildSearchParam(lastSyncTime, pageNumber, pageSize); |
| | | |
| | | // è°ç¨å®ææ¥å£æåæ°æ® |
| | | String dataRes = HttpUtils.sendPostJson(aliDingConfig.getSearchFormDataUrl(), searchParam.toJSONString(), StandardCharsets.UTF_8.name(), null, accessToken); |
| | | |
| | | if (StringUtils.isEmpty(dataRes)) { |
| | | log.warn("第 {} 页æåæ°æ®ä¸ºç©º", pageNumber); |
| | | break; |
| | | } |
| | | |
| | | JSONObject resultObj = JSON.parseObject(dataRes); |
| | | JSONArray dataArr = resultObj.getJSONArray("data"); |
| | | Integer totalCount = resultObj.getInteger("totalCount"); |
| | | |
| | | if (dataArr == null || dataArr.isEmpty()) { |
| | | log.info("æ²¡ææ´å¤æ°æ°æ®éè¦åæ¥"); |
| | | break; |
| | | } |
| | | |
| | | // è§£æå¹¶ä¿åæ°æ® |
| | | List<ProductMaterialSku> list = parseProductMaterials(dataArr, totalCount); |
| | | if (!list.isEmpty()) { |
| | | // å¤çæ´æ°ææ°å¢ |
| | | int affected = processSaveOrUpdate(list); |
| | | totalSynced += affected; |
| | | } |
| | | |
| | | // 夿æ¯å¦è¿æä¸ä¸é¡µ |
| | | hasMore = (pageNumber * pageSize) < totalCount; |
| | | pageNumber++; |
| | | |
| | | log.info("æ£å¨åæ¥ç¬¬ {} 页ï¼å½å已忥 {}/{}", pageNumber - 1, totalSynced, totalCount); |
| | | // è§£æå¹¶ä¿åæ°æ® |
| | | List<ProductMaterialSku> list = parseProductMaterials(dataArr, dataArr.size()); |
| | | if (!list.isEmpty()) { |
| | | // å¤çæ´æ°ææ°å¢ |
| | | int affected = processSaveOrUpdate(list); |
| | | log.info("ç©ææ°æ®åæ¥å®æï¼å
±åæ¥ {} æ¡æ°æ®", affected); |
| | | } |
| | | |
| | | log.info("ç©ææ°æ®åæ¥å®æï¼å
±åæ¥ {} æ¡æ°æ®", totalSynced); |
| | | } catch (Exception e) { |
| | | log.error("åæ¥ç©æç¼ç å¼å¸¸", e); |
| | | } finally { |
| | | // éæ¾é |
| | | syncLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | private String getAccessToken() { |
| | | String params = "appkey=" + aliDingConfig.getAppKey() + "&appsecret=" + aliDingConfig.getAppSecret(); |
| | | String tokenRes = HttpUtils.sendGet(aliDingConfig.getAccessTokenUrl(), params); |
| | | JSONObject tokenObj = JSON.parseObject(tokenRes); |
| | | String accessToken = tokenObj.getString("access_token"); |
| | | if (StringUtils.isEmpty(accessToken)) { |
| | | log.error("è·åééAccessToken失败: {}", tokenRes); |
| | | } |
| | | return accessToken; |
| | | } |
| | | |
| | | private LocalDateTime getLastSyncTime() { |
| | | LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.orderByDesc(ProductMaterialSku::getFormModifiedTime).last("LIMIT 1"); |
| | | ProductMaterialSku lastRecord = productMaterialSkuService.getOne(queryWrapper); |
| | | return lastRecord != null ? lastRecord.getFormModifiedTime() : null; |
| | | } |
| | | |
| | | private JSONObject buildSearchParam(LocalDateTime lastSyncTime, int pageNumber, int pageSize) { |
| | | JSONObject searchParam = new JSONObject(); |
| | | searchParam.put("appType", aliDingConfig.getAppType()); |
| | | searchParam.put("systemToken", aliDingConfig.getSystemToken()); |
| | | searchParam.put("userId", aliDingConfig.getUserId()); |
| | | searchParam.put("formUuid", aliDingConfig.getMaterialCodeFormUuid()); |
| | | searchParam.put("currentPage", pageNumber); |
| | | searchParam.put("pageSize", pageSize); |
| | | |
| | | JSONArray searchConditions = new JSONArray(); |
| | | JSONObject statusCondition = new JSONObject(); |
| | | statusCondition.put("key", "processInstanceStatus"); |
| | | JSONArray statusValueArray = new JSONArray(); |
| | | statusValueArray.add("COMPLETED"); |
| | | statusCondition.put("value", statusValueArray); |
| | | statusCondition.put("type", "ARRAY"); |
| | | statusCondition.put("operator", "in"); |
| | | statusCondition.put("componentName", "SelectField"); |
| | | searchConditions.add(statusCondition); |
| | | |
| | | JSONObject resultCondition = new JSONObject(); |
| | | resultCondition.put("key", "processApprovedResult"); |
| | | JSONArray resultValueArray = new JSONArray(); |
| | | resultValueArray.add("agree"); |
| | | resultCondition.put("value", resultValueArray); |
| | | resultCondition.put("type", "ARRAY"); |
| | | resultCondition.put("operator", "in"); |
| | | resultCondition.put("componentName", "SelectField"); |
| | | searchConditions.add(resultCondition); |
| | | |
| | | searchParam.put("searchFieldJson", searchConditions.toJSONString()); |
| | | searchParam.put("orderConfigJson", "{\"gmt_modified\":\"+\"}"); |
| | | |
| | | if (lastSyncTime != null) { |
| | | String startTime = lastSyncTime.plusSeconds(1).atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | searchParam.put("modifiedFromTimeGMT", startTime); |
| | | } |
| | | |
| | | String endTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | searchParam.put("modifiedToTimeGMT", endTime); |
| | | |
| | | return searchParam; |
| | | } |
| | | |
| | | private List<ProductMaterialSku> parseProductMaterials(JSONArray dataArr, Integer totalCount) { |
| | |
| | | JSONObject formData = item.getJSONObject("formData"); |
| | | // å¤çç©æä¸»è¡¨æ°æ® |
| | | ProductMaterial material = new ProductMaterial(); |
| | | material.setMaterialName(formData.getString("textField_l92f36f5")); |
| | | material.setBaseUnit(formData.getString("textField_la147lnw")); |
| | | material.setProductName(formData.getString("textField_l92f36f5")); |
| | | material.setUnit(formData.getString("textField_la147lnw")); |
| | | material.setRemark(formData.getString("textareaField_l92f36f9")); |
| | | |
| | | String materialType = formData.getString("selectField_l92f36fb"); |
| | |
| | | |
| | | // å¤çç©æè§æ ¼æ°æ® |
| | | ProductMaterialSku sku = new ProductMaterialSku(); |
| | | sku.setMaterialId(materialId); |
| | | sku.setProductId(materialId); |
| | | sku.setFormInstanceId(formInstanceId); |
| | | sku.setIdentifierCode(formData.getString("textField_l92h77ju")); |
| | | sku.setMaterialCode(formData.getString("textField_l92f36f2")); |
| | | sku.setSpecification(formData.getString("textField_l92f36f6")); |
| | | sku.setModel(formData.getString("textField_l92f36f6")); |
| | | sku.setSupplyType(formData.getString("selectField_la14k51j")); |
| | | sku.setOriginatorName(originatorName); |
| | | sku.setOriginatorOrg("å®å¤ä¸å绿è½å®ä¸é墿éå
¬å¸"); |
| | | sku.setFormModifiedTime(parseUtcTime(item.getString("modifiedTimeGMT"))); |
| | | sku.setFormModifiedTime(AliDingUtils.parseUtcTime(item.getString("modifiedTimeGMT"))); |
| | | sku.setCreateTime(now); |
| | | sku.setUpdateTime(now); |
| | | |
| | |
| | | |
| | | private Long getOrCreateMaterial(ProductMaterial material) { |
| | | LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterial::getMaterialName, material.getMaterialName()); |
| | | queryWrapper.eq(ProductMaterial::getProductName, material.getProductName()); |
| | | |
| | | ProductMaterial exist = this.getOne(queryWrapper); |
| | | if (exist == null) { |
| | |
| | | exist.setInventoryCategoryId(material.getInventoryCategoryId()); |
| | | needUpdate = true; |
| | | } |
| | | if (StringUtils.isNotEmpty(material.getBaseUnit()) && !material.getBaseUnit().equals(exist.getBaseUnit())) { |
| | | exist.setBaseUnit(material.getBaseUnit()); |
| | | if (StringUtils.isNotEmpty(material.getUnit()) && !material.getUnit().equals(exist.getUnit())) { |
| | | exist.setUnit(material.getUnit()); |
| | | needUpdate = true; |
| | | } |
| | | if (needUpdate) { |
| | |
| | | for (ProductMaterialSku sku : list) { |
| | | |
| | | LambdaQueryWrapper<ProductMaterialSku> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ProductMaterialSku::getMaterialId, sku.getMaterialId()) |
| | | .eq(ProductMaterialSku::getSpecification, sku.getSpecification()); |
| | | wrapper.eq(ProductMaterialSku::getProductId, sku.getProductId()) |
| | | .eq(ProductMaterialSku::getModel, sku.getModel()); |
| | | |
| | | if (StringUtils.isNotEmpty(sku.getMaterialCode())) { |
| | | wrapper.eq(ProductMaterialSku::getMaterialCode, sku.getMaterialCode()); |
| | |
| | | if (exist == null) { |
| | | productMaterialSkuService.save(sku); |
| | | affected++; |
| | | log.info("æ°å¢ç©æè§æ ¼ {}", sku.getSpecification()); |
| | | log.info("æ°å¢ç©æè§æ ¼ {}", sku.getModel()); |
| | | } else { |
| | | if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(sku.getFormModifiedTime())) { |
| | | sku.setId(exist.getId()); |
| | |
| | | productMaterialSkuService.updateById(sku); |
| | | |
| | | affected++; |
| | | log.info("æ´æ°ç©æè§æ ¼ {}", sku.getSpecification()); |
| | | log.info("æ´æ°ç©æè§æ ¼ {}", sku.getModel()); |
| | | } |
| | | } |
| | | } |
| | | return affected; |
| | | } |
| | | |
| | | private LocalDateTime parseUtcTime(String utcString) { |
| | | if (StringUtils.isEmpty(utcString)) { |
| | | return null; |
| | | } |
| | | try { |
| | | OffsetDateTime odt = OffsetDateTime.parse(utcString); |
| | | return odt.toLocalDateTime(); |
| | | } catch (DateTimeParseException ex) { |
| | | log.warn("è§£ææ¶é´ {} 失败: {}", utcString, ex.getMessage()); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | ProductMaterial::getId, |
| | | ProductMaterial::getMaterialTypeId, |
| | | ProductMaterial::getInventoryCategoryId, |
| | | ProductMaterial::getMaterialName |
| | | ProductMaterial::getProductName |
| | | ) |
| | | ); |
| | | materialMap = materialList.stream() |
| | |
| | | ProductMaterial::getId, |
| | | ProductMaterial::getMaterialTypeId, |
| | | ProductMaterial::getInventoryCategoryId, |
| | | ProductMaterial::getMaterialName |
| | | ProductMaterial::getProductName |
| | | ); |
| | | if (StringUtils.isNotEmpty(materialName)) { |
| | | wrapper.like(ProductMaterial::getMaterialName, materialName); |
| | | wrapper.like(ProductMaterial::getProductName, materialName); |
| | | } |
| | | if (materialTypeId != null) { |
| | | wrapper.eq(ProductMaterial::getMaterialTypeId, materialTypeId); |
| | |
| | | private ProductMaterialDto convert(ProductMaterial m) { |
| | | ProductMaterialDto dto = new ProductMaterialDto(); |
| | | dto.setId(m.getId()); |
| | | dto.setMaterialName(m.getMaterialName()); |
| | | dto.setProductName(m.getProductName()); |
| | | dto.setMaterialTypeId(m.getMaterialTypeId()); |
| | | dto.setInventoryCategoryId(m.getInventoryCategoryId()); |
| | | return dto; |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addProductMaterial(ProductMaterial productMaterial) { |
| | | validateProductMaterial(productMaterial, false); |
| | | if (existsMaterialName(productMaterial.getMaterialName(), null)) { |
| | | if (existsMaterialName(productMaterial.getProductName(), null)) { |
| | | throw new ServiceException("ç©æåç§°å·²åå¨"); |
| | | } |
| | | LocalDateTime now = LocalDateTime.now(); |
| | |
| | | if (!this.save(productMaterial)) { |
| | | throw new ServiceException("æ°å¢ç©æå¤±è´¥"); |
| | | } |
| | | log.info("æ°å¢ç©ææå materialName={}", productMaterial.getMaterialName()); |
| | | log.info("æ°å¢ç©ææå materialName={}", productMaterial.getProductName()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (exist == null) { |
| | | throw new ServiceException("ç©æä¸åå¨"); |
| | | } |
| | | if (existsMaterialName(productMaterial.getMaterialName(), productMaterial.getId())) { |
| | | if (existsMaterialName(productMaterial.getProductName(), productMaterial.getId())) { |
| | | throw new ServiceException("ç©æåç§°å·²åå¨"); |
| | | } |
| | | productMaterial.setUpdateTime(LocalDateTime.now()); |
| | |
| | | if (requireId && productMaterial.getId() == null) { |
| | | throw new ServiceException("主é®IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (StringUtils.isEmpty(productMaterial.getMaterialName())) { |
| | | if (StringUtils.isEmpty(productMaterial.getProductName())) { |
| | | throw new ServiceException("ç©æåç§°ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | |
| | | return false; |
| | | } |
| | | LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterial::getMaterialName, materialName); |
| | | queryWrapper.eq(ProductMaterial::getProductName, materialName); |
| | | if (excludeId != null) { |
| | | queryWrapper.ne(ProductMaterial::getId, excludeId); |
| | | } |
| | |
| | | import com.ruoyi.production.mapper.ProductMaterialSkuMapper; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.pojo.ProductMaterialSkuImportDto; |
| | | import com.ruoyi.production.dto.ProductMaterialSkuImportDto; |
| | | import com.ruoyi.production.service.ProductMaterialSkuService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ProductMaterialSkuServiceImpl |
| | | extends ServiceImpl<ProductMaterialSkuMapper, ProductMaterialSku> |
| | | implements ProductMaterialSkuService { |
| | | public class ProductMaterialSkuServiceImpl extends ServiceImpl<ProductMaterialSkuMapper, ProductMaterialSku> implements ProductMaterialSkuService { |
| | | |
| | | @Autowired |
| | | private ProductMaterialMapper productMaterialMapper; |
| | |
| | | * æ¥è¯¢ç©æè§æ ¼å表 |
| | | */ |
| | | @Override |
| | | public Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto) { |
| | | if (dto == null || dto.getMaterialId() == null) { |
| | | return new Page<>(); |
| | | } |
| | | LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterialSku::getMaterialId, dto.getMaterialId()) |
| | | .like(StringUtils.isNotBlank(dto.getSpecification()), |
| | | ProductMaterialSku::getSpecification, dto.getSpecification()) |
| | | .like(StringUtils.isNotBlank(dto.getMaterialCode()), |
| | | ProductMaterialSku::getMaterialCode, dto.getMaterialCode()) |
| | | .orderByAsc(ProductMaterialSku::getId); |
| | | |
| | | Page<ProductMaterialSku> skuPage = this.page(page, queryWrapper); |
| | | List<ProductMaterialSku> skuList = skuPage.getRecords(); |
| | | if (skuList == null || skuList.isEmpty()) { |
| | | return new Page<>(); |
| | | } |
| | | |
| | | ProductMaterial material = productMaterialMapper.selectById(dto.getMaterialId()); |
| | | String materialName = material != null ? material.getMaterialName() : null; |
| | | String baseUnit = material != null ? material.getBaseUnit() : null; |
| | | List<ProductMaterialSkuDto> result = new ArrayList<>(skuList.size()); |
| | | for (ProductMaterialSku sku : skuList) { |
| | | ProductMaterialSkuDto productMaterialSkuDto = new ProductMaterialSkuDto(); |
| | | productMaterialSkuDto.setMaterialId(dto.getMaterialId()); |
| | | productMaterialSkuDto.setMaterialName(materialName); |
| | | productMaterialSkuDto.setMaterialCode(sku.getMaterialCode()); |
| | | productMaterialSkuDto.setBaseUnit(baseUnit); |
| | | productMaterialSkuDto.setSkuId(sku.getId()); |
| | | productMaterialSkuDto.setSpecification(sku.getSpecification()); |
| | | productMaterialSkuDto.setSupplyType(sku.getSupplyType()); |
| | | result.add(productMaterialSkuDto); |
| | | } |
| | | Page<ProductMaterialSkuDto> dtoPage = new Page<>(); |
| | | dtoPage.setCurrent(skuPage.getCurrent()); |
| | | dtoPage.setSize(skuPage.getSize()); |
| | | dtoPage.setTotal(skuPage.getTotal()); |
| | | dtoPage.setRecords(result); |
| | | return dtoPage; |
| | | public Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSkuDto> page, ProductMaterialSkuDto dto, Integer type) { |
| | | return baseMapper.selectSkuWithMaterialPage(page, dto, type); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void addProductMaterialSku(ProductMaterialSku sku) { |
| | | validateProductMaterialSku(sku, false); |
| | | // æ ¡éªç©ææ¯å¦åå¨ |
| | | ProductMaterial material = productMaterialMapper.selectById(sku.getMaterialId()); |
| | | ProductMaterial material = productMaterialMapper.selectById(sku.getProductId()); |
| | | if (material == null) { |
| | | throw new ServiceException("ç©æä¸åå¨"); |
| | | } |
| | | // æ ¡éªè§æ ¼æ¯å¦éå¤ |
| | | if (existsSameSpecification(sku.getMaterialId(), sku.getSpecification(), null)) { |
| | | if (existsSameSpecification(sku.getProductId(), sku.getModel(), null)) { |
| | | throw new ServiceException("è¯¥ç©æå·²åå¨ç¸åè§æ ¼"); |
| | | } |
| | | LocalDateTime now = LocalDateTime.now(); |
| | |
| | | if (!this.save(sku)) { |
| | | throw new ServiceException("æ°å¢ç©æè§æ ¼å¤±è´¥"); |
| | | } |
| | | log.info("æ°å¢ç©æè§æ ¼æå materialId={}, specification={}", sku.getMaterialId(), sku.getSpecification()); |
| | | log.info("æ°å¢ç©æè§æ ¼æå materialId={}, specification={}", sku.getProductId(), sku.getModel()); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void updateProductMaterialSku(ProductMaterialSku sku) { |
| | | validateProductMaterialSku(sku, true); |
| | | // æ ¡éªè§æ ¼æ¯å¦éå¤ |
| | | if (existsSameSpecification(sku.getMaterialId(), sku.getSpecification(), sku.getId())) { |
| | | if (existsSameSpecification(sku.getProductId(), sku.getModel(), sku.getId())) { |
| | | throw new ServiceException("è¯¥ç©æå·²åå¨ç¸åè§æ ¼"); |
| | | } |
| | | sku.setUpdateTime(LocalDateTime.now()); |
| | |
| | | if (requireId && sku.getId() == null) { |
| | | throw new ServiceException("主é®IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (sku.getMaterialId() == null) { |
| | | if (sku.getProductId() == null) { |
| | | throw new ServiceException("ç©æIDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (StringUtils.isEmpty(sku.getSpecification())) { |
| | | if (StringUtils.isEmpty(sku.getModel())) { |
| | | throw new ServiceException("è§æ ¼ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | |
| | | */ |
| | | private boolean existsSameSpecification(Long materialId, String specification, Long excludeId) { |
| | | LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterialSku::getMaterialId, materialId) |
| | | .eq(ProductMaterialSku::getSpecification, specification); |
| | | queryWrapper.eq(ProductMaterialSku::getProductId, materialId) |
| | | .eq(ProductMaterialSku::getModel, specification); |
| | | if (excludeId != null) { |
| | | queryWrapper.ne(ProductMaterialSku::getId, excludeId); |
| | | } |
| | |
| | | |
| | | Map<String, ProductMaterialSkuImportDto> specMap = new LinkedHashMap<>(); |
| | | for (ProductMaterialSkuImportDto dto : importList) { |
| | | if (dto == null || StringUtils.isEmpty(dto.getSpecification())) { |
| | | if (dto == null || StringUtils.isEmpty(dto.getModel())) { |
| | | continue; |
| | | } |
| | | String specification = dto.getSpecification().trim(); |
| | | String specification = dto.getModel().trim(); |
| | | if (specification.isEmpty()) { |
| | | continue; |
| | | } |
| | |
| | | Set<String> specifications = specMap.keySet(); |
| | | |
| | | List<ProductMaterialSku> existList = this.list(new LambdaQueryWrapper<ProductMaterialSku>() |
| | | .eq(ProductMaterialSku::getMaterialId, materialId) |
| | | .in(ProductMaterialSku::getSpecification, specifications)); |
| | | .eq(ProductMaterialSku::getProductId, materialId) |
| | | .in(ProductMaterialSku::getModel, specifications)); |
| | | Map<String, ProductMaterialSku> existMap = existList.stream() |
| | | .collect(Collectors.toMap(ProductMaterialSku::getSpecification, sku -> sku, (a, b) -> a)); |
| | | .collect(Collectors.toMap(ProductMaterialSku::getModel, sku -> sku, (a, b) -> a)); |
| | | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | List<ProductMaterialSku> saveList = new ArrayList<>(); |
| | |
| | | ProductMaterialSku exist = existMap.get(specification); |
| | | if (exist == null) { |
| | | ProductMaterialSku sku = new ProductMaterialSku(); |
| | | sku.setMaterialId(materialId); |
| | | sku.setSpecification(specification); |
| | | sku.setProductId(materialId); |
| | | sku.setModel(specification); |
| | | sku.setSupplyType(supplyType); |
| | | sku.setCreateTime(now); |
| | | sku.setUpdateTime(now); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.service.BaseParamService; |
| | | import com.ruoyi.production.dto.ProductProcessParamDto; |
| | | import com.ruoyi.production.dto.ProductProcessParamSortDTO; |
| | | import com.ruoyi.production.mapper.ProductProcessParamMapper; |
| | | import com.ruoyi.production.pojo.ProductProcessParam; |
| | | import com.ruoyi.production.service.ProductProcessParamService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * å·¥åºç»å®åæ°æ¥å£å®ç°ç±» |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/14 13:18 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ProductProcessParamServiceImpl extends ServiceImpl<ProductProcessParamMapper, ProductProcessParam> implements ProductProcessParamService { |
| | | |
| | | @Autowired |
| | | private BaseParamService baseParamService; |
| | | |
| | | @Override |
| | | public List<ProductProcessParamDto> listByProcessId(Long processId) { |
| | | if (processId == null) { |
| | | throw new IllegalArgumentException("å·¥åºIDä¸è½ä¸ºç©º"); |
| | | } |
| | | return baseMapper.selectDtoListByProcessId(processId); |
| | | } |
| | | |
| | | @Override |
| | | public void add(ProductProcessParam productProcessParam) { |
| | | if (productProcessParam.getProcessId() == null) { |
| | | throw new IllegalArgumentException("å
³èå·¥åºIDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (productProcessParam.getParamId() == null) { |
| | | throw new IllegalArgumentException("å
³èåºç¡åæ°IDä¸è½ä¸ºç©º"); |
| | | } |
| | | productProcessParam.setCreateTime(new Date()); |
| | | if (!this.save(productProcessParam)) { |
| | | throw new RuntimeException("æ°å¢å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void edit(ProductProcessParam productProcessParam) { |
| | | if (productProcessParam.getId() == null) { |
| | | throw new IllegalArgumentException("IDä¸è½ä¸ºç©º"); |
| | | } |
| | | productProcessParam.setUpdateTime(new Date()); |
| | | if (!this.updateById(productProcessParam)) { |
| | | throw new RuntimeException("ä¿®æ¹å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByIds(List<Long> ids) { |
| | | if (ids == null || ids.isEmpty()) { |
| | | throw new IllegalArgumentException("IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (!this.removeByIds(ids)) { |
| | | throw new RuntimeException("å é¤å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateSort(ProductProcessParamSortDTO dto) { |
| | | if (dto == null || dto.getItems() == null || dto.getItems().isEmpty()) { |
| | | throw new IllegalArgumentException("æåºæ°æ®ä¸è½ä¸ºç©º"); |
| | | } |
| | | List<ProductProcessParam> list = new ArrayList<>(); |
| | | for (ProductProcessParamSortDTO.SortItem item : dto.getItems()) { |
| | | ProductProcessParam param = new ProductProcessParam(); |
| | | param.setId(item.getId()); |
| | | param.setSort(item.getSort()); |
| | | list.add(param); |
| | | } |
| | | this.updateBatchById(list); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<ProductStructureDto> listBybomId(Integer bomId) { |
| | | List<ProductStructureDto> list = productStructureMapper.listBybomId(bomId); |
| | | public List<ProductStructureDto> listByBomId(Integer bomId) { |
| | | List<ProductStructureDto> list = productStructureMapper.listByBomId(bomId); |
| | | |
| | | Map<Long, ProductStructureDto> map = new HashMap<>(); |
| | | for (ProductStructureDto node : list) { |
| | |
| | | productionProductMain.setStatus(0); |
| | | productionProductMainMapper.insert(productionProductMain); |
| | | /*æ°å¢æ¥å·¥æå
¥è¡¨*/ |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomAndProcess(productProcessRoute.getBomId(), productProcess.getId()); |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listByBomAndProcess(productProcessRoute.getBomId(), productProcess.getId()); |
| | | if (productStructureDtos.size() == 0) { |
| | | //å¦æè¯¥å·¥åºæ²¡æäº§åç»æçæå
¥å,é£è¿ä¸ªæå
¥åå产åºåæ¯åä¸ä¸ª |
| | | ProductStructureDto productStructureDto = new ProductStructureDto(); |
| | |
| | | package com.ruoyi.productionPlan.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.framework.util.AliDingUtils; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import com.ruoyi.production.service.ProductMaterialService; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.time.*; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.format.DateTimeParseException; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | |
| | | } |
| | | |
| | | try { |
| | | // è·å AccessToken |
| | | String accessToken = getAccessToken(); |
| | | if (StringUtils.isEmpty(accessToken)) { |
| | | JSONArray searchConditions = new JSONArray(); |
| | | JSONObject condition = new JSONObject(); |
| | | condition.put("key", "processApprovedResult"); |
| | | JSONArray valueArray = new JSONArray(); |
| | | valueArray.add("agree"); |
| | | |
| | | condition.put("value", valueArray); |
| | | condition.put("type", "ARRAY"); |
| | | condition.put("operator", "in"); |
| | | condition.put("componentName", "SelectField"); |
| | | searchConditions.add(condition); |
| | | |
| | | String searchFieldJson = searchConditions.toJSONString(); |
| | | |
| | | JSONArray dataArr = AliDingUtils.getFormDataList(aliDingConfig, aliDingConfig.getProducePlanFormUuid(), searchFieldJson, this, ProductionPlan::getFormModifiedTime); |
| | | |
| | | if (dataArr.isEmpty()) { |
| | | log.info("æ²¡ææ´å¤æ°æ°æ®éè¦åæ¥"); |
| | | return; |
| | | } |
| | | |
| | | // è·åæ¬å°æå忥æ¶é´ |
| | | LocalDateTime lastSyncTime = getLastSyncTime(); |
| | | log.info("å¼å§å¢éåæ¥ï¼æ¬å°æåä¿®æ¹æ¶é´: {}", lastSyncTime); |
| | | |
| | | int pageNumber = 1; |
| | | int pageSize = 50; |
| | | boolean hasMore = true; |
| | | int totalSynced = 0; |
| | | |
| | | while (hasMore) { |
| | | // æ¥è¯¢åæ° |
| | | JSONObject searchParam = buildSearchParam(lastSyncTime, pageNumber, pageSize); |
| | | |
| | | // è°ç¨å®ææ¥å£æåæ°æ® |
| | | String dataRes = HttpUtils.sendPostJson( |
| | | aliDingConfig.getSearchFormDataUrl(), |
| | | searchParam.toJSONString(), |
| | | StandardCharsets.UTF_8.name(), |
| | | null, |
| | | accessToken |
| | | ); |
| | | |
| | | if (StringUtils.isEmpty(dataRes)) { |
| | | log.warn("第 {} 页æåæ°æ®ä¸ºç©º", pageNumber); |
| | | break; |
| | | } |
| | | |
| | | JSONObject resultObj = JSON.parseObject(dataRes); |
| | | JSONArray dataArr = resultObj.getJSONArray("data"); |
| | | Integer totalCount = resultObj.getInteger("totalCount"); |
| | | |
| | | if (dataArr == null || dataArr.isEmpty()) { |
| | | log.info("æ²¡ææ´å¤æ°æ°æ®éè¦åæ¥"); |
| | | break; |
| | | } |
| | | |
| | | // è§£æå¹¶ä¿åæ°æ® |
| | | List<ProductionPlan> list = parseProductionPlans(dataArr, dataSyncType, totalCount); |
| | | if (!list.isEmpty()) { |
| | | // å¤çæ´æ°ææ°å¢ |
| | | int affected = processSaveOrUpdate(list); |
| | | totalSynced += affected; |
| | | } |
| | | |
| | | // 夿æ¯å¦è¿æä¸ä¸é¡µ |
| | | hasMore = (pageNumber * pageSize) < totalCount; |
| | | pageNumber++; |
| | | |
| | | log.info("æ£å¨åæ¥ç¬¬ {} 页ï¼å½å已忥 {}/{}", pageNumber - 1, totalSynced, totalCount); |
| | | // è§£æå¹¶ä¿åæ°æ® |
| | | List<ProductionPlan> list = parseProductionPlans(dataArr, dataSyncType, dataArr.size()); |
| | | if (!list.isEmpty()) { |
| | | // å¤çæ´æ°ææ°å¢ |
| | | int affected = processSaveOrUpdate(list); |
| | | log.info("æ°æ®åæ¥å®æï¼å
±åæ¥ {} æ¡æ°æ®", affected); |
| | | } |
| | | |
| | | log.info("æ°æ®åæ¥å®æï¼å
±åæ¥ {} æ¡æ°æ®", totalSynced); |
| | | } catch (Exception e) { |
| | | log.error("忥ç产计åå¼å¸¸", e); |
| | | } finally { |
| | | // éæ¾é |
| | | syncLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | private String getAccessToken() { |
| | | String params = "appkey=" + aliDingConfig.getAppKey() |
| | | + "&appsecret=" + aliDingConfig.getAppSecret(); |
| | | String tokenRes = HttpUtils.sendGet(aliDingConfig.getAccessTokenUrl(), params); |
| | | JSONObject tokenObj = JSON.parseObject(tokenRes); |
| | | String accessToken = tokenObj.getString("access_token"); |
| | | if (StringUtils.isEmpty(accessToken)) { |
| | | log.error("è·åééAccessToken失败: {}", tokenRes); |
| | | } |
| | | return accessToken; |
| | | } |
| | | |
| | | private LocalDateTime getLastSyncTime() { |
| | | // æ¥è¯¢æ¬å°æ°æ®åºä¸ formModifiedTime æå¤§çè®°å½ |
| | | LambdaQueryWrapper<ProductionPlan> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.orderByDesc(ProductionPlan::getFormModifiedTime).last("LIMIT 1"); |
| | | ProductionPlan lastRecord = this.getOne(queryWrapper); |
| | | return lastRecord != null ? lastRecord.getFormModifiedTime() : null; |
| | | } |
| | | |
| | | private JSONObject buildSearchParam(LocalDateTime lastSyncTime, int pageNumber, int pageSize) { |
| | | JSONObject searchParam = new JSONObject(); |
| | | searchParam.put("appType", aliDingConfig.getAppType()); |
| | | searchParam.put("systemToken", aliDingConfig.getSystemToken()); |
| | | searchParam.put("userId", aliDingConfig.getUserId()); |
| | | searchParam.put("formUuid", aliDingConfig.getProducePlanFormUuid()); |
| | | searchParam.put("currentPage", pageNumber); |
| | | searchParam.put("pageSize", pageSize); |
| | | |
| | | JSONArray searchConditions = new JSONArray(); |
| | | JSONObject condition = new JSONObject(); |
| | | condition.put("key", "processApprovedResult"); |
| | | JSONArray valueArray = new JSONArray(); |
| | | valueArray.add("agree"); |
| | | |
| | | condition.put("value", valueArray); |
| | | condition.put("type", "ARRAY"); |
| | | condition.put("operator", "in"); |
| | | condition.put("componentName", "SelectField"); |
| | | searchConditions.add(condition); |
| | | |
| | | searchParam.put("searchFieldJson", searchConditions.toJSONString()); |
| | | |
| | | // é»è®¤æä¿®æ¹æ¶é´ååºæåºï¼ç¡®ä¿å页æåæ°æ®çè¿ç»æ§ |
| | | // "+" 表示ååºï¼"gmt_modified" æ¯å®æ¹å
ç½®åæ®µ |
| | | searchParam.put("orderConfigJson", "{\"gmt_modified\":\"+\"}"); |
| | | |
| | | // è®¾ç½®ä¿®æ¹æ¶é´çéåºé´ (æ ¼å¼å¿
须为yyyy-MM-dd HH:mm:ss) |
| | | if (lastSyncTime != null) { |
| | | // èµ·å§æ¶é´ï¼ä¸æ¬¡åæ¥å°çæå䏿¡æ°æ®çä¿®æ¹æ¶é´ |
| | | String startTime = lastSyncTime.plusSeconds(1).atZone(ZoneId.systemDefault()) |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | searchParam.put("modifiedFromTimeGMT", startTime); |
| | | } |
| | | |
| | | // æªæ¢æ¶é´ï¼å½åæ¶é´ï¼ç¡®ä¿è·åææ°ç已修æ¹/å·²æ°å¢æ°æ® |
| | | String endTime = LocalDateTime.now().atZone(ZoneId.systemDefault()) |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | searchParam.put("modifiedToTimeGMT", endTime); |
| | | |
| | | return searchParam; |
| | | } |
| | | |
| | | private List<ProductionPlan> parseProductionPlans(JSONArray dataArr, Integer dataSyncType, Integer totalCount) { |
| | |
| | | plan.setModifierName(modifyUser.getJSONObject("userName").getString("nameInChinese")); |
| | | } |
| | | |
| | | plan.setFormCreatedTime(parseUtcTime(item.getString("createdTimeGMT"))); |
| | | plan.setFormModifiedTime(parseUtcTime(item.getString("modifiedTimeGMT"))); |
| | | plan.setFormCreatedTime(AliDingUtils.parseUtcTime(item.getString("createdTimeGMT"))); |
| | | plan.setFormModifiedTime(AliDingUtils.parseUtcTime(item.getString("modifiedTimeGMT"))); |
| | | plan.setDataSourceType(DataSourceTypeEnum.DING_TALK.getCode()); |
| | | plan.setCreateTime(now); |
| | | plan.setUpdateTime(now); |
| | |
| | | } |
| | | } |
| | | return affected; |
| | | } |
| | | |
| | | private LocalDateTime parseUtcTime(String utcString) { |
| | | if (StringUtils.isEmpty(utcString)) { |
| | | return null; |
| | | } |
| | | try { |
| | | OffsetDateTime odt = OffsetDateTime.parse(utcString); |
| | | return odt.toLocalDateTime(); |
| | | } catch (DateTimeParseException ex) { |
| | | log.warn("è§£ææ¶é´ {} 失败: {}", utcString, ex.getMessage()); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty("产åID") |
| | | //å®å¤-ä¸ç建æä½¿ç¨æ°ç产å表å
³èproduct_material_sku |
| | | private Long productId; |
| | | |
| | | @ApiModelProperty("å
³èæ£æµæ å主表id") |
| | |
| | | if (processRoute == null) { |
| | | return R.fail("请å
设置工èºè·¯çº¿"); |
| | | } |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomId(processRoute.getBomId()); |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listByBomId(processRoute.getBomId()); |
| | | if (productStructureDtos.isEmpty()) { |
| | | return R.fail("请å
设置产åç»æ"); |
| | | } |
| | |
| | | app-type: "APP_UY8XMO7GNA8OF08EFNVQ" |
| | | produce-plan-form-uuid: "FORM-4IA66891C5H3QWMDBSGO05C0OX9628GRPYF7L8" |
| | | material-code-form-uuid: "FORM-8I666N718RW4ALO4ETYDDB0U6U8T3EIWTQ0ALL1" |
| | | customer-code-form-uuid: "FORM-4V966QC1M8B5W4Q89M1VL4ZURJ6C3FVA021ALE" |
| | | system-token: "4J766L91OFH3V612E7LG5B4DI8M13MQF9VF7LG4" |
| | | # æ¥å£å°å |
| | | access-token-url: "https://oapi.dingtalk.com/gettoken" |
| | |
| | | |
| | | file: |
| | | temp-dir: /javaWork/product-inventory-management/file/temp/uploads |
| | | upload-dir: /javaWork/product-inventory-management/file/prod/uploads |
| | | upload-dir: /javaWork/product-inventory-management/file/prod/uploads |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.basic.mapper.BaseParamMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.basic.pojo.BaseParam"> |
| | | <id column="id" property="id"/> |
| | | <result column="param_key" property="paramKey"/> |
| | | <result column="param_name" property="paramName"/> |
| | | <result column="param_type" property="paramType"/> |
| | | <result column="param_format" property="paramFormat"/> |
| | | <result column="value_mode" property="valueMode"/> |
| | | <result column="unit" property="unit"/> |
| | | <result column="is_required" property="isRequired"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | </resultMap> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | </resultMap> |
| | | |
| | | <select id="listPage" resultType="com.ruoyi.production.dto.ProductBomDto"> |
| | | select * from (select pb.*, |
| | | pm.model productModelName, |
| | | p.product_name productName |
| | | from product_bom pb |
| | | left join product_model pm on pb.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id)A |
| | | where 1=1 |
| | | <if test="c.productModelName != null"> |
| | | and productModelName = #{c.productModelName} |
| | | SELECT * FROM ( |
| | | SELECT |
| | | pb.*, |
| | | pms.model AS productModelName, |
| | | pm.product_name AS productName |
| | | FROM product_bom pb |
| | | LEFT JOIN product_material_sku pms ON pb.product_model_id = pms.id |
| | | LEFT JOIN product_material pm ON pms.product_id = pm.id |
| | | ) A |
| | | WHERE 1=1 |
| | | <if test="c.productModelName != null and c.productModelName != ''"> |
| | | AND productModelName LIKE CONCAT('%', #{c.productModelName}, '%') |
| | | </if> |
| | | <if test="c.productName != null"> |
| | | and productName = #{c.productName} |
| | | <if test="c.productName != null and c.productName != ''"> |
| | | AND productName LIKE CONCAT('%', #{c.productName}, '%') |
| | | </if> |
| | | <if test="c.bomNo != null"> |
| | | and bom_no = #{c.bomNo} |
| | | <if test="c.bomNo != null and c.bomNo != ''"> |
| | | AND bom_no = #{c.bomNo} |
| | | </if> |
| | | <if test="c.version != null"> |
| | | and version = #{c.version} |
| | | <if test="c.version != null and c.version != ''"> |
| | | AND version = #{c.version} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getById" resultType="com.ruoyi.production.dto.ProductBomDto"> |
| | | select pb.*, |
| | | pm.model productModelName, |
| | | p.product_name productName |
| | | pms.model AS productModelName, |
| | | pm.product_name AS productName |
| | | from product_bom pb |
| | | left join product_model pm on pb.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | left join product_material_sku pms on pb.product_model_id = pms.id |
| | | left join product_material pm on pms.product_id = pm.id |
| | | where pb.id = #{id} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <result property="tenantId" column="tenant_id"/> |
| | | <result property="materialTypeId" column="material_type_id"/> |
| | | <result property="inventoryCategoryId" column="inventory_category_id"/> |
| | | <result property="materialName" column="material_name"/> |
| | | <result property="baseUnit" column="base_unit"/> |
| | | <result property="productName" column="product_name"/> |
| | | <result property="unit" column="unit"/> |
| | | <result property="remark" column="remark"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| | |
| | | |
| | | <resultMap id="ProductMaterialSkuResultMap" type="com.ruoyi.production.pojo.ProductMaterialSku"> |
| | | <id property="id" column="id"/> |
| | | <result property="materialId" column="material_id"/> |
| | | <result property="productId" column="product_id"/> |
| | | <result property="identifierCode" column="identifier_code"/> |
| | | <result property="materialCode" column="material_code"/> |
| | | <result property="specification" column="specification"/> |
| | | <result property="model" column="model"/> |
| | | <result property="supplyType" column="supply_type"/> |
| | | <result property="originatorName" column="originator_name"/> |
| | | <result property="originatorOrg" column="originator_org"/> |
| | |
| | | <result property="updateTime" column="update_time"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectSkuWithMaterialPage" resultType="com.ruoyi.production.dto.ProductMaterialSkuDto"> |
| | | SELECT |
| | | sku.id AS id, |
| | | sku.product_id AS productId, |
| | | sku.material_code AS materialCode, |
| | | sku.model AS model, |
| | | sku.supply_type AS supplyType, |
| | | m.product_name AS productName, |
| | | m.unit AS unit |
| | | FROM product_material_sku sku |
| | | LEFT JOIN product_material m ON sku.product_id = m.id |
| | | <where> |
| | | <if test="dto.productId != null"> |
| | | AND sku.product_id = #{dto.productId} |
| | | </if> |
| | | <if test="dto.model != null and dto.model != ''"> |
| | | AND sku.model LIKE CONCAT('%', #{dto.model}, '%') |
| | | </if> |
| | | <if test="dto.materialCode != null and dto.materialCode != ''"> |
| | | AND sku.material_code LIKE CONCAT('%', #{dto.materialCode}, '%') |
| | | </if> |
| | | |
| | | <if test="type != null and type == 1 and dto.productName != null and dto.productName != ''"> |
| | | AND m.product_name LIKE CONCAT('%', #{dto.productName}, '%') |
| | | </if> |
| | | </where> |
| | | ORDER BY sku.id ASC |
| | | </select> |
| | | |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.production.mapper.ProductProcessParamMapper"> |
| | | |
| | | <resultMap id="ProductProcessParamResult" type="com.ruoyi.production.pojo.ProductProcessParam"> |
| | | <id property="id" column="id"/> |
| | | <result property="processId" column="process_id"/> |
| | | <result property="paramId" column="param_id"/> |
| | | <result property="standardValue" column="standard_value"/> |
| | | <result property="minValue" column="min_value"/> |
| | | <result property="maxValue" column="max_value"/> |
| | | <result property="isRequired" column="is_required"/> |
| | | <result property="sort" column="sort"/> |
| | | <result property="tenantId" column="tenant_id"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectDtoListByProcessId" resultType="com.ruoyi.production.dto.ProductProcessParamDto" |
| | | parameterType="java.lang.Long"> |
| | | SELECT ppp.id, |
| | | ppp.process_id, |
| | | ppp.param_id, |
| | | ppp.standard_value, |
| | | ppp.min_value, |
| | | ppp.max_value, |
| | | ppp.is_required, |
| | | ppp.sort, |
| | | ppp.create_time, |
| | | ppp.update_time, |
| | | bp.param_name, |
| | | bp.param_type, |
| | | bp.param_format, |
| | | bp.value_mode, |
| | | bp.unit |
| | | FROM product_process_param ppp |
| | | LEFT JOIN base_param bp ON ppp.param_id = bp.id |
| | | WHERE ppp.process_id = #{processId} |
| | | ORDER BY ppp.sort ASC |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | <result property="unit" column="unit"/> |
| | | <result property="tenantId" column="tenant_id"/> |
| | | </resultMap> |
| | | <select id="listBybomId" resultType="com.ruoyi.production.dto.ProductStructureDto"> |
| | | |
| | | <select id="listByBomId" resultType="com.ruoyi.production.dto.ProductStructureDto"> |
| | | select ps.*, |
| | | p.product_name, |
| | | pp.name as process_name, |
| | | pm.product_id, |
| | | pm.model |
| | | from |
| | | product_structure ps |
| | | left join product_model pm on ps.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | left join product_process pp on ps.process_id = pp.id |
| | | pm.product_name as product_name, |
| | | pp.name as process_name, |
| | | pms.product_id as product_id, |
| | | pms.model as model |
| | | from product_structure ps |
| | | left join product_material_sku pms on ps.product_model_id = pms.id |
| | | left join product_material pm on pms.product_id = pm.id |
| | | left join product_process pp on ps.process_id = pp.id |
| | | where ps.bom_id = #{bomId} |
| | | order by ps.id |
| | | </select> |
| | | <select id="listBybomAndProcess" resultType="com.ruoyi.production.dto.ProductStructureDto"> |
| | | |
| | | <select id="listByBomAndProcess" resultType="com.ruoyi.production.dto.ProductStructureDto"> |
| | | select ps.*, |
| | | p.product_name, |
| | | pp.name as process_name, |
| | | pm.product_id, |
| | | pm.model |
| | | from |
| | | product_structure ps |
| | | left join product_model pm on ps.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | left join product_process pp on ps.process_id = pp.id |
| | | pm.product_name as product_name, |
| | | pp.name as process_name, |
| | | pms.product_id as product_id, |
| | | pms.model as model |
| | | from product_structure ps |
| | | left join product_material_sku pms on ps.product_model_id = pms.id |
| | | left join product_material pm on pms.product_id = pm.id |
| | | left join product_process pp on ps.process_id = pp.id |
| | | where ps.bom_id = #{bomId} |
| | | and ps.process_id=#{processId} |
| | | and ps.process_id = #{processId} |
| | | order by ps.id |
| | | </select> |
| | | </mapper> |