jiaosong
2023-08-18 b5a63b29313463d1c2fd1b5678a2d6b2bb8a7044
Merge remote-tracking branch 'origin/master'
已修改14个文件
276 ■■■■■ 文件已修改
server/src/main/java/doumeemes/api/ext/WorkorderRecordExtController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/dao/ext/dto/QueryWorkorderExtDTO.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/dao/ext/vo/MaterialDistributeExtListVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/business/impl/WTransferServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/WorkorderExtService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/WorkorderRecordStandardService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/impl/NoticesExtServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/impl/WorkorderExtServiceImpl.java 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordExtServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/resources/mappers/MaterialDistributeExtMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/resources/mappers/PlansExtMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/resources/mappers/WOutboundExtMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/api/ext/WorkorderRecordExtController.java
@@ -91,7 +91,7 @@
    public ApiResponse comfirmDoneStandard(@RequestBody AutoWorkReportDTO autoWorkReportDTO) {
        Workorder workorder =workorderRecordStandardService.comfirmDoneNew(autoWorkReportDTO,true);
        //发送消息队列处理分享操作
        workorderExtService.statisticNum(workorder);
        workorderExtService.statisticNumAsync(workorder);
        return ApiResponse.success("操作成功");
    }
server/src/main/java/doumeemes/dao/ext/dto/QueryWorkorderExtDTO.java
@@ -5,6 +5,8 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@@ -91,10 +93,10 @@
    private Integer proGroupId;
    @ApiModelProperty(value = "合格数量", example = "1")
    private Integer qualifiedNum;
    private BigDecimal qualifiedNum;
    @ApiModelProperty(value = "不合格数量", example = "1")
    private Integer unqualifiedNum;
    private BigDecimal unqualifiedNum;
    @ApiModelProperty(value = "检验人员编码", example = "1")
    private Integer checkUserId;
server/src/main/java/doumeemes/dao/ext/vo/MaterialDistributeExtListVO.java
@@ -139,4 +139,8 @@
    @ApiModelProperty(value = "分类小类id")
    private Integer cmodel3Id;
    @ApiModelProperty(value = "是否有bom:0=无;1=有")
    private Integer hasBom;
}
server/src/main/java/doumeemes/service/business/impl/WTransferServiceImpl.java
@@ -469,6 +469,7 @@
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到转库单类型信息【"+wTransfer.getType()+"】");
        }
        sendOutNotice(companyUser.getId(),wTransfer.getId(),wTransfer.getCode(),notices_type_transfer,Constants.getNoticeUrl(loginUserInfo.getCompany(),Constants.DINGDING_NOTICE_URL.out));
        //记录操作记录
@@ -480,6 +481,7 @@
    public void sendOutNotice(Integer userId ,Integer billId , String billCode ,Constants.Notices_Type_Transfer notices_type_transfer,String url){
        //发送通知
        Notices notices = new Notices();
        notices.setCompanyUserId(userId);
@@ -487,10 +489,13 @@
        notices.setContent("【"+billCode+"】"+ notices_type_transfer.getContent().replace("{optType}","出库"));
        notices.setTitle(notices_type_transfer.getTitle());
        notices.setObjId(billId);
        if(!Objects.isNull(url)){
        notices.setUrl(url.replace("{id}",billId.toString()));
        }
        noticesExtService.sendNotice(notices);
    }
    public void sendOutNotice(LoginUserInfo user,Integer userId ,Integer billId , String billCode ,Constants.Notices_Type_Transfer notices_type_transfer,String url){
        //发送通知
        Notices notices = new Notices();
        notices.setCompanyUserId(userId);
@@ -498,11 +503,14 @@
        notices.setContent("【"+billCode+"】"+ notices_type_transfer.getContent().replace("{optType}","出库"));
        notices.setTitle(notices_type_transfer.getTitle());
        notices.setObjId(billId);
        if(!Objects.isNull(url)){
        notices.setUrl(url.replace("{id}",billId.toString()));
        }
        noticesExtService.sendNoticeNologin(notices,user);
    }
    public void sendInNotice(Integer userId ,Integer billId , String billCode ,Constants.Notices_Type_Transfer notices_type_transfer,String url){
        //发送通知
        Notices notices = new Notices();
        notices.setCompanyUserId(userId);
@@ -510,7 +518,9 @@
        notices.setContent("【"+billCode+"】"+ notices_type_transfer.getContent().replace("{optType}","入库"));
        notices.setTitle(notices_type_transfer.getTitle());
        notices.setObjId(billId);
        if(!Objects.isNull(url)){
        notices.setUrl(url.replace("{id}",billId.toString()));
        }
        noticesExtService.sendNotice(notices);
    }
server/src/main/java/doumeemes/service/ext/WorkorderExtService.java
@@ -54,4 +54,6 @@
    ApiResponse<Integer> dataToWtWO(String deviceIds,String inIds,LoginUserInfo userInfo);
    void statisticNum(Workorder model);
    void statisticNumAsync(Workorder param);
}
server/src/main/java/doumeemes/service/ext/WorkorderRecordStandardService.java
@@ -35,7 +35,7 @@
    WorkorderRecord dealWorkorderRecord(DealWorkorderRecordDTO dealWorkorderRecordDTO, LoginUserInfo loginUserInfo);
    WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo);
    WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo,Integer userId);
    List<WorkorderRecord> getWorkorderRecordList(Integer workorderId);
server/src/main/java/doumeemes/service/ext/impl/NoticesExtServiceImpl.java
@@ -89,6 +89,7 @@
        model.setCreateUser(user.getId());
        CompanyExtListVO company = user.getCompany();
        model.setDdStatus(Constants.ZERO);
        if(StringUtils.isNotBlank(model.getUrl())){
        model.setUrl(model.getUrl().replace("{dbid}",model.getId()));
        if(StringUtils.isNotBlank(cu.getDdUserid())){
            try {
@@ -102,6 +103,7 @@
                e.printStackTrace();
            }
        }
        }
        //插入数据
        return   noticesExtMapper.insert(model);
    }
server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
@@ -668,9 +668,9 @@
        order.setQrcodeId(barcodeParamExtService.getByType(user.getCompany().getId(),mp.getDepartId(),Constants.BARCODEPARAM_TYPE.workorder));
        order.setProUserList(param.getProUserList());
        order.setProGroupId(param.getProGroupId());
        //查询生产班组和人员是否合法
        checkUserAndGroup(order,mp,user);
        workorderExtMapper.insert(order);
        //查询生产班组和人员是否合法
        checkUserAndGroupNew(order,mp,user);
        //工单历史数据
        whList.add(WorkorderExtServiceImpl.initHistoryByModel(order,user.getId(),Constants.WORKORDER_HISTORY_STATUS.create));
        workorderHistoryExtMapper.insertBatch(whList);
@@ -681,6 +681,34 @@
            workorderUserExtMapper.insert(wu);
        }
        return order;
    }
    private void checkUserAndGroupNew(Workorder param, PlansExtListVO  model,LoginUserInfo user) throws BusinessException{
        QueryDeviceExtDTO ud = new QueryDeviceExtDTO();
        ud.setDeleted(Constants.ZERO);
        ud.setId(param.getProGroupId());
        ud.setRootDepartId(user.getRootDepartment().getId());
        //查询用户设备关联关系
        DeviceExtListVO d = deviceExtMapper.selectByModel( ud );
        if(d == null){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,生产设备信息不正确,请刷新页面重试!");
        }
        List<WorkorderUser> userList = new ArrayList<>();
        for(Integer userId : param.getProUserList()){
            WorkorderUser u = new WorkorderUser();
            u.setProUserId(userId);
            u.setPlanId(model.getId());
            u.setCreateUser(user.getId());
            u.setDeleted(Constants.ZERO);
            u.setCreateTime(DateUtil.getCurrentDate());
            u.setRootDepartId(model.getRootDepartId());
            u.setDepartId(model.getDepartId());
            userList.add(u);
        }
        param.setWorkorderUserList(userList);
    }
    private void checkUserAndGroup(Workorder param, PlansExtListVO  model,LoginUserInfo user) throws BusinessException{
@@ -1638,7 +1666,7 @@
        }
        //工单产出记录
        autoWorkReportDTO.getCreateWorkorderRecordDTO().setWorkorderId(workorder.getId());
        WorkorderRecord workorderRecord = workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user);
        WorkorderRecord workorderRecord = workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user,autoWorkReportDTO.getProUserList().get(Constants.ZERO));
        //工单报工
        workorderRecordStandardService.comfirmDone(workorder,false);
        //更新工单状态
server/src/main/java/doumeemes/service/ext/impl/WorkorderExtServiceImpl.java
@@ -807,12 +807,14 @@
                }
                if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.create)
                ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.material)
                ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.producing)
                ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.check)
                ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.done)){
                    //统计已分配未报工数量
                    distributeNoDoneNum += Constants.formatIntegerNum(order.getPlanNum());
                }
                if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.baogong)
                        ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.producing)
                        || Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.instock)){
                   doneNum += Constants.formatIntegerNum(order.getUnqualifiedNum()) + Constants.formatIntegerNum(order.getQualifiedNum());
                   int tNum =Constants.formatIntegerNum(order.getUnqualifiedNum()) + Constants.formatIntegerNum(order.getQualifiedNum());
@@ -855,7 +857,148 @@
            if(!Objects.isNull(plan.getWorkPlansId())){
                //更新主订单数据信息
               if(plansMapper.selectCount(new QueryWrapper<Plans>()
                        .in("STATUS",0,1,4,5)
                        .eq("STATUS",Constants.PLAN_STATUS.done)
                        .eq("DELETED",Constants.ZERO)
                        .ne("id",p.getId())
                        .eq("WORK_PLANS_ID",plan.getWorkPlansId()))<=Constants.ZERO){
                   WorkPlans  workPlans = workPlansExtMapper.selectById(plan.getWorkPlansId());
                   if(!Objects.isNull(workPlans)){
                       workPlans.setStatus(Constants.WORKPLANHISTORY_TYPE.done);
                       workPlans.setUpdateTime(new Date());
                       workPlansExtMapper.updateById(workPlans);
                       planHistoryExtMapper.insert(initPlanHistoryByModel(workPlans,null,Constants.WORKPLANHISTORY_TYPE.done));
                   }
               };
            }
            //
            plan.getWorkPlansId();
            updateWrapper.set("STATUS",p.getStatus());
            if(Constants.equalsInteger(plan.getStatus(),Constants.PLAN_STATUS.distribute)){
              //如果已分配
              planHistoryExtMapper.insertBatch(Arrays.asList(PlansExtServiceImpl.initHistoryByModel(plan,null,Constants.PLANHISTORY_TYPE.done)));
          }
//          planHistoryService.create(PlansExtServiceImpl.initHistoryByModel(plan,null,Constants.PLANHISTORY_TYPE.done));
        }
        //更新统计信息
//        plansExtMapper.updateById(p);
        updateWrapper.eq("ID",param.getPlanId());
        updateWrapper.set("STATISTIC_INFO",json.toJSONString());
        updateWrapper.set("UPDATE_TIME",DateUtil.getCurrentDate());
        plansExtMapper.update(null,updateWrapper);
//        Workorder order = new Workorder();
//        order.setUpdateTime(DateUtil.getCurrentDate());
//        //已关闭
//        order.setId(param.getId());
//        workorderExtMapper.updateById(order);
    }
    @Override
    @Async
    public void statisticNumAsync(Workorder param){
        if(param.getPlanId()== null){
            if(param.getId()== null){
                return;
            }
            Workorder wModel = new Workorder();
            wModel.setDeleted(Constants.ZERO);
            wModel.setId(param.getId());
            wModel = workorderExtMapper.selectOne(wModel);
            if(wModel== null){
                return;
            }
            param.setPlanId(wModel.getPlanId());
        }
        Plans plan = plansExtMapper.selectById(param.getPlanId());
        if(plan == null){
            return;
        }
        JSONObject json = new JSONObject();
        QueryWorkorderExtDTO qw = new QueryWorkorderExtDTO();
        qw.setPlanId(param.getPlanId());
        qw.setDeleted(Constants.ZERO);
        //查询全部工单数据
        List<WorkorderExtListVO> orderList = workorderExtMapper.selectList(qw);
        //已完工数量
        int doneNum=0;
        //已分配数量
        //已报工工单(包括工单状态:已报工、已入库)的完工数量(包括:合格、不良、报废)
        //+未报工工单(包括工单状态:已创建、已备料、已检验、已完工)的已分配数量
        int distributNum=0;
        //已分配未报工数量=未报工工单(工单状态:已创建、已备料、已检验、已完工)的计划生产数量之和;
        int distributeNoDoneNum=0;
        //合格数量=已报工工单(工单状态:已报工、已入库)产出为合格的数量之和;
        int qulifiedNum=0;
        //不良数量=已报工工单(工单状态:已报工、已入库)产出为不良的数量之和;
        int unqulifiedNum =0;
        int allOrderNum =0;
        if(orderList!=null && orderList.size()>0){
            QueryWorkorderRecordExtDTO rw = new QueryWorkorderRecordExtDTO();
            rw.setPlanId(param.getPlanId());
            rw.setDeleted(Constants.ZERO);
            //查询全部工单产出和投料数据
            List<WorkorderRecordExtListVO> allRecordList = workorderRecordExtMapper.selectListNew(rw);
            for(WorkorderExtListVO order : orderList){
                if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.cancel)){
                    //取消的工单不累计数量
                    continue;
                }
                if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.create)
                        ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.material)
                        ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.producing)
                        ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.check)
                        ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.done)){
                    //统计已分配未报工数量
                    distributeNoDoneNum += Constants.formatIntegerNum(order.getPlanNum());
                }
                if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.baogong)
                        ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.producing)
                        || Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.instock)){
                    doneNum += Constants.formatIntegerNum(order.getUnqualifiedNum()) + Constants.formatIntegerNum(order.getQualifiedNum());
                    int tNum =Constants.formatIntegerNum(order.getUnqualifiedNum()) + Constants.formatIntegerNum(order.getQualifiedNum());
                    distributNum += tNum;
                    allOrderNum += tNum;
                }else {
                    distributNum += Constants.formatIntegerNum(order.getPlanNum());
                }
                List<WorkorderRecordExtListVO> rList = getRecordListById(order.getId(),allRecordList);
                if(rList!=null){
                    for(WorkorderRecordExtListVO item : rList){
                        if(Constants.equalsInteger(item.getType(),Constants.WORKORDER_RECORD_TYPE.produce)
                                && item.getOmodel()!=null
                                && (Constants.equalsInteger(item.getOmodel().getStatus() ,Constants.WORKORDER_STATUS.baogong)
                                ||Constants.equalsInteger(item.getOmodel().getStatus() ,Constants.WORKORDER_STATUS.instock))){
                            //如果是合格产出,累计数量
                            qulifiedNum += Constants.formatBigdecimal(BigDecimal.valueOf(item.getQualifiedNum())).intValue();
                            //如果是不良产出,累计数量
                            unqulifiedNum += Constants.formatBigdecimal(BigDecimal.valueOf(item.getUnqualifiedNum())).intValue();
                        }
                    }
                }
            }
        }
        json.put(Constants.STATISTIC.distributeNoDone,distributeNoDoneNum);
        json.put(Constants.STATISTIC.done,doneNum);
        json.put(Constants.STATISTIC.distribute,distributNum);
        json.put(Constants.STATISTIC.qulified,qulifiedNum);
        json.put(Constants.STATISTIC.unqulified,unqulifiedNum);
        UpdateWrapper updateWrapper = new UpdateWrapper();
        Plans p = new Plans();
        p.setId(param.getPlanId());
        p.setStatisticInfo(json.toJSONString());
        p.setUpdateTime(DateUtil.getCurrentDate());
        if( Constants.formatIntegerNum(plan.getNum())  <= allOrderNum){
            //如果满足计划已完工,更新计划状态
            p.setStatus(Constants.PLAN_STATUS.done);
            if(!Objects.isNull(plan.getWorkPlansId())){
                //更新主订单数据信息
                if(plansMapper.selectCount(new QueryWrapper<Plans>()
                        .eq("STATUS",Constants.PLAN_STATUS.done)
                        .eq("DELETED",Constants.ZERO)
                        .ne("id",p.getId())
                        .eq("WORK_PLANS_ID",plan.getWorkPlansId()))<=Constants.ZERO){
server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordExtServiceImpl.java
@@ -495,6 +495,7 @@
        }
        if(!Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.create)
                && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.material)
                && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.producing)
                && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.check)
                && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.done)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该工单状态已流转,不能进行该操作!");
@@ -532,6 +533,7 @@
        }
        if(!Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.create)
                && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.material)
                && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.producing)
                && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.check)
                && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.done)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该工单状态已流转,不能进行该操作!");
@@ -835,9 +837,11 @@
                if(!Constants.equalsInteger(tModel.getDoneType(),Constants.ZERO)){
                    //如果不良,累计工单的不良产出
                    mp.setUnqualifiedNum(Constants.formatIntegerNum(mp.getUnqualifiedNum())+(Constants.formatBigdecimal(tModel.getNum()).intValue()));
//                    mp.setUnqualifiedNum(mp.getUnqualifiedNum().add(tModel.getNum()));
                }else{
                    //如果是合格,累计工单的合格数量
                    mp.setQualifiedNum(Constants.formatIntegerNum(mp.getQualifiedNum())+(Constants.formatBigdecimal(tModel.getNum()).intValue()));
//                    mp.setUnqualifiedNum(mp.getQualifiedNum().add(tModel.getNum()));
                }
                //检查篮筐是否被作为产出篮筐,如果是,则需要判断该篮筐是否投料余额为0
                Appliances curUpdateModel = getApplianceFromList(tModel.getAppliancesId(),updateApplianceList);
@@ -1582,6 +1586,7 @@
        }
        if(!Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create)
                && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material)
                && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.producing)
                && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.check)
                && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.done)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该工单状态已流转,不能进行该操作!");
server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
@@ -87,6 +87,8 @@
    private DeviceExtMapper deviceExtMapper;
    @Autowired
    private UnqualifiedRecordMapper unqualifiedRecordMapper;
    @Autowired
    private CompanyUserExtMapper companyUserExtMapper;
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    @Override
@@ -185,6 +187,7 @@
        }
        if(!Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create)
                && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material)
                && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.producing)
                && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.check)
                && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.done)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该工单状态已流转,不能进行该操作!");
@@ -300,7 +303,7 @@
        wrModel.setType(Constants.WORKORDER_RECORD_TYPE.materail);
        wrModel.setFactoryId(mp.getFactoryId());
        wrModel.setProcedureId(mp.getProcedureId());
        wrModel.setBatch(mp.getBatch());
        wrModel.setBatch(wStock.getBatch());
        wrModel.setUnitId(mp.getUnitId());
        wrModel.setPlanId(mp.getPlanId());
        //TODO 目前使用工装主键存储货位主键
@@ -519,10 +522,27 @@
        if(mp== null){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该记录不存在!");
        }
        Plans plans = plansExtMapper.selectById(mp.getPlanId());
        if(Objects.isNull(plans)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,工序计划记录不存在!");
        }
        //查询工序计划下 所有工单已报工数量
        QueryWorkorderExtDTO dto = new QueryWorkorderExtDTO();
        dto.setPlanId(mp.getPlanId());
        dto.setDeleted(Constants.ZERO);
        dto.setStatus(Constants.WORKORDER_STATUS.baogong);
        List<WorkorderExtListVO> workorderList = workorderExtMapper.selectList(dto);
        Integer plansQualifiedNum = 0 , plansUnQualifiedNum = 0;
        plansQualifiedNum = workorderList.stream().map( workorderExtListVO -> workorderExtListVO.getQualifiedNum()).reduce(Constants.ZERO, Integer::sum);
        plansUnQualifiedNum = workorderList.stream().map( workorderExtListVO -> workorderExtListVO.getUnqualifiedNum()).reduce(Constants.ZERO, Integer::sum);
        if((BigDecimal.valueOf(plansQualifiedNum).add(BigDecimal.valueOf(plansUnQualifiedNum).add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum())
                .add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum()))).compareTo(BigDecimal.valueOf(plans.getNum()))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,报工数量超出工序计划总数!");
        }
        Workorder param = new Workorder();
        param.setPlanId(mp.getPlanId());
        param.setId(autoWorkReportDTO.getCreateWorkorderRecordDTO().getWorkorderId());
        if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,工单已暂停!");
        }
@@ -541,13 +561,13 @@
        List<Appliances> updateApplianceProList = new ArrayList<>();
        //待更新库存集合
        List<WStock> stockList = new ArrayList<>();
        //处理产出数据
        WorkorderRecord workorderRecord = this.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user,null);
        //查询投料和报工记录列表
        List<WorkorderRecordExtListVO>  allRecordList = workorderRecordExtMapper.selectAllList(getQueryRecordParam(param));
        if(Objects.isNull(allRecordList)||allRecordList.size()==Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询投料和报工记录!");
        }
        //处理产出数据
        WorkorderRecord workorderRecord = this.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user);
        //检查数据信息
//        caculateCheckRecord(user, mp,allRecordList);
        QueryBomDetailExtDTO bdparam = initBomParam(user,mp);
@@ -572,6 +592,8 @@
            }
        }
        //更新工单状态为已报工
        mp.setUnqualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().intValue());
        mp.setQualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().intValue());
        updateOrderInfo(user,mp,Constants.WORKORDER_HISTORY_STATUS.baogong);
        //批量插入出入库明细记录
@@ -1154,6 +1176,9 @@
        detail.setWarehouseId(outbound.getWarehouseId());
        detail.setLocationId(mp.getFinishWarehouseLocationId());
        detail.setNum(BigDecimal.valueOf(doneType.equals(Constants.ZERO)?tModel.getQualifiedNum():tModel.getUnqualifiedNum()));
        if(detail.getNum().compareTo(BigDecimal.ZERO)==Constants.ZERO){
            return;
        }
        detail.setStatus(Constants.ONE);
        detail.setDoneNum(detail.getNum());
        detail.setDoneDate(new Date());
@@ -1472,7 +1497,7 @@
    @Override
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo){
    public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo ,Integer userId){
        Workorder workorder  = workorderExtMapper.selectById(createWorkorderRecordDTO.getWorkorderId());
        if(Objects.isNull(workorder)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到该工单信息!");
@@ -1501,11 +1526,21 @@
        //数据存储
        workorderRecord = new WorkorderRecord();
        workorderRecord.setDeleted(Constants.ZERO);
        if(!Objects.isNull(userId)){
            CompanyUser companyUser = companyUserExtMapper.selectById(userId);
            if(Objects.isNull(companyUser)){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到生产人员对应企业用户信息!");
            }
            workorderRecord.setCreateUser(companyUser.getUserId());
            workorderRecord.setRootDepartId(companyUser.getRootDepartId());
            workorderRecord.setDepartId(companyUser.getComDepartId());
        }else{
        workorderRecord.setCreateUser(loginUserInfo.getId());
        workorderRecord.setCreateTime(new Date());
        workorderRecord.setNum(num);
        workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId());
        workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId());
        }
        workorderRecord.setCreateTime(new Date());
        workorderRecord.setNum(num);
        workorderRecord.setPlanId(workorder.getPlanId());
        workorderRecord.setWorkorderId(createWorkorderRecordDTO.getWorkorderId());
        workorderRecord.setBatch(workorder.getBatch());
@@ -1521,7 +1556,7 @@
        //计算工资信息
        SalaryParam salaryParam = salaryParamMapper.selectOne(new QueryWrapper<SalaryParam>().eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",workorderRecord.getMaterialId())
                .eq("DEPART_ID",workorderRecord.getFactoryId()).eq("PROCEDURE_ID",workorderRecord.getProcedureId()).last(" limit 1  "));
        if(!Objects.isNull(salaryParam)){
        if(!Objects.isNull(salaryParam)&&!Objects.isNull(createWorkorderRecordDTO.getDuration())){
            workorderRecord.setSalaryPrice(salaryParam.getSalary());
            workorderRecord.setSalaryType(salaryParam.getType());
            workorderRecord.setSalaryUnqualified(salaryParam.getUnqualified());
server/src/main/resources/mappers/MaterialDistributeExtMapper.xml
@@ -717,7 +717,8 @@
    mmodel.UNION_NAME as MMODEL_UNION_NAME,
    mmodel.code as MMODEL_CODE,
    umodel.name as UMODEL_NAME,
    umodel.ATTRIBUTE_DATA as UMODEL_ATTRIBUTE_DATA
    umodel.ATTRIBUTE_DATA as UMODEL_ATTRIBUTE_DATA,
    (select count(1) from bom b where a.id = b.MATERIAL_ID   and b.`STATUS` = 1 and b.DELETED = 0 ) as hasBom
    FROM `material_distribute` `a`
    LEFT JOIN `material` `mmodel` ON a.MATERIAL_ID=mmodel.ID
server/src/main/resources/mappers/PlansExtMapper.xml
@@ -389,13 +389,13 @@
      `usermodel`.`SYSTEMID` AS USERMODEL_SYSTEMID,
      `usermodel`.`INVALID_TIME` AS USERMODEL_INVALID_TIME,
      `usermodel`.`TYPE` AS USERMODEL_TYPE
    , ifnull((  SELECT sum( b.PLAN_NUM ) FROM  workorder b  WHERE b.deleted = 0  AND b.PLAN_ID = a.id  and b.status !=6),0) AS workorderDistributNum ,
    , ifnull((  SELECT sum(  b.UNQUALIFIED_NUM + QUALIFIED_NUM ) FROM  workorder b  WHERE b.deleted = 0  AND b.PLAN_ID = a.id  and b.status  = 4 ),0) AS workorderDistributNum ,
    `mmodel`.name as materialName , `mmodel`.code as materialCode ,`fmodel`.name as factoryName , `pmodel`.name as produceName ,
      concat(`usermodel`.realname,' ',`usermodel`.mobile) as planUserName , `umodel`.name as unitName ,
      w.PLAN_CODE as workPlanCode , w.SALESORDER as salesOrder ,
      w.START_DATE as workPlanStartDate  , w.PLAN_DATE as workPlanEndDate,
      w.`PLAN_DATE` as workPlanPlanDate,
      ifnull((select  sum(worder.PLAN_NUM) from workorder worder where worder.PLAN_ID = a.id and worder.STATUS not in (7,8)  ),0) as produceNum
      ifnull((select  sum(worder.UNQUALIFIED_NUM + worder.QUALIFIED_NUM ) from workorder worder where worder.PLAN_ID = a.id and worder.STATUS = 4  ),0) as produceNum
    FROM `plans` `a`
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID
    LEFT JOIN `material_distribute` `mdmodel` ON a.MATERIAL_ID=mdmodel.ID
server/src/main/resources/mappers/WOutboundExtMapper.xml
@@ -561,6 +561,12 @@
      <if test="endDate != null and endDate != '' ">
        AND CONCAT(#{endDate},' 23:59:59') >= `w`.`VALID_DATE`
      </if>
      <if test="rootDepartId != null">
        AND `w`.`ROOT_DEPART_ID` = #{rootDepartId}
      </if>
      <if test="departId != null">
        AND `w`.`DEPART_ID` = #{departId}
      </if>
    </where>
    group by SUBSTR(w.VALID_DATE,1,10) , m.`CODE`  ,m.`NAME`  , wd.BATCH   , p.`NAME`   , wd.QUALITY_TYPE    , wh.`NAME`  , w.`CODE` ,u.`NAME` ,w.CREATE_TIME , w.ORIGIN_TYPE,w.ORIGIN_CODE, w.type , w.BILL_TYPE
    order by w.VALID_DATE desc, w.CREATE_TIME desc