| | |
| | | index idx_sys_user_id (sys_user_id), |
| | | unique idx_production_team_user (production_team_id, sys_user_id) |
| | | ); |
| | | |
| | | alter table production_order add column team_leader_user_id bigint not null default 0 comment 'çç»é¿ID'; |
| | | alter table production_order add index idx_team_leader_user_id (team_leader_user_id); |
| | | |
| | | alter table production_operation_task |
| | | add team_user_id bigint default 0 not null comment 'çç»å¢åç¨æ·id'; |
| | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | @Schema(description = "çç»æåç¨æ·ID") |
| | | private Long teamUserId; |
| | | } |
| | |
| | | @Schema(description = "éå®ååå·") |
| | | private String salesContractNo; |
| | | |
| | | @Schema(description = "çç»é¿ID") |
| | | private Long leaderId; |
| | | } |
| | |
| | | |
| | | @Schema(description = "ç±»å åºå计æ¶å计件(0计æ¶1计件)") |
| | | private Integer type; |
| | | |
| | | @Schema(description = "çç»é¿åç§°") |
| | | private String leaderName; |
| | | |
| | | @Schema(description = "çç»é¿ç¨æ·ID") |
| | | private Long leaderUserId; |
| | | |
| | | @Schema(description = "çç»å¢åç¨æ·ID") |
| | | private Long teamUserId; |
| | | |
| | | @Schema(description = "çç»å¢ååç§°") |
| | | private String teamUserName; |
| | | } |
| | |
| | | |
| | | @Schema(description = "æ¯å¦å·²éæ") |
| | | private Boolean returned; |
| | | |
| | | @Schema(description = "çç»é¿æµç§°") |
| | | private String teamLeaderUserName; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.bean.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class TeamLeaderVo extends ProductionTeamVo.MemberVo { |
| | | @Schema(description = "çç»ID") |
| | | private Long productionTeamId; |
| | | |
| | | @Schema(description = "çç»åç§°") |
| | | private String teamName; |
| | | } |
| | |
| | | return R.ok(productionOperationTaskService.assign(dto)); |
| | | } |
| | | |
| | | @Operation(summary = "ææ´¾çç»æå") |
| | | @PostMapping("/assignTeamUser") |
| | | public R<Boolean> assignTeamUser(@RequestBody ProductionOperationTaskDto dto) { |
| | | return R.ok(productionOperationTaskService.assignTeamUser(dto)); |
| | | } |
| | | |
| | | @PostMapping("/down") |
| | | @Operation(summary = "å·¥åæµè½¬å¡ä¸è½½") |
| | | public void down(HttpServletResponse response, @RequestBody ProductionOperationTaskDto dto) { |
| | |
| | | import com.ruoyi.production.service.ProductionTeamService;
|
| | | import io.swagger.v3.oas.annotations.Operation;
|
| | | import io.swagger.v3.oas.annotations.tags.Tag;
|
| | | import lombok.AllArgsConstructor;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | |
| | | * ç产çç»æ§å¶å¨
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/production_team")
|
| | | @RequestMapping("/productionTeam")
|
| | | @Tag(name = "ç产çç»ç®¡ç", description = "ç产çç»å¢å æ¹æ¥æ¥å£")
|
| | | @AllArgsConstructor
|
| | | public class ProductionTeamController {
|
| | |
|
| | | private final ProductionTeamService productionTeamService;
|
| | |
|
| | | public ProductionTeamController(ProductionTeamService productionTeamService) {
|
| | | this.productionTeamService = productionTeamService;
|
| | | }
|
| | | private ProductionTeamService productionTeamService;
|
| | |
|
| | | /**
|
| | | * å建çç»
|
| | |
| | | package com.ruoyi.production.controller;
|
| | |
|
| | | import com.ruoyi.framework.web.domain.R;
|
| | | import com.ruoyi.production.bean.dto.ProductionTeamDto;
|
| | | import com.ruoyi.production.bean.vo.ProductionTeamVo;
|
| | | import com.ruoyi.production.bean.vo.TeamLeaderVo;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import com.ruoyi.production.service.ProductionTeamUserRelService;
|
| | | import io.swagger.v3.oas.annotations.Operation;
|
| | | import lombok.AllArgsConstructor;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * <p>
|
| | |
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/productionTeamUserRel")
|
| | | @AllArgsConstructor
|
| | | public class ProductionTeamUserRelController {
|
| | | private ProductionTeamUserRelService productionTeamUserRelService;
|
| | | /**
|
| | | * æ¥è¯¢çç»é¿å表
|
| | | */
|
| | | @GetMapping("/leaderList")
|
| | | @Operation(summary = "æ¥è¯¢çç»é¿å表", description = "æ¥è¯¢ç产çç»çç»é¿å表")
|
| | | public R<List<TeamLeaderVo>> getTeamLeaderList() {
|
| | | return R.ok(productionTeamUserRelService.listAllLeaders());
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ ¹æ®çç»é¿ç¨æ·IDæ¥è¯¢çç»æåå表
|
| | | */
|
| | | @GetMapping("/memberListByLeader")
|
| | | @Operation(summary = "æ ¹æ®çç»é¿æ¥è¯¢çç»æå", description = "æ ¹æ®çç»é¿ç¨æ·IDæ¥è¯¢æå±çç»çæåå表")
|
| | | public R<List<ProductionTeamVo.MemberVo>> getMemberListByLeader(@RequestParam Long leaderUserId) {
|
| | | return R.ok(productionTeamUserRelService.listTeamMembersByLeader(leaderUserId));
|
| | | }
|
| | | }
|
| | |
| | | package com.ruoyi.production.mapper;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
| | | import com.ruoyi.production.bean.vo.ProductionTeamVo;
|
| | | import com.ruoyi.production.bean.vo.TeamLeaderVo;
|
| | | import com.ruoyi.production.pojo.ProductionTeamUserRel;
|
| | | import org.apache.ibatis.annotations.Mapper;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * <p>
|
| | |
| | | @Mapper
|
| | | public interface ProductionTeamUserRelMapper extends BaseMapper<ProductionTeamUserRel> {
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢ææçç»é¿ä¿¡æ¯ï¼å
å«ç¨æ·åç§°åçç»åç§°ï¼
|
| | | * @return çç»é¿ä¿¡æ¯å表
|
| | | */
|
| | | List<TeamLeaderVo> selectAllLeaders();
|
| | |
|
| | | /**
|
| | | * æ ¹æ®çç»é¿ç¨æ·IDæ¥è¯¢çç»æåå表
|
| | | * @param leaderUserId çç»é¿ç¨æ·ID
|
| | | * @return çç»æåå表
|
| | | */
|
| | | List<ProductionTeamVo.MemberVo> selectTeamMembersByLeader(Long leaderUserId);
|
| | | }
|
| | |
| | | |
| | | @Schema(description = "æéç¨æ·IDåè¡¨ï¼æ ¼å¼ï¼[1,2,3]ãæå®å¤ä¸ªç¨æ·IDæ¶ï¼ç¨éå·åéã") |
| | | private String userIds; |
| | | |
| | | @Schema(description = "çç»æåç¨æ·ID") |
| | | private Long teamUserId; |
| | | } |
| | |
| | | @Schema(description = "æ¯å¦ç»æï¼") |
| | | @TableField("is_end_order") |
| | | private Boolean endOrder; |
| | | |
| | | @Schema(description = "çç»é¿ID") |
| | | private Long teamLeaderUserId; |
| | | } |
| | |
| | | |
| | | boolean assign(ProductionOperationTaskDto dto); |
| | | |
| | | /** |
| | | * ææ´¾çç»æå |
| | | * @param dto å·¥åDTO |
| | | * @return æ¯å¦æå |
| | | */ |
| | | boolean assignTeamUser(ProductionOperationTaskDto dto); |
| | | |
| | | void down(HttpServletResponse response, ProductionOperationTaskDto dto); |
| | | |
| | | List<ProductionOperationTaskVo> getOperation(ProductionOperationTaskDto dto); |
| | |
| | | package com.ruoyi.production.service;
|
| | |
|
| | | import com.ruoyi.production.pojo.ProductionTeamUserRel;
|
| | | import com.ruoyi.production.bean.vo.ProductionTeamVo;
|
| | | import com.ruoyi.production.bean.vo.TeamLeaderVo;
|
| | | import com.baomidou.mybatisplus.extension.service.IService;
|
| | | import com.ruoyi.production.pojo.ProductionTeamUserRel;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * <p>
|
| | |
| | | */
|
| | | public interface ProductionTeamUserRelService extends IService<ProductionTeamUserRel> {
|
| | |
|
| | | /**
|
| | | * è·åææçç»é¿éå
|
| | | * @return çç»é¿éå
|
| | | */
|
| | | List<TeamLeaderVo> listAllLeaders();
|
| | |
|
| | | /**
|
| | | * æ ¹æ®çç»é¿ç¨æ·IDè·åçç»æåå表
|
| | | * @param leaderUserId çç»é¿ç¨æ·ID
|
| | | * @return çç»æåå表
|
| | | */
|
| | | List<ProductionTeamVo.MemberVo> listTeamMembersByLeader(Long leaderUserId);
|
| | | }
|
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean assignTeamUser(ProductionOperationTaskDto dto) { |
| | | // ææ´¾çç»æå |
| | | if (dto == null || dto.getId() == null) { |
| | | throw new ServiceException("å·¥åIDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (dto.getTeamUserId() == null) { |
| | | throw new ServiceException("çç»ç¨æ·IDä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | ProductionOperationTask update = new ProductionOperationTask(); |
| | | update.setId(dto.getId()); |
| | | update.setTeamUserId(dto.getTeamUserId()); |
| | | int rows = baseMapper.updateById(update); |
| | | if (rows <= 0) { |
| | | throw new ServiceException("å·¥åä¸å卿已å é¤"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ProductionOperationTask> buildQueryWrapper(ProductionOperationTaskDto dto) { |
| | | // ææ¡ä»¶å¨ææå»ºæ°æ®åºæ¥è¯¢æ¡ä»¶ |
| | | ProductionOperationTask query = dto == null ? new ProductionOperationTask() : dto; |
| | |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.production.bean.dto.ProductionOrderPickDto; |
| | | import com.ruoyi.production.bean.vo.ProductionOrderPickVo; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean savePick(ProductionOrderPickDto dto) { |
| | | // æ ¡éªå½åç¨æ·å¿
须为订åçç»é¿ |
| | | validateTeamLeader(dto); |
| | | |
| | | // 颿æ°å¢æ»æµç¨ï¼ |
| | | // 1) è§£æåç«¯è¡æ°æ®å¹¶éè¡åå¹¶åæ°ï¼ |
| | | // 2) æ ¡éªåæ°ä¸æ¹æ¬¡ï¼ |
| | |
| | | // æ°éæ ¼å¼åè¾åºï¼å»é¤æ«å°¾æ æ0ï¼ã |
| | | return defaultDecimal(value).stripTrailingZeros().toPlainString(); |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªå½åç¨æ·å¿
须为订åçç»é¿ |
| | | * @param dto 颿DTO |
| | | */ |
| | | private void validateTeamLeader(ProductionOrderPickDto dto) { |
| | | // è·åå½åç»å½ç¨æ·ID |
| | | Long currentUserId = SecurityUtils.getLoginUser().getUserId(); |
| | | |
| | | // è·åç产订åID |
| | | Long productionOrderId = resolveProductionOrderId(dto); |
| | | if (productionOrderId == null) { |
| | | throw new ServiceException("ç产订åIDä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | // æ¥è¯¢ç产订å |
| | | ProductionOrder productionOrder = productionOrderMapper.selectById(productionOrderId); |
| | | if (productionOrder == null) { |
| | | throw new ServiceException("ç产订åä¸åå¨"); |
| | | } |
| | | |
| | | // è·å订åççç»é¿ID |
| | | Long teamLeaderUserId = productionOrder.getTeamLeaderUserId(); |
| | | if (teamLeaderUserId == null) { |
| | | throw new ServiceException("è¯¥è®¢åæªè®¾ç½®çç»é¿"); |
| | | } |
| | | |
| | | // æ ¡éªå½åç¨æ·æ¯å¦ä¸ºçç»é¿ |
| | | if (!Objects.equals(currentUserId, teamLeaderUserId)) { |
| | | throw new ServiceException("å½åç¨æ·ä¸æ¯è¯¥è®¢åççç»é¿ï¼æ æ³è¿è¡é¢ææä½"); |
| | | } |
| | | } |
| | | } |
| | |
| | | productionOrder.setProductModelId(firstPlan.getProductModelId()); |
| | | productionOrder.setQuantity(assignedQuantity); |
| | | productionOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime()); |
| | | productionOrder.setTeamLeaderUserId(productionPlanDto.getLeaderId()); |
| | | if (!productionOrderService.saveProductionOrder(productionOrder)) { |
| | | throw new ServiceException("ä¸å失败ï¼ç产订åä¿å失败"); |
| | | } |
| | |
| | | package com.ruoyi.production.service.impl;
|
| | |
|
| | | import com.ruoyi.production.pojo.ProductionTeamUserRel;
|
| | | import com.ruoyi.production.bean.vo.ProductionTeamVo;
|
| | | import com.ruoyi.production.bean.vo.TeamLeaderVo;
|
| | | import com.ruoyi.production.mapper.ProductionTeamUserRelMapper;
|
| | | import com.ruoyi.production.pojo.ProductionTeamUserRel;
|
| | | import com.ruoyi.production.service.ProductionTeamUserRelService;
|
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import lombok.AllArgsConstructor;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * <p>
|
| | |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸
|
| | | * @since 2026-05-11 11:15:05
|
| | | */
|
| | | @AllArgsConstructor
|
| | | @Service
|
| | | @RequiredArgsConstructor
|
| | | public class ProductionTeamUserRelServiceImpl extends ServiceImpl<ProductionTeamUserRelMapper, ProductionTeamUserRel> implements ProductionTeamUserRelService {
|
| | |
|
| | | @Override
|
| | | public List<TeamLeaderVo> listAllLeaders() {
|
| | | return baseMapper.selectAllLeaders();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ProductionTeamVo.MemberVo> listTeamMembersByLeader(Long leaderUserId) {
|
| | | return baseMapper.selectTeamMembersByLeader(leaderUserId);
|
| | | }
|
| | | }
|
| | |
| | | select pot.*, |
| | | po.nps_no as npsNo, |
| | | po.is_end_order as endOrder, |
| | | po.team_leader_user_id as leaderUserId, |
| | | u.nick_name as leaderName, |
| | | teamUser.nick_name as teamUserName, |
| | | p.product_name as productName, |
| | | pm.model as model, |
| | | pm.unit as unit, |
| | |
| | | left join production_order_routing_operation poro on pot.production_order_routing_operation_id = poro.id |
| | | left join product_model pm on pm.id = ifnull(poro.product_model_id, po.product_model_id) |
| | | left join product p on pm.product_id = p.id |
| | | left join sys_user u on po.team_leader_user_id = u.user_id |
| | | left join sys_user teamUser on pot.team_user_id = teamUser.user_id |
| | | left join ( |
| | | select ppm.production_operation_task_id as taskId, |
| | | sum(ifnull(ppo.scrap_qty, 0)) as scrapQty |
| | |
| | | <result column="model" property="model" /> |
| | | <result column="processRouteCode" property="processRouteCode" /> |
| | | <result column="returned" property="returned" /> |
| | | <result column="teamLeaderUserName" property="teamLeaderUserName" /> |
| | | </resultMap> |
| | | |
| | | <sql id="ProductionOrderVoColumns"> |
| | |
| | | po.dept_id, |
| | | po.plan_complete_time, |
| | | po.status, |
| | | po.team_leader_user_id, |
| | | sl_user.nick_name as teamLeaderUserName, |
| | | po_sales.salesContractNo, |
| | | po_sales.customerName, |
| | | p.product_name as productName, |
| | |
| | | left join product p on pm.product_id = p.id |
| | | left join technology_routing tr on po.technology_routing_id = tr.id |
| | | left join technology_bom tb on tb.id = tr.bom_id |
| | | left join sys_user sl_user on sl_user.user_id = po.team_leader_user_id |
| | | left join ( |
| | | select production_order_id as productionOrderId, |
| | | if(max(case when ifnull(is_returned, 0) = 1 then 1 else 0 end) = 1, true, false) as returned |
| | |
| | | <result column="update_time" property="updateTime" />
|
| | | </resultMap>
|
| | |
|
| | | <!-- æ¥è¯¢ææçç»é¿ä¿¡æ¯ -->
|
| | | <select id="selectAllLeaders" resultType="com.ruoyi.production.bean.vo.TeamLeaderVo">
|
| | | SELECT
|
| | | rel.sys_user_id AS user_id,
|
| | | u.nick_name,
|
| | | rel.production_team_id,
|
| | | t.team_name
|
| | | FROM production_team_user_rel rel
|
| | | LEFT JOIN sys_user u ON rel.sys_user_id = u.user_id
|
| | | LEFT JOIN production_team t ON rel.production_team_id = t.id
|
| | | WHERE rel.is_leader = 1
|
| | | GROUP BY rel.sys_user_id, rel.production_team_id
|
| | | </select>
|
| | |
|
| | | <!-- æ ¹æ®çç»é¿ç¨æ·IDæ¥è¯¢çç»æåå表 -->
|
| | | <select id="selectTeamMembersByLeader" resultType="com.ruoyi.production.bean.vo.ProductionTeamVo$MemberVo">
|
| | | SELECT
|
| | | rel.sys_user_id AS userId,
|
| | | u.nick_name,
|
| | | CASE WHEN rel.is_leader = 1 THEN TRUE ELSE FALSE END AS isLeader
|
| | | FROM production_team_user_rel rel
|
| | | LEFT JOIN sys_user u ON rel.sys_user_id = u.user_id
|
| | | WHERE rel.production_team_id IN (
|
| | | SELECT production_team_id
|
| | | FROM production_team_user_rel
|
| | | WHERE sys_user_id = #{leaderUserId} AND is_leader = 1
|
| | | )
|
| | | AND rel.is_leader = 0
|
| | | </select>
|
| | |
|
| | | </mapper>
|