구글애드-가로긴거2



트랜잭션 참조 소스

/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package com.mnwise.atok.service.imp;

import com.mnwise.atok.dao.auto.mapper.FtaddrMapper;
import com.mnwise.atok.dao.auto.mapper.FtaddrgrpMapper;
import com.mnwise.atok.dao.auto.mapper.FtlistMapper;
import com.mnwise.atok.dao.auto.vo.FtaddrExample;
import com.mnwise.atok.dao.auto.vo.FtaddrExample.Criteria;
import com.mnwise.atok.dao.auto.vo.FtaddrgrpExample;
import com.mnwise.atok.dao.auto.vo.FtaddrgrpExample.Criteria;
import com.mnwise.atok.dao.auto.vo.FtlistExample;
import com.mnwise.atok.dao.auto.vo.FtlistExample.Criteria;
import com.mnwise.atok.dao.manual.mapper.FtMapper;
import com.mnwise.atok.dao.manual.vo.AtCustVo;
import com.mnwise.atok.dao.manual.vo.FtAddrGrpVo;
import com.mnwise.atok.dao.manual.vo.FtAddrVo;
import com.mnwise.atok.dao.manual.vo.FtListVo;
import com.mnwise.atok.service.FtService;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import kr.japps.common.util.Common;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;

@Service("ftService")
public class FtServiceImpl implements FtService {
private static final Logger logger = LoggerFactory.getLogger(FtService.class);

@Resource(name = "ftlistMapper")
FtlistMapper ftlistMapper;

@Resource(name = "ftMapper")
FtMapper ftMapper;

@Resource(name = "ftaddrgrpMapper")
FtaddrgrpMapper ftaddrgrpMapper;

@Autowired
private DataSourceTransactionManager transactionManager;

@Resource(name = "ftaddrMapper")
FtaddrMapper ftaddrMapper;

public DataSourceTransactionManager getTransactionManager() {
return this.transactionManager;
}

@Transactional(readOnly = false, rollbackFor = { Exception.class }, isolation = Isolation.DEFAULT)
public void saveFtList(FtListVo ftListVo, String uid) {
int nFtIdCnt = 0;
if (ftListVo.getFT_ID() != null) {
FtlistExample ftListExample = new FtlistExample();
ftListExample.createCriteria().andFT_IDEqualTo(ftListVo.getFT_ID());
nFtIdCnt = this.ftlistMapper.countByExample(ftListExample);
}

if (nFtIdCnt == 0) {
ftListVo.setINS_DTS(Common.simpleDateFormat.format(new Date()));
ftListVo.setINS_UID(uid);
ftListVo.setUPD_DTS(Common.simpleDateFormat.format(new Date()));
ftListVo.setUPD_UID(uid);
this.ftlistMapper.insertSelective(ftListVo);
} else {
ftListVo.setUPD_DTS(Common.simpleDateFormat.format(new Date()));
ftListVo.setUPD_UID(uid);
this.ftlistMapper.updateByPrimaryKeySelective(ftListVo);
}
}

public List<FtListVo> getFtList(FtListVo dto) {
return this.ftMapper.getFtList(dto);
}

@Transactional(readOnly = false, rollbackFor = { Exception.class }, isolation = Isolation.DEFAULT)
public List getFtAddrGrpList(FtAddrGrpVo ftAddrGrpVo, String uid) {
FtaddrgrpExample ftaddrgrpExample = new FtaddrgrpExample();
FtaddrgrpExample.Criteria criteria = ftaddrgrpExample.createCriteria();

criteria.andINS_UIDEqualTo(uid);
if (ftAddrGrpVo.getADDR_OPT_NO() != null) {
if (ftAddrGrpVo.getADDR_OPT_NO().intValue() == 0)
criteria.andADDR_OPT_NOEqualTo(Integer.valueOf(0));
else
criteria.andADDR_OPT_NONotEqualTo(Integer.valueOf(0));
}
return this.ftaddrgrpMapper.selectByExample(ftaddrgrpExample);
}

public void saveFtAddrGrp(FtAddrGrpVo ftAddrGrpVo) {
this.ftaddrgrpMapper.insertSelective(ftAddrGrpVo);
}

public int saveFtAddrGrpGetKey(FtAddrGrpVo ftAddrGrpVo) {
this.ftMapper.insertSelectiveGetKey(ftAddrGrpVo);
return ftAddrGrpVo.getAGRP_ID().intValue();
}

public void updateFtAddrGrp(FtAddrGrpVo ftAddrGrpVo) {
FtaddrgrpExample ftaddrgrpExample = new FtaddrgrpExample();
ftaddrgrpExample.createCriteria().andAGRP_IDEqualTo(ftAddrGrpVo.getAGRP_ID());
this.ftaddrgrpMapper.updateByExampleSelective(ftAddrGrpVo, ftaddrgrpExample);
}

public void deleteFtAddrGrpByAgrpId(int agrpId) {
FtaddrgrpExample ftaddrgrpExample = new FtaddrgrpExample();
ftaddrgrpExample.createCriteria().andAGRP_IDEqualTo(Integer.valueOf(agrpId));
this.ftaddrgrpMapper.deleteByExample(ftaddrgrpExample);
}

@Transactional(readOnly = false, rollbackFor = { Exception.class }, isolation = Isolation.DEFAULT)
public List getFtAddrList(FtAddrVo ftAddrVo) {
FtaddrExample ftaddrExample = new FtaddrExample();
ftaddrExample.createCriteria().andAGRP_IDEqualTo(ftAddrVo.getAGRP_ID());

return this.ftaddrMapper.selectByExample(ftaddrExample);
}

public void saveFtAddr(FtAddrVo ftAddrVo) {
this.ftaddrMapper.insertSelective(ftAddrVo);
}

public void deleteFtAddrByAgrpId(int agrpId) {
FtaddrExample ftaddrExample = new FtaddrExample();
ftaddrExample.createCriteria().andAGRP_IDEqualTo(Integer.valueOf(agrpId));
this.ftaddrMapper.deleteByExample(ftaddrExample);
}

public Map uploadFtAddrGrpExcel(File f, String authUid, AtCustVo custVo, String submitType, int p_agrpId, String agrpNm, String agrpDesc, String realPath, String fn, SimpleDateFormat sdf, Pattern p)
  {
    logger.info("start excel upload! {}/{}", custVo.getYELLOW_ID(), authUid);

    Map resultMap = null;
    InputStream fis = null;
    POIFSFileSystem poif = null;
    Object workbook = null;
    Object sheet = null;

    String[] headers = null;
    try
    {
      fis = new FileInputStream(f);

      if (f.getName().endsWith(".xls")) {
        poif = new POIFSFileSystem(fis);
        workbook = new HSSFWorkbook(poif);
      } else {
        workbook = new XSSFWorkbook(fis);
      }
      if (workbook instanceof HSSFWorkbook) sheet = ((HSSFWorkbook)workbook).getSheetAt(0);
      else sheet = ((XSSFWorkbook)workbook).getSheetAt(0);

      if (sheet == null)
        break label288;
      Iterator rows = null;
      if (workbook instanceof HSSFWorkbook) rows = ((HSSFSheet)sheet).rowIterator();
      else rows = ((XSSFSheet)sheet).rowIterator();

      if (!(rows.hasNext()))
        break label288;
      rows.next();

      resultMap = uploadFtAddrGrpExcel(rows, authUid, custVo, submitType, p_agrpId, agrpNm, agrpDesc, realPath, fn, sdf, p);
      int agrpId = ((Integer)resultMap.get("agrpId")).intValue();
      int nAddrCnt = ((Integer)resultMap.get("nAddrCnt")).intValue();

      if (agrpId == 0) break label288;
      FtAddrGrpVo ftAddrGrpDto = null;
      ftAddrGrpDto = new FtAddrGrpVo();
      ftAddrGrpDto.setAGRP_ID(Integer.valueOf(agrpId));
      ftAddrGrpDto.setADDR_CNT(Integer.valueOf(nAddrCnt));
      label288: label608: label487: label364: updateFtAddrGrp(ftAddrGrpDto);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      logger.error("AddrGrp Excel upload error: {}", e.getStackTrace());
    }
    finally
    {
      if (workbook != null) try { if (workbook instanceof HSSFWorkbook) { ((HSSFWorkbook)workbook).close(); break label487: } ((XSSFWorkbook)workbook).close(); } catch (Exception localException4) { } finally { workbook = null; }
      if (poif != null) try { poif.close(); } catch (Exception localException5) { } finally { poif = null; }
      if (fis != null) try { fis.close(); } catch (Exception localException6) { } finally { fis = null; }
    }
    return resultMap;
  }

public Map uploadFtAddrGrpExcel(Iterator rows, String authUid, AtCustVo custVo, String submitType, int p_agrpId,
String agrpNm, String agrpDesc, String realPath, String fn, SimpleDateFormat sdf, Pattern p) {
Map resultMap = new HashMap();
String[] headers = null;
String senderKey = null;
int agrpId = -1;
int nAddrCnt = 0;
int nErrAddrCnt = 0;
FtAddrGrpVo ftAddrGrpDto = null;
FtAddrVo ftAddrDto = null;

DefaultTransactionDefinition def = new DefaultTransactionDefinition();

def.setPropagationBehavior(0);

TransactionStatus trStatus = this.transactionManager.getTransaction(def);
try {
for (int i = 0; rows.hasNext(); ++i) {
Object row = rows.next();
int cc = 0;
if (row instanceof XSSFRow)
cc = ((XSSFRow) row).getLastCellNum();
else
cc = ((HSSFRow) row).getLastCellNum();

String[] sDataArray = new String[cc];
if (headers == null)
headers = new String[cc];
Iterator cells = null;
if (row instanceof XSSFRow)
cells = ((XSSFRow) row).cellIterator();
else
cells = ((HSSFRow) row).cellIterator();

int j = 0;

if (i == 0) {
while (cells.hasNext()) {
Object cell = cells.next();
if (cell instanceof XSSFCell) {
if (((XSSFCell) cell).getCellType() == 0)
headers[j] = Integer.toString((int) ((XSSFCell) cell).getNumericCellValue());
else
headers[j] = StringUtils
.defaultIfEmpty(((XSSFCell) cell).getRichStringCellValue().getString(), "");

} else if (((HSSFCell) cell).getCellType() == 0)
headers[j] = Integer.toString((int) ((HSSFCell) cell).getNumericCellValue());
else
headers[j] = StringUtils
.defaultIfEmpty(((HSSFCell) cell).getRichStringCellValue().getString(), "");

++j;
}

String optTit = "";
int optNo = headers.length - 1;
if (optNo > 10)
optNo = 10;
for (int k = 1; k <= optNo; ++k) {
if (k == 1)
optTit = headers[k];
else {
optTit = optTit + "|" + headers[k];
}
}

senderKey = custVo.getSENDER_KEY();
if (("".equalsIgnoreCase(StringUtils.defaultIfEmpty(authUid, "")))
|| ("sa".equalsIgnoreCase(authUid)) || ("administrator".equalsIgnoreCase(authUid)))
authUid = "ADMIN";

if ("SAVE".equals(submitType)) {
ftAddrGrpDto = new FtAddrGrpVo();
ftAddrGrpDto.setAGRP_NM(agrpNm);
ftAddrGrpDto.setAGRP_DESC(agrpDesc);
ftAddrGrpDto.setADDR_CNT(Integer.valueOf(-1));
ftAddrGrpDto.setADDR_OPT_NO(Integer.valueOf(optNo));
ftAddrGrpDto.setADDR_OPT_TIT(optTit);
ftAddrGrpDto.setTGT_FILE(realPath + "/" + fn);
ftAddrGrpDto.setINS_DTS(sdf.format(new Date()));
ftAddrGrpDto.setINS_UID(authUid);
ftAddrGrpDto.setUPD_DTS(sdf.format(new Date()));
ftAddrGrpDto.setUPD_UID(authUid);
ftAddrGrpDto.setSENDER_KEY(senderKey);

agrpId = saveFtAddrGrpGetKey(ftAddrGrpDto);
} else {
if (!("UPDATE".equals(submitType)))
continue;
agrpId = p_agrpId;
ftAddrGrpDto = new FtAddrGrpVo();
ftAddrGrpDto.setAGRP_ID(Integer.valueOf(agrpId));
ftAddrGrpDto.setAGRP_NM(agrpNm);
ftAddrGrpDto.setAGRP_DESC(agrpDesc);
ftAddrGrpDto.setADDR_CNT(Integer.valueOf(-1));
ftAddrGrpDto.setADDR_OPT_NO(Integer.valueOf(headers.length - 1));
ftAddrGrpDto.setADDR_OPT_TIT(optTit);
ftAddrGrpDto.setTGT_FILE(realPath + "/" + fn);
ftAddrGrpDto.setUPD_DTS(sdf.format(new Date()));
ftAddrGrpDto.setUPD_UID(authUid);
ftAddrGrpDto.setSENDER_KEY(senderKey);
updateFtAddrGrp(ftAddrGrpDto);

deleteFtAddrByAgrpId(agrpId);
}
} else {
j = 0;

while (cells.hasNext()) {
Object cell = cells.next();
if (cell instanceof XSSFCell) {
if (((XSSFCell) cell).getCellType() == 0)
sDataArray[j] = Integer.toString((int) ((XSSFCell) cell).getNumericCellValue());
else
sDataArray[j] = StringUtils
.defaultIfEmpty(((XSSFCell) cell).getRichStringCellValue().getString(), "");

} else if (((HSSFCell) cell).getCellType() == 0)
sDataArray[j] = Integer.toString((int) ((HSSFCell) cell).getNumericCellValue());
else
sDataArray[j] = StringUtils
.defaultIfEmpty(((HSSFCell) cell).getRichStringCellValue().getString(), "");

++j;
}

if (("".equals(sDataArray[0].trim())) || ("".equals(sDataArray[0].trim()))
|| ("".equals(sDataArray[0].trim())))
continue;
if ("".equals(sDataArray[0].trim())) {
continue;
}

String vali = "N";

Matcher m = p.matcher(sDataArray[0]);
if (m.matches())
vali = "Y";
else {
vali = "X";
}

ftAddrDto = null;
ftAddrDto = new FtAddrVo();
try {
ftAddrDto.setAGRP_ID(Integer.valueOf(agrpId));
ftAddrDto.setADDR_NO(Integer.valueOf(i));
ftAddrDto.setMBL_NO(sDataArray[0]);
if (sDataArray.length > 1)
ftAddrDto.setOPT1(sDataArray[1]);
if (sDataArray.length > 2)
ftAddrDto.setOPT2(sDataArray[2]);
if (sDataArray.length > 3)
ftAddrDto.setOPT3(sDataArray[3]);
if (sDataArray.length > 4)
ftAddrDto.setOPT4(sDataArray[4]);
if (sDataArray.length > 5)
ftAddrDto.setOPT5(sDataArray[5]);
if (sDataArray.length > 6)
ftAddrDto.setOPT6(sDataArray[6]);
if (sDataArray.length > 7)
ftAddrDto.setOPT7(sDataArray[7]);
if (sDataArray.length > 8)
ftAddrDto.setOPT8(sDataArray[8]);
if (sDataArray.length > 9)
ftAddrDto.setOPT9(sDataArray[9]);
if (sDataArray.length > 10)
ftAddrDto.setOPT10(sDataArray[10]);
ftAddrDto.setVALI(vali);
saveFtAddr(ftAddrDto);
++nAddrCnt;
} catch (Exception e3) {
logger.error("Addr Excel upload error! {}/{}/agrp_id:{}",
new Object[] { custVo.getYELLOW_ID(), authUid, Integer.valueOf(agrpId) });
logger.error(e3.getLocalizedMessage());
++nErrAddrCnt;
}
if ((nAddrCnt + nErrAddrCnt) % 1000 == 0) {
logger.info("upload.. {}/{}:{}", new Object[] { custVo.getYELLOW_ID(), authUid,
Integer.valueOf(nAddrCnt + nErrAddrCnt) });
this.transactionManager.commit(trStatus);

trStatus = this.transactionManager.getTransaction(def);
}
}
}
} catch (Exception e) {
logger.error("excel upload error! {}/{}/agrp_id:{}",
new Object[] { custVo.getYELLOW_ID(), authUid, Integer.valueOf(agrpId) });
logger.error(e.getLocalizedMessage());
} finally {
resultMap.put("agrpId", Integer.valueOf(agrpId));
resultMap.put("nAddrCnt", Integer.valueOf(nAddrCnt));
resultMap.put("nErrAddrCnt", Integer.valueOf(nErrAddrCnt));
this.transactionManager.commit(trStatus);
logger.info("upload end {}/{}:{}",
new Object[] { custVo.getYELLOW_ID(), authUid, Integer.valueOf(nAddrCnt + nErrAddrCnt) });
}
return resultMap;
}
}

1 2 3 4 5 6 7 8 9 10 다음


DNSErver

DNS server, DNS service

구글애드-세로


정사각디스플레이

통계 위젯 (화이트)

11118
655
864876

구글애드3