刘小明
2024-08-29 af8b0ddeeb5fc71f5099e6be44dc9d3064a3b243
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java
@@ -76,6 +76,10 @@
    @Transactional
    public int save(PltProduct p) {
        //判断产品不能重名
        if (dao.exists(p.name, p.id)) {
            throw new RuntimeException("产品名称重复");
        }
        int flag=0;
        do {
            p.code = getNextCode();
@@ -110,6 +114,9 @@
    @Transactional
    public int update(PltProduct p) {
        if (dao.exists(p.name, p.id)) {
            throw new RuntimeException("产品名称重复");
        }
        int count = dao.updateByPrimaryKeySelective(p);
        //删除旧数据,重新插入
        pfDao.deleteByProId(p.id);
@@ -170,7 +177,7 @@
                     return;
                 }
                 FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
                 doc.webUrl = fileRestVo.fileSysRestUrl + fileRestVo.fileWebDownloadPath + doc.fileId;
                 doc.webUrl = fileRestVo.fileWebDownloadPath + doc.fileId;
                 doc.orgName = file.orgName;
                 doc.extName = file.extName;
             });
@@ -204,46 +211,48 @@
                    item.qrCode = "data:image/jpeg;base64," + Base64.encode(codes);
                    item = addWebUrl(item);
                } catch (IOException e) {
                    e.printStackTrace();
                    log.error("IOException:",e);
                } catch (WriterException e) {
                    e.printStackTrace();
                    log.error("WriterException:",e);
                }
            });
        }
        return rsVo ;
    }
    /**
     * 添加产品文档关联
     * @param proId 产品id
     * @param fileId 文档id
     * @return 更新数量
     */
    public int addDoc(long proId,long fileId,String fileType){
        PltProductFile pf=new PltProductFile();
        pf.fileId = fileId;
        pf.proId = proId;
        pf.fileType = fileType;
        return pfDao.insertSelective(pf);
    }
//    /**
//     * 添加产品文档关联
//     * @param proId 产品id
//     * @param fileId 文档id
//     * @return 更新数量
//     */
//    public int addDoc(long proId,long fileId,String fileType){
//        PltProductFile pf=new PltProductFile();
//        pf.fileId = fileId;
//        pf.proId = proId;
//        pf.fileType = fileType;
//        return pfDao.insertSelective(pf);
//    }
    /**
     * 查询产品关联文档
     * @param proId 产品id
     * @return 返回关联文档集合
     */
    public List<OthFile> selectDoc(long proId){
        return othFileMapper.selectByProId(proId);
    }
//    /**
//     * 查询产品关联文档
//     * @param proId 产品id
//     * @return 返回关联文档集合
//     */
//    public List<OthFile> selectDoc(long proId){
//        return othFileMapper.selectByProId(proId);
//    }
    public List<PltProduct> selectAll(QueryVo queryVo) {
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
        return dao.selectAll(params);
    }
    public void downloadDoc(HttpServletResponse response) {
        PltProduct pro=dao.selectByPrimaryKey(Long.valueOf(1));
    public List<PltProduct> getProduct(Long orderId) {
        return dao.selectByOrderId(orderId);
    }
//    public void downloadDoc(HttpServletResponse response) {
//        PltProduct pro=dao.selectByPrimaryKey(Long.valueOf(1));
//    }
}