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";
}
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);
}
}
}
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更新教材申报信息失败请查看原因");
}
}
Aggregations