feat(production): 扩展生产工艺路线支持多产品绑定及工单权限控制
- 给生产工单表增加报工人字段,用于工单级权限判断
- 在工艺路线表中添加BOM ID、工艺路线编号和多产品ID字段
- 在工艺路线明细表中添加多产品ID、拖拽排序和质检标识字段
- 实现产品规格多选绑定功能,支持单产品和多产品的灵活配置
- 增加工艺路线明细查询时的产品筛选功能
- 实现基于报工人ID的工单权限控制机制
- 优化生产订单分页查询,集成用户权限验证逻辑
- 添加BOM根据规格型号ID列表查询接口
- 重构生产订单绑定工艺路线逻辑,支持自定义工序配置
- 规范化产品模型ID处理,统一多产品ID的数据格式转换
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- ç»ç产工åå¢å æ¥å·¥äººå段ï¼ç¨äºå·¥å级æé夿 |
| | | ALTER TABLE product_work_order |
| | | ADD COLUMN report_user_ids varchar(1024) NULL COMMENT 'æ¥å·¥äººidï¼å¤éï¼éå·åé'; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- å·¥èºè·¯çº¿ãå·¥èºè·¯çº¿æç»æ¯æç»å®å¤ä¸ªäº§åï¼2026-04-14ï¼ |
| | | ALTER TABLE process_route |
| | | ADD COLUMN product_model_ids VARCHAR(1024) NULL COMMENT 'å¤äº§åidï¼éå·åé' AFTER product_model_id; |
| | | |
| | | UPDATE process_route |
| | | SET product_model_ids = CAST(product_model_id AS CHAR) |
| | | WHERE (product_model_ids IS NULL OR product_model_ids = '') |
| | | AND product_model_id IS NOT NULL |
| | | AND product_model_id <> 0; |
| | | |
| | | ALTER TABLE process_route_item |
| | | ADD COLUMN product_model_ids VARCHAR(1024) NULL COMMENT 'å¤äº§åidï¼éå·åé' AFTER product_model_id; |
| | | |
| | | UPDATE process_route_item |
| | | SET product_model_ids = CAST(product_model_id AS CHAR) |
| | | WHERE (product_model_ids IS NULL OR product_model_ids = '') |
| | | AND product_model_id IS NOT NULL |
| | | AND product_model_id <> 0; |
| | |
| | | create table process_route |
| | | ( |
| | | id bigint auto_increment primary key, |
| | | bom_id bigint not null default 0 comment 'BOMid', |
| | | product_model_id bigint not null default 0 comment '产åid', |
| | | process_route_code varchar(255) not null default '' comment 'å·¥èºè·¯çº¿ç¼å·', |
| | | product_model_ids varchar(1024) null 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_model_id bigint not null default 0 comment '产åid', |
| | | product_model_ids varchar(1024) null comment 'å¤äº§åidï¼éå·åé', |
| | | drag_sort bigint not null default 0 comment 'ææ½æåº', |
| | | process_id bigint not null default 0 comment 'å·¥åºid', |
| | | is_quality tinyint not null default 0 comment 'æ¯å¦è´¨æ£ 0 䏿¯ 1 æ¯', |
| | | tenant_id bigint not null comment 'ç§æ·id', |
| | | create_time datetime null comment 'å½å
¥æ¶é´', |
| | | update_time datetime null comment 'æ´æ°æ¶é´' |
| | |
| | | ); |
| | | |
| | | alter table product_process |
| | | add salary_quota numeric(16,3) null comment 'å·¥èµå®é¢'; |
| | | add salary_quota numeric(16,3) null comment 'å·¥èµå®é¢'; |
| | |
| | | package com.ruoyi.production.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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.pojo.ProcessRouteItem; |
| | | import com.ruoyi.production.service.ProcessRouteItemService; |
| | | 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.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | @RequestMapping("processRoute") |
| | | @RequestMapping("/processRoute") |
| | | @Api(tags = "å·¥èºè·¯çº¿") |
| | | public class ProcessRouteController { |
| | | |
| | | @Autowired |
| | | private ProcessRouteService processRouteService; |
| | | |
| | | @GetMapping("page") |
| | | @GetMapping("/page") |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | public R page(Page<ProcessRouteDto> page, ProcessRouteDto processRouteDto) { |
| | | public R page(Page<ProcessRouteDto> page, ProcessRouteDto processRouteDto) { |
| | | return R.ok(processRouteService.pageProcessRouteDto(page, processRouteDto)); |
| | | } |
| | | |
| | | @ApiOperation("æ°å¢å·¥èºè·¯çº¿") |
| | | @PostMapping () |
| | | public R add(@RequestBody ProcessRoute processRoute) { |
| | | @PostMapping |
| | | public R add(@RequestBody ProcessRoute processRoute) { |
| | | normalizeProductBinding(processRoute); |
| | | return R.ok(processRouteService.saveProcessRoute(processRoute)); |
| | | } |
| | | |
| | | @ApiOperation("ä¿®æ¹å·¥èºè·¯çº¿") |
| | | @PutMapping () |
| | | public R update(@RequestBody ProcessRoute processRoute) { |
| | | @PutMapping |
| | | public R update(@RequestBody ProcessRoute processRoute) { |
| | | normalizeProductBinding(processRoute); |
| | | return R.ok(processRouteService.updateById(processRoute)); |
| | | } |
| | | |
| | | @ApiOperation("å é¤å·¥èºè·¯çº¿") |
| | | @DeleteMapping("/{ids}") |
| | | public R delete(@PathVariable("ids") Long[] ids) { |
| | | return R.ok(processRouteService.batchDelete(Arrays.asList(ids))); |
| | | } |
| | | |
| | | private void normalizeProductBinding(ProcessRoute processRoute) { |
| | | if (processRoute == null) { |
| | | return; |
| | | } |
| | | String ids = null; |
| | | List<Long> idList = processRoute.getProductModelIdList(); |
| | | if (idList != null && !idList.isEmpty()) { |
| | | ids = idList.stream() |
| | | .filter(item -> item != null && item > 0) |
| | | .distinct() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(",")); |
| | | } else if (StringUtils.hasText(processRoute.getProductModelIds())) { |
| | | ids = Arrays.stream(processRoute.getProductModelIds().split(",")) |
| | | .map(String::trim) |
| | | .filter(StringUtils::hasText) |
| | | .distinct() |
| | | .collect(Collectors.joining(",")); |
| | | } else if (processRoute.getProductModelId() != null) { |
| | | ids = String.valueOf(processRoute.getProductModelId()); |
| | | } |
| | | processRoute.setProductModelIds(ids); |
| | | if (StringUtils.hasText(ids)) { |
| | | processRoute.setProductModelId(Long.valueOf(ids.split(",")[0])); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.production.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | 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.R; |
| | | import com.ruoyi.production.dto.ProcessRouteItemDto; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import com.ruoyi.production.pojo.ProcessRouteItem; |
| | | import com.ruoyi.production.service.ProcessRouteItemService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | @RequestMapping("processRouteItem") |
| | | @Api(tags = "å·¥èºè·¯çº¿æç»") |
| | | public class ProcessRouteItemController { |
| | | |
| | | @Autowired |
| | | private ProcessRouteItemService processRouteItemService; |
| | | |
| | |
| | | return R.ok(processRouteItemService.listProcessRouteItemDto(processRouteItemDto)); |
| | | } |
| | | |
| | | @PostMapping () |
| | | @PostMapping |
| | | @ApiOperation("æ°å¢ä¿®æ¹") |
| | | public R addOrUpdate(@RequestBody ProcessRouteItem processRouteItem) { |
| | | normalizeProductBinding(processRouteItem); |
| | | return R.ok(processRouteItemService.saveOrUpdate(processRouteItem)); |
| | | } |
| | | |
| | | @PostMapping ("/sort") |
| | | @PostMapping("/sort") |
| | | @ApiOperation("æåº") |
| | | public R sort(@RequestBody ProcessRouteItem processRouteItem) { |
| | | return R.ok(processRouteItemService.sort(processRouteItem)); |
| | |
| | | public AjaxResult batchDelete(@PathVariable("id") Long id) { |
| | | return AjaxResult.success(processRouteItemService.batchDelete(id)); |
| | | } |
| | | |
| | | private void normalizeProductBinding(ProcessRouteItem processRouteItem) { |
| | | if (processRouteItem == null) { |
| | | return; |
| | | } |
| | | String ids = null; |
| | | List<Long> idList = processRouteItem.getProductModelIdList(); |
| | | if (idList != null && !idList.isEmpty()) { |
| | | ids = idList.stream() |
| | | .filter(item -> item != null && item > 0) |
| | | .distinct() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(",")); |
| | | } else if (StringUtils.hasText(processRouteItem.getProductModelIds())) { |
| | | ids = Arrays.stream(processRouteItem.getProductModelIds().split(",")) |
| | | .map(String::trim) |
| | | .filter(StringUtils::hasText) |
| | | .distinct() |
| | | .collect(Collectors.joining(",")); |
| | | } else if (processRouteItem.getProductModelId() != null) { |
| | | ids = String.valueOf(processRouteItem.getProductModelId()); |
| | | } |
| | | processRouteItem.setProductModelIds(ids); |
| | | if (StringUtils.hasText(ids)) { |
| | | processRouteItem.setProductModelId(Long.valueOf(ids.split(",")[0])); |
| | | } |
| | | } |
| | | } |
| | |
| | | return AjaxResult.success(productBoms); |
| | | } |
| | | |
| | | @PostMapping("/getByModelList") |
| | | @Log(title = "BOM-æ ¹æ®éæ©çè§æ ¼åå·idsæ¥è¯¢åå¨çbom", businessType = BusinessType.OTHER) |
| | | @ApiOperation("BOM-æ ¹æ®éæ©çè§æ ¼åå·idæ¥è¯¢åå¨çbom") |
| | | public AjaxResult getByModelList(@RequestBody List<Long> productModelId) { |
| | | if (CollectionUtils.isEmpty(productModelId)) return AjaxResult.error("è¯·éæ©è¦æ¥è¯¢çè§æ ¼åå·"); |
| | | List<ProductBom> productBoms = productBomService.list(Wrappers.<ProductBom>lambdaQuery().in(ProductBom::getProductModelId, productModelId)); |
| | | return AjaxResult.success(productBoms); |
| | | } |
| | | |
| | | |
| | | @PostMapping("uploadBom") |
| | | @PreAuthorize("@ss.hasPermi('product:bom:import')") |
| | |
| | | import com.ruoyi.production.dto.ProductWorkOrderDto; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.production.service.ProductWorkOrderService; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | |
| | | @RequestMapping("/productWorkOrder") |
| | | public class ProductWorkOrderController { |
| | | |
| | | private ProductWorkOrderService productWorkOrderservice; |
| | | private final ProductWorkOrderService productWorkOrderservice; |
| | | |
| | | |
| | | /** |
| | | * 产åå·¥åå®ä½ç±»å页æ¥è¯¢ |
| | | */ |
| | | @ApiOperation("产åå·¥åå®ä½ç±»å页æ¥è¯¢") |
| | | @ApiOperation("产åå·¥åå页æ¥è¯¢") |
| | | @GetMapping("/page") |
| | | public R page(Page<ProductWorkOrderDto> page, ProductWorkOrderDto productWorkOrder) { |
| | | return R.ok(productWorkOrderservice.listPage(page, productWorkOrder)); |
| | | } |
| | | |
| | | /** |
| | | * 产åå·¥åæ´æ° |
| | | */ |
| | | @ApiOperation("产å工忴æ°") |
| | | @PostMapping ("/updateProductWorkOrder") |
| | | @PostMapping("/updateProductWorkOrder") |
| | | public R updateProductWorkOrder(@RequestBody ProductWorkOrderDto productWorkOrderDto) { |
| | | return R.ok(productWorkOrderservice.updateProductWorkOrder(productWorkOrderDto)); |
| | | } |
| | | |
| | | /** |
| | | * pdaæ ¹æ®äºç»´ç çå·¥åidæ¥è¯¢æ°æ® |
| | | */ |
| | | @ApiOperation("pdaæ ¹æ®äºç»´ç çå·¥åidæ¥è¯¢æ°æ®") |
| | | @ApiOperation("æ ¹æ®idæ¥è¯¢å·¥å") |
| | | @GetMapping("/getProductWorkOrderById") |
| | | public R getProductWorkOrderById(Long id) { |
| | | return R.ok(productWorkOrderservice.getById(id)); |
| | | return R.ok(productWorkOrderservice.getProductWorkOrderById(id)); |
| | | } |
| | | |
| | | /** |
| | | * å·¥åæµè½¬å¡ä¸è½½ |
| | | * @param response |
| | | * @param productWorkOrder |
| | | */ |
| | | @PostMapping("/down") |
| | | public void down(HttpServletResponse response, @RequestBody ProductWorkOrder productWorkOrder) { |
| | | productWorkOrderservice.down(response, productWorkOrder); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.production.pojo.ProductWorkOrderFile; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @Data |
| | | public class ProductWorkOrderDto extends ProductWorkOrder { |
| | | |
| | | //产ååç§° |
| | | @ApiModelProperty(value = "产ååç§°") |
| | | private String productName; |
| | | |
| | | //è§æ ¼ |
| | | @ApiModelProperty(value = "è§æ ¼") |
| | | private String model; |
| | | |
| | | //å·¥åº |
| | | @ApiModelProperty(value = "å·¥åº") |
| | | private String processName; |
| | | |
| | | //åä½ |
| | | @ApiModelProperty(value = "åä½") |
| | | private String unit; |
| | | |
| | | |
| | | //ç产订åå· |
| | | @ApiModelProperty(value = "ç产订åå·") |
| | | private String productOrderNpsNo; |
| | | |
| | |
| | | |
| | | @ApiModelProperty(value = "å·¥åç±»å æ£å¸¸ /è¿å·¥è¿ä¿®") |
| | | private String workOrderType; |
| | | |
| | | @ApiModelProperty(value = "æ¥å·¥äººåç§°ï¼å¤ä¸ªéå·åé") |
| | | private String reportUserNames; |
| | | } |
| | |
| | | @Mapper |
| | | public interface ProductOrderMapper extends BaseMapper<ProductOrder> { |
| | | |
| | | IPage<ProductOrderDto> pageProductOrder(Page page, @Param("c") ProductOrderDto productOrder); |
| | | default IPage<ProductOrderDto> pageProductOrder(Page page, ProductOrderDto productOrder) { |
| | | return pageProductOrder(page, productOrder, null, true); |
| | | } |
| | | |
| | | IPage<ProductOrderDto> pageProductOrder(Page page, |
| | | @Param("c") ProductOrderDto productOrder, |
| | | @Param("userId") Long userId, |
| | | @Param("isAdmin") Boolean isAdmin); |
| | | |
| | | List<ProcessRoute> listProcessRoute(@Param("productModelId") Long productModelId); |
| | | |
| | |
| | | @Mapper |
| | | public interface ProductWorkOrderMapper extends BaseMapper<ProductWorkOrder> { |
| | | |
| | | IPage<ProductWorkOrderDto> pageProductWorkOrder(Page<ProductWorkOrderDto> page, @Param("c") ProductWorkOrderDto productWorkOrder); |
| | | default IPage<ProductWorkOrderDto> pageProductWorkOrder(Page<ProductWorkOrderDto> page, ProductWorkOrderDto productWorkOrder) { |
| | | return pageProductWorkOrder(page, productWorkOrder, null, true); |
| | | } |
| | | |
| | | IPage<ProductWorkOrderDto> pageProductWorkOrder(Page<ProductWorkOrderDto> page, |
| | | @Param("c") ProductWorkOrderDto productWorkOrder, |
| | | @Param("userId") Long userId, |
| | | @Param("isAdmin") Boolean isAdmin); |
| | | |
| | | Integer checkUserCanAccess(@Param("workOrderId") Long workOrderId, @Param("userId") Long userId); |
| | | |
| | | ProductWorkOrderDto getProductWorkOrderFlowCard(@Param("id") Long id); |
| | | |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @TableName("process_route") |
| | | @Data |
| | | @ApiModel(value = "processRoute", description = "å·¥èºè·¯çº¿ä¸»è¡¨") |
| | | public class ProcessRoute { |
| | | |
| | | @ApiModelProperty(value = "åºå·") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "产åID") |
| | | //product_model |
| | | @ApiModelProperty(value = "产åè§æ ¼IDï¼å
¼å®¹æ§å段ï¼") |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty(value = "å¤äº§åIDï¼éå·åé") |
| | | private String productModelIds; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "å¤äº§åIDå表") |
| | | private List<Long> productModelIdList; |
| | | |
| | | @ApiModelProperty(value = "æè¿°") |
| | | private String description; |
| | |
| | | @ApiModelProperty(value = "å·¥èºè·¯çº¿ç¼ç ") |
| | | private String processRouteCode; |
| | | |
| | | @ApiModelProperty(value = "BOMçID") |
| | | @ApiModelProperty(value = "BOM ID") |
| | | private Integer bomId; |
| | | } |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @TableName("process_route_item") |
| | | @ApiModel(value = "processRouteItem", description = "å·¥èºè·¯çº¿å表") |
| | | @ApiModel(value = "processRouteItem", description = "å·¥èºè·¯çº¿æç»") |
| | | public class ProcessRouteItem { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "å·¥èºè·¯çº¿id") |
| | | @ApiModelProperty(value = "å·¥èºè·¯çº¿ID") |
| | | private Long routeId; |
| | | |
| | | @ApiModelProperty(value = "å·¥åºid") |
| | | @ApiModelProperty(value = "å·¥åºID") |
| | | private Long processId; |
| | | |
| | | @ApiModelProperty(value ="产åid") |
| | | @ApiModelProperty(value = "产åè§æ ¼IDï¼å
¼å®¹æ§å段ï¼") |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty(value = "å¤äº§åIDï¼éå·åé") |
| | | private String productModelIds; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "å¤äº§åIDå表") |
| | | private List<Long> productModelIdList; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | @TableField(fill = FieldFill.UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty(value ="æå¨æåº") |
| | | @ApiModelProperty(value = "æå¨æåº") |
| | | private Integer dragSort; |
| | | |
| | | |
| | | @ApiModelProperty(value ="æ¯å¦è´¨æ£") |
| | | @ApiModelProperty(value = "æ¯å¦è´¨æ£") |
| | | private Boolean isQuality; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.production.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @TableName("product_order") |
| | | public class ProductOrder implements Serializable { |
| | | public class ProductOrder implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * éå®å°è´¦id |
| | | */ |
| | | @ApiModelProperty(value = "éå®å°è´¦id") |
| | | private Long salesLedgerId; |
| | | |
| | | /** |
| | | * éå®å°è´¦äº§åid(sales_ledger_product) |
| | | */ |
| | | @ApiModelProperty(value = "éå®å°è´¦äº§åid") |
| | | private Long saleLedgerProductId; |
| | | |
| | | /** |
| | | * 产åè§æ ¼id |
| | | */ |
| | | @ApiModelProperty(value = "产åè§æ ¼id") |
| | | private Long productModelId; |
| | | |
| | | /** |
| | | * 模ççå·¥èºè·¯çº¿id |
| | | */ |
| | | @ApiModelProperty(value = "å·¥èºè·¯çº¿id") |
| | | private Long routeId; |
| | | |
| | | /** |
| | | * ç产订åå· |
| | | */ |
| | | @ApiModelProperty(value = "ç产订åå·") |
| | | @Excel(name = "ç产订åå·") |
| | | private String npsNo; |
| | | |
| | | /** |
| | | * ç§æ·id |
| | | */ |
| | | @ApiModelProperty(value = "ç§æ·id") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | //å建æ¶é´ |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | |
| | | @Excel(name = "å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | //ä¿®æ¹æ¶é´ |
| | | @ApiModelProperty(value = "ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | |
| | | /** |
| | | * éæ±æ°é |
| | | */ |
| | | @ApiModelProperty(value = "éæ±æ°é") |
| | | @Excel(name = "éæ±æ°é") |
| | | private BigDecimal quantity; |
| | | |
| | | /** |
| | | * 宿æ°é |
| | | */ |
| | | @ApiModelProperty(value = "宿æ°é") |
| | | @Excel(name = "宿æ°é") |
| | | private BigDecimal completeQuantity; |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime endTime; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "åç«¯ä¼ å
¥çå·¥åºå表") |
| | | private List<ProductProcessRouteItem> processRouteItems; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "åç«¯ä¼ å
¥çå·¥èºè·¯çº¿ç¼å·") |
| | | private String processRouteCode; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "åç«¯ä¼ å
¥çBOM id") |
| | | private Integer bomId; |
| | | } |
| | |
| | | package com.ruoyi.production.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "ç产订åid(product_order_id)") |
| | | @ApiModelProperty(value = "ç产订åid") |
| | | private Long productOrderId; |
| | | |
| | | @ApiModelProperty(value = "ç产订åçå·¥èºè·¯çº¿id(product_process_route)") |
| | | @ApiModelProperty(value = "ç产订åçå·¥èºè·¯çº¿id") |
| | | private Long productRouteId; |
| | | |
| | | @ApiModelProperty(value = "å·¥åºid") |
| | | private Long processId; |
| | | |
| | | @ApiModelProperty(value ="产åid") |
| | | @ApiModelProperty(value = "产åè§æ ¼id") |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | | @ApiModelProperty(value = "ç§æ·id") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | @TableField(fill = FieldFill.UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty(value ="æå¨æåº") |
| | | @ApiModelProperty(value = "æå¨æåº") |
| | | private Integer dragSort; |
| | | |
| | | @ApiModelProperty(value ="æ¯å¦è´¨æ£") |
| | | @ApiModelProperty(value = "æ¯å¦è´¨æ£") |
| | | private Boolean isQuality; |
| | | |
| | | @ApiModelProperty(value = "æ¥å·¥äººidï¼å¤éï¼éå·åé") |
| | | @TableField(exist = false) |
| | | private String reportUserIds; |
| | | } |
| | |
| | | @ApiModelProperty(value = "宿æ°é") |
| | | private BigDecimal completeQuantity; |
| | | |
| | | /** |
| | | * æ¥å·¥äººidï¼å¤éï¼éå·åé |
| | | */ |
| | | @ApiModelProperty(value = "æ¥å·¥äººidï¼å¤éï¼éå·åé") |
| | | private String reportUserIds; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | int updateProductWorkOrder(ProductWorkOrderDto productWorkOrderDto); |
| | | |
| | | ProductWorkOrder getProductWorkOrderById(Long id); |
| | | |
| | | void down(HttpServletResponse response, ProductWorkOrder productWorkOrder); |
| | | } |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | |
| | | |
| | | @Override |
| | | public IPage<ProcessRouteDto> pageProcessRouteDto(Page<ProcessRouteDto> page, ProcessRouteDto processRouteDto) { |
| | | |
| | | return processRouteMapper.pageProcessRouteDto(page, processRouteDto); |
| | | } |
| | | |
| | | @Override |
| | | public Integer saveProcessRoute(ProcessRoute processRoute) { |
| | | normalizeProductModelIds(processRoute); |
| | | this.save(processRoute); |
| | | |
| | | String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | String idStr = String.format("%06d", processRoute.getId()); |
| | | String newProductCode = "GYLX" + dateStr + idStr; |
| | | // æ´æ°æ°æ®åºä¸çproductCode |
| | | processRoute.setProcessRouteCode(newProductCode); |
| | | // æ¥è¯¢bomæ¸
å |
| | | String routeCode = "GYLX" + dateStr + idStr; |
| | | processRoute.setProcessRouteCode(routeCode); |
| | | |
| | | List<ProductStructureDto> productStructureDtos = productStructureService.listDetailBybomId(processRoute.getBomId()); |
| | | if(CollectionUtils.isNotEmpty(productStructureDtos)){ |
| | | if (CollectionUtils.isNotEmpty(productStructureDtos)) { |
| | | AtomicInteger i = new AtomicInteger(1); |
| | | productStructureDtos.forEach(productStructureDto -> { |
| | | ProcessRouteItem processRouteItem = new ProcessRouteItem(); |
| | | processRouteItem.setRouteId(processRoute.getId()); |
| | | processRouteItem.setProcessId(productStructureDto.getProcessId()); |
| | | processRouteItem.setProductModelId(processRoute.getProductModelId()); |
| | | processRouteItem.setProductModelIds(processRoute.getProductModelIds()); |
| | | processRouteItem.setDragSort(i.get()); |
| | | processRouteItem.setIsQuality(false); |
| | | processRouteItemMapper.insert(processRouteItem); |
| | |
| | | |
| | | @Override |
| | | public int batchDelete(List<Long> ids) { |
| | | //å
夿æ¯å¦å·²ç»å¼ç¨äº |
| | | List<ProductOrder> productOrders = productOrderMapper.selectList(Wrappers.<ProductOrder>lambdaQuery().in(ProductOrder::getRouteId, ids)); |
| | | if (productOrders.size()>0){ |
| | | throw new RuntimeException("该工èºè·¯çº¿ç产已å¼ç¨ï¼ä¸è½å é¤"); |
| | | List<ProductOrder> productOrders = productOrderMapper.selectList( |
| | | Wrappers.<ProductOrder>lambdaQuery().in(ProductOrder::getRouteId, ids) |
| | | ); |
| | | if (!productOrders.isEmpty()) { |
| | | throw new RuntimeException("该工èºè·¯çº¿å·²è¢«ç产订åå¼ç¨ï¼ä¸è½å é¤"); |
| | | } |
| | | //å é¤å·¥èºè·¯çº¿è¯¦æ
|
| | | processRouteItemMapper.delete(Wrappers.<ProcessRouteItem>lambdaQuery().in(ProcessRouteItem::getRouteId, ids)); |
| | | return processRouteMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | private void normalizeProductModelIds(ProcessRoute processRoute) { |
| | | if (processRoute == null) { |
| | | return; |
| | | } |
| | | String ids = joinProductModelIds( |
| | | processRoute.getProductModelIdList(), |
| | | processRoute.getProductModelIds(), |
| | | processRoute.getProductModelId() |
| | | ); |
| | | processRoute.setProductModelIds(ids); |
| | | processRoute.setProductModelId(firstProductModelId(ids, processRoute.getProductModelId())); |
| | | } |
| | | |
| | | private String joinProductModelIds(List<Long> idList, String ids, Long fallbackId) { |
| | | if (CollectionUtils.isNotEmpty(idList)) { |
| | | return idList.stream() |
| | | .filter(item -> item != null && item > 0) |
| | | .distinct() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(",")); |
| | | } |
| | | if (StringUtils.hasText(ids)) { |
| | | return Arrays.stream(ids.split(",")) |
| | | .map(String::trim) |
| | | .filter(StringUtils::hasText) |
| | | .distinct() |
| | | .collect(Collectors.joining(",")); |
| | | } |
| | | return fallbackId == null ? null : String.valueOf(fallbackId); |
| | | } |
| | | |
| | | private Long firstProductModelId(String ids, Long fallbackId) { |
| | | if (!StringUtils.hasText(ids)) { |
| | | return fallbackId; |
| | | } |
| | | String first = ids.split(",")[0].trim(); |
| | | if (!StringUtils.hasText(first)) { |
| | | return fallbackId; |
| | | } |
| | | try { |
| | | return Long.parseLong(first); |
| | | } catch (NumberFormatException ignore) { |
| | | return fallbackId; |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.production.dto.ProductOrderDto; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.mapper.ProcessRouteMapper; |
| | | import com.ruoyi.production.mapper.ProductOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductProcessRouteItemMapper; |
| | | import com.ruoyi.production.mapper.ProductProcessRouteMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import com.ruoyi.production.pojo.ProductProcessRoute; |
| | | import com.ruoyi.production.pojo.ProductProcessRouteItem; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.production.service.ProductOrderService; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | private ProductProcessRouteMapper productProcessRouteMapper; |
| | | |
| | | @Autowired |
| | | private ProcessRouteItemMapper processRouteItemMapper; |
| | | |
| | | @Autowired |
| | | private ProductProcessRouteItemMapper productProcessRouteItemMapper; |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private ProductionProductMainMapper productionProductMainMapper; |
| | | |
| | | @Autowired |
| | | private ProductionProductOutputMapper productionProductOutputMapper; |
| | | |
| | | @Autowired |
| | | private ProductionProductInputMapper productionProductInputMapper; |
| | | |
| | | @Autowired |
| | | private QualityInspectMapper qualityInspectMapper; |
| | | |
| | | @Autowired |
| | | private SalesLedgerProductionAccountingMapper salesLedgerProductionAccountingMapper; |
| | | |
| | | @Autowired |
| | | private StockUtils stockUtils; |
| | | |
| | | @Override |
| | | public IPage<ProductOrderDto> pageProductOrder(Page page, ProductOrderDto productOrder) { |
| | | return productOrderMapper.pageProductOrder(page, productOrder); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | boolean isAdmin = SecurityUtils.isAdmin(userId) || SecurityUtils.hasRole(Constants.SUPER_ADMIN); |
| | | return productOrderMapper.pageProductOrder(page, productOrder, userId, isAdmin); |
| | | } |
| | | |
| | | @Override |
| | | public int bindingRoute(ProductOrder productOrder) { |
| | | //æ°å¢ç产订åä¸çå·¥èºè·¯çº¿ä¸»è¡¨ |
| | | ProcessRoute processRoute = processRouteMapper.selectById(productOrder.getRouteId()); |
| | | List<ProductProcessRouteItem> processRouteItems = productOrder.getProcessRouteItems(); |
| | | if (ObjectUtils.isEmpty(processRouteItems)) { |
| | | throw new RuntimeException("å·¥åºå表ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | ProcessRoute processRoute = null; |
| | | if (ObjectUtils.isNotEmpty(productOrder.getRouteId())) { |
| | | processRoute = processRouteMapper.selectById(productOrder.getRouteId()); |
| | | } |
| | | |
| | | ProductProcessRoute productProcessRoute = new ProductProcessRoute(); |
| | | productProcessRoute.setProductModelId(processRoute.getProductModelId()); |
| | | productProcessRoute.setProcessRouteCode(processRoute.getProcessRouteCode()); |
| | | productProcessRoute.setProductModelId(productOrder.getProductModelId()); |
| | | productProcessRoute.setProcessRouteCode(processRoute != null ? processRoute.getProcessRouteCode() : productOrder.getProcessRouteCode()); |
| | | productProcessRoute.setProductOrderId(productOrder.getId()); |
| | | productProcessRoute.setBomId(processRoute.getBomId()); |
| | | productProcessRoute.setBomId(processRoute != null ? processRoute.getBomId() : productOrder.getBomId()); |
| | | productProcessRouteMapper.insert(productProcessRoute); |
| | | //æ°å¢ç产订åä¸çå·¥èºè·¯çº¿å表 |
| | | List<ProcessRouteItem> processRouteItems = processRouteItemMapper.selectList(new QueryWrapper<ProcessRouteItem>().lambda().eq(ProcessRouteItem::getRouteId, processRoute.getId())); |
| | | // çæå½åæ¥æçåç¼ï¼å¹´ææ¥ |
| | | |
| | | String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | for (ProcessRouteItem processRouteItem : processRouteItems) { |
| | | for (ProductProcessRouteItem processRouteItem : processRouteItems) { |
| | | ProductProcessRouteItem productProcessRouteItem = new ProductProcessRouteItem(); |
| | | productProcessRouteItem.setProductModelId(processRouteItem.getProductModelId()); |
| | | productProcessRouteItem.setProductModelId(productOrder.getProductModelId()); |
| | | productProcessRouteItem.setProcessId(processRouteItem.getProcessId()); |
| | | productProcessRouteItem.setProductOrderId(productOrder.getId()); |
| | | productProcessRouteItem.setProductRouteId(productProcessRoute.getId()); |
| | | productProcessRouteItem.setDragSort(processRouteItem.getDragSort()); |
| | | productProcessRouteItem.setIsQuality(processRouteItem.getIsQuality()); |
| | | productProcessRouteItem.setReportUserIds(processRouteItem.getReportUserIds()); |
| | | int insert = productProcessRouteItemMapper.insert(productProcessRouteItem); |
| | | if (insert > 0) { |
| | | // æ¥è¯¢ä»æ¥å·²åå¨çæå¤§å·¥åå· |
| | | ProductWorkOrder lastWorkOrder = productWorkOrderMapper.selectMax(datePrefix); |
| | | int sequenceNumber = 1; // é»è®¤åºå· |
| | | int sequenceNumber = 1; |
| | | if (lastWorkOrder != null && lastWorkOrder.getWorkOrderNo() != null) { |
| | | String lastNo = lastWorkOrder.getWorkOrderNo().toString(); |
| | | String lastNo = lastWorkOrder.getWorkOrderNo(); |
| | | if (lastNo.startsWith(datePrefix)) { |
| | | String seqStr = lastNo.substring(datePrefix.length()); |
| | | try { |
| | |
| | | } |
| | | } |
| | | } |
| | | // çæå®æ´çå·¥åå· |
| | | String workOrderNoStr = "GD" + String.format("%s%03d", datePrefix, sequenceNumber); |
| | | ProductWorkOrder productWorkOrder = new ProductWorkOrder(); |
| | | productWorkOrder.setProductProcessRouteItemId(productProcessRouteItem.getId()); |
| | | productWorkOrder.setProductOrderId(productOrder.getId()); |
| | | ProductOrder order = productOrderMapper.selectById(productOrder.getId()); |
| | | productWorkOrder.setPlanQuantity(order.getQuantity()); |
| | | // æ°å¢çäº§è®¢åæ¶ï¼å°å·¥åºä¸çæ¥å·¥äººåæ¥å°å·¥åï¼åç»æå·¥åæ¥å·¥äººåæéæ ¡éª |
| | | productWorkOrder.setReportUserIds(productProcessRouteItem.getReportUserIds()); |
| | | productWorkOrder.setWorkOrderNo(workOrderNoStr); |
| | | productWorkOrder.setStatus(1); |
| | | productWorkOrderMapper.insert(productWorkOrder); |
| | |
| | | |
| | | @Override |
| | | public Boolean addProductOrder(ProductOrder productOrder) { |
| | | String string = generateNextOrderNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); |
| | | productOrder.setNpsNo(string); |
| | | String orderNo = generateNextOrderNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); |
| | | productOrder.setNpsNo(orderNo); |
| | | productOrder.setCompleteQuantity(BigDecimal.ZERO); |
| | | this.save(productOrder); |
| | | if (ObjectUtils.isNotEmpty(productOrder.getRouteId())) { |
| | | if (ObjectUtils.isNotEmpty(productOrder.getProcessRouteItems())) { |
| | | this.bindingRoute(productOrder); |
| | | } |
| | | return true; |
| | |
| | | |
| | | @Override |
| | | public Boolean delete(Long[] ids) { |
| | | //妿已ç»å¼å§ç产,ä¸è½å é¤ |
| | | //æ¥è¯¢ç产订åä¸çå·¥å |
| | | List<ProductWorkOrder> productWorkOrders = productWorkOrderMapper.selectList(Wrappers.<ProductWorkOrder>lambdaQuery().in(ProductWorkOrder::getProductOrderId, ids)); |
| | | if (productWorkOrders.size()>0){ |
| | | //夿æ¯å¦ææ¥å·¥æ°æ® |
| | | List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList(Wrappers.<ProductionProductMain>lambdaQuery() |
| | | .in(ProductionProductMain::getWorkOrderId, productWorkOrders.stream().map(ProductWorkOrder::getId).collect(Collectors.toList()))); |
| | | if (productionProductMains.size()>0){ |
| | | throw new RuntimeException("ç产订åå·²ç»å¼å§ç产,ä¸è½å é¤"); |
| | | List<ProductWorkOrder> productWorkOrders = productWorkOrderMapper.selectList( |
| | | Wrappers.<ProductWorkOrder>lambdaQuery().in(ProductWorkOrder::getProductOrderId, ids) |
| | | ); |
| | | if (!productWorkOrders.isEmpty()) { |
| | | List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList( |
| | | Wrappers.<ProductionProductMain>lambdaQuery() |
| | | .in(ProductionProductMain::getWorkOrderId, productWorkOrders.stream().map(ProductWorkOrder::getId).collect(Collectors.toList())) |
| | | ); |
| | | if (!productionProductMains.isEmpty()) { |
| | | throw new RuntimeException("ç产订åå·²ç»å¼å§ç产ï¼ä¸è½å é¤"); |
| | | } |
| | | //å é¤å·¥å |
| | | productWorkOrderMapper.delete(Wrappers.<ProductWorkOrder>lambdaQuery().in(ProductWorkOrder::getProductOrderId, ids)); |
| | | } |
| | | //å é¤å·¥èºè·¯çº¿ |
| | | |
| | | productProcessRouteItemMapper.delete(new LambdaQueryWrapper<ProductProcessRouteItem>() |
| | | .in(ProductProcessRouteItem::getProductOrderId, ids)); |
| | | productProcessRouteMapper.delete(new LambdaQueryWrapper<ProductProcessRoute>() |
| | | .in(ProductProcessRoute::getProductOrderId, ids)); |
| | | //å é¤ç产订å |
| | | productOrderMapper.delete(new LambdaQueryWrapper<ProductOrder>() |
| | | .in(ProductOrder::getId, ids)); |
| | | return true; |
| | | } |
| | | |
| | | //è·åå½åç产订åå· |
| | | public String getMaxOrderNoByDate(String datePrefix) { |
| | | QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>(); |
| | | // å¹é
以 SC + æ¥æå¼å¤´ç订åå· |
| | | queryWrapper.likeRight("nps_no", "SC" + datePrefix); |
| | | // æè®¢åå·ååºæå |
| | | queryWrapper.orderByDesc("nps_no"); |
| | | queryWrapper.last("LIMIT 1"); |
| | | |
| | |
| | | |
| | | public String generateNextOrderNo(String datePrefix) { |
| | | String maxOrderNo = getMaxOrderNoByDate(datePrefix); |
| | | int sequence = 1; // é»è®¤èµ·å§åºå· |
| | | int sequence = 1; |
| | | if (maxOrderNo != null && !maxOrderNo.isEmpty()) { |
| | | // æåæµæ°´å·é¨åï¼åè®¾æ ¼å¼ä¸º SC + æ¥æ + æµæ°´å·ï¼ |
| | | String sequenceStr = maxOrderNo.substring(("SC" + datePrefix).length()); |
| | | try { |
| | | sequence = Integer.parseInt(sequenceStr) + 1; |
| | | } catch (NumberFormatException e) { |
| | | // å¼å¸¸æ
åµä¸é置为1 |
| | | sequence = 1; |
| | | } |
| | | } |
| | | // çææ°è®¢åå· |
| | | return "SC" + datePrefix + String.format("%04d", sequence); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | productWorkOrder.setProductProcessRouteItemId(productProcessRouteItem.getId()); |
| | | productWorkOrder.setProductOrderId(productProcessRouteItem.getProductOrderId()); |
| | | productWorkOrder.setPlanQuantity(productOrder.getQuantity()); |
| | | // æå¨æ°å¢å·¥åºå¹¶çæå·¥åæ¶ï¼åæ¥å·¥åºæ¥å·¥äººå°å·¥å |
| | | productWorkOrder.setReportUserIds(productProcessRouteItem.getReportUserIds()); |
| | | productWorkOrder.setWorkOrderNo(workOrderNoStr); |
| | | productWorkOrder.setStatus(1); |
| | | productWorkOrderMapper.insert(productWorkOrder); |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.ProductStructureMapper; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | |
| | | // çå®çç¶èç¹ ID |
| | | Long realParentId; |
| | | for (ProductStructureDto psDto : flatDtoList) { |
| | | if (psDto.getId() == null && psDto.getParentTempId() != null) { |
| | | if (psDto.getId() == null && StringUtils.isNotEmpty(psDto.getParentTempId())) { |
| | | ProductStructure child = tempEntityMap.get(psDto.getTempId()); |
| | | if (tempEntityMap.containsKey(psDto.getParentTempId())) { |
| | | // ç¶èç¹æ¯æ°èç¹ |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.deepoove.poi.data.PictureRenderData; |
| | | import com.deepoove.poi.data.Pictures; |
| | | import com.ruoyi.common.utils.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.utils.MatrixToImageWriter; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.production.dto.ProductWorkOrderDto; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderFileMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.production.pojo.ProductWorkOrderFile; |
| | | import com.ruoyi.production.service.ProductWorkOrderService; |
| | | import com.ruoyi.quality.pojo.QualityInspectParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Override |
| | | public IPage<ProductWorkOrderDto> listPage(Page<ProductWorkOrderDto> page, ProductWorkOrderDto productWorkOrder) { |
| | | return productWorkOrdermapper.pageProductWorkOrder(page, productWorkOrder); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | boolean isAdmin = SecurityUtils.isAdmin(userId) || SecurityUtils.hasRole(Constants.SUPER_ADMIN); |
| | | return productWorkOrdermapper.pageProductWorkOrder(page, productWorkOrder, userId, isAdmin); |
| | | } |
| | | |
| | | @Override |
| | | public int updateProductWorkOrder(ProductWorkOrderDto productWorkOrderDto) { |
| | | checkWorkOrderPermission(productWorkOrderDto.getId()); |
| | | return productWorkOrdermapper.updateById(productWorkOrderDto); |
| | | } |
| | | |
| | | @Override |
| | | public ProductWorkOrder getProductWorkOrderById(Long id) { |
| | | checkWorkOrderPermission(id); |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void down(HttpServletResponse response, ProductWorkOrder productWorkOrder) { |
| | | checkWorkOrderPermission(productWorkOrder.getId()); |
| | | ProductWorkOrderDto productWorkOrderDto = productWorkOrdermapper.getProductWorkOrderFlowCard(productWorkOrder.getId()); |
| | | String codePath; |
| | | try { |
| | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | /*è·åéä»¶å¾çç±»å*/ |
| | | List<Map<String, Object>> images = new ArrayList<>(); |
| | | List<ProductWorkOrderFile> productWorkOrderFiles = productWorkOrderFileMapper.selectList(Wrappers.<ProductWorkOrderFile>lambdaQuery().eq(ProductWorkOrderFile::getWorkOrderId, productWorkOrder.getId())); |
| | | if (CollectionUtils.isNotEmpty(productWorkOrderFiles)) { |
| | | productWorkOrderFiles.forEach(productWorkOrderFile -> { |
| | | Map<String, Object> image = new HashMap<>(); |
| | | PictureRenderData pictureRenderData = Pictures.ofLocal( productWorkOrderFile.getUrl()).sizeInCm(17, 20).create(); |
| | | PictureRenderData pictureRenderData = Pictures.ofLocal(productWorkOrderFile.getUrl()).sizeInCm(17, 20).create(); |
| | | image.put("url", pictureRenderData); |
| | | images.add(image); |
| | | }); |
| | |
| | | put("actualStartTime", productWorkOrderDto.getActualStartTime()); |
| | | put("actualEndTime", productWorkOrderDto.getActualEndTime()); |
| | | put("twoCode", Pictures.ofLocal(codePath).create()); |
| | | put("images", images.isEmpty()?null:images); |
| | | put("images", images.isEmpty() ? null : images); |
| | | }}); |
| | | |
| | | try { |
| | | response.setContentType("application/msword"); |
| | | String fileName = URLEncoder.encode( |
| | | "æµè½¬å¡", "UTF-8"); |
| | | String fileName = URLEncoder.encode("æµè½¬å¡", "UTF-8"); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | response.setHeader("Content-disposition", |
| | | "attachment;filename=" + fileName + ".docx"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".docx"); |
| | | OutputStream os = response.getOutputStream(); |
| | | template.write(os); |
| | | os.flush(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void checkWorkOrderPermission(Long workOrderId) { |
| | | if (workOrderId == null) { |
| | | throw new RuntimeException("å·¥åIDä¸è½ä¸ºç©º"); |
| | | } |
| | | Long userId = SecurityUtils.getUserId(); |
| | | boolean isAdmin = SecurityUtils.isAdmin(userId) || SecurityUtils.hasRole(Constants.SUPER_ADMIN); |
| | | if (isAdmin) { |
| | | return; |
| | | } |
| | | Integer count = productWorkOrdermapper.checkUserCanAccess(workOrderId, userId); |
| | | if (count == null || count == 0) { |
| | | throw new RuntimeException("æ æè®¿é®è¯¥å·¥å"); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.framework.web.domain.R; |
| | |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | |
| | | private PurchaseLedgerMapper purchaseLedgerMapper; |
| | | |
| | | private ProductMapper productMapper; |
| | | |
| | | private ProductModelMapper productModelMapper; |
| | | |
| | | private ProductOrderMapper productOrderMapper; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * éè¿äº§å大类ï¼è§æ ¼åå·æ¥è¯¢productModelId |
| | | */ |
| | | public Long getProductModelId(String productCategory, String productSpecification) { |
| | | Product product = productMapper.selectOne(new QueryWrapper<Product>() |
| | | .lambda() |
| | | .eq(Product::getProductName, productCategory) |
| | | .orderByDesc(Product::getId) |
| | | .last("LIMIT 1")); |
| | | if(product == null){ |
| | | throw new RuntimeException("请å
æ·»å 产å"); |
| | | } |
| | | ProductModel productModel = productModelMapper.selectOne(new QueryWrapper<ProductModel>() |
| | | .lambda() |
| | | .eq(ProductModel::getProductId, product.getId()) |
| | | .eq(ProductModel::getModel, productSpecification) |
| | | .orderByDesc(ProductModel::getId) |
| | | .last("LIMIT 1")); |
| | | return productModel == null ? null : productModel.getId(); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢çäº§æ°æ® |
| | | */ |
| | | public void addProductionData(SalesLedgerProduct salesLedgerProduct) { |
| | | ProductOrder productOrder = new ProductOrder(); |
| | | productOrder.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId()); |
| | | productOrder.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | if(salesLedgerProduct.getProductModelId() == null){ |
| | | Long productModelId = getProductModelId(salesLedgerProduct.getProductCategory(), salesLedgerProduct.getSpecificationModel()); |
| | | productOrder.setProductModelId(productModelId); |
| | | }else{ |
| | | productOrder.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | } |
| | | productOrder.setSaleLedgerProductId(salesLedgerProduct.getId()); |
| | | String string = productOrderServiceImpl.generateNextOrderNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); |
| | | productOrder.setNpsNo(string); |
| | | productOrder.setQuantity(salesLedgerProduct.getQuantity());//éæ±æ°é |
| | | productOrder.setCompleteQuantity(BigDecimal.ZERO);//宿æ°é |
| | | productOrderMapper.insert(productOrder); |
| | | |
| | | List<ProcessRoute> processRoutes = processRouteMapper.selectList(new QueryWrapper<ProcessRoute>().lambda() |
| | | .eq(ProcessRoute::getProductModelId, salesLedgerProduct.getProductModelId()) |
| | | .orderByDesc(ProcessRoute::getCreateTime)); |
| | | if (processRoutes.size()>0){ |
| | | ProcessRoute processRoute = processRoutes.get(0); |
| | | //æ°å¢ç产订åå·¥èºè·¯çº¿ä¸»è¡¨ |
| | | ProductProcessRoute productProcessRoute = new ProductProcessRoute(); |
| | | productProcessRoute.setProductModelId(processRoute.getProductModelId()); |
| | | productProcessRoute.setProcessRouteCode(processRoute.getProcessRouteCode()); |
| | | productProcessRoute.setProductOrderId(productOrder.getId()); |
| | | productProcessRoute.setBomId(processRoute.getBomId()); |
| | | productProcessRouteMapper.insert(productProcessRoute); |
| | | //æ°å¢ç产订åå·¥èºè·¯çº¿å表 |
| | | List<ProcessRouteItem> processRouteItems = processRouteItemMapper.selectList(new QueryWrapper<ProcessRouteItem>().lambda().eq(ProcessRouteItem::getRouteId, processRoute.getId())); |
| | | // çæå½åæ¥æçåç¼ï¼å¹´ææ¥ |
| | | String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | for (ProcessRouteItem processRouteItem : processRouteItems) { |
| | | ProductProcessRouteItem productProcessRouteItem = new ProductProcessRouteItem(); |
| | | productProcessRouteItem.setProductModelId(processRouteItem.getProductModelId()); |
| | | productProcessRouteItem.setProcessId(processRouteItem.getProcessId()); |
| | | productProcessRouteItem.setProductOrderId(productOrder.getId()); |
| | | productProcessRouteItem.setProductRouteId(productProcessRoute.getId()); |
| | | productProcessRouteItem.setDragSort(processRouteItem.getDragSort()); |
| | | int insert = productProcessRouteItemMapper.insert(productProcessRouteItem); |
| | | if (insert > 0) { |
| | | // æ¥è¯¢ä»æ¥å·²åå¨çæå¤§å·¥åå· |
| | | ProductWorkOrder lastWorkOrder = productWorkOrderMapper.selectMax(datePrefix); |
| | | int sequenceNumber = 1; // é»è®¤åºå· |
| | | if (lastWorkOrder != null && lastWorkOrder.getWorkOrderNo() != null) { |
| | | String lastNo = lastWorkOrder.getWorkOrderNo().toString(); |
| | | if (lastNo.startsWith(datePrefix)) { |
| | | String seqStr = lastNo.substring(datePrefix.length()); |
| | | try { |
| | | sequenceNumber = Integer.parseInt(seqStr) + 1; |
| | | } catch (NumberFormatException e) { |
| | | sequenceNumber = 1; |
| | | } |
| | | } |
| | | } |
| | | // çæå®æ´çå·¥åå· |
| | | String workOrderNoStr ="GD"+ String.format("%s%03d", datePrefix, sequenceNumber); |
| | | ProductWorkOrder productWorkOrder = new ProductWorkOrder(); |
| | | productWorkOrder.setProductProcessRouteItemId(productProcessRouteItem.getId()); |
| | | productWorkOrder.setProductOrderId(productOrder.getId()); |
| | | productWorkOrder.setPlanQuantity(salesLedgerProduct.getQuantity()); |
| | | productWorkOrder.setWorkOrderNo(workOrderNoStr); |
| | | productWorkOrder.setStatus(1); |
| | | |
| | | productWorkOrderMapper.insert(productWorkOrder); |
| | | } |
| | | |
| | | } |
| | | productOrder.setRouteId(processRoute.getId()); |
| | | productOrderMapper.updateById(productOrder); |
| | | } |
| | | // åæ¶é»è®¤çå·¥èºè·¯çº¿ |
| | | // List<ProcessRoute> processRoutes = processRouteMapper.selectList( |
| | | // new QueryWrapper<ProcessRoute>() |
| | | // .and(wrapper -> wrapper.eq("product_model_id", salesLedgerProduct.getProductModelId()) |
| | | // .or() |
| | | // .apply("find_in_set({0}, product_model_ids)", salesLedgerProduct.getProductModelId())) |
| | | // .orderByDesc("create_time")); |
| | | // if (processRoutes.size()>0){ |
| | | // ProcessRoute processRoute = processRoutes.get(0); |
| | | // //æ°å¢ç产订åå·¥èºè·¯çº¿ä¸»è¡¨ |
| | | // ProductProcessRoute productProcessRoute = new ProductProcessRoute(); |
| | | // productProcessRoute.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | // productProcessRoute.setProcessRouteCode(processRoute.getProcessRouteCode()); |
| | | // productProcessRoute.setProductOrderId(productOrder.getId()); |
| | | // productProcessRoute.setBomId(processRoute.getBomId()); |
| | | // productProcessRouteMapper.insert(productProcessRoute); |
| | | // //æ°å¢ç产订åå·¥èºè·¯çº¿å表 |
| | | // List<ProcessRouteItem> processRouteItems = processRouteItemMapper.selectList(new QueryWrapper<ProcessRouteItem>().lambda().eq(ProcessRouteItem::getRouteId, processRoute.getId())); |
| | | // // çæå½åæ¥æçåç¼ï¼å¹´ææ¥ |
| | | // String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | // for (ProcessRouteItem processRouteItem : processRouteItems) { |
| | | // ProductProcessRouteItem productProcessRouteItem = new ProductProcessRouteItem(); |
| | | // productProcessRouteItem.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | // productProcessRouteItem.setProcessId(processRouteItem.getProcessId()); |
| | | // productProcessRouteItem.setProductOrderId(productOrder.getId()); |
| | | // productProcessRouteItem.setProductRouteId(productProcessRoute.getId()); |
| | | // productProcessRouteItem.setDragSort(processRouteItem.getDragSort()); |
| | | // int insert = productProcessRouteItemMapper.insert(productProcessRouteItem); |
| | | // if (insert > 0) { |
| | | // // æ¥è¯¢ä»æ¥å·²åå¨çæå¤§å·¥åå· |
| | | // ProductWorkOrder lastWorkOrder = productWorkOrderMapper.selectMax(datePrefix); |
| | | // int sequenceNumber = 1; // é»è®¤åºå· |
| | | // if (lastWorkOrder != null && lastWorkOrder.getWorkOrderNo() != null) { |
| | | // String lastNo = lastWorkOrder.getWorkOrderNo().toString(); |
| | | // if (lastNo.startsWith(datePrefix)) { |
| | | // String seqStr = lastNo.substring(datePrefix.length()); |
| | | // try { |
| | | // sequenceNumber = Integer.parseInt(seqStr) + 1; |
| | | // } catch (NumberFormatException e) { |
| | | // sequenceNumber = 1; |
| | | // } |
| | | // } |
| | | // } |
| | | // // çæå®æ´çå·¥åå· |
| | | // String workOrderNoStr ="GD"+ String.format("%s%03d", datePrefix, sequenceNumber); |
| | | // ProductWorkOrder productWorkOrder = new ProductWorkOrder(); |
| | | // productWorkOrder.setProductProcessRouteItemId(productProcessRouteItem.getId()); |
| | | // productWorkOrder.setProductOrderId(productOrder.getId()); |
| | | // productWorkOrder.setPlanQuantity(salesLedgerProduct.getQuantity()); |
| | | // productWorkOrder.setWorkOrderNo(workOrderNoStr); |
| | | // productWorkOrder.setStatus(1); |
| | | // |
| | | // productWorkOrderMapper.insert(productWorkOrder); |
| | | // } |
| | | // |
| | | // } |
| | | // productOrder.setRouteId(processRoute.getId()); |
| | | // productOrderMapper.updateById(productOrder); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public R judgmentInventory(SalesLedgerProduct salesLedgerProduct) { |
| | | //è·åäº§åææ°çå·¥èºè·¯çº¿ |
| | | ProcessRoute processRoute = processRouteMapper.selectOne(new QueryWrapper<ProcessRoute>().lambda().eq(ProcessRoute::getProductModelId, salesLedgerProduct.getProductModelId()).orderByDesc(ProcessRoute::getCreateTime).last("LIMIT 1")); |
| | | ProcessRoute processRoute = processRouteMapper.selectOne( |
| | | new QueryWrapper<ProcessRoute>() |
| | | .and(wrapper -> wrapper.eq("product_model_id", salesLedgerProduct.getProductModelId()) |
| | | .or() |
| | | .apply("find_in_set({0}, product_model_ids)", salesLedgerProduct.getProductModelId())) |
| | | .orderByDesc("create_time") |
| | | .last("LIMIT 1")); |
| | | if (processRoute == null) { |
| | | return R.fail("请å
设置工èºè·¯çº¿"); |
| | | } |
| | |
| | | <?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"> |
| | | <?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.ProcessRouteItemMapper"> |
| | | |
| | | <resultMap id="basicMap" type="com.ruoyi.production.pojo.ProcessRouteItem"> |
| | |
| | | <result property="routeId" column="route_id"/> |
| | | <result property="processId" column="process_id"/> |
| | | <result property="productModelId" column="product_model_id"/> |
| | | <result property="productModelIds" column="product_model_ids"/> |
| | | <result property="tenantId" column="tenant_id"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | <result property="dragSort" column="drag_sort"/> |
| | | <result property="isQuality" column="is_quality"/> |
| | | </resultMap> |
| | | |
| | | <select id="listProcessRouteItemDto" resultType="com.ruoyi.production.dto.ProcessRouteItemDto"> |
| | | select pri.*, |
| | | pr.description , |
| | | pr.description as route_name, |
| | | pp.name as process_name, |
| | | pm.speculative_trading_name, |
| | | pm.product_id, |
| | | pm.model, |
| | | p.product_name, |
| | | pm.unit |
| | | from |
| | | process_route_item pri |
| | | left join product_model pm on pri.product_model_id = pm.id |
| | | left join product_process pp on pp.id = pri.process_id |
| | | left join product p on p.id = pm.product_id |
| | | left join process_route pr on pr.id = pri.route_id |
| | | where |
| | | pri.route_id = #{c.routeId} |
| | | t.speculative_trading_name, |
| | | t.product_id, |
| | | t.model, |
| | | t.product_name, |
| | | t.unit |
| | | from process_route_item pri |
| | | left join product_process pp on pp.id = pri.process_id |
| | | left join process_route pr on pr.id = pri.route_id |
| | | left join ( |
| | | select item.id as item_id, |
| | | group_concat( |
| | | distinct pm.speculative_trading_name |
| | | order by |
| | | case |
| | | when item.product_model_ids is null or item.product_model_ids = '' then pm.id |
| | | else find_in_set(pm.id, item.product_model_ids) |
| | | end |
| | | separator ',' |
| | | ) as speculative_trading_name, |
| | | max(pm.product_id) as product_id, |
| | | group_concat( |
| | | distinct pm.model |
| | | order by |
| | | case |
| | | when item.product_model_ids is null or item.product_model_ids = '' then pm.id |
| | | else find_in_set(pm.id, item.product_model_ids) |
| | | end |
| | | separator ',' |
| | | ) as model, |
| | | group_concat( |
| | | distinct p.product_name |
| | | order by |
| | | case |
| | | when item.product_model_ids is null or item.product_model_ids = '' then pm.id |
| | | else find_in_set(pm.id, item.product_model_ids) |
| | | end |
| | | separator ',' |
| | | ) as product_name, |
| | | group_concat( |
| | | distinct pm.unit |
| | | order by |
| | | case |
| | | when item.product_model_ids is null or item.product_model_ids = '' then pm.id |
| | | else find_in_set(pm.id, item.product_model_ids) |
| | | end |
| | | separator ',' |
| | | ) as unit |
| | | from process_route_item item |
| | | left join product_model pm |
| | | on (find_in_set(pm.id, item.product_model_ids) > 0 |
| | | or ((item.product_model_ids is null or item.product_model_ids = '') and pm.id = item.product_model_id)) |
| | | left join product p on p.id = pm.product_id |
| | | group by item.id |
| | | ) t on t.item_id = pri.id |
| | | where pri.route_id = #{c.routeId} |
| | | <if test="c.productModelId != null"> |
| | | and exists ( |
| | | select 1 |
| | | from product_model pm_filter |
| | | where ( |
| | | find_in_set(pm_filter.id, pri.product_model_ids) > 0 |
| | | or ((pri.product_model_ids is null or pri.product_model_ids = '') and pm_filter.id = pri.product_model_id) |
| | | ) |
| | | and pm_filter.id = #{c.productModelId} |
| | | ) |
| | | </if> |
| | | order by pri.drag_sort |
| | | </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"> |
| | | <?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"> |
| | | |
| | | |
| | | <resultMap id="basicMap" type="com.ruoyi.production.pojo.ProcessRoute"> |
| | | <id property="id" column="id"/> |
| | | <result property="productModelId" column="product_model_id"/> |
| | | <result property="description" column="description"/> |
| | | <result property="tenantId" column="tenant_id"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | <id property="id" column="id"/> |
| | | <result property="productModelId" column="product_model_id"/> |
| | | <result property="productModelIds" column="product_model_ids"/> |
| | | <result property="description" column="description"/> |
| | | <result property="tenantId" column="tenant_id"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | <result property="processRouteCode" column="process_route_code"/> |
| | | <result property="bomId" column="bom_id"/> |
| | | </resultMap> |
| | | |
| | | <select id="pageProcessRouteDto" resultType="com.ruoyi.production.dto.ProcessRouteDto"> |
| | | select ps.*, p.product_name,pm.product_id,pm.model,pb.bom_no |
| | | select ps.*, |
| | | t.product_name, |
| | | t.product_id, |
| | | t.model, |
| | | pb.bom_no |
| | | from process_route ps |
| | | left join product_bom pb on ps.bom_id = pb.id |
| | | left join product_model pm on ps.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | left join ( |
| | | select pr.id as route_id, |
| | | group_concat( |
| | | distinct p.product_name |
| | | order by |
| | | case |
| | | when pr.product_model_ids is null or pr.product_model_ids = '' then pm.id |
| | | else find_in_set(pm.id, pr.product_model_ids) |
| | | end |
| | | separator ',' |
| | | ) as product_name, |
| | | max(pm.product_id) as product_id, |
| | | group_concat( |
| | | distinct pm.model |
| | | order by |
| | | case |
| | | when pr.product_model_ids is null or pr.product_model_ids = '' then pm.id |
| | | else find_in_set(pm.id, pr.product_model_ids) |
| | | end |
| | | separator ',' |
| | | ) as model |
| | | from process_route pr |
| | | left join product_model pm |
| | | on (find_in_set(pm.id, pr.product_model_ids) > 0 |
| | | or ((pr.product_model_ids is null or pr.product_model_ids = '') and pm.id = pr.product_model_id)) |
| | | left join product p on pm.product_id = p.id |
| | | group by pr.id |
| | | ) t on t.route_id = ps.id |
| | | <where> |
| | | <if test="c.model != null and c.model != ''"> |
| | | and pm.model like concat('%',#{c.model},'%') |
| | | and t.model like concat('%',#{c.model},'%') |
| | | </if> |
| | | </where> |
| | | order by ps.id asc |
| | |
| | | <if test="c.startTime != null and c.endTime != null"> |
| | | and po.create_time between #{c.startTime} and #{c.endTime} |
| | | </if> |
| | | <if test="isAdmin == false"> |
| | | and exists ( |
| | | select 1 |
| | | from product_work_order pwo_auth |
| | | where pwo_auth.product_order_id = po.id |
| | | and find_in_set(#{userId}, pwo_auth.report_user_ids) |
| | | ) |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="listProcessRoute" resultType="com.ruoyi.production.pojo.ProcessRoute"> |
| | |
| | | <select id="pageProductWorkOrder" resultType="com.ruoyi.production.dto.ProductWorkOrderDto"> |
| | | SELECT |
| | | pwo.*, |
| | | pwo.report_user_ids, |
| | | pp.NAME as processName, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name AS productName, |
| | | po.nps_no AS productOrderNpsNo, |
| | | ( |
| | | SELECT GROUP_CONCAT(COALESCE(NULLIF(su.nick_name, ''), su.user_name) |
| | | ORDER BY FIND_IN_SET(su.user_id, pwo.report_user_ids) SEPARATOR ',') |
| | | FROM sys_user su |
| | | WHERE FIND_IN_SET(su.user_id, pwo.report_user_ids) |
| | | ) AS reportUserNames, |
| | | ROUND(pwo.complete_quantity / pwo.plan_quantity * 100, 2) AS completionStatus, |
| | | CASE |
| | | WHEN pwo.work_order_no LIKE 'FG%' THEN 'è¿å·¥è¿ä¿®' |
| | |
| | | <if test="c.productOrderId != null and c.productOrderId != ''"> |
| | | and pwo.product_order_id = #{c.productOrderId} |
| | | </if> |
| | | <if test="isAdmin == false"> |
| | | and find_in_set(#{userId}, pwo.report_user_ids) |
| | | </if> |
| | | </select> |
| | | <select id="checkUserCanAccess" resultType="java.lang.Integer"> |
| | | SELECT COUNT(1) |
| | | FROM product_work_order pwo |
| | | WHERE pwo.id = #{workOrderId} |
| | | AND find_in_set(#{userId}, pwo.report_user_ids) |
| | | </select> |
| | | <select id="getProductWorkOrderFlowCard" resultType="com.ruoyi.production.dto.ProductWorkOrderDto"> |
| | | SELECT |