38 changed files with 68 additions and 854 deletions
@ -1,167 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation; |
|
||||
|
|
||||
import com.win.module.mes.controller.workstation.vo.*; |
|
||||
import com.win.module.mes.convert.workstation.WorkstationTeamConvert; |
|
||||
import com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO; |
|
||||
import com.win.module.mes.service.workstation.WorkstationTeamService; |
|
||||
import io.swagger.v3.oas.annotations.Parameters; |
|
||||
import org.springframework.web.bind.annotation.*; |
|
||||
import javax.annotation.Resource; |
|
||||
import org.springframework.validation.annotation.Validated; |
|
||||
import org.springframework.security.access.prepost.PreAuthorize; |
|
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
|
||||
import io.swagger.v3.oas.annotations.Parameter; |
|
||||
import io.swagger.v3.oas.annotations.Operation; |
|
||||
|
|
||||
import javax.validation.*; |
|
||||
import javax.servlet.http.*; |
|
||||
import java.time.LocalDateTime; |
|
||||
import java.time.ZoneOffset; |
|
||||
import java.util.*; |
|
||||
import java.io.IOException; |
|
||||
|
|
||||
import com.win.framework.common.pojo.PageResult; |
|
||||
import com.win.framework.common.pojo.CommonResult; |
|
||||
import static com.win.framework.common.pojo.CommonResult.success; |
|
||||
|
|
||||
import com.win.framework.excel.core.util.ExcelUtils; |
|
||||
|
|
||||
import com.win.framework.operatelog.core.annotations.OperateLog; |
|
||||
import org.springframework.web.multipart.MultipartFile; |
|
||||
|
|
||||
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; |
|
||||
|
|
||||
|
|
||||
@Tag(name = "管理后台 - 班组") |
|
||||
@RestController |
|
||||
@RequestMapping("/mes/team") |
|
||||
@Validated |
|
||||
public class WorkstationTeamController { |
|
||||
|
|
||||
@Resource |
|
||||
private WorkstationTeamService mesWorkstationTeamService; |
|
||||
|
|
||||
@PostMapping("/create") |
|
||||
@Operation(summary = "创建班组") |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:create')") |
|
||||
public CommonResult<Long> createTeam(@Valid @RequestBody WorkstationTeamCreateReqVO createReqVO) { |
|
||||
return success(mesWorkstationTeamService.createTeam(createReqVO)); |
|
||||
} |
|
||||
|
|
||||
@PutMapping("/update") |
|
||||
@Operation(summary = "更新班组") |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:update')") |
|
||||
public CommonResult<Boolean> updateTeam(@Valid @RequestBody WorkstationTeamUpdateReqVO updateReqVO) { |
|
||||
int result = mesWorkstationTeamService.updateTeam(updateReqVO); |
|
||||
return success(result > 0); |
|
||||
} |
|
||||
|
|
||||
@DeleteMapping("/delete") |
|
||||
@Operation(summary = "删除班组") |
|
||||
@Parameter(name = "id", description = "编号", required = true) |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:delete')") |
|
||||
public CommonResult<Boolean> deleteTeam(@RequestParam("id") Long id) { |
|
||||
int result = mesWorkstationTeamService.deleteTeam(id); |
|
||||
return success(result > 0); |
|
||||
} |
|
||||
|
|
||||
@GetMapping("/get") |
|
||||
@Operation(summary = "获得班组") |
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:query')") |
|
||||
public CommonResult<WorkstationTeamRespVO> getTeam(@RequestParam("id") Long id) { |
|
||||
WorkstationTeamDO team = mesWorkstationTeamService.getTeam(id); |
|
||||
return success(WorkstationTeamConvert.INSTANCE.convert(team)); |
|
||||
} |
|
||||
|
|
||||
@GetMapping("/list") |
|
||||
@Operation(summary = "获得班组列表") |
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:query')") |
|
||||
public CommonResult<List<WorkstationTeamRespVO>> getTeamList(@RequestParam("ids") Collection<Long> ids) { |
|
||||
List<WorkstationTeamDO> list = mesWorkstationTeamService.getTeamList(ids); |
|
||||
return success(WorkstationTeamConvert.INSTANCE.convertList(list)); |
|
||||
} |
|
||||
|
|
||||
@GetMapping("/page") |
|
||||
@Operation(summary = "获得班组分页") |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:query')") |
|
||||
public CommonResult<PageResult<WorkstationTeamRespVO>> getTeamPage(@Valid WorkstationTeamPageReqVO pageVO) { |
|
||||
PageResult<WorkstationTeamDO> pageResult = mesWorkstationTeamService.getTeamPage(pageVO); |
|
||||
return success(WorkstationTeamConvert.INSTANCE.convertPage(pageResult)); |
|
||||
} |
|
||||
|
|
||||
@GetMapping("/export-excel") |
|
||||
@Operation(summary = "导出班组 Excel") |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:export')") |
|
||||
@OperateLog(type = EXPORT) |
|
||||
public void exportTeamExcel(@Valid WorkstationTeamExportReqVO exportReqVO, |
|
||||
HttpServletResponse response) throws IOException { |
|
||||
List<WorkstationTeamDO> list = mesWorkstationTeamService.getTeamList(exportReqVO); |
|
||||
// 导出 Excel
|
|
||||
List<WorkstationTeamExcelVO> datas = WorkstationTeamConvert.INSTANCE.convertList02(list); |
|
||||
ExcelUtils.write(response, "班组.xls", "数据", WorkstationTeamExcelVO.class, datas); |
|
||||
} |
|
||||
|
|
||||
@GetMapping("/get-import-template") |
|
||||
@Operation(summary = "获得导入班组模板") |
|
||||
public void importTemplate(HttpServletResponse response) throws IOException { |
|
||||
List<WorkstationTeamExcelVO> list = Arrays.asList(); |
|
||||
// 输出
|
|
||||
ExcelUtils.write(response, "班组基本信息导入模板.xls", "班组基本信息列表", WorkstationTeamExcelVO.class, list); |
|
||||
} |
|
||||
|
|
||||
@PostMapping("/import") |
|
||||
@Operation(summary = "导入班组基本信息") |
|
||||
@Parameters({ |
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true), |
|
||||
@Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), |
|
||||
@Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") |
|
||||
}) |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:import')") |
|
||||
public CommonResult<Map<String, Object>> importExcel(HttpServletResponse response, |
|
||||
@RequestParam("file") MultipartFile file, |
|
||||
@RequestParam(value = "mode") Integer mode, |
|
||||
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { |
|
||||
|
|
||||
List<WorkstationTeamExcelVO> list = ExcelUtils.read(file, WorkstationTeamExcelVO.class); |
|
||||
List<WorkstationTeamExcelVO> errorList = mesWorkstationTeamService.importTeamList(list, mode, updatePart); |
|
||||
|
|
||||
Map<String, Object> returnMap = new HashMap<>(); |
|
||||
returnMap.put("errorCount", errorList.size()); |
|
||||
if(!errorList.isEmpty()) { |
|
||||
String url = ExcelUtils.writeLocalFile("班组基本信息导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xlsx", "错误列表", errorList); |
|
||||
returnMap.put("errorFile", url); |
|
||||
} |
|
||||
|
|
||||
return success(returnMap); |
|
||||
} |
|
||||
@GetMapping("/pageListByWorkstationCode") |
|
||||
@Operation(summary = "根据工位code获得已关联班组列表") |
|
||||
@Parameter(name = "code", description = "工位编号", required = true) |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:query')") |
|
||||
public CommonResult<PageResult<WorkstationTeamRespVO>> pageListByWorkstationCode(@Valid WorkstationTeamPageReqVO pageVO) { |
|
||||
PageResult<WorkstationTeamDO> pageResult = mesWorkstationTeamService.pageListByWorkstationCode(pageVO); |
|
||||
return success(WorkstationTeamConvert.INSTANCE.convertPage(pageResult)); |
|
||||
} |
|
||||
@GetMapping("/pageCheckListByWorkstationCode") |
|
||||
@Operation(summary = "根据工位code获得可关联班组列表") |
|
||||
@Parameter(name = "code", description = "工位编号", required = true) |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:query')") |
|
||||
public CommonResult<PageResult<WorkstationTeamRespVO>> pageCheckListByWorkstationCode(@Valid WorkstationTeamPageReqVO pageVO) { |
|
||||
PageResult<WorkstationTeamDO> pageResult = mesWorkstationTeamService.pageCheckListByWorkstationCode(pageVO); |
|
||||
return success(WorkstationTeamConvert.INSTANCE.convertPage(pageResult)); |
|
||||
} |
|
||||
@PostMapping("/createRelation") |
|
||||
@Operation(summary = "工位关联班组") |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:update')") |
|
||||
public CommonResult<Object> createRelation(@Valid @RequestBody WorkstationTeamRelationReqVO workstationTeamRelationReqVO) { |
|
||||
return success(mesWorkstationTeamService.createRelation(workstationTeamRelationReqVO)); |
|
||||
} |
|
||||
@PostMapping("/deleteRelation") |
|
||||
@Operation(summary = "删除工位班组关联") |
|
||||
@PreAuthorize("@ss.hasPermission('mes:team:update')") |
|
||||
public CommonResult<Object> deleteRelation(@Valid @RequestBody WorkstationTeamRelationReqVO workstationTeamRelationReqVO) { |
|
||||
return success(mesWorkstationTeamService.deleteRelation(workstationTeamRelationReqVO)); |
|
||||
} |
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation.vo; |
|
||||
|
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
|
||||
import lombok.*; |
|
||||
|
|
||||
/** |
|
||||
* 班组 Base VO,提供给添加、修改、详细的子 VO 使用 |
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
|
||||
*/ |
|
||||
@Data |
|
||||
public class WorkstationTeamBaseVO { |
|
||||
@Schema(description = "id", example = "id") |
|
||||
private Long id; |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation.vo; |
|
||||
|
|
||||
import lombok.*; |
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
|
||||
|
|
||||
@Schema(description = "管理后台 - 班组创建 Request VO") |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@ToString(callSuper = true) |
|
||||
public class WorkstationTeamCreateReqVO extends WorkstationTeamBaseVO { |
|
||||
|
|
||||
} |
|
@ -1,21 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation.vo; |
|
||||
|
|
||||
import lombok.*; |
|
||||
|
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
|
||||
|
|
||||
/** |
|
||||
* 班组 Excel VO |
|
||||
* |
|
||||
* @author 超级管理员 |
|
||||
*/ |
|
||||
@Data |
|
||||
public class WorkstationTeamExcelVO { |
|
||||
|
|
||||
@ExcelProperty("代码") |
|
||||
private String code; |
|
||||
|
|
||||
@ExcelProperty("名称") |
|
||||
private String name; |
|
||||
|
|
||||
} |
|
@ -1,16 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation.vo; |
|
||||
|
|
||||
import lombok.*; |
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
|
||||
|
|
||||
@Schema(description = "管理后台 - 班组 Excel 导出 Request VO,参数和 TeamPageReqVO 是一致的") |
|
||||
@Data |
|
||||
public class WorkstationTeamExportReqVO { |
|
||||
|
|
||||
@Schema(description = "代码") |
|
||||
private String code; |
|
||||
|
|
||||
@Schema(description = "名称") |
|
||||
private String name; |
|
||||
|
|
||||
} |
|
@ -1,18 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation.vo; |
|
||||
|
|
||||
import lombok.*; |
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
|
||||
import com.win.framework.common.pojo.PageParam; |
|
||||
|
|
||||
@Schema(description = "管理后台 - 班组分页 Request VO") |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@ToString(callSuper = true) |
|
||||
public class WorkstationTeamPageReqVO extends PageParam { |
|
||||
@Schema(description = "工位code") |
|
||||
private String workstationCode; |
|
||||
|
|
||||
@Schema(description = "名称") |
|
||||
private String name; |
|
||||
|
|
||||
} |
|
@ -1,21 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation.vo; |
|
||||
|
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
|
||||
import lombok.Data; |
|
||||
import lombok.ToString; |
|
||||
|
|
||||
import javax.validation.constraints.NotEmpty; |
|
||||
import javax.validation.constraints.NotNull; |
|
||||
|
|
||||
@Schema(description = "管理后台 - 关联班组 Request VO") |
|
||||
@Data |
|
||||
@ToString(callSuper = true) |
|
||||
public class WorkstationTeamRelationReqVO { |
|
||||
@Schema(description = "工位code") |
|
||||
@NotNull(message = "工位code不能为空") |
|
||||
private String workstationCode; |
|
||||
|
|
||||
@Schema(description = "班组code数组") |
|
||||
@NotEmpty(message = "班组不能为空") |
|
||||
private String[] teamCodes; |
|
||||
} |
|
@ -1,20 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation.vo; |
|
||||
|
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
|
||||
import lombok.*; |
|
||||
|
|
||||
@Schema(description = "管理后台 - 班组 Response VO") |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@ToString(callSuper = true) |
|
||||
public class WorkstationTeamRespVO extends WorkstationTeamBaseVO { |
|
||||
|
|
||||
@Schema(description = "代码", requiredMode = Schema.RequiredMode.REQUIRED) |
|
||||
private String code; |
|
||||
|
|
||||
@Schema(description = "名称") |
|
||||
private String name; |
|
||||
|
|
||||
@Schema(description = "给前端Detail组件使用的,没有这个属性不显示添加修改按钮") |
|
||||
private String status = "1"; |
|
||||
} |
|
@ -1,21 +0,0 @@ |
|||||
package com.win.module.mes.controller.workstation.vo; |
|
||||
|
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
|
||||
import lombok.*; |
|
||||
|
|
||||
import javax.validation.constraints.NotEmpty; |
|
||||
import javax.validation.constraints.NotNull; |
|
||||
|
|
||||
@Schema(description = "管理后台 - 班组更新 Request VO") |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@ToString(callSuper = true) |
|
||||
public class WorkstationTeamUpdateReqVO extends WorkstationTeamBaseVO { |
|
||||
@Schema(description = "工位code") |
|
||||
@NotNull(message = "工位code不能为空") |
|
||||
private String workstationCode; |
|
||||
|
|
||||
@Schema(description = "班组code数组") |
|
||||
@NotEmpty(message = "班组不能为空") |
|
||||
private String[] teamCodes; |
|
||||
} |
|
@ -1,37 +0,0 @@ |
|||||
package com.win.module.mes.convert.workstation; |
|
||||
|
|
||||
import java.util.*; |
|
||||
|
|
||||
import com.win.framework.common.pojo.PageResult; |
|
||||
|
|
||||
import com.win.module.mes.controller.workstation.vo.*; |
|
||||
import com.win.module.mes.controller.workstation.vo.WorkstationTeamUpdateReqVO; |
|
||||
import com.win.module.mes.controller.workstation.vo.WorkstationTeamRespVO; |
|
||||
import com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO; |
|
||||
import org.mapstruct.Mapper; |
|
||||
import org.mapstruct.factory.Mappers; |
|
||||
|
|
||||
/** |
|
||||
* 班组 Convert |
|
||||
* |
|
||||
* @author 超级管理员 |
|
||||
*/ |
|
||||
@Mapper |
|
||||
public interface WorkstationTeamConvert { |
|
||||
|
|
||||
WorkstationTeamConvert INSTANCE = Mappers.getMapper(WorkstationTeamConvert.class); |
|
||||
|
|
||||
WorkstationTeamDO convert(WorkstationTeamCreateReqVO bean); |
|
||||
|
|
||||
WorkstationTeamDO convert(WorkstationTeamUpdateReqVO bean); |
|
||||
|
|
||||
WorkstationTeamRespVO convert(WorkstationTeamDO bean); |
|
||||
|
|
||||
List<WorkstationTeamRespVO> convertList(List<WorkstationTeamDO> list); |
|
||||
|
|
||||
PageResult<WorkstationTeamRespVO> convertPage(PageResult<WorkstationTeamDO> page); |
|
||||
|
|
||||
List<WorkstationTeamExcelVO> convertList02(List<WorkstationTeamDO> list); |
|
||||
|
|
||||
WorkstationTeamDO convert(WorkstationTeamExcelVO item); |
|
||||
} |
|
@ -1,90 +0,0 @@ |
|||||
package com.win.module.mes.dal.dataobject.workstation; |
|
||||
|
|
||||
import lombok.*; |
|
||||
|
|
||||
import java.time.LocalDateTime; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.annotation.*; |
|
||||
import com.win.framework.mybatis.core.dataobject.BaseDO; |
|
||||
|
|
||||
/** |
|
||||
* 班组 DO |
|
||||
* |
|
||||
* @author 超级管理员 |
|
||||
*/ |
|
||||
@TableName("basic_team") |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@ToString(callSuper = true) |
|
||||
@Builder |
|
||||
@NoArgsConstructor |
|
||||
@AllArgsConstructor |
|
||||
public class WorkstationTeamDO extends BaseDO { |
|
||||
|
|
||||
/** |
|
||||
* id |
|
||||
*/ |
|
||||
@TableId |
|
||||
private Long id; |
|
||||
/** |
|
||||
* 代码 |
|
||||
*/ |
|
||||
private String code; |
|
||||
/** |
|
||||
* 车间代码 |
|
||||
*/ |
|
||||
private String workshopCode; |
|
||||
/** |
|
||||
* 生产线代码 |
|
||||
*/ |
|
||||
private String productionLineCode; |
|
||||
/** |
|
||||
* 名称 |
|
||||
*/ |
|
||||
private String name; |
|
||||
/** |
|
||||
* 描述 |
|
||||
*/ |
|
||||
private String description; |
|
||||
/** |
|
||||
* 成员 |
|
||||
*/ |
|
||||
private String members; |
|
||||
/** |
|
||||
* 生效时间 |
|
||||
*/ |
|
||||
private LocalDateTime activeTime; |
|
||||
/** |
|
||||
* 失效时间 |
|
||||
*/ |
|
||||
private LocalDateTime expireTime; |
|
||||
/** |
|
||||
* 备注 |
|
||||
*/ |
|
||||
private String remark; |
|
||||
/** |
|
||||
* 删除时间 |
|
||||
*/ |
|
||||
private LocalDateTime deletionTime; |
|
||||
/** |
|
||||
* 删除者ID |
|
||||
*/ |
|
||||
private String deleterId; |
|
||||
/** |
|
||||
* 扩展属性 |
|
||||
*/ |
|
||||
private String extraProperties; |
|
||||
/** |
|
||||
* 并发乐观锁 |
|
||||
*/ |
|
||||
private String concurrencyStamp; |
|
||||
/** |
|
||||
* 地点ID |
|
||||
*/ |
|
||||
private String siteId; |
|
||||
/** |
|
||||
* 是否可用 |
|
||||
*/ |
|
||||
private String available; |
|
||||
|
|
||||
} |
|
@ -1,39 +0,0 @@ |
|||||
package com.win.module.mes.dal.mysql.workstation; |
|
||||
|
|
||||
import java.util.*; |
|
||||
|
|
||||
import com.win.framework.common.pojo.PageResult; |
|
||||
import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; |
|
||||
import com.win.framework.mybatis.core.mapper.BaseMapperX; |
|
||||
import com.win.module.mes.controller.workstation.vo.WorkstationTeamExportReqVO; |
|
||||
import com.win.module.mes.controller.workstation.vo.WorkstationTeamPageReqVO; |
|
||||
import com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO; |
|
||||
import org.apache.ibatis.annotations.Mapper; |
|
||||
import org.apache.ibatis.annotations.Param; |
|
||||
|
|
||||
/** |
|
||||
* 班组 Mapper |
|
||||
* |
|
||||
* @author 超级管理员 |
|
||||
*/ |
|
||||
@Mapper |
|
||||
public interface WorkstationTeamMapper extends BaseMapperX<WorkstationTeamDO> { |
|
||||
default PageResult<WorkstationTeamDO> selectPage(WorkstationTeamPageReqVO reqVO) { |
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<WorkstationTeamDO>() |
|
||||
.exists("select 1 from basic_workstation where code={0} and basic_team.code=team_code", reqVO.getWorkstationCode()) |
|
||||
.orderByDesc(WorkstationTeamDO::getId)); |
|
||||
} |
|
||||
|
|
||||
default List<WorkstationTeamDO> selectList(WorkstationTeamExportReqVO reqVO) { |
|
||||
return selectList(new LambdaQueryWrapperX<WorkstationTeamDO>() |
|
||||
.eqIfPresent(WorkstationTeamDO::getCode, reqVO.getCode()) |
|
||||
.likeIfPresent(WorkstationTeamDO::getName, reqVO.getName()) |
|
||||
.orderByDesc(WorkstationTeamDO::getId)); |
|
||||
} |
|
||||
default WorkstationTeamDO selectByCode(String code) { |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
Long checkCountByWorkstationCode(Map<String,Object> params); |
|
||||
List<WorkstationTeamDO> checkListByWorkstationCode(Map<String,Object> params); |
|
||||
} |
|
@ -1,106 +0,0 @@ |
|||||
package com.win.module.mes.service.workstation; |
|
||||
|
|
||||
import java.util.*; |
|
||||
import javax.validation.*; |
|
||||
import com.win.framework.common.pojo.PageResult; |
|
||||
import com.win.module.mes.controller.workstation.vo.*; |
|
||||
import com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO; |
|
||||
|
|
||||
/** |
|
||||
* 班组 Service 接口 |
|
||||
* |
|
||||
* @author 超级管理员 |
|
||||
*/ |
|
||||
public interface WorkstationTeamService { |
|
||||
|
|
||||
/** |
|
||||
* 创建班组 |
|
||||
* |
|
||||
* @param createReqVO 创建信息 |
|
||||
* @return 编号 |
|
||||
*/ |
|
||||
Long createTeam(@Valid WorkstationTeamCreateReqVO createReqVO); |
|
||||
|
|
||||
/** |
|
||||
* 更新班组 |
|
||||
* |
|
||||
* @param updateReqVO 更新信息 |
|
||||
*/ |
|
||||
Integer updateTeam(@Valid WorkstationTeamUpdateReqVO updateReqVO); |
|
||||
|
|
||||
/** |
|
||||
* 删除班组 |
|
||||
* |
|
||||
* @param id 编号 |
|
||||
*/ |
|
||||
Integer deleteTeam(Long id); |
|
||||
|
|
||||
/** |
|
||||
* 获得班组 |
|
||||
* |
|
||||
* @param id 编号 |
|
||||
* @return 班组 |
|
||||
*/ |
|
||||
WorkstationTeamDO getTeam(Long id); |
|
||||
|
|
||||
/** |
|
||||
* 获得班组列表 |
|
||||
* |
|
||||
* @param ids 编号 |
|
||||
* @return 班组列表 |
|
||||
*/ |
|
||||
List<WorkstationTeamDO> getTeamList(Collection<Long> ids); |
|
||||
/** |
|
||||
* 根据工位code获得已关联班组列表 |
|
||||
* |
|
||||
* @param pageVO |
|
||||
* @return 班组列表 |
|
||||
*/ |
|
||||
PageResult<WorkstationTeamDO> pageListByWorkstationCode(WorkstationTeamPageReqVO pageVO); |
|
||||
/** |
|
||||
* 根据工位code获得可关联班组列表 |
|
||||
* |
|
||||
* @param pageVO |
|
||||
* @return 班组列表 |
|
||||
*/ |
|
||||
PageResult<WorkstationTeamDO> pageCheckListByWorkstationCode(WorkstationTeamPageReqVO pageVO); |
|
||||
/** |
|
||||
* 获得班组分页 |
|
||||
* |
|
||||
* @param pageReqVO 分页查询 |
|
||||
* @return 班组分页 |
|
||||
*/ |
|
||||
PageResult<WorkstationTeamDO> getTeamPage(WorkstationTeamPageReqVO pageReqVO); |
|
||||
|
|
||||
/** |
|
||||
* 获得班组列表, 用于 Excel 导出 |
|
||||
* |
|
||||
* @param exportReqVO 查询条件 |
|
||||
* @return 班组列表 |
|
||||
*/ |
|
||||
List<WorkstationTeamDO> getTeamList(WorkstationTeamExportReqVO exportReqVO); |
|
||||
|
|
||||
/** |
|
||||
* 导入班组主信息 |
|
||||
* |
|
||||
* @param datas 导入班组主信息列表 |
|
||||
* @param mode 导入模式1更新2追加3覆盖 |
|
||||
* @param updatePart 是否支持更新 |
|
||||
* @return 导入结果 |
|
||||
*/ |
|
||||
List<WorkstationTeamExcelVO> importTeamList(List<WorkstationTeamExcelVO> datas, Integer mode, boolean updatePart); |
|
||||
|
|
||||
/** |
|
||||
* 创建工位班组关联 |
|
||||
* @param workstationTeamRelationReqVO |
|
||||
* @return |
|
||||
*/ |
|
||||
Object createRelation(WorkstationTeamRelationReqVO workstationTeamRelationReqVO); |
|
||||
|
|
||||
/** |
|
||||
* 删除工位班组关联 |
|
||||
* @param workstationTeamRelationReqVO |
|
||||
* @return |
|
||||
*/ |
|
||||
Object deleteRelation(WorkstationTeamRelationReqVO workstationTeamRelationReqVO); |
|
||||
} |
|
@ -1,141 +0,0 @@ |
|||||
package com.win.module.mes.service.workstation; |
|
||||
|
|
||||
import cn.hutool.core.bean.BeanUtil; |
|
||||
import cn.hutool.core.collection.CollUtil; |
|
||||
import com.alibaba.fastjson.JSONObject; |
|
||||
import com.win.module.mes.controller.workstation.vo.*; |
|
||||
import com.win.module.mes.convert.workstation.WorkstationTeamConvert; |
|
||||
import com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO; |
|
||||
import com.win.module.mes.dal.mysql.workstation.WorkstationTeamMapper; |
|
||||
import com.win.module.mes.dal.mysql.workstation.MesWorkstationMapper; |
|
||||
import org.apache.calcite.util.Util; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
import javax.annotation.Resource; |
|
||||
|
|
||||
import org.springframework.validation.annotation.Validated; |
|
||||
|
|
||||
import java.util.*; |
|
||||
import com.win.framework.common.pojo.PageResult; |
|
||||
|
|
||||
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
||||
import static com.win.module.mes.enums.ErrorCodeConstants.TEAM_IMPORT_LIST_IS_EMPTY; |
|
||||
import static com.win.module.mes.enums.ErrorCodeConstants.TEAM_NOT_EXISTS; |
|
||||
|
|
||||
/** |
|
||||
* 班组 Service 实现类 |
|
||||
* |
|
||||
* @author 超级管理员 |
|
||||
*/ |
|
||||
@Service(value = "mesTeamService") |
|
||||
@Validated |
|
||||
public class WorkstationTeamServiceImpl implements WorkstationTeamService { |
|
||||
|
|
||||
@Resource |
|
||||
private WorkstationTeamMapper workstationTeamMapper; |
|
||||
@Resource |
|
||||
private MesWorkstationMapper mesWorkstationMapper; |
|
||||
@Override |
|
||||
public Long createTeam(WorkstationTeamCreateReqVO createReqVO) { |
|
||||
// 插入
|
|
||||
WorkstationTeamDO team = WorkstationTeamConvert.INSTANCE.convert(createReqVO); |
|
||||
workstationTeamMapper.insert(team); |
|
||||
// 返回
|
|
||||
return team.getId(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public Integer updateTeam(WorkstationTeamUpdateReqVO updateReqVO) { |
|
||||
// 校验存在
|
|
||||
validateTeamExists(updateReqVO.getId()); |
|
||||
// 更新
|
|
||||
WorkstationTeamDO updateObj = WorkstationTeamConvert.INSTANCE.convert(updateReqVO); |
|
||||
return workstationTeamMapper.updateById(updateObj); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public Integer deleteTeam(Long id) { |
|
||||
// 校验存在
|
|
||||
validateTeamExists(id); |
|
||||
// 删除
|
|
||||
return workstationTeamMapper.deleteById(id); |
|
||||
} |
|
||||
|
|
||||
private void validateTeamExists(Long id) { |
|
||||
if (workstationTeamMapper.selectById(id) == null) { |
|
||||
throw exception(TEAM_NOT_EXISTS); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public WorkstationTeamDO getTeam(Long id) { |
|
||||
return workstationTeamMapper.selectById(id); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<WorkstationTeamDO> getTeamList(Collection<Long> ids) { |
|
||||
return workstationTeamMapper.selectBatchIds(ids); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public PageResult<WorkstationTeamDO> pageListByWorkstationCode(WorkstationTeamPageReqVO pageVO) { |
|
||||
return workstationTeamMapper.selectPage(pageVO); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public PageResult<WorkstationTeamDO> pageCheckListByWorkstationCode(WorkstationTeamPageReqVO pageVO) { |
|
||||
Map<String,Object> params = BeanUtil.beanToMap(pageVO); |
|
||||
params.put("productionLineCodeCheck",false); |
|
||||
Long count = workstationTeamMapper.checkCountByWorkstationCode(params); |
|
||||
PageResult<WorkstationTeamDO> pageResult = new PageResult(); |
|
||||
if (count > 0){ |
|
||||
pageResult.setList(workstationTeamMapper.checkListByWorkstationCode(params)); |
|
||||
pageResult.setTotal(count); |
|
||||
} |
|
||||
return pageResult; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public PageResult<WorkstationTeamDO> getTeamPage(WorkstationTeamPageReqVO pageReqVO) { |
|
||||
return workstationTeamMapper.selectPage(pageReqVO); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<WorkstationTeamDO> getTeamList(WorkstationTeamExportReqVO exportReqVO) { |
|
||||
return workstationTeamMapper.selectList(exportReqVO); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<WorkstationTeamExcelVO> importTeamList(List<WorkstationTeamExcelVO> datas, Integer mode, boolean updatePart) { |
|
||||
if (CollUtil.isEmpty(datas)) { |
|
||||
throw exception(TEAM_IMPORT_LIST_IS_EMPTY); |
|
||||
} |
|
||||
|
|
||||
List<WorkstationTeamExcelVO> errorList = new ArrayList<>(); |
|
||||
datas.forEach(item -> { |
|
||||
if(errorList == null){ |
|
||||
// 判断如果不存在,在进行插入
|
|
||||
WorkstationTeamDO obj = workstationTeamMapper.selectByCode(item.getCode()); |
|
||||
if (obj == null&& mode != 3) { |
|
||||
workstationTeamMapper.insert(WorkstationTeamConvert.INSTANCE.convert(item)); |
|
||||
} |
|
||||
else if (obj != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
||||
WorkstationTeamDO teamDO = WorkstationTeamConvert.INSTANCE.convert(item); |
|
||||
teamDO.setId(obj.getId()); |
|
||||
workstationTeamMapper.updateById(obj); |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
return errorList; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public Object createRelation(WorkstationTeamRelationReqVO workstationTeamRelationReqVO) { |
|
||||
return mesWorkstationMapper.createRelation(workstationTeamRelationReqVO); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public Object deleteRelation(WorkstationTeamRelationReqVO workstationTeamRelationReqVO) { |
|
||||
return mesWorkstationMapper.deleteRelation(workstationTeamRelationReqVO); |
|
||||
} |
|
||||
} |
|
@ -1,20 +0,0 @@ |
|||||
<?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.win.module.mes.dal.mysql.workstation.WorkstationTeamMapper"> |
|
||||
<select id="checkCountByWorkstationCode" resultType="java.lang.Long"> |
|
||||
select count(1) from basic_team t where exists( |
|
||||
select 1 from basic_workstation where code=#{workstationCode} and t.workshop_code=workshop_code |
|
||||
<if test="productionLineCodeCheck"> |
|
||||
and t.production_line_code=production_line_code |
|
||||
</if> |
|
||||
) |
|
||||
</select> |
|
||||
<select id="checkListByWorkstationCode" resultType="com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO"> |
|
||||
select t.code,t.name from basic_team t where exists( |
|
||||
select 1 from basic_workstation where code=#{workstationCode} and t.workshop_code=workshop_code |
|
||||
<if test="productionLineCodeCheck"> |
|
||||
and t.production_line_code=production_line_code |
|
||||
</if> |
|
||||
) limit #{pageStart},#{pageSize} |
|
||||
</select> |
|
||||
</mapper> |
|
Loading…
Reference in new issue