吴羡
4 天以前 cde451468d868fc7d3044d915c5b71e7cb9cb203
feat(production): 新增车间、班组、生产排产管理接口及Mapper
已添加20个文件
720 ■■■■■ 文件已修改
src/main/java/com/ruoyi/production/controller/ProductionSchedulingController.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/ProductionTeamController.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/WorkshopController.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductionSchedulingDto.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductionTeamDto.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/mapper/ProductionSchedulingMapper.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/mapper/ProductionTeamMapper.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/mapper/WorkshopMapper.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/pojo/ProductionScheduling.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/pojo/ProductionTeam.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/pojo/Workshop.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/ProductionSchedulingService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/ProductionTeamService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/WorkshopService.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionSchedulingServiceImpl.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionTeamServiceImpl.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/WorkshopServiceImpl.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductionSchedulingMapper.xml 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductionTeamMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/WorkshopMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/ProductionSchedulingController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,52 @@
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.ProductionSchedulingDto;
import com.ruoyi.production.pojo.ProductionScheduling;
import com.ruoyi.production.service.ProductionSchedulingService;
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("productionScheduling")
@Api(tags = "生产排班")
public class ProductionSchedulingController {
    @Autowired
    private ProductionSchedulingService productionSchedulingService;
    @GetMapping("page")
    @ApiOperation("分页查询")
    public R page(Page<ProductionSchedulingDto> page, ProductionSchedulingDto dto) {
        return R.ok(productionSchedulingService.pageProductionScheduling(page, dto));
    }
    @GetMapping("today")
    @ApiOperation("查询班组今日排班")
    public R today(@RequestParam("teamId") Long teamId) {
        return R.ok(productionSchedulingService.todayByTeam(teamId));
    }
    @ApiOperation("新增排班")
    @PostMapping()
    public R add(@RequestBody ProductionScheduling productionScheduling) {
        return R.ok(productionSchedulingService.save(productionScheduling));
    }
    @ApiOperation("修改排班")
    @PutMapping()
    public R update(@RequestBody ProductionScheduling productionScheduling) {
        return R.ok(productionSchedulingService.updateById(productionScheduling));
    }
    @ApiOperation("删除排班")
    @DeleteMapping("/{ids}")
    public R delete(@PathVariable("ids") Long[] ids) {
        return R.ok(productionSchedulingService.batchDelete(Arrays.asList(ids)));
    }
}
src/main/java/com/ruoyi/production/controller/ProductionTeamController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,52 @@
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.ProductionTeamDto;
import com.ruoyi.production.pojo.ProductionTeam;
import com.ruoyi.production.service.ProductionTeamService;
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("productionTeam")
@Api(tags = "班组管理")
public class ProductionTeamController {
    @Autowired
    private ProductionTeamService productionTeamService;
    @GetMapping("page")
    @ApiOperation("分页查询")
    public R page(Page<ProductionTeamDto> page, ProductionTeamDto dto) {
        return R.ok(productionTeamService.pageProductionTeam(page, dto));
    }
    @GetMapping("listAll")
    @ApiOperation("查询全部班组(可按车间过滤)")
    public R listAll(@RequestParam(value = "workshopId", required = false) Long workshopId) {
        return R.ok(productionTeamService.listDto(workshopId));
    }
    @ApiOperation("新增班组")
    @PostMapping()
    public R add(@RequestBody ProductionTeam productionTeam) {
        return R.ok(productionTeamService.save(productionTeam));
    }
    @ApiOperation("修改班组")
    @PutMapping()
    public R update(@RequestBody ProductionTeam productionTeam) {
        return R.ok(productionTeamService.updateById(productionTeam));
    }
    @ApiOperation("删除班组")
    @DeleteMapping("/{ids}")
    public R delete(@PathVariable("ids") Long[] ids) {
        return R.ok(productionTeamService.batchDelete(Arrays.asList(ids)));
    }
}
src/main/java/com/ruoyi/production/controller/WorkshopController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,51 @@
package com.ruoyi.production.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.production.pojo.Workshop;
import com.ruoyi.production.service.WorkshopService;
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("workshop")
@Api(tags = "车间管理")
public class WorkshopController {
    @Autowired
    private WorkshopService workshopService;
    @GetMapping("page")
    @ApiOperation("分页查询")
    public R page(Page<Workshop> page, Workshop workshop) {
        return R.ok(workshopService.pageWorkshop(page, workshop));
    }
    @GetMapping("listAll")
    @ApiOperation("查询全部车间")
    public R listAll() {
        return R.ok(workshopService.listAll());
    }
    @ApiOperation("新增车间")
    @PostMapping()
    public R add(@RequestBody Workshop workshop) {
        return R.ok(workshopService.save(workshop));
    }
    @ApiOperation("修改车间")
    @PutMapping()
    public R update(@RequestBody Workshop workshop) {
        return R.ok(workshopService.updateById(workshop));
    }
    @ApiOperation("删除车间")
    @DeleteMapping("/{ids}")
    public R delete(@PathVariable("ids") Long[] ids) {
        return R.ok(workshopService.batchDelete(Arrays.asList(ids)));
    }
}
src/main/java/com/ruoyi/production/dto/ProductionSchedulingDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.ruoyi.production.dto;
import com.ruoyi.production.pojo.ProductionScheduling;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
@Data
public class ProductionSchedulingDto extends ProductionScheduling {
    @ApiModelProperty("所属车间名称")
    private String workshopName;
    @ApiModelProperty("班组名称")
    private String teamName;
    @ApiModelProperty("开始日期(查询用)")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate startDate;
    @ApiModelProperty("结束日期(查询用)")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate endDate;
}
src/main/java/com/ruoyi/production/dto/ProductionTeamDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
package com.ruoyi.production.dto;
import com.ruoyi.production.pojo.ProductionTeam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ProductionTeamDto extends ProductionTeam {
    @ApiModelProperty("所属车间名称")
    private String workshopName;
}
src/main/java/com/ruoyi/production/mapper/ProductionSchedulingMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
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.ProductionSchedulingDto;
import com.ruoyi.production.pojo.ProductionScheduling;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
@Mapper
public interface ProductionSchedulingMapper extends BaseMapper<ProductionScheduling> {
    IPage<ProductionSchedulingDto> pageProductionScheduling(Page<ProductionSchedulingDto> page, @Param("c") ProductionSchedulingDto dto);
    ProductionSchedulingDto todayByTeam(@Param("teamId") Long teamId, @Param("workDate") LocalDate workDate);
}
src/main/java/com/ruoyi/production/mapper/ProductionTeamMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
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.ProductionTeamDto;
import com.ruoyi.production.pojo.ProductionTeam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ProductionTeamMapper extends BaseMapper<ProductionTeam> {
    IPage<ProductionTeamDto> pageProductionTeam(Page<ProductionTeamDto> page, @Param("c") ProductionTeamDto dto);
    List<ProductionTeamDto> listProductionTeamDto(@Param("workshopId") Long workshopId);
}
src/main/java/com/ruoyi/production/mapper/WorkshopMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
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.pojo.Workshop;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface WorkshopMapper extends BaseMapper<Workshop> {
    IPage<Workshop> pageWorkshop(Page<Workshop> page, @Param("c") Workshop workshop);
}
src/main/java/com/ruoyi/production/pojo/ProductionScheduling.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
package com.ruoyi.production.pojo;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
@TableName("production_scheduling")
@Data
@ApiModel(value = "productionScheduling", description = "生产排班")
public class ProductionScheduling {
    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty(value = "序号")
    private Long id;
    @ApiModelProperty(value = "工作日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate workDate;
    @ApiModelProperty(value = "班次 å­—å…¸shift_type 1早班 2中班 3晚班 4夜班")
    private Integer shiftType;
    @ApiModelProperty(value = "所属车间ID")
    private Long workshopId;
    @ApiModelProperty(value = "班组ID")
    private Long teamId;
    @ApiModelProperty(value = "状态 å­—å…¸schedule_status 1已安排 2已确认 3已完成 4已取消")
    private Integer status;
    @ApiModelProperty(value = "备注")
    private String remark;
    @ApiModelProperty(value = "租户ID")
    @TableField(fill = FieldFill.INSERT)
    private Long tenantId;
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    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;
}
src/main/java/com/ruoyi/production/pojo/ProductionTeam.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,64 @@
package com.ruoyi.production.pojo;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@TableName("production_team")
@Data
@ApiModel(value = "productionTeam", description = "班组管理")
public class ProductionTeam {
    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty(value = "序号")
    private Long id;
    @ApiModelProperty(value = "班组名称")
    private String teamName;
    @ApiModelProperty(value = "班组编码")
    private String teamCode;
    @ApiModelProperty(value = "所属车间ID")
    private Long workshopId;
    @ApiModelProperty(value = "班组长用户ID")
    private Long leaderUserId;
    @ApiModelProperty(value = "班组长姓名")
    private String leaderName;
    @ApiModelProperty(value = "联系电话")
    private String contactPhone;
    @ApiModelProperty(value = "状态 0启用 1停用")
    private Integer status;
    @ApiModelProperty(value = "备注")
    private String remark;
    @ApiModelProperty(value = "租户ID")
    @TableField(fill = FieldFill.INSERT)
    private Long tenantId;
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    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;
}
src/main/java/com/ruoyi/production/pojo/Workshop.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,58 @@
package com.ruoyi.production.pojo;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@TableName("workshop")
@Data
@ApiModel(value = "workshop", description = "车间管理")
public class Workshop {
    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty(value = "序号")
    private Long id;
    @ApiModelProperty(value = "车间名称")
    private String name;
    @ApiModelProperty(value = "车间编码")
    private String code;
    @ApiModelProperty(value = "负责人")
    private String principal;
    @ApiModelProperty(value = "联系电话")
    private String contactPhone;
    @ApiModelProperty(value = "状态 0启用 1停用")
    private Integer status;
    @ApiModelProperty(value = "备注")
    private String remark;
    @ApiModelProperty(value = "租户ID")
    @TableField(fill = FieldFill.INSERT)
    private Long tenantId;
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    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;
}
src/main/java/com/ruoyi/production/service/ProductionSchedulingService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
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.ProductionSchedulingDto;
import com.ruoyi.production.pojo.ProductionScheduling;
import java.util.List;
public interface ProductionSchedulingService extends IService<ProductionScheduling> {
    IPage<ProductionSchedulingDto> pageProductionScheduling(Page<ProductionSchedulingDto> page, ProductionSchedulingDto dto);
    ProductionSchedulingDto todayByTeam(Long teamId);
    int batchDelete(List<Long> ids);
}
src/main/java/com/ruoyi/production/service/ProductionTeamService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
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.ProductionTeamDto;
import com.ruoyi.production.pojo.ProductionTeam;
import java.util.List;
public interface ProductionTeamService extends IService<ProductionTeam> {
    IPage<ProductionTeamDto> pageProductionTeam(Page<ProductionTeamDto> page, ProductionTeamDto dto);
    List<ProductionTeamDto> listDto(Long workshopId);
    int batchDelete(List<Long> ids);
}
src/main/java/com/ruoyi/production/service/WorkshopService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
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.pojo.Workshop;
import java.util.List;
public interface WorkshopService extends IService<Workshop> {
    IPage<Workshop> pageWorkshop(Page<Workshop> page, Workshop workshop);
    List<Workshop> listAll();
    int batchDelete(List<Long> ids);
}
src/main/java/com/ruoyi/production/service/impl/ProductionSchedulingServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,40 @@
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.ProductionSchedulingDto;
import com.ruoyi.production.mapper.ProductionSchedulingMapper;
import com.ruoyi.production.pojo.ProductionScheduling;
import com.ruoyi.production.service.ProductionSchedulingService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
@Service
@AllArgsConstructor
@Slf4j
public class ProductionSchedulingServiceImpl extends ServiceImpl<ProductionSchedulingMapper, ProductionScheduling> implements ProductionSchedulingService {
    @Autowired
    private ProductionSchedulingMapper productionSchedulingMapper;
    @Override
    public IPage<ProductionSchedulingDto> pageProductionScheduling(Page<ProductionSchedulingDto> page, ProductionSchedulingDto dto) {
        return productionSchedulingMapper.pageProductionScheduling(page, dto);
    }
    @Override
    public ProductionSchedulingDto todayByTeam(Long teamId) {
        return productionSchedulingMapper.todayByTeam(teamId, LocalDate.now());
    }
    @Override
    public int batchDelete(List<Long> ids) {
        return productionSchedulingMapper.deleteBatchIds(ids);
    }
}
src/main/java/com/ruoyi/production/service/impl/ProductionTeamServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
package com.ruoyi.production.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.production.dto.ProductionTeamDto;
import com.ruoyi.production.mapper.ProductionSchedulingMapper;
import com.ruoyi.production.mapper.ProductionTeamMapper;
import com.ruoyi.production.pojo.ProductionScheduling;
import com.ruoyi.production.pojo.ProductionTeam;
import com.ruoyi.production.service.ProductionTeamService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@AllArgsConstructor
@Slf4j
public class ProductionTeamServiceImpl extends ServiceImpl<ProductionTeamMapper, ProductionTeam> implements ProductionTeamService {
    @Autowired
    private ProductionTeamMapper productionTeamMapper;
    @Autowired
    private ProductionSchedulingMapper productionSchedulingMapper;
    @Override
    public IPage<ProductionTeamDto> pageProductionTeam(Page<ProductionTeamDto> page, ProductionTeamDto dto) {
        return productionTeamMapper.pageProductionTeam(page, dto);
    }
    @Override
    public List<ProductionTeamDto> listDto(Long workshopId) {
        return productionTeamMapper.listProductionTeamDto(workshopId);
    }
    @Override
    public int batchDelete(List<Long> ids) {
        List<ProductionScheduling> schedulings = productionSchedulingMapper.selectList(Wrappers.<ProductionScheduling>lambdaQuery().in(ProductionScheduling::getTeamId, ids));
        if (schedulings.size() > 0) {
            throw new RuntimeException("该班组已被排班引用,不能删除");
        }
        return productionTeamMapper.deleteBatchIds(ids);
    }
}
src/main/java/com/ruoyi/production/service/impl/WorkshopServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,57 @@
package com.ruoyi.production.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.production.mapper.ProductionSchedulingMapper;
import com.ruoyi.production.mapper.ProductionTeamMapper;
import com.ruoyi.production.mapper.WorkshopMapper;
import com.ruoyi.production.pojo.ProductionScheduling;
import com.ruoyi.production.pojo.ProductionTeam;
import com.ruoyi.production.pojo.Workshop;
import com.ruoyi.production.service.WorkshopService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@AllArgsConstructor
@Slf4j
public class WorkshopServiceImpl extends ServiceImpl<WorkshopMapper, Workshop> implements WorkshopService {
    @Autowired
    private WorkshopMapper workshopMapper;
    @Autowired
    private ProductionTeamMapper productionTeamMapper;
    @Autowired
    private ProductionSchedulingMapper productionSchedulingMapper;
    @Override
    public IPage<Workshop> pageWorkshop(Page<Workshop> page, Workshop workshop) {
        return workshopMapper.pageWorkshop(page, workshop);
    }
    @Override
    public List<Workshop> listAll() {
        return this.list(Wrappers.<Workshop>lambdaQuery().orderByAsc(Workshop::getId));
    }
    @Override
    public int batchDelete(List<Long> ids) {
        List<ProductionTeam> teams = productionTeamMapper.selectList(Wrappers.<ProductionTeam>lambdaQuery().in(ProductionTeam::getWorkshopId, ids));
        if (teams.size() > 0) {
            throw new RuntimeException("该车间已被班组引用,不能删除");
        }
        List<ProductionScheduling> schedulings = productionSchedulingMapper.selectList(Wrappers.<ProductionScheduling>lambdaQuery().in(ProductionScheduling::getWorkshopId, ids));
        if (schedulings.size() > 0) {
            throw new RuntimeException("该车间已被排班引用,不能删除");
        }
        return workshopMapper.deleteBatchIds(ids);
    }
}
src/main/resources/mapper/production/ProductionSchedulingMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,39 @@
<?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.ProductionSchedulingMapper">
    <select id="pageProductionScheduling" resultType="com.ruoyi.production.dto.ProductionSchedulingDto">
        select t.*, w.name as workshop_name, pt.team_name
        from production_scheduling t
        left join workshop w on t.workshop_id = w.id
        left join production_team pt on t.team_id = pt.id
        <where>
            <if test="c.startDate != null">
                and t.work_date &gt;= #{c.startDate}
            </if>
            <if test="c.endDate != null">
                and t.work_date &lt;= #{c.endDate}
            </if>
            <if test="c.workshopId != null">
                and t.workshop_id = #{c.workshopId}
            </if>
            <if test="c.teamId != null">
                and t.team_id = #{c.teamId}
            </if>
            <if test="c.status != null">
                and t.status = #{c.status}
            </if>
        </where>
        order by t.work_date desc, t.id desc
    </select>
    <select id="todayByTeam" resultType="com.ruoyi.production.dto.ProductionSchedulingDto">
        select t.*, w.name as workshop_name, pt.team_name
        from production_scheduling t
        left join workshop w on t.workshop_id = w.id
        left join production_team pt on t.team_id = pt.id
        where t.team_id = #{teamId} and t.work_date = #{workDate}
        order by t.id desc
        limit 1
    </select>
</mapper>
src/main/resources/mapper/production/ProductionTeamMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
<?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.ProductionTeamMapper">
    <select id="pageProductionTeam" resultType="com.ruoyi.production.dto.ProductionTeamDto">
        select t.*, w.name as workshop_name
        from production_team t
        left join workshop w on t.workshop_id = w.id
        <where>
            <if test="c.teamName != null and c.teamName != ''">
                and t.team_name like concat('%',#{c.teamName},'%')
            </if>
            <if test="c.workshopId != null">
                and t.workshop_id = #{c.workshopId}
            </if>
            <if test="c.status != null">
                and t.status = #{c.status}
            </if>
        </where>
        order by t.id desc
    </select>
    <select id="listProductionTeamDto" resultType="com.ruoyi.production.dto.ProductionTeamDto">
        select t.*, w.name as workshop_name
        from production_team t
        left join workshop w on t.workshop_id = w.id
        <where>
            <if test="workshopId != null">
                and t.workshop_id = #{workshopId}
            </if>
        </where>
        order by t.id asc
    </select>
</mapper>
src/main/resources/mapper/production/WorkshopMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
<?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.WorkshopMapper">
    <select id="pageWorkshop" resultType="com.ruoyi.production.pojo.Workshop">
        select * from workshop
        <where>
            <if test="c.name != null and c.name != ''">
                and name like concat('%',#{c.name},'%')
            </if>
            <if test="c.code != null and c.code != ''">
                and code like concat('%',#{c.code},'%')
            </if>
            <if test="c.status != null">
                and status = #{c.status}
            </if>
        </where>
        order by id desc
    </select>
</mapper>