feat(production): 添加工艺路线管理功能并重构产品结构相关代码
| | |
| | | create table process_route |
| | | ( |
| | | id bigint auto_increment primary key, |
| | | product_id bigint not null default 0 comment '产åid', |
| | | product_model_id bigint not null default 0 comment '产åid', |
| | | description varchar(255) not null default '' comment 'æè¿°', |
| | | tenant_id bigint not null comment 'ç§æ·id', |
| | | create_time datetime null comment 'å½å
¥æ¶é´', |
| | |
| | | ( |
| | | id bigint auto_increment primary key, |
| | | route_id bigint not null default 0 comment 'å·¥èºè·¯çº¿id', |
| | | product_id bigint not null default 0 comment '产åid', |
| | | product_model_id bigint not null default 0 comment '产åid', |
| | | tenant_id bigint not null comment 'ç§æ·id', |
| | | create_time datetime null comment 'å½å
¥æ¶é´', |
| | | update_time datetime null comment 'æ´æ°æ¶é´' |
| | | update_time datetime null comment 'æ´æ°æ¶é´', |
| | | sort bigint not null comment 'æåº' |
| | | ); |
| | |
| | | ( |
| | | id bigint auto_increment |
| | | primary key, |
| | | product_id bigint not null comment '产åid', |
| | | product_model_id bigint not null comment '产åid', |
| | | process_id bigint not null comment 'å·¥åºid', |
| | | unit_quantity numeric(16, 4) not null comment 'åä½äº§åºéè¦æ°é', |
| | | demanded_quantity numeric(16, 4) not null comment 'éæ±æ°é', |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.production.dto.ProcessRouteDto; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import com.ruoyi.production.service.ProcessRouteService; |
| | | 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.Arrays; |
| | | |
| | | @RestController |
| | | @RequestMapping("processRoute") |
| | | @Api(tags = "å·¥èºè·¯çº¿") |
| | | public class ProcessRouteController { |
| | | |
| | | @Autowired |
| | | private ProcessRouteService processRouteService; |
| | | |
| | | @GetMapping("page") |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | public R page(Page<ProcessRouteDto> page, ProcessRouteDto processRouteDto) { |
| | | return R.ok(processRouteService.pageProcessRouteDto(page, processRouteDto)); |
| | | } |
| | | |
| | | @ApiOperation("æ°å¢å·¥èºè·¯çº¿") |
| | | @PostMapping () |
| | | public R add(@RequestBody ProcessRoute processRoute) { |
| | | return R.ok(processRouteService.save(processRoute)); |
| | | } |
| | | @ApiOperation("ä¿®æ¹å·¥èºè·¯çº¿") |
| | | @PutMapping () |
| | | public R update(@RequestBody ProcessRoute processRoute) { |
| | | return R.ok(processRouteService.updateById(processRoute)); |
| | | } |
| | | @ApiOperation("å é¤å·¥èºè·¯çº¿") |
| | | @DeleteMapping("/{ids}") |
| | | public R delete(@PathVariable("ids") Long[] ids) { |
| | | return R.ok(processRouteService.removeBatchByIds(Arrays.asList(ids))); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | @ApiOperation("æ ¹æ®productIdæ¥è¯¢") |
| | | @GetMapping("listByProductId") |
| | | public R listByProductId( Long productId){ |
| | | return R.ok(productStructureService.listByProductId( productId)); |
| | | @GetMapping("listByproductModelId") |
| | | public R listByproductModelId( Long productModelId){ |
| | | return R.ok(productStructureService.listByproductModelId( productModelId)); |
| | | } |
| | | |
| | | @ApiOperation("æ°å¢äº§åç»æ") |
| | | @PostMapping() |
| | | public R add(ProductStructure productStructure){ |
| | | public R add(@RequestBody ProductStructure productStructure){ |
| | | return R.ok(productStructureService.save(productStructure)); |
| | | } |
| | | |
| | | @ApiOperation("ä¿®æ¹äº§åç»æ") |
| | | @PutMapping() |
| | | public R update(ProductStructure productStructure){ |
| | | public R update(@RequestBody ProductStructure productStructure){ |
| | | return R.ok(productStructureService.updateById(productStructure)); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ProcessRouteDto extends ProcessRoute { |
| | | |
| | | @ApiModelProperty(value = "产ååç§°") |
| | | private String speculativeTradingName; |
| | | } |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ProductStructureDto extends ProductStructure { |
| | | |
| | | @ApiModelProperty(value = "å·¥èºåç§°") |
| | | private String processName; |
| | | private String productName; |
| | | @ApiModelProperty(value = "产ååç§°") |
| | | private String speculativeTradingName; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.production.dto.ProcessRouteDto; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | @Mapper |
| | | public interface ProcessRouteMapper extends BaseMapper<ProcessRoute> { |
| | | |
| | | IPage<ProcessRouteDto> pageProcessRouteDto(Page<ProcessRouteDto> page,@Param("c") ProcessRouteDto processRouteDto); |
| | | } |
| | |
| | | |
| | | @Mapper |
| | | public interface ProductStructureMapper extends BaseMapper<ProductStructure> { |
| | | List<ProductStructure> listByProductId(@Param("productId") Long productId); |
| | | List<ProductStructureDto> listByproductModelId(@Param("productModelId") Long productModelId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class ProcessRoute { |
| | | |
| | | @ApiModelProperty(value = "åºå·") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "产åID") |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty(value = "æè¿°") |
| | | private String description; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | @TableField(fill = FieldFill.UPDATE) |
| | | private LocalDateTime updateTime; |
| | | } |
| | |
| | | /** |
| | | * 产ååç§° |
| | | */ |
| | | private Long productId; |
| | | private Long productModelId; |
| | | |
| | | /** |
| | | * å·¥åºid |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.production.dto.ProcessRouteDto; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | |
| | | public interface ProcessRouteService extends IService<ProcessRoute> { |
| | | |
| | | IPage<ProcessRouteDto> pageProcessRouteDto(Page<ProcessRouteDto> page, ProcessRouteDto processRouteDto); |
| | | } |
| | |
| | | package com.ruoyi.production.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | |
| | | import java.util.List; |
| | |
| | | public interface ProductStructureService extends IService<ProductStructure> { |
| | | |
| | | |
| | | List<ProductStructure> listByProductId( Long productId); |
| | | List<ProductStructureDto> listByproductModelId(Long productId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | 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.production.dto.ProcessRouteDto; |
| | | import com.ruoyi.production.mapper.ProcessRouteMapper; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import com.ruoyi.production.service.ProcessRouteService; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | @Slf4j |
| | | public class ProcessRouteServiceImpl extends ServiceImpl<ProcessRouteMapper, ProcessRoute> implements ProcessRouteService { |
| | | |
| | | @Autowired |
| | | private ProcessRouteMapper processRouteMapper; |
| | | |
| | | @Override |
| | | public IPage<ProcessRouteDto> pageProcessRouteDto(Page<ProcessRouteDto> page, ProcessRouteDto processRouteDto) { |
| | | |
| | | return processRouteMapper.pageProcessRouteDto(page, processRouteDto); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.ProductStructureMapper; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | import com.ruoyi.production.service.ProductStructureService; |
| | |
| | | private ProductStructureMapper productStructureMapper; |
| | | |
| | | @Override |
| | | public List<ProductStructure> listByProductId(Long productId) { |
| | | return productStructureMapper.listByProductId( productId); |
| | | public List<ProductStructureDto> listByproductModelId(Long productModelId) { |
| | | return productStructureMapper.listByproductModelId( productModelId); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.ProcessRouteMapper"> |
| | | |
| | | |
| | | <select id="pageProcessRouteDto" resultType="com.ruoyi.production.dto.ProcessRouteDto"> |
| | | select ps.*, pm.speculative_trading_name |
| | | from process_route ps |
| | | left join product_model pm on ps.product_model_id = pm.id |
| | | <where> |
| | | <if test="c.speculativeTradingName != null || c.speculativeTradingName != ''"> |
| | | and pm.speculative_trading_name like concat('%',#{c.speculativeTradingName},'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |
| | |
| | | <mapper namespace="com.ruoyi.production.mapper.ProductStructureMapper"> |
| | | |
| | | |
| | | <select id="listByProductId" resultType="com.ruoyi.production.pojo.ProductStructure"> |
| | | <select id="listByproductModelId" resultType="com.ruoyi.production.dto.ProductStructureDto"> |
| | | select ps.*, |
| | | p.product_name as product_name, |
| | | pm.speculative_trading_name , |
| | | pp.name as process_name |
| | | from |
| | | product_structure ps |
| | | left join product p on ps.process_id = p.id |
| | | left join product_process pp on ps.process_id = pp.process_id |
| | | where p.id = #{productId} |
| | | left join product_model pm on ps.product_model_id = pm.id |
| | | left join product_process pp on ps.process_id = pp.id |
| | | where pm.id = #{productId} |
| | | </select> |
| | | </mapper> |