打包接口,工序加工-板材类型查询修改

This commit is contained in:
liuzhaotian
2024-06-25 09:39:05 +08:00
parent 3c9977a9f8
commit c5775f8638
47 changed files with 433 additions and 308 deletions
@@ -0,0 +1,29 @@
package com.cf.imes.module.system.api.process;
import com.cf.imes.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
@Tag(name = "RPC 服务 - 工序")
public interface ProcessApi {
String PREFIX = ApiConstants.PREFIX + "/process";
@GetMapping(PREFIX + "/getProcess")
@Operation(summary = "查看当前工序的信息")
// @Parameter(name = "processId", description = "工序ID", required = true, example = "1024")
BigDecimal getProcess(/*@RequestParam("processId") Long processId*/);
}
@@ -0,0 +1,40 @@
package com.cf.imes.module.system.api.process;
import com.cf.imes.framework.common.enums.ProcessProcessingTypeEnum;
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
import com.cf.imes.module.system.dal.mysql.process.ProcessMapper;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class ProcessApiImpl implements ProcessApi {
@Resource
private ProcessMapper processMapper;
@Override
public BigDecimal getProcess() {
ProcessDO processDO = processMapper.selectByType(ProcessProcessingTypeEnum.COMPONENTPROCESSING.getNumber(),getUserOrganId());
return processDO.getPieceRate();
}
}
@@ -68,14 +68,14 @@ public class OrganController {
@PostMapping("/create")
@Operation(summary = "创建组织")
@PreAuthorize("@ss.hasPermission('system:organ:create')")
@PreAuthorize("@ss.hasPermission('organizationLIst:create')")
public CommonResult<Long> createOrgan(@Valid @RequestBody OrganSaveReqVO createReqVO) {
return success(organService.createOrgan(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新组织")
@PreAuthorize("@ss.hasPermission('system:organ:update')")
@PreAuthorize("@ss.hasPermission('organizationLIst:update')")
public CommonResult<Boolean> updateOrgan(@Valid @RequestBody OrganSaveReqVO updateReqVO) {
organService.updateOrgan(updateReqVO);
return success(true);
@@ -84,7 +84,7 @@ public class OrganController {
@DeleteMapping("/delete")
@Operation(summary = "删除组织")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:organ:delete')")
@PreAuthorize("@ss.hasPermission('organizationLIst:delete')")
public CommonResult<Boolean> deleteOrgan(@RequestParam("id") Long id) {
organService.deleteOrgan(id);
return success(true);
@@ -93,7 +93,7 @@ public class OrganController {
@GetMapping("/get")
@Operation(summary = "获得组织")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:organ:query')")
@PreAuthorize("@ss.hasPermission('organizationLIst:query')")
public CommonResult<OrganRespVO> getOrgan(@RequestParam("id") Long id) {
OrganizationDO organ = organService.getOrgan(id);
TenantPackageDO tenantPackageDO = tenantPackageMapper.selectById(organ.getPackageId());
@@ -104,7 +104,7 @@ public class OrganController {
@GetMapping("/page")
@Operation(summary = "获得组织分页")
@PreAuthorize("@ss.hasPermission('system:organ:query')")
@PreAuthorize("@ss.hasPermission('organizationLIst:query')")
public CommonResult<PageResult<OrganRespVO>> getOrganPage(@Valid OrganPageReqVO pageVO) {
PageResult<OrganizationDO> pageResult = organService.getOrganPage(pageVO);
if(CollectionUtil.isEmpty(pageResult.getList())) {
@@ -126,7 +126,7 @@ public class OrganController {
@GetMapping("/export-excel")
@Operation(summary = "导出组织 Excel")
@PreAuthorize("@ss.hasPermission('system:organ:export')")
@PreAuthorize("@ss.hasPermission('organizationLIst:export')")
@OperateLog(type = EXPORT)
public void exportOrganExcel(@Valid OrganPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
@@ -164,6 +164,7 @@ public class OrganController {
@GetMapping({"/list-all-simple", "/simple-list"})
@Operation(summary = "获取组织精简信息列表", description = "主要用于前端的下拉选项")
@Parameter(name = "name", description = "组织名称", required = false, example = "xxx")
@PreAuthorize("@ss.hasPermission('organizationLIst:query')")
public CommonResult<List<OrganSimpleRespVO>> getSimpleOrganList(@RequestParam(required = false, value = "name") String name) {
return success(organService.getSimpleOrganList(name));
}
@@ -5,7 +5,7 @@ import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupRespVO;
import com.cf.imes.module.system.controller.admin.process.vo.processUser.UserProcessRespVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
@@ -129,6 +129,15 @@ public class ProcessController {
@GetMapping("/getUserProcess")
@Operation(summary = "获取当前组织的工序名称和加工人名称")
@PreAuthorize("@ss.hasPermission('manage:process:query')")
public CommonResult<UserProcessRespVO> getUserProcess() {
return success(processService.getUserProcessName());
}
@@ -6,17 +6,15 @@ import com.alibaba.excel.annotation.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 工序用户表 process_user Response VO")
@Schema(description = "管理后台 - 工序用户表")
@Data
@ExcelIgnoreUnannotated
public class ProcessAndUserRespVO {
@Schema(description = "工序 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9416")
@ExcelProperty("工序 ID")
private Long processId;
@Schema(description = "工序名称")
private String processName;
@Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24517")
@ExcelProperty("用户 ID")
@Schema(description = "加工人ID")
private Long userId;
}
@@ -0,0 +1,26 @@
package com.cf.imes.module.system.controller.admin.process.vo.processUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Schema(description = "管理后台 - 工序和加工人信息")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserProcessRespVO {
@Schema(description = "工序名称")
private List<String> processName;
@Schema(description = "加工人")
private List<String> processUser;
}
@@ -1,6 +1,8 @@
package com.cf.imes.module.system.dal.dataobject.process;
import lombok.*;
import java.math.BigDecimal;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
@@ -34,7 +36,7 @@ public class ProcessDO extends BaseDO {
/**
* 计件工资
*/
private Double pieceRate;
private BigDecimal pieceRate;
/**
* 计件类型:1 数量 2 长度 3 平方 4 宽 5 高 6 体积 7 生产单金额百分比
*/
@@ -6,6 +6,7 @@ import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.cf.imes.module.system.controller.admin.process.vo.process.ProcessPageReqVO;
import com.cf.imes.module.system.controller.admin.process.vo.processUser.ProcessAndUserRespVO;
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
import com.cf.imes.module.system.dal.dataobject.process.ProcessUserDO;
import org.apache.ibatis.annotations.Mapper;
@@ -64,4 +65,17 @@ public interface ProcessMapper extends BaseMapperX<ProcessDO> {
}
default ProcessDO selectByType(Integer number,Long organId) {
return selectOne(new MPJLambdaWrapperX<ProcessDO>()
.eq(ProcessDO::getOrganId, organId)
.eqIfPresent(ProcessDO::getType,number));
}
List<ProcessAndUserRespVO> selectUserProcess(@Param("organId")Long organId);
}
@@ -91,4 +91,13 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
.likeIfPresent(AdminUserDO::getPinyinInitial, namePyFirstChar)
.orderByDesc(AdminUserDO::getId));
}
default List<AdminUserDO> selectListByIds(List<Long> userIds, Long userOrganId) {
return selectList(new LambdaQueryWrapperX<AdminUserDO>()
.eq(AdminUserDO::getOrganId, userOrganId)
.in(AdminUserDO::getId, userIds));
}
}
@@ -1,6 +1,7 @@
package com.cf.imes.module.system.service.process;
import com.cf.imes.module.system.controller.admin.process.vo.process.*;
import com.cf.imes.module.system.controller.admin.process.vo.processUser.UserProcessRespVO;
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
import com.cf.imes.framework.common.pojo.PageResult;
@@ -68,4 +69,7 @@ public interface ProcessService {
List<ProcessDO> getAllProcess();
List<ProcessDO> getUserProcess(Long userId);
UserProcessRespVO getUserProcessName();
}
@@ -6,9 +6,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.system.controller.admin.process.vo.process.*;
import com.cf.imes.module.system.controller.admin.process.vo.processUser.ProcessAndUserRespVO;
import com.cf.imes.module.system.controller.admin.process.vo.processUser.ProcessAndUserSaveReqVO;
import com.cf.imes.module.system.controller.admin.process.vo.processUser.UserProcessRespVO;
import com.cf.imes.module.system.dal.dataobject.process.ProcessUserDO;
import com.cf.imes.module.system.dal.mysql.process.ProcessGroupMapper;
import com.cf.imes.module.system.dal.mysql.user.AdminUserMapper;
import com.cf.imes.module.system.enums.ErrorCodeConstants;
import com.cf.imes.module.system.service.user.AdminUserService;
import org.springframework.stereotype.Service;
@@ -26,9 +29,11 @@ import com.cf.imes.module.system.dal.mysql.process.ProcessMapper;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.CUSTOM_ORDER_EXISTS;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
@@ -54,6 +59,9 @@ public class ProcessServiceImpl implements ProcessService {
@Resource
private AdminUserService adminUserService;
@Resource
private AdminUserMapper userMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createProcess(ProcessUserSaveReqVO createReqVO) {
@@ -229,4 +237,28 @@ public class ProcessServiceImpl implements ProcessService {
}
@Override
public UserProcessRespVO getUserProcessName() {
// 查询当前组织的工序信息和已经分配了加工人的工序信息
List<ProcessAndUserRespVO> userProcessDTO = processMapper.selectUserProcess(getUserOrganId());
List<String> processName = userProcessDTO.stream().map(m -> m.getProcessName()).distinct().collect(Collectors.toList());
List<Long> userIds = userProcessDTO.stream().map(m -> m.getUserId()).distinct().collect(Collectors.toList());
List<String> userName = userMapper.selectListByIds(userIds, getUserOrganId())
.stream().map(m -> m.getNickname()).collect(Collectors.toList());
return UserProcessRespVO.builder()
.processName(processName)
.processUser(userName)
.build();
}
}
@@ -68,8 +68,26 @@
where p.id = #{id} and p.organ_id = #{organId} and p.deleted = 0
</select>
<delete id="deleteById" parameterType="java.lang.Long">
DELETE FROM process
WHERE id = #{id};
</delete>
<select id="selectUserProcess"
resultType="com.cf.imes.module.system.controller.admin.process.vo.processUser.ProcessAndUserRespVO">
select distinct p.name as processName,pu.user_id as userId
from process p
join process_user pu on p.id = pu.process_id
where p.organ_id = #{organId} and p.deleted = false
</select>
</mapper>