Fancy
2024-07-01 f4486e42360320b7c241066b8321baf07348e7ed
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java
@@ -3,14 +3,17 @@
import com.alibaba.excel.util.StringUtils;
import com.dy.pmsGlobal.daoBa.BaUserMapper;
import com.dy.pmsGlobal.daoOth.OthFileMapper;
import com.dy.pmsGlobal.daoPlt.PltProductMapper;
import com.dy.pmsGlobal.daoPlt.PltStationMapper;
import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper;
import com.dy.pmsGlobal.daoPr.PrProductionNodeMapper;
import com.dy.pmsGlobal.daoSta.StaAssemblyWorkHistoryMapper;
import com.dy.pmsGlobal.daoSta.StaAssemblyWorkLastMapper;
import com.dy.pmsGlobal.dyFile.FileOperate;
import com.dy.pmsGlobal.dyFile.FileRestVo;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.pojoOth.OthFile;
import com.dy.pmsGlobal.pojoPlt.PltProduct;
import com.dy.pmsGlobal.pojoPlt.PltStation;
import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan;
import com.dy.pmsGlobal.pojoPr.PrProductionNode;
@@ -44,6 +47,8 @@
    private PltStationMapper pltStationDao;
    private StaAssemblyWorkLastMapper assemblyWorkLastDao;
    private StaAssemblyWorkHistoryMapper assemblyWorkHistoryDao;
    private PrProductionNodeMapper nodeDao;
    private PltProductMapper productDao;
    private FileOperate fileOperate;
    private OthFileMapper othFileMapper;
    @Value("${dy.webFile.fmUrl}")
@@ -72,6 +77,16 @@
    @Autowired
    private void setStaAssemblyWorkLastDao(StaAssemblyWorkLastMapper assemblyWorkLastDao) {
        this.assemblyWorkLastDao = assemblyWorkLastDao;
    }
    @Autowired
    public void setNodeDao(PrProductionNodeMapper nodeDao) {
        this.nodeDao = nodeDao;
    }
    @Autowired
    public void setPltProductDao(PltProductMapper productDao) {
        this.productDao = productDao;
    }
    @Autowired
@@ -202,7 +217,7 @@
        StaAssemblyWorkLast checkResult = checkUserAndStationUsed(vo);
        //校验planId processId nodeId
        PrAssemblyPlan assyPlan = assemblyDao.selectByPrimaryKey(vo.getPlanId());
        if(assyPlan == null){
        if (assyPlan == null) {
            throw new RuntimeException("组装任务已经在系统中删除请检查,刷新并重新选择任务");
        }
        boolean hasNodeId = assyPlan.getProcess().getNodes().stream()
@@ -238,7 +253,7 @@
            throw new RuntimeException("数据库存储失败");
        }
        StaAssemblyWorkLast result = assemblyWorkLastDao.selectByPrimaryKey(staLast.getId());
        List<PrProductionNode> nodeInfo =assyPlan.getProcess().getNodes().stream()
        List<PrProductionNode> nodeInfo = assyPlan.getProcess().getNodes().stream()
                .filter(node -> node.id.equals(vo.getNodeId())).collect(Collectors.toList());
        assyPlan.getProcess().setNodes(nodeInfo);
        result.setPlan(assyPlan);
@@ -375,7 +390,58 @@
        List<BaUser> assistantList = baUserDao.selectByAssistants(workLast.getAssistants());
        return assistantList;
    }
    //根据节点的查出节点作业指导书
    // 根据产品查出产品文件 主要技术参数
    //根据节点查出节点作业指导书
    public PrProductionNode getSopByNodeId(String nodeId) {
        if(StringUtils.isBlank(nodeId)){
            throw new RuntimeException("节点ID不能为空");
        }
        PrProductionNode node = nodeDao.selectByPrimaryKey(Long.parseLong(nodeId));
        if(node == null){
            throw new RuntimeException("节点ID不存在,请检查");
        }
        if(node.instruction != null){
            addUrl(node.instruction);
        }
        return  node;
    }
    // 根据产品查出产品文件 主要技术参数    同 platform-->product-->productSv
    public PltProduct getFileByProId(String proId) {
        if(StringUtils.isBlank(proId)){
            throw new RuntimeException("产品ID不能为空");
        }
        PltProduct product = productDao.selectByPrimaryKey(Long.parseLong(proId));
        if(product == null){
            throw new RuntimeException("产品ID不存在,请检查");
        }
        product = addWebUrl(product);
        return  product;
    }
    private PltProduct addWebUrl(PltProduct pro) {
        if (pro != null) {
            if (pro.image != null) {
                String filePathWithWebUrl = getFilePathWithWebUrl(pro.image);
                pro.imageWebPath = filePathWithWebUrl;
                pro.imageWebPathZip = fileOperate.getImgFileZipPath(filePathWithWebUrl);
            }
            pro.proFiles.stream().forEach(doc -> {
                OthFile file = othFileMapper.selectByPrimaryKey(doc.fileId);
                if (file == null) {
                    return;
                }
                FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
                doc.webUrl = fileRestVo.fileSysRestUrl + fileRestVo.fileWebDownloadPath + doc.fileId;
                doc.orgName = file.orgName;
                doc.extName = file.extName;
            });
        }
        return pro;
    }
    private String getFilePathWithWebUrl(Long fileId) {
        OthFile file = othFileMapper.selectByPrimaryKey(fileId);
        FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
        return fileRestVo.fileWebUrl + file.filePath;
    }
}