add app work report
parent
cdef4910b1
commit
a4a798664e
@ -0,0 +1,121 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.app;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.service.AppService;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.vo.AppOrgWorkerVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.vo.AppProductVo;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.vo.AppReportReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.vo.AppReportSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.orgworker.vo.OrgWorkerPageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanStatusEnum;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ProduceReportSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.orgworker.OrgWorkerDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.workteam.WorkTeamDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.workteam.WorkTeamDetailDO;
|
||||
import cn.iocoder.yudao.module.mes.service.orgworker.OrgWorkerService;
|
||||
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
|
||||
import cn.iocoder.yudao.module.mes.service.producereport.ProduceReportService;
|
||||
import cn.iocoder.yudao.module.mes.service.workteam.WorkTeamService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "app - 工位安排")
|
||||
@RestController
|
||||
@RequestMapping("/mes/app/org-worker")
|
||||
@Validated
|
||||
public class AppOrgWorkerController {
|
||||
|
||||
@Resource
|
||||
private OrgWorkerService orgWorkerService;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
@Resource
|
||||
private AppService appService;
|
||||
@Resource
|
||||
private WorkTeamService workTeamService;
|
||||
@Resource
|
||||
private PlanService planService;
|
||||
@Resource
|
||||
private ProduceReportService produceReportService;
|
||||
|
||||
/**个人报工,获取某日期当前用户绑定的工位情况**/
|
||||
@GetMapping("/getOrgList")
|
||||
@Operation(summary = "获得工位安排")
|
||||
public CommonResult<List<AppOrgWorkerVO>> getOrgWorkerRespVO(@Valid AppReportReqVO reqVO) {
|
||||
OrgWorkerPageReqVO pageReqVO = new OrgWorkerPageReqVO().setOrgType(reqVO.getOrgType()).setGroupType(reqVO.getGroupType());
|
||||
pageReqVO.setWorkDate(DateUtils.getDateRange(reqVO.getReportDate()));
|
||||
Long userId = getLoginUserId();
|
||||
pageReqVO.setWorkerId(userId);
|
||||
List<OrgWorkerDO> orgWorkers = orgWorkerService.getOrgWorkerByReportResVo(pageReqVO);
|
||||
return success(appService.getOrgList(orgWorkers));
|
||||
}
|
||||
|
||||
/**代替报工,获取某日期某用户绑定的工位情况**/
|
||||
@GetMapping("/getOtherOrgList")
|
||||
@Operation(summary = "获得工位安排")
|
||||
public CommonResult<List<AppOrgWorkerVO>> getOtherPersonal(@Valid AppReportReqVO reqVO) {
|
||||
OrgWorkerPageReqVO pageReqVO = new OrgWorkerPageReqVO().setOrgType(reqVO.getOrgType()).setGroupType(reqVO.getGroupType());
|
||||
pageReqVO.setWorkDate(DateUtils.getDateRange(reqVO.getReportDate()));
|
||||
List<OrgWorkerDO> orgWorkers = orgWorkerService.getOrgWorkerByReportResVo(pageReqVO);
|
||||
return success(appService.getOrgList(orgWorkers));
|
||||
}
|
||||
|
||||
/**代替报工,用户列表**/
|
||||
@GetMapping("/getOtherPersonalUser")
|
||||
@Operation(summary = "获得用户列表")
|
||||
public CommonResult<List<AppOrgWorkerVO>> getOtherPersonalUser(@Valid AppReportReqVO reqVO) {
|
||||
|
||||
WorkTeamDO workTeamDO = new WorkTeamDO().setGroupType(reqVO.getGroupType().toString())
|
||||
.setTeamType(reqVO.getOrgType());
|
||||
List<WorkTeamDO> workTeamDOList =workTeamService.getList(workTeamDO);
|
||||
List<Long> teamIds = workTeamDOList.stream().map(WorkTeamDO::getId).collect(Collectors.toList());
|
||||
List<WorkTeamDetailDO> doList = workTeamService.getDetailByWorkTeamIds(teamIds);
|
||||
|
||||
List<Long> ids = doList.stream().map(WorkTeamDetailDO::getUserId).collect(Collectors.toList());
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(ids);
|
||||
List<AdminUserRespDTO> userList = new ArrayList<>(userMap.values());
|
||||
return success(appService.getUserList(userList));
|
||||
}
|
||||
@GetMapping("/getProductList")
|
||||
@Operation(summary = "获得正在开工生产的产品")
|
||||
public CommonResult<List<AppProductVo>> getProductList() {
|
||||
List<Integer> status = new ArrayList<>();
|
||||
status.add(PlanStatusEnum.开工.getValue());
|
||||
List<ErpProductRespVO> proList = planService.getProductByPlanStatus(status);
|
||||
return success(appService.getProductList(proList));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/createReport")
|
||||
@Operation(summary = "创建生产报工单")
|
||||
//@PreAuthorize("@ss.hasPermission('mes:produce-report:create')")
|
||||
public CommonResult<Long> createReport(@Valid @RequestBody AppReportSaveReqVO appSaveVo) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(appSaveVo.getReportDateString(), formatter);
|
||||
appSaveVo.setReportDate(localDateTime);
|
||||
|
||||
ProduceReportSaveReqVO createReqVO = BeanUtils.toBean(appSaveVo,ProduceReportSaveReqVO.class);
|
||||
createReqVO.setProduceReportDetails(appSaveVo.getProductList());
|
||||
|
||||
return success(produceReportService.createProduceReport(createReqVO));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.app.service;
|
||||
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.vo.AppOrgWorkerVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.vo.AppProductVo;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.orgworker.OrgWorkerDO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AppService 接口
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
public interface AppService {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return 获取app端个人报工的工位列表
|
||||
*/
|
||||
List<AppOrgWorkerVO> getOrgList(List<OrgWorkerDO> orgWorkerDOList);
|
||||
List<AppOrgWorkerVO> getUserList(List<AdminUserRespDTO> list);
|
||||
List<AppProductVo> getProductList(List<ErpProductRespVO> list);
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.app.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.vo.AppOrgWorkerVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.app.vo.AppProductVo;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.orgworker.OrgWorkerDO;
|
||||
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
/**
|
||||
* APPService 实现类
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AppServiceImpl implements AppService {
|
||||
|
||||
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
|
||||
@Override
|
||||
public List<AppOrgWorkerVO> getOrgList(List<OrgWorkerDO> list){
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Map<Long, OrganizationDO> map = organizationService.getMap(
|
||||
convertSet(list, OrgWorkerDO::getOrgId));
|
||||
|
||||
return BeanUtils.toBean(list, AppOrgWorkerVO.class, item -> {
|
||||
MapUtils.findAndThen(map, item.getOrgId(),
|
||||
org -> item.setOrgName(org.getName()).setOrgType(org.getOrgType())
|
||||
.setValue(org.getId()).setText(org.getName())
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public List<AppOrgWorkerVO> getUserList(List<AdminUserRespDTO> list){
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<AppOrgWorkerVO> workerList = new ArrayList<>();
|
||||
for (AdminUserRespDTO user : list) {
|
||||
AppOrgWorkerVO workerVO = new AppOrgWorkerVO().setValue(user.getId()).setText(user.getNickname());
|
||||
workerList.add(workerVO);
|
||||
}
|
||||
return workerList;
|
||||
}
|
||||
@Override
|
||||
public List<AppProductVo> getProductList(List<ErpProductRespVO> list){
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<AppProductVo> workerList = new ArrayList<>();
|
||||
for (ErpProductRespVO product : list) {
|
||||
AppProductVo workerVO = new AppProductVo().setValue(product.getId()).setText(product.getName())
|
||||
.setProductId(product.getId()).setProductName(product.getName());
|
||||
workerList.add(workerVO);
|
||||
}
|
||||
return workerList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.app.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "app 工位选择 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class AppOrgWorkerVO {
|
||||
|
||||
@Schema(description = "工位id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private Long value;
|
||||
|
||||
@Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private String text;
|
||||
|
||||
@Schema(description = "工位id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private Long orgId;
|
||||
|
||||
@Schema(description = "工位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private String orgName;
|
||||
@Schema(description = "工位类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private String orgType;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.app.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "app 工位选择 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class AppProductVo {
|
||||
|
||||
@Schema(description = "产品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private Long value;
|
||||
|
||||
@Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private String text;
|
||||
|
||||
@Schema(description = "产品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private Long productId;
|
||||
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "4727")
|
||||
private String productName;
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.app.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "app 报工单 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppReportReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户ID", example = "19983")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "工序ID", example = "28795")
|
||||
private Long orgId;
|
||||
|
||||
@Schema(description = "工序", example = "2")
|
||||
private String orgType;
|
||||
|
||||
@Schema(description = "计件时段")
|
||||
private String reportTime;
|
||||
|
||||
@Schema(description = "总时长")
|
||||
private BigDecimal totalTime;
|
||||
|
||||
@Schema(description = "报工状态", example = "2")
|
||||
private Integer reportStatus;
|
||||
|
||||
@Schema(description = "班别", example = "1")
|
||||
private Integer groupType;
|
||||
|
||||
@Schema(description = "报工类型", example = "1")
|
||||
private String reportType;
|
||||
|
||||
@Schema(description = "报工日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime reportDate;
|
||||
|
||||
private List<Long> userIds;
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.app.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDetailDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 生产报工单新增/修改 Request VO")
|
||||
@Data
|
||||
public class AppReportSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29099")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "编号")
|
||||
private String reportCode;
|
||||
|
||||
@Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "19983")
|
||||
@NotNull(message = "用户ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "工序ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "28795")
|
||||
@NotNull(message = "工序ID不能为空")
|
||||
private Long orgId;
|
||||
|
||||
@Schema(description = "工序", example = "2")
|
||||
private String orgType;
|
||||
|
||||
@Schema(description = "计件时段")
|
||||
private String reportTime;
|
||||
|
||||
@Schema(description = "总时长")
|
||||
private BigDecimal totalTime;
|
||||
|
||||
@Schema(description = "报工状态", example = "2")
|
||||
private Integer reportStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "班别", example = "1")
|
||||
private Integer groupType;
|
||||
|
||||
@Schema(description = "报工类型", example = "1")
|
||||
private String reportType;
|
||||
|
||||
@Schema(description = "报工日期")
|
||||
private LocalDateTime reportDate;
|
||||
|
||||
@Schema(description = "生产报工明细列表")
|
||||
private List<ProduceReportDetailDO> productList;
|
||||
@Schema(description = "报工日期字符串")
|
||||
private String reportDateString;
|
||||
}
|
||||
Loading…
Reference in New Issue