150 lines
7.2 KiB
Java
150 lines
7.2 KiB
Java
|
|
package com.veve_plus.root.service;
|
||
|
|
|
||
|
|
import com.veve_plus.root.entity.GSheetData;
|
||
|
|
import com.veve_plus.root.entity.GSheetFileData;
|
||
|
|
import com.veve_plus.root.mapper.GSheetMapper;
|
||
|
|
import com.veve_plus.root.mapper.MaterialMapper;
|
||
|
|
import com.veve_plus.root.utils.CustomStringUtils;
|
||
|
|
import com.veve_plus.root.utils.GSheetsUtils;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
import org.springframework.transaction.annotation.Transactional;
|
||
|
|
|
||
|
|
import java.io.IOException;
|
||
|
|
import java.net.InetAddress;
|
||
|
|
import java.net.URISyntaxException;
|
||
|
|
import java.security.GeneralSecurityException;
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.LinkedHashMap;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
@Service
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
public class TmsGSheetService {
|
||
|
|
|
||
|
|
private final GSheetsUtils googleSheetsUtil;
|
||
|
|
private final GSheetMapper GSheetMapper;
|
||
|
|
private final MaterialMapper materialMapper;
|
||
|
|
|
||
|
|
public void insertTaskData(String sheetName, String range, String spreadId, String runVersion) throws GeneralSecurityException, IOException, URISyntaxException {
|
||
|
|
String hostName = InetAddress.getLocalHost().getHostName();
|
||
|
|
|
||
|
|
List<LinkedHashMap<String, Object>> result = googleSheetsUtil.getKSTData(spreadId, range);
|
||
|
|
if(result == null){
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
int rowNo = 7;
|
||
|
|
List<GSheetData> insertList = new ArrayList<>();
|
||
|
|
System.out.println("Processing on sheet: " + sheetName);
|
||
|
|
for (LinkedHashMap<String, Object> i : result) {
|
||
|
|
GSheetData sheet = new GSheetData();
|
||
|
|
sheet.setDiskType(CustomStringUtils.valueOf(i.get("TMS")));
|
||
|
|
sheet.setGeId(CustomStringUtils.valueOf(i.get("GeId")));
|
||
|
|
sheet.setPlatformCode(CustomStringUtils.valueOf(i.get("Platform")));
|
||
|
|
sheet.setTitle(CustomStringUtils.valueOf(i.get("Title")));
|
||
|
|
sheet.setChapter(CustomStringUtils.valueOf(i.get("Chap")));
|
||
|
|
sheet.setOpenDate(CustomStringUtils.convertSheetStringDate(i.get("Open Day")));
|
||
|
|
sheet.setTransDeliveryDate(CustomStringUtils.convertSheetStringDate(i.get("Translation delivery date")));
|
||
|
|
sheet.setTransReviewDate(CustomStringUtils.convertSheetStringDate(i.get("TR")));
|
||
|
|
sheet.setIsTransReview((CustomStringUtils.valueOf(i.get("TR ready"))));
|
||
|
|
sheet.setAffectedDeliveryDate(CustomStringUtils.convertSheetStringDate(i.get("Delivery date")));
|
||
|
|
sheet.setAffectedChapter(CustomStringUtils.removeSpecialChar(i.get("Affected chapter")));
|
||
|
|
sheet.setDkiDeliveryDate(CustomStringUtils.convertSheetStringDate(i.get("DL")));
|
||
|
|
sheet.setIsModify(CustomStringUtils.validBoolean(CustomStringUtils.valueOf(i.get("Necessity of modification (TMS)"))));
|
||
|
|
sheet.setPsdUploadDealine(CustomStringUtils.convertSheetStringDate(i.get("PSD upload deadline")));
|
||
|
|
sheet.setFinalSubsetUpload(CustomStringUtils.validBoolean(CustomStringUtils.valueOf(i.get("Final Subset upload"))));
|
||
|
|
sheet.setTmsPsdUpload(CustomStringUtils.validBoolean(CustomStringUtils.valueOf(i.get("PSD upload check"))));
|
||
|
|
sheet.setQcUserId(CustomStringUtils.valueOf(i.get("worker")));
|
||
|
|
sheet.setIssuedDate(CustomStringUtils.convertSheetStringDate(i.get("Date of issue")));
|
||
|
|
sheet.setWriter(CustomStringUtils.valueOf(i.get("Writer")));
|
||
|
|
sheet.setScheduleChangeReason(CustomStringUtils.valueOf(i.get("Reason for schedule change")));
|
||
|
|
sheet.setIsConfirmed(CustomStringUtils.validBoolean(CustomStringUtils.valueOf(i.get("DKI schedule change confirmation"))));
|
||
|
|
sheet.setNote(CustomStringUtils.valueOf(i.get("Reason")));
|
||
|
|
if("TN".equals(sheetName)){
|
||
|
|
sheet.setLanguage(CustomStringUtils.valueOf(i.get("Lang")).substring(2,4));
|
||
|
|
}
|
||
|
|
else if("YL".equals(sheetName)){
|
||
|
|
sheet.setLanguage(CustomStringUtils.valueOf(i.get("Lang")).substring(2,4));
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
sheet.setLanguage(CustomStringUtils.valueOf(i.get("Lang")));
|
||
|
|
}
|
||
|
|
sheet.setGoogleSheetName(sheetName);
|
||
|
|
if("Urgent".equals(sheetName)){
|
||
|
|
sheet.setIsUrgent("01");
|
||
|
|
} else if("TN".equals(sheetName)) {
|
||
|
|
sheet.setIsUrgent("02");
|
||
|
|
} else if("YL".equals(sheetName)){
|
||
|
|
sheet.setIsUrgent("04");
|
||
|
|
} else {
|
||
|
|
sheet.setIsUrgent("03");
|
||
|
|
}
|
||
|
|
sheet.setGoogleApiId(spreadId);
|
||
|
|
sheet.setGoogleRow(rowNo);
|
||
|
|
sheet.setVersion(runVersion);
|
||
|
|
sheet.setCreatedBy(hostName);
|
||
|
|
|
||
|
|
insertList.add(sheet);
|
||
|
|
rowNo++;
|
||
|
|
|
||
|
|
if (insertList.size() >= 1000) {
|
||
|
|
insertTaskList(insertList);
|
||
|
|
insertList.clear();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
insertTaskList(insertList);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Transactional
|
||
|
|
private void insertTaskList(List<GSheetData> insertList) {
|
||
|
|
if (insertList.size() > 0) {
|
||
|
|
GSheetMapper.insertTaskListHistory(insertList);
|
||
|
|
for(GSheetData data : insertList){
|
||
|
|
materialMapper.insertMaterial(data);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Transactional(readOnly = true)
|
||
|
|
public String getGoogleSheetSpreadId(String dataType) {
|
||
|
|
return GSheetMapper.getGoogleSheetSpreadId(dataType);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void insertFileData(String range, String spreadId, String runVersion) throws GeneralSecurityException, IOException, URISyntaxException {
|
||
|
|
String hostName = InetAddress.getLocalHost().getHostName();
|
||
|
|
List<LinkedHashMap<String, Object>> result = googleSheetsUtil.getFileData(spreadId, range);
|
||
|
|
List<GSheetFileData> targetLst = new ArrayList<>();
|
||
|
|
int rowNo = 3;
|
||
|
|
for (LinkedHashMap<String, Object> i : result) {
|
||
|
|
GSheetFileData sheet = new GSheetFileData();
|
||
|
|
sheet.setVersion(runVersion);
|
||
|
|
sheet.setLanguage(CustomStringUtils.valueOf(i.get("언어")));
|
||
|
|
sheet.setTms(CustomStringUtils.valueOf(i.get("TMS")));
|
||
|
|
sheet.setContent(CustomStringUtils.valueOf(i.get("작품명")));
|
||
|
|
sheet.setIsCensored(CustomStringUtils.valueOf(i.get("우선 순위")));
|
||
|
|
sheet.setFileSpec(CustomStringUtils.valueOf(i.get("파일규격")));
|
||
|
|
sheet.setUseUsPsd(CustomStringUtils.valueOf(i.get("US PSD 작업")));
|
||
|
|
sheet.setIs_set(CustomStringUtils.valueOf(i.get("식자 세팅")));
|
||
|
|
sheet.setIs_logo(CustomStringUtils.valueOf(i.get("로고 전달")));
|
||
|
|
sheet.setDm_name(CustomStringUtils.valueOf(i.get("담당 DM")));
|
||
|
|
sheet.setPsd_url_kr(CustomStringUtils.valueOf(i.get("국문 PSD")));
|
||
|
|
sheet.setPsd_url_en(CustomStringUtils.valueOf(i.get("영문 PSD")));
|
||
|
|
sheet.setNote(CustomStringUtils.valueOf(i.get("특이사항 (식자가 전달)")));
|
||
|
|
sheet.setTr_url(CustomStringUtils.valueOf(i.get("번역문 링크")));
|
||
|
|
sheet.setMemo(CustomStringUtils.valueOf(i.get("비고 (레진 내부 정보 공유)")));
|
||
|
|
rowNo++;
|
||
|
|
targetLst.add(sheet);
|
||
|
|
if (targetLst.size() >= 1000) {
|
||
|
|
GSheetMapper.insertFileListHistory(targetLst);
|
||
|
|
targetLst.clear();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (targetLst.size() > 0) {
|
||
|
|
GSheetMapper.insertFileListHistory(targetLst);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|