연계파일 단속등록 수정

main
mjkhan21 8 months ago
parent 5f339e3f63
commit 9a3d1d488a

@ -63,9 +63,9 @@ public class CodeConverter extends AbstractComponent {
* @return
*/
public void fillIfEmpty(DataObject dataObject, String codeGroupName, String codeName, String valueName) {
if(!isEmpty(dataObject.get(valueName)) && isEmpty(dataObject.get(codeName))) {
if (!isEmpty(dataObject.get(valueName)) && isEmpty(dataObject.get(codeName))) {
dataObject.put(codeName, this.valueToCode(codeGroupName, dataObject.string(valueName)));
} else if(isEmpty(dataObject.get(valueName)) && !isEmpty(dataObject.get(codeName))) {
} else if (isEmpty(dataObject.get(valueName)) && !isEmpty(dataObject.get(codeName))) {
dataObject.put(valueName, this.codeToValue(codeGroupName, dataObject.string(codeName)));
}
}

@ -7,6 +7,8 @@ import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.Arrays;
import org.apache.commons.io.IOUtils;
import cokr.xit.foundation.data.DataObject;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
@ -27,7 +29,7 @@ public class AttachedTxtParser extends LayoutParser{
if (isMetaData) {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file),Charset.forName("EUC-KR")));
String content = org.apache.commons.io.IOUtils.toString(br);
String content = IOUtils.toString(br);
String[] contentDivision = null;
String part = "";
int contentDivisionIndex = 0;

@ -12,6 +12,7 @@ import java.util.regex.Matcher;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import cokr.xit.applib.Hangul;
import cokr.xit.base.code.CommonCode;
@ -161,6 +162,60 @@ abstract public class LayoutParser extends AbstractComponent {
.toList();
}
public List<DataObject> parse(String workPath, List<MultipartFile> uploads){
String taskSeCd = descriptor.getTaskSeCd();
return uploads.stream()
.sorted((upload1, upload2) -> upload1.getOriginalFilename().compareTo(upload2.getOriginalFilename())) //파일명으로 정렬(파싱 전)
.map(upload -> {
String filename = upload.getOriginalFilename();
DataObject dataObject = createParsedDataObject()
.set("FILE_GROUP_TYPE", groupingType)
.set("FILE_LAYOUT_ID", descriptor.getFileLayoutId())
.set("FILE_PATH", filename)
.set("FILE_NAME", filename)
// .set("FILE_LAST_MODIFIED", new SimpleDateFormat("yyyy-MM-dd / HH:mm:ss").format(new Date(file.lastModified())))
// .set("FILE_SIZE", file.length() + " byte")
.set("FILE_EXTENSION", FilenameUtils.getExtension(filename));
if (need.fileNameAnalyze) {
String noExtensionName = FilenameUtils.removeExtension(dataObject.string("FILE_NAME"));
analyzeFileName(dataObject, noExtensionName);
refineValue(dataObject);
}
if (need.contentAnalyze) {
try {
File file = new File(workPath + "/" + filename);
upload.transferTo(file);
analyzeFileContent(dataObject, file);
refineValue(dataObject);
dataObject.set("upload", file);
} catch (Exception e) {
throw runtimeException(e);
}
}
//단속구분코드 보정
String crdnSeCd = taskProcessor.getCrdnSeCd(taskSeCd, descriptor.getEnterpriseName(), dataObject);
dataObject.put("CRDN_SE_CD", crdnSeCd);
if (!before.isEmpty()) {
if (need.checkChangeCrackdown) {
boolean isChangeTempGroup = isChangeCrackdown(dataObject, before);
if (isChangeTempGroup) {
tempGroupSeq++;
}
} else {
tempGroupSeq++;
}
}
return before = dataObject.set("TEMP_GROUP_ID", tempGroupSeq);
})
.toList();
}
/** .<br />
* @param dataObject , File
* @return
@ -275,11 +330,11 @@ abstract public class LayoutParser extends AbstractComponent {
public void refineNumberValue(DataObject dataObject, String[] items) {
for (int i = 0;i < items.length;i++) {
String itemValue = dataObject.string(items[i]);
if (!itemValue.equals("")) {
if (!isEmpty(itemValue)) {
//소수부 0제거
if (itemValue.contains(".")) {
boolean end = false;
while(!end) {
while (!end) {
String removed = StringUtils.removeEnd(itemValue, "0");
if (removed.equals(itemValue)) {
end = true;

@ -150,7 +150,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
}
//metaInfo.string("PLATE_WIDTH");
//metaInfo.string("PLATE_HEIGHT");
List<FileInfo> fileInfos = parseDataInfoToFileInfo(imageList, fileGroupType);
List<FileInfo> fileInfos = parseDataInfoToFileInfo(imageList, ifEmpty(fileGroupType, () -> metaInfo.string("FILE_GROUP_TYPE")));
DataObject result = new DataObject()
.set("crdn", crdn)
.set("fileInfos", fileInfos);
@ -192,7 +192,8 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
resultMap.put("failReason", "기타 오류");
}
});
fileList.forEach(delInfo -> crdnBean.removeEquipmentLinkFile(workPath, delInfo.string("FILE_NAME")));
if (!isEmpty(workPath))
fileList.forEach(delInfo -> crdnBean.removeEquipmentLinkFile(workPath, delInfo.string("FILE_NAME")));
return resultMap;
}
@ -207,7 +208,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
return filename.substring(0, filename.lastIndexOf("_"));
}));
List<DataObject> list = byName.values().stream()
return byName.values().stream()
.map(files -> {
DataObject result = new DataObject();
DataObject metaInfo = null;
@ -249,8 +250,6 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
return result;
})
.toList();
return list;
}
/** . null . <br />
@ -305,7 +304,10 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
List<FileInfo> fileInfos = null;
if ("JPG,TXT".contains(fileGroupType)) {
List<File> files = imageList.stream()
.map(imageInfo -> new File(imageInfo.string("FILE_PATH")))
.map(imageInfo -> {
File img = (File)imageInfo.get("upload");
return ifEmpty(img, new File(imageInfo.string("FILE_PATH")));
})
.toList();
fileInfos = new FileInfoFactory().createFileInfos(null, files);

@ -141,12 +141,12 @@ public class Crdn05Controller extends ApplicationController {
*/
@Task
@RequestMapping(name="단속자료 파일 등록 화면", value=METHOD_URL.getFileRegistrationScreen)
public ModelAndView getFileRegistrationScreen(HttpServletRequest hReq) {
public ModelAndView getFileRegistrationScreen(HttpServletRequest hreq) {
Map<String, List<CommonCode>> commonCodes = getCodesOf("FIM054");
return new ModelAndView("fims/crdn/crdn05020-info")
.addObject("pageName", "crdn05020")
.addObject("taskSeCd", hReq.getParameter("taskSeCd"))
.addObject("taskSeCd", hreq.getParameter("taskSeCd"))
.addObject("FIM054List", commonCodes.get("FIM054"))
.addObject("TaskListForSgg", stngBean.filterTaskSectionCodeForSgg(commonCodes.get("FIM054")));
}
@ -157,9 +157,9 @@ public class Crdn05Controller extends ApplicationController {
*/
@Task
@RequestMapping(name="단속연계파일 가져오기(FTP)", value=METHOD_URL.importFileFromServer)
public ModelAndView importFileFromServer(HttpServletRequest hReq) {
public ModelAndView importFileFromServer(HttpServletRequest hreq) {
FimsUser currentUser = (FimsUser) currentUser().getUser();
List<LayoutDescriptor> layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(currentUser.getOrgID(), hReq.getParameter("taskSeCd"), currentUser().getInstitute(), currentUser.getDeptCode());
List<LayoutDescriptor> layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(currentUser.getOrgID(), hreq.getParameter("taskSeCd"), currentUser().getInstitute(), currentUser.getDeptCode());
ModelAndView mav = new ModelAndView("jsonView");
for(int i=0; i < layoutDescriptors.size(); i++) {
LayoutDescriptor layoutDescriptor = layoutDescriptors.get(i);
@ -198,11 +198,11 @@ public class Crdn05Controller extends ApplicationController {
*/
@Task
@RequestMapping(name="단속연계파일 가져오기(파일업로드)", value=METHOD_URL.importFileFromClient)
public ModelAndView importFileFromClient(HttpServletRequest hReq, MultipartFile[] uploadFiles) {
public ModelAndView importFileFromClient(HttpServletRequest hreq, MultipartFile[] uploadFiles) {
UserInfo currentUser = currentUser();
List<LayoutDescriptor> layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(
currentUser.getOrgID(),
hReq.getParameter("taskSeCd"),
hreq.getParameter("taskSeCd"),
currentUser.getInstitute(),
currentUser.getDeptCode()
);
@ -217,9 +217,9 @@ public class Crdn05Controller extends ApplicationController {
ModelAndView mav = new ModelAndView("jsonView");
try {
for(int j=0; j < uploadFiles.length; j++) {
File newFile = new File(workPath+File.separator+uploadFiles[j].getOriginalFilename());
uploadFiles[j].transferTo(newFile);
for (MultipartFile upload: uploadFiles) {
File newFile = new File(workPath+File.separator+upload.getOriginalFilename());
upload.transferTo(newFile);
}
} catch (Exception e) {
return mav.addObject("saved", false);
@ -236,11 +236,11 @@ public class Crdn05Controller extends ApplicationController {
*/
@Task
@RequestMapping(name="장비업체 단속파일 목록 조회", value=METHOD_URL.getEquipmentFileInfoList)
public ModelAndView getEquipmentFileInfoList(HttpServletRequest hReq) {
public ModelAndView getEquipmentFileInfoList(HttpServletRequest hreq) {
UserInfo currentUser = currentUser();
List<LayoutDescriptor> layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(
currentUser.getOrgID(),
hReq.getParameter("taskSeCd"),
hreq.getParameter("taskSeCd"),
currentUser.getInstitute(),
currentUser.getDeptCode()
);
@ -250,9 +250,8 @@ public class Crdn05Controller extends ApplicationController {
int nextTempGroupSeq = 1;
List<DataObject> allParsedDataList = new ArrayList<DataObject>();
TaskProcessor taskProcessor = TaskProcessor.get();
Map<String, List<CommonCode>> codeInfo = getCodesOf("FIM007","FIM004","FIM005","FIM006","FIM005","FIM061");
for(int i = 0; i < layoutDescriptors.size(); i++) {
LayoutDescriptor layoutDescriptor = layoutDescriptors.get(i);
Map<String, List<CommonCode>> codeInfo = getCodesOf("FIM004","FIM005","FIM006","FIM007","FIM061");
for(LayoutDescriptor layoutDescriptor: layoutDescriptors) {
String workPath = layoutDescriptor.getLinkFileLocation();
ensureDir(workPath);
@ -284,7 +283,7 @@ public class Crdn05Controller extends ApplicationController {
}
/** .
* @param hReq
* @param hreq
* @return jsonView
* <pre><code> {
* "saved": true, false
@ -292,11 +291,11 @@ public class Crdn05Controller extends ApplicationController {
*/
@Task
@RequestMapping(name="장비업체 단속파일 삭제", value=METHOD_URL.removeLinkFile)
public ModelAndView removeLinkFile(HttpServletRequest hReq) {
LayoutDescriptor info = crdnEqpmntBean.getLinkFileLayoutMetadata(hReq.getParameter("fileLayoutId"));
public ModelAndView removeLinkFile(HttpServletRequest hreq) {
LayoutDescriptor info = crdnEqpmntBean.getLinkFileLayoutMetadata(hreq.getParameter("fileLayoutId"));
String workPath = info.getLinkFileLocation();
String fileName = hReq.getParameter("fileName");
String fileName = hreq.getParameter("fileName");
String rtnMsg = crdnService.removeEquipmentLinkFile(workPath, fileName);
return new ModelAndView("jsonView")
@ -339,6 +338,58 @@ public class Crdn05Controller extends ApplicationController {
return mav;
}
@RequestMapping(name="장비업체 단속파일로 단속자료 생성", value="/020/upload.do")
public ModelAndView createCrdnFromLinkFile(HttpServletRequest hreq, MultipartFile[] uploadFiles) {
UserInfo currentUser = currentUser();
String sggCd = currentUser.getOrgID(),
taskSeCd = hreq.getParameter("taskSeCd"),
instCd = currentUser.getInstitute(),
deptCode = currentUser.getDeptCode();
List<LayoutDescriptor> descriptors = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, instCd, deptCode);
if (isEmpty(descriptors))
throw new RuntimeException("연계파일 레이아웃 정보 조회에 실패하였습니다.");
int nextTempGroupSeq = 1;
TaskProcessor taskProcessor = TaskProcessor.get();
HashMap<String, String> processInfo = new HashMap<>();
processInfo.put("institute", currentUser().getInstitute());
processInfo.put("taskSeCd", taskSeCd);
Map<String, LayoutParser> parsers = Map.of(
"TXT", new AttachedTxtParser(),
"JPG", new OnlyImageParser(),
"BIN", new SingleFileParser()
);
Map<String, List<CommonCode>> codeInfo = getCodesOf("FIM004","FIM005","FIM006","FIM007","FIM061");
List<DataObject> allParsedDataList = new ArrayList<DataObject>();
for (LayoutDescriptor descriptor: descriptors) {
String workPath = crdnEqpmntBean.getLinkFileLayoutMetadata(descriptor.getFileLayoutId()).getLinkFileLocation();
processInfo.put("workPath", workPath);
LayoutParser parser = parsers.get(descriptor.getFileGroup());
parser.setTaskProcessor(taskProcessor);
parser.setTempGroupSeq(nextTempGroupSeq);
parser.addCommonCode(codeInfo);
parser.setDescriptor(descriptor);
allParsedDataList.addAll(parser.parse(workPath, List.of(uploadFiles)));
nextTempGroupSeq = parser.getTempGroupSeq();
}
HashMap<String, Object> resultMap = importService.createCrdnByEquipmentLinkFile(processInfo, allParsedDataList);
boolean saved = (boolean) resultMap.get("saved");
ModelAndView mav = new ModelAndView("jsonView")
.addObject("saved", saved);
if (!isEmpty(resultMap.get("alertMessage")))
mav.addObject("alertMessage", resultMap.get("alertMessage"));
if (!saved)
mav.addObject("failReason", ifEmpty(resultMap.get("failReason"), () -> "알 수 없는 오류"));
return mav;
}
/** .
* @param
* @return fims/crdn/crdn05030-info

@ -171,7 +171,7 @@ public class Excl01Controller extends ApplicationController {
DataObject levyExclInfo = levyExclService.getLevyExclInfo(req);
if (req.getCallPurpose().equals("create")) { // 등록
if (!levyExclInfo.string("LEVY_EXCL_ID").equals("")) {
if (!isEmpty(levyExclInfo.string("LEVY_EXCL_ID"))) {
return new ModelAndView("jsonView")
.addObject("rtnMsg", "이미 등록된 부과제외 정보가 있습니다.")
.addObject("message", "이미 등록된 부과제외 정보가 있습니다.");

Loading…
Cancel
Save