Search in sources :

Example 1 with InfoWorking

use of com.bc.pmpheep.erp.service.InfoWorking in project pmph by BCSquad.

the class BookServiceImpl method AllSynchronization.

@Override
public String AllSynchronization(Integer type) throws CheckedServiceException {
    if (ObjectUtil.isNull(type)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "同步中产生了错误,请重新同步");
    }
    Const.AllSYNCHRONIZATION = 100;
    String[] vns = new InfoWorking().listBookInfo();
    vns = ArrayUtil.array_unique(vns);
    if (1 == type) {
        AbuttingJoint(vns, type);
    } else {
        List<String> vn = ArrayUtil.toList(vns);
        List<String> bookVns = bookDao.getBookByVn();
        vn.remove(bookVns);
        String[] newBookVn = new String[vn.size()];
        for (int i = 0; i < vn.size(); i++) {
            newBookVn[i] = vn.get(i);
        }
        AbuttingJoint(newBookVn, type);
    }
    Const.AllSYNCHRONIZATION = 0;
    return "SUCCESS";
}
Also used : CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) InfoWorking(com.bc.pmpheep.erp.service.InfoWorking)

Example 2 with InfoWorking

use of com.bc.pmpheep.erp.service.InfoWorking in project pmph by BCSquad.

the class MigrationBook method clearBook.

protected void clearBook() {
    StringBuilder sns = new StringBuilder();
    InputStream is;
    Workbook workbook;
    String path = this.getClass().getClassLoader().getResource("book.xlsx").getPath();
    try {
        is = new FileInputStream(path);
    } catch (IOException e) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.FILE_CREATION_FAILED, "未找到模板文件");
    }
    try {
        workbook = new XSSFWorkbook(is);
    } catch (IOException e) {
        throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.ILLEGAL_PARAM, "读取文件失败");
    }
    Map<String, String> snsAndMaterNames = new HashMap<String, String>(16);
    for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
        Sheet sheet = workbook.getSheetAt(numSheet);
        if (ObjectUtil.isNull(sheet)) {
            continue;
        }
        for (int rowNum = 1; rowNum <= sheet.getLastRowNum(); rowNum++) {
            Row row = sheet.getRow(rowNum);
            Cell sn = row.getCell(1);
            if (ObjectUtil.notNull(sn) && !"".equals(sn.toString())) {
                sns.append(",'" + sn.toString().replace(".0", "") + "'");
                snsAndMaterNames.put(sn.toString().replace(".0", ""), String.valueOf(row.getCell(8)));
            }
        }
    }
    bookDao.deleted();
    bookDetailDao.deleteBookDetailByBookIds();
    bookDao.deletedBookSupport();
    bookCorrectionDao.deleteBookCoorrectionTrackByBookIds();
    bookEditorDao.deleteBookEditorByBookIds();
    bookUserCommentDao.deleteBookUserCommentBookIds();
    bookUserLikeDao.deleteBookUserLikeByBookIds();
    bookUserMarkDao.deleteBookUserMarkByBookIds();
    bookVideoDao.deleteBookVideoByBookIds();
    // 同步更新或者插入书籍
    String sn = sns.toString().substring(1);
    JSONArray bookInfo = new InfoWorking().listBook(sn);
    // 版本号
    String[] vns = new String[bookInfo.size()];
    for (int i = 0; i < bookInfo.size(); i++) {
        JSONObject job = bookInfo.getJSONObject(i);
        vns[i] = job.getString("editionnum");
    }
    bookService.AbuttingJoint(vns, 1);
    // 初始化教材社区数据
    Map<String, Long> materNamesAndIds = new HashMap<String, Long>(16);
    for (int i = 0; i < bookInfo.size(); i++) {
        JSONObject job = bookInfo.getJSONObject(i);
        // 本版号
        String bookVn = job.getString("editionnum");
        // 书号
        String bookSn = job.getString("booknumber");
        String materName = snsAndMaterNames.get(bookSn);
        if (null == materName || "".equals(materName.trim())) {
            continue;
        }
        Long materId = materNamesAndIds.get(materName);
        if (null == materId) {
            materId = Long.MAX_VALUE - i;
            Content content = new Content(materName);
            content = contentService.add(content);
            CmsContent cmsContent = new CmsContent();
            cmsContent.setParentId(0L);
            cmsContent.setPath("0");
            cmsContent.setMid(content.getId());
            cmsContent.setCategoryId(3L);
            cmsContent.setTitle(materName);
            cmsContent.setAuthorType(new Short("0"));
            cmsContent.setAuthorId(342L);
            cmsContent.setIsPublished(true);
            cmsContent.setAuthStatus(new Short("2"));
            cmsContent.setAuthDate(DateUtil.date2Str(new Date()));
            cmsContent.setAuthUserId(342L);
            cmsContent.setGmtCreate(DateUtil.getCurrentTime());
            cmsContent.setGmtUpdate(DateUtil.getCurrentTime());
            cmsContent.setIsMaterialEntry(true);
            cmsContent.setMaterialId(materId);
            cmsContentService.addCmsContent(cmsContent);
            materNamesAndIds.put(materName, materId);
        }
        // 更新书籍
        Book book = bookDao.getBookByVn2(bookVn);
        if (null != book) {
            book.setMaterialId(materId);
            book.setSn(bookSn);
            bookDao.updateBook(book);
        }
    }
}
Also used : HashMap(java.util.HashMap) InfoWorking(com.bc.pmpheep.erp.service.InfoWorking) Book(com.bc.pmpheep.back.po.Book) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Cell(org.apache.poi.ss.usermodel.Cell) CmsContent(com.bc.pmpheep.back.po.CmsContent) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) JSONArray(net.sf.json.JSONArray) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) IOException(java.io.IOException) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) FileInputStream(java.io.FileInputStream) Date(java.util.Date) JSONObject(net.sf.json.JSONObject) CmsContent(com.bc.pmpheep.back.po.CmsContent) Content(com.bc.pmpheep.general.po.Content) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet)

Example 3 with InfoWorking

use of com.bc.pmpheep.erp.service.InfoWorking in project pmph by BCSquad.

the class TopicServiceImpl method updateByErp.

@Override
public void updateByErp() {
    InfoWorking bookInfoWorking = new InfoWorking();
    JSONArray topicInfo = bookInfoWorking.listTopicInfo();
    Long[] recordIds = new Long[topicInfo.size()];
    Integer total = 0;
    for (int i = 0; i < topicInfo.size(); i++) {
        JSONObject job = topicInfo.getJSONObject(i);
        String auditstates = job.getString("auditstates");
        String topicnumber = job.getString("topicnumber");
        String topicname = job.getString("topicname");
        String vn = job.getString("editionnum");
        recordIds[i] = job.getLong("record_id");
        switch(auditstates) {
            case "11":
                auditstates = "选题通过";
                break;
            case "12":
                auditstates = "转稿";
                break;
            case "13":
                auditstates = "发稿";
                break;
            case "14":
                auditstates = "即将出书";
                break;
            default:
                auditstates = "状态出现错误";
                break;
        }
        Topic topic = new Topic();
        topic.setNote(auditstates);
        topic.setTn(topicnumber);
        topic.setBookname(topicname);
        topic.setVn(vn);
        total += topicDao.updateByVn(topic);
    }
    if (total == topicInfo.size()) {
        bookInfoWorking.updateTopic(recordIds);
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "从erp更新教材申报信息失败请查看原因");
    }
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Topic(com.bc.pmpheep.back.po.Topic) InfoWorking(com.bc.pmpheep.erp.service.InfoWorking)

Aggregations

InfoWorking (com.bc.pmpheep.erp.service.InfoWorking)3 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)3 JSONArray (net.sf.json.JSONArray)2 JSONObject (net.sf.json.JSONObject)2 Book (com.bc.pmpheep.back.po.Book)1 CmsContent (com.bc.pmpheep.back.po.CmsContent)1 Topic (com.bc.pmpheep.back.po.Topic)1 Content (com.bc.pmpheep.general.po.Content)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Cell (org.apache.poi.ss.usermodel.Cell)1 Row (org.apache.poi.ss.usermodel.Row)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1 Workbook (org.apache.poi.ss.usermodel.Workbook)1 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)1