plp
chenshuichuan 2 years ago
parent 7f47311ff8
commit 8b6d6bea45

@ -103,7 +103,11 @@ public class AppOrgWorkerController {
List<ErpProductRespVO> proList = planService.getProductByPlanStatus(status);
return success(appService.getProductList(proList));
}
@GetMapping("/getPlanProductList")
@Operation(summary = "获得正在开工生产的产品以及工序的需求")
public CommonResult<List<AppProductVo>> getPlanProductList(String orgType) {
return success(appService.getPlanProductList(orgType));
}
@PostMapping("/createReport")
@Operation(summary = "创建生产报工单")

@ -23,4 +23,5 @@ public interface AppService {
List<AppOrgWorkerVO> getOrgList(List<OrgWorkerDO> orgWorkerDOList);
List<AppOrgWorkerVO> getUserList(List<AdminUserRespDTO> list);
List<AppProductVo> getProductList(List<ErpProductRespVO> list);
List<AppProductVo> getPlanProductList(String orgType);
}

@ -4,11 +4,18 @@ 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.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
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.organization.vo.ProcessTypeEnum;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanStatusEnum;
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.dal.dataobject.plan.PlanDO;
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
import cn.iocoder.yudao.module.mes.service.producereport.ProduceReportDetailService;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -33,7 +40,12 @@ public class AppServiceImpl implements AppService {
@Resource
private OrganizationService organizationService;
@Resource
private PlanService planService;
@Resource
private ProduceReportDetailService produceReportDetailService;
@Resource
private ErpProductService productService;
@Override
public List<AppOrgWorkerVO> getOrgList(List<OrgWorkerDO> list){
if (CollUtil.isEmpty(list)) {
@ -75,4 +87,35 @@ public class AppServiceImpl implements AppService {
}
return workerList;
}
//获取正在开工的计划某工序的报工情况
@Override
public List<AppProductVo> getPlanProductList(String orgType){
List<Integer> status = new ArrayList<>();
status.add(PlanStatusEnum..getValue());
List<PlanDO> planList = planService.getPlanByStatus(status);
Map<Long, ErpProductDO> map = productService.getProductMap(
convertSet(planList, PlanDO::getProductId));
List<AppProductVo> appProductVoList = new ArrayList<>();
for (PlanDO plan :planList) {
Long finish = produceReportDetailService.sumByPlanAndOrgType(plan.getId(), orgType);
AppProductVo appProductVo = new AppProductVo().setValue(plan.getId())
.setProductId(plan.getProductId()).setProductName(map.get(plan.getProductId()).getName());
StringBuilder builder = new StringBuilder().append("[").append(plan.getCode()).append("]");
builder.append(map.get(plan.getProductId()).getName()).append("-");
if(orgType.equals(ProcessTypeEnum..getValue())){
if(plan.getReyaNumber() - finish > 0)
builder.append("需:").append(plan.getReyaNumber() - finish);
else builder.append("超:").append(finish - plan.getReyaNumber());
}
else{
if(plan.getPlanNumber() - finish > 0)
builder.append("需:").append(plan.getPlanNumber() - finish);
else builder.append("超:").append(finish - plan.getPlanNumber());
}
appProductVo.setText(builder.toString());
appProductVoList.add(appProductVo);
}
return appProductVoList;
}
}

@ -19,6 +19,7 @@ public enum ProcessTypeEnum {
("pinjian"),
("dabao"),
("tiebiao"),
("pinyin"),
("sufeng");
private final String value;

@ -31,6 +31,8 @@ public class PlanPageReqVO extends PageParam {
@Schema(description = "数量")
private Long planNumber;
@Schema(description = "计划热压数量")
private Long reyaNumber;
@Schema(description = "成品数量")
private Long finishNumber;

@ -38,9 +38,15 @@ public class PlanRespVO {
@ExcelProperty("任务单ID")
private String taskCode;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("数量")
@Schema(description = "计划成型数量", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("计划成型数量")
private Long planNumber;
/**
*
*/
@Schema(description = "计划热压数量")
@ExcelProperty("计划热压数量")
private Long reyaNumber;
@Schema(description = "成品数量")
@ExcelProperty("成品数量")

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.mes.controller.admin.plan.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -30,6 +31,9 @@ public class PlanSaveReqVO {
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "计划数量不能为空")
private Long planNumber;
@Schema(description = "计划热压数量")
@ExcelProperty("计划热压数量")
private Long reyaNumber;
@Schema(description = "成品数量")
private Long finishNumber;

@ -147,7 +147,7 @@ public class TaskItemNeedController {
//对得到的日期做一下排序,防止拿到的是乱序日期
Arrays.sort(planParam.getPlanDate(), Comparator.naturalOrder());
}
TaskDetailDO detailDO = taskService.getTaskDetail(planParam.getTaskId());
TaskDetailDO detailDO = taskService.getTaskDetail(planParam.getTaskDetailId());
//已经计划数 planMapper.selectSumTaskDetail(detailDO.getId(),null);
Long number = planParam.getPlanNumber();
if(number==null)number = detailDO.getNumber();

@ -16,6 +16,9 @@ public class TaskPlanParam {
@Schema(description = "任务id")
private Long taskId;
@Schema(description = "任务明细id")
private Long taskDetailId;
@Schema(description = "计划数")
private int sizeOfPlan;
@Schema(description = "计划产品数")

@ -19,6 +19,7 @@ public enum ProcessTypeEnum {
("pinjian"),
("dabao"),
("sufeng"),
("pinyin"),
("tiebiao");
private final String value;

@ -45,9 +45,13 @@ public class PlanDO extends BaseDO {
*/
private Long taskId;
/**
*
*
*/
private Long planNumber;
/**
*
*/
private Long reyaNumber;
/**
*
*/

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.mes.dal.mysql.producereport;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
@ -7,9 +9,12 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ProduceReportDetailPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ReportStatusEnum;
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDetailDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* Mapper
@ -64,4 +69,17 @@ public interface ProduceReportDetailMapper extends BaseMapperX<ProduceReportDeta
default int deleteByReportId(Long reportId) {
return delete(ProduceReportDetailDO::getReportId, reportId);
}
default Long sumByPlanAndOrgType(Long planId,String orgType) {
// SQL sum 查询
List<Map<String, Object>> result = selectMaps(new QueryWrapper<ProduceReportDetailDO>()
.select("SUM(quality_number) AS quality_number,SUM(waste_number) AS waste_number, SUM(total_number) AS total_number ")
.eq(planId != null, "plan_id", planId)
.eq(StringUtils.isNotEmpty(orgType), "org_type", orgType));
// 获得数量
if (CollUtil.isEmpty(result)) {
return 0L;
}
return MapUtil.getLong(result.get(0), "quality_number", 0L);
}
}

@ -64,4 +64,6 @@ public interface ProduceReportDetailService {
void updateStatus(Long id, Integer status);
void updateStatus2( ProduceReportDetailDO reportDetailDO, Integer status);
Long sumByPlanAndOrgType(Long planId,String orgType);
}

@ -267,4 +267,9 @@ public class ProduceReportDetailServiceImpl implements ProduceReportDetailServic
}
else throw exception(PLAN_NOT_EXISTS);
}
@Override
public Long sumByPlanAndOrgType(Long planId,String orgType){
return produceReportDetailMapper.sumByPlanAndOrgType(planId, orgType);
}
}

@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ProduceRepo
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ProduceReportSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDetailDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ViewReportUserDateSummary;
import javax.validation.Valid;
import java.util.List;
@ -69,4 +70,9 @@ public interface ProduceReportService {
void updateStatus(Long id, Integer status);
List<ProduceReportDO> getList(ProduceReportPageReqVO pageReqVO);
//汇总某人某段时间的报工成品废品数据
ViewReportUserDateSummary selectSumBy(Long userId, String[]reportDays);
List<ViewReportUserDateSummary> selectBy(Long userId, String reportDay, String[]reportDays);
}

@ -9,8 +9,10 @@ import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDetailDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ViewReportUserDateSummary;
import cn.iocoder.yudao.module.mes.dal.mysql.producereport.ProduceReportDetailMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.producereport.ProduceReportMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.producereport.ViewReportUserDateMapper;
import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO;
import cn.iocoder.yudao.module.mes.service.changerecord.ProduceReportChangeRecordService;
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
@ -22,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -198,4 +201,27 @@ public class ProduceReportServiceImpl implements ProduceReportService {
public List<ProduceReportDO> getList(ProduceReportPageReqVO pageReqVO){
return produceReportMapper.selectBy(pageReqVO);
}
@Resource
private ViewReportUserDateMapper viewReportUserDateMapper;
@Override
public ViewReportUserDateSummary selectSumBy(Long userId, String[] reportDays) {
List<ViewReportUserDateSummary> list = viewReportUserDateMapper.selectBy(userId,null,reportDays);
BigDecimal sumNumber = list.stream()
.map(ViewReportUserDateSummary::getSumNumber).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal quality = list.stream()
.map(ViewReportUserDateSummary::getTotalQualityNumber).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal waste = list.stream()
.map(ViewReportUserDateSummary::getTotalWasteNumber).reduce(BigDecimal.ZERO, BigDecimal::add);
ViewReportUserDateSummary summary = new ViewReportUserDateSummary().setUserId(userId)
.setSumNumber(sumNumber).setTotalQualityNumber(quality).setTotalWasteNumber(waste);
return summary;
}
@Override
public List<ViewReportUserDateSummary> selectBy(Long userId, String reportDay, String[] reportDays) {
return viewReportUserDateMapper.selectBy(userId,reportDay,reportDays);
}
}

@ -295,6 +295,7 @@ public class TaskServiceImpl implements TaskService {
totalNumber = totalNumber - productsOfPlan;
planDO.setCode(noRedisDAO.generate3(MesNoRedisDAO.PLAN_NO_PREFIX));
planDO.setPriorityNum(1L);
planDO.setReyaNumber(planDO.getPlanNumber());
list.add(planDO);
}
return list;

@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.mes.controller.admin.workteam.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
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.dal.mysql.workteam.WorkTeamDetailMapper;
@ -15,13 +14,15 @@ import cn.iocoder.yudao.module.mes.dal.mysql.workteam.WorkTeamMapper;
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -232,7 +233,8 @@ public class WorkTeamServiceImpl implements WorkTeamService {
*/
@Override
public List<AdminUserRespDTO> getUserList(String processType , String groupType){
List<WorkTeamDetailDO> list = getProcessUsers( processType, groupType);
//班组和工序没关系了
List<WorkTeamDetailDO> list = getProcessUsers(null, groupType);
List<Long> idList = list.stream() // 将list转换为stream
.map(WorkTeamDetailDO::getUserId)
.collect(Collectors.toList());
@ -240,11 +242,12 @@ public class WorkTeamServiceImpl implements WorkTeamService {
}
@Override
public List<AdminUserRespDTO> getUserList2(Long orgId , String groupType){
if(orgId == null)return null;
OrganizationDO organizationDO = organizationService.getOrganization(orgId);
if(organizationDO==null || StringUtils.isEmpty(organizationDO.getOrgType()))return null;
//班组和工序没关系了
// if(orgId == null)return null;
// OrganizationDO organizationDO = organizationService.getOrganization(orgId);
// if(organizationDO==null || StringUtils.isEmpty(organizationDO.getOrgType()))return null;
List<WorkTeamDetailDO> list = getProcessUsers( organizationDO.getOrgType(), groupType);
List<WorkTeamDetailDO> list = getProcessUsers( null, groupType);
List<Long> idList = list.stream() // 将list转换为stream
.map(WorkTeamDetailDO::getUserId)
.collect(Collectors.toList());

Loading…
Cancel
Save