新功能:标准表的校验+抽取(包括oracle、sqlServer)

web_backend_develope
chenlw 8 years ago
parent 0e4cc24af9
commit 670bdea55d

@ -15,6 +15,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ExceptionHandler;
import com.platform.utils.Configs;
@ -48,13 +49,16 @@ public class BaseController {
new CustomException("base_code_", ex);
// 根据不同错误转向不同页面
if(ex instanceof CustomException) {
//返回异常信息
ModelMap modelMap = new ModelMap();
CustomException cuse = (CustomException) ex;
Map<String, String> errmsg = new HashMap<>();
errmsg.put("code", cuse.getCode());
errmsg.put("msg", cuse.getMsg());
log.error(cuse.getCode());
modelMap.addAllAttributes(errmsg);
response.setStatus(500);
return response;
return modelMap;
} else {
//其他错误则 调到指定页面
log.error(Configs.GLOBAL_EXP_NOT_CUSTOM, ex);

@ -42,4 +42,8 @@ public class Custom4exception {
/** * MySQL错误 */
public final static String MySQL_Except = "3002002001";
//3003001
/** * 信息系统-校验-sqlserver抽取标准表 --连接不上标准表汇总库错误 */
public final static String CHECKOUT_EXTRACT_EXCEPT = "3003001001";
}

@ -7,7 +7,6 @@ import java.lang.reflect.InvocationTargetException;
import org.apache.log4j.Logger;
import com.platform.controller.DataModelController;
import com.platform.utils.Bean2MapUtils;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
@ -51,7 +50,7 @@ public class CustomException extends Exception {
* @param obj
*/
public CustomException(String code,Exception e,Object... obj) {
super(code);
// super(code);
StringBuffer sbuf= new StringBuffer();
this.code = code;
sbuf.append(code);

@ -8,4 +8,7 @@
3002001003=\u8FDE\u63A5\u6C47\u603B-\u521B\u5EFAoracle\u8FDE\u63A5\u5931\u8D25
#3002002
3002002001=MySQL\u9519\u8BEF
3002002001=MySQL\u9519\u8BEF
#3003001
3003001001=\u8FDE\u63A5\u4E0D\u4E0A\u6807\u51C6\u8868\u6C47\u603B\u5E93

@ -15,10 +15,11 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<result property="tableName" column="service_table" javaType="string" jdbcType="VARCHAR"/>
<result property="suffix" column="service_suffix" javaType="string" jdbcType="VARCHAR"/>
<result property="status" column="service_status" javaType="string" jdbcType="VARCHAR"/>
<result property="type" column="type" javaType="string" jdbcType="VARCHAR"/>
<result property="remove" column="remove" jdbcType="CHAR"/>
</resultMap>
<sql id="baseOracleInfo">
id id, service_port port, service_ip ip, service_name name, service_user user, service_password password, service_database databaseName, service_table tableName, service_suffix suffix, service_status status
id id,service_port port,service_ip ip,service_name name,service_user user,service_password password,service_database databaseName,service_table tableName,service_suffix suffix,service_status status,type type
</sql>
<select id="selectAllOracle" resultType="com.platform.entities.GatherOracleInfo">
@ -59,6 +60,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
service_status,
</if>
<if test="type != null and type != ''">
type,
</if>
</trim>
)
VALUES(
@ -90,6 +94,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
#{status},
</if>
<if test="type != null and type != ''">
#{type},
</if>
</trim>
)
</insert>
@ -133,6 +140,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
service_status= #{status},
</if>
<if test="type != null and type != ''">
type= #{type},
</if>
<if test="remove != null and remove != ''">
remove= #{remove},
</if>
@ -142,5 +152,30 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
id = #{id}
</where>
</update>
<update id="updateAllOracle" parameterType="com.platform.entities.GatherOracleInfo">
UPDATE
services_info
<set >
<trim suffixOverrides=",">
<if test="type != null and type != ''">
type= #{type},
</if>
</trim>
</set>
</update>
<update id="updateAllOracleExceptId" parameterType="com.platform.entities.GatherOracleInfo">
UPDATE
services_info
<set >
<trim suffixOverrides=",">
<if test="type != null and type != ''">
type= #{type},
</if>
</trim>
</set>
<where>
id != #{id}
</where>
</update>
</mapper>

@ -48,8 +48,20 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
jdbcType="VARCHAR" />
<result property="volumePath" column="volume_path" javaType="string"
jdbcType="VARCHAR" />
<result property="dataBaseType" column="data_base_type" javaType="string"
jdbcType="VARCHAR" />
<result property="execResultLast" column="checkout_indicate_last" javaType="string"
jdbcType="VARCHAR" />
<result property="payResultLast" column="checkout_pay_last" javaType="string"
jdbcType="VARCHAR" />
<result property="standardExtractStatus" column="standard_extract_status" javaType="string"
jdbcType="VARCHAR" />
<result property="checkoutFlag" column="checkout_flag" javaType="string"
jdbcType="VARCHAR" />
<result property="mark" column="mark" javaType="string"
jdbcType="VARCHAR" />
jdbcType="VARCHAR" />
</resultMap>
<sql id="conditionsFilters">
<if test="dataType!=null">
@ -89,7 +101,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<select id="getLimitedDataInfoEntities" parameterType="com.platform.entities.PagerOptions"
resultMap="getEntityByText">
SELECT
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,extract_status,data_year,start_year,end_year,volume_ip,volume_path,mark
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,extract_status,data_year,start_year,end_year,volume_ip,volume_path,data_base_type,standard_extract_status,checkout_flag,mark
FROM data_details
<where>
<include refid="conditionsFilters" />
@ -112,11 +124,19 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<!-- 获取数据符合筛选条件的全部记录信息 -->
<select id="findAll" resultMap="getEntityByText">
SELECT
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,extract_status,data_year,start_year,end_year,volume_ip,volume_path,mark
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,extract_status,data_year,start_year,end_year,volume_ip,volume_path,data_base_type,standard_extract_status,checkout_flag,mark
FROM data_details
ORDER BY data_details.id
</select>
<!-- 获取数据符合筛选条件的全部记录信息 -->
<select id="findById" resultMap="getEntityByText" parameterType="java.lang.Integer">
SELECT
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,extract_status,data_year,start_year,end_year,volume_ip,volume_path,data_base_type,standard_extract_status,checkout_indicate_last,checkout_pay_last,checkout_flag,mark
FROM data_details
WHERE id =#{id}
</select>
<!-- 获取数据 条件:采集时间 -->
<select id="findByParam" resultType="com.platform.entities.DataInfoEntity" parameterType="com.platform.entities.DataInfoEntity">
SELECT

@ -108,7 +108,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<!-- sql txt find_city_Column_List -->
<sql id="find_city_Column_List">
d.id dataId,a.area_code areaCode,a.city_name cityName,a.district_name districtName,a.system_name sysName,a.sys_code sysCode,a.area_level areaLevel,a.sys_version sysVersion,a.begin_in_use beginUseTime,a.function_details functionDetails,
d.standard_extract_status standardExtractStatus,d.extract_status extractStatus,d.data_year year,d.data_path path,d.id dataId,a.area_code areaCode,a.city_name cityName,a.district_name districtName,a.system_name sysName,a.sys_code sysCode,a.area_level areaLevel,a.sys_version sysVersion,a.begin_in_use beginUseTime,a.function_details functionDetails,
a.department_manager departmentManager,a.manager_contacts managerContacts,a.sys_developer_full_name developerFullName,a.data_base_type dataBaseType,a.data_base_version dataBaseVersion,
a.is_budget_exec budgetExecManage,a.is_budget_quota budgetQuotaManage,a.is_collection collection,a.is_department_budget departmentBudgetManage,a.total_budget_account totalBudgetAccount,
a.final_account_manage finalAccountManage,a.report_form_manage reportFormManage,a.non_tax_revenue_manage nonTaxManage,a.wage_system wageSystem,
@ -197,7 +197,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<include refid="find_city_Column_List" />
FROM standard_data_details a left join collection_data_description l on a.area_code=l.regionalism_code AND a.sys_code=l.sys_code
left join data_info d on a.area_code=d.regionalism_code AND a.sys_code=d.system_code AND d.remove='0'
WHERE a.is_collection='是' AND a.city_name=#{cityName}
<where>
a.is_collection='是' AND a.city_name=#{cityName}
</where>
ORDER BY a.area_code,a.sys_code,d.data_version
</select>

@ -36,7 +36,7 @@ public class CheckoutController extends BaseController {
private ICheckoutService checkoutService;
/**
*
* ----
* @return
* @throws Exception
*/
@ -52,7 +52,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -68,7 +68,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -89,7 +89,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -110,7 +110,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ---- ->
* @return
* @throws Exception
*/
@ -138,7 +138,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -157,4 +157,27 @@ public class CheckoutController extends BaseController {
}
return modelMap;
}
/** ----sqlserver
* @param form
* @param req
* @param res
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/extractList")
public ModelMap extractList(@RequestBody List<CheckoutEntity> form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelMap modelMap = new ModelMap();
if (null != form) {
log.info("---------/extractList--- "+ form.size());
List<CheckoutEntity> result = checkoutService.extractSqlServer(form);
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
}
else {
log.info("---------/extractList--- "+ form);
}
return modelMap;
}
}

@ -158,42 +158,7 @@ public class DataModelController extends BaseController {
req.setStatus(200);
}
@RequestMapping(value = "/oracle/{name}/extract", method = RequestMethod.POST)
public void oracleExtract(HttpServletRequest res, HttpServletResponse req,
@RequestBody oracleForm form) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
// res.setCharacterEncoding("UTF-8");
boolean isConnect = false;
//5秒内是否能获得oracle连接否则认为超时。
if (null != form.getTarget()) {
ThreadGainOracleConnect thOrcl = new ThreadGainOracleConnect(form, OracleExtract);
thOrcl.start();
for (int i = 0; i < 10; i++) {
Thread.sleep(400);
isConnect = thOrcl.isConnect();
if (isConnect) {
break;
}
else {
if (thOrcl.isExcept()) {
break;
}
Thread.sleep(100);
}
}
}
if (isConnect)
req.setStatus(200);
else
req.setStatus(500);
// 开始抽取数据到汇总库
if (isConnect && null != form.getInneed() && form.getInneed().size() > 0) {
ThreadExtractOracle thExtra = new ThreadExtractOracle(form, OracleExtract);
thExtra.start();
// OracleExtract.extractOracle(form.getName(), form.getInneed(),
// form.getTarget());
}
}
// public void oracleExtract(HttpServletRequest res,
// HttpServletResponse req, String name, @RequestBody GatherOracleInfo
@ -259,6 +224,43 @@ public class DataModelController extends BaseController {
req.setStatus(200);
}
@RequestMapping(value = "/oracle/{name}/extract", method = RequestMethod.POST)
public void oracleExtract(HttpServletRequest res, HttpServletResponse req,
@RequestBody oracleForm form) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
// res.setCharacterEncoding("UTF-8");
boolean isConnect = false;
//5秒内是否能获得oracle连接否则认为超时。
if (null != form.getTarget()) {
ThreadGainOracleConnect thOrcl = new ThreadGainOracleConnect(form, OracleExtract);
thOrcl.start();
for (int i = 0; i < 10; i++) {
Thread.sleep(400);
isConnect = thOrcl.isConnect();
if (isConnect) {
break;
}
else {
if (thOrcl.isExcept()) {
break;
}
Thread.sleep(100);
}
}
}
if (isConnect)
req.setStatus(200);
else
req.setStatus(500);
// 开始抽取数据到汇总库
if (isConnect && null != form.getInneed() && form.getInneed().size() > 0) {
ThreadExtractOracle thExtra = new ThreadExtractOracle(form, OracleExtract);
thExtra.start();
// OracleExtract.extractOracle(form.getName(), form.getInneed(),
// form.getTarget());
}
}
@RequestMapping(value = "/oracle/list", method = RequestMethod.POST)
@ResponseBody
public List<GatherOracleInfo> oracleList() throws Exception {

@ -54,7 +54,7 @@ import com.platform.utils.HttpUtils;
import com.platform.utils.ThreadRemoveFile;
import com.platform.utils.UtilsHelper;
/** --excel
/** --excel
* @author chen
*
*/
@ -67,8 +67,12 @@ public class ExcelController extends BaseController{
@Resource(name = "preDataInfoService")
private IPreDataInfoService preDataInfoService;
// 文件上传处理函数
/** ----
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
public void upload(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
@ -129,7 +133,12 @@ public class ExcelController extends BaseController{
log.info("----");
}
// 文件下载处理函数
/** ----(excel)
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value = "/file/download")
public ResponseEntity<byte[]> download(HttpServletRequest request,
HttpServletResponse response) throws Exception {
@ -153,7 +162,12 @@ public class ExcelController extends BaseController{
}
}
// 文件上传处理函数
/**
* @param request
* @return
* @throws ServletException
* @throws IOException
*/
private ResumableInfo getResumableInfo(HttpServletRequest request)
throws ServletException, IOException {
String base_dir = Configs.FILE_UPLOAD_PATH;
@ -186,6 +200,12 @@ public class ExcelController extends BaseController{
return info;
}
/** ----
* @param res
* @param req
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/findByParam")
public ModelMap findByParam(HttpServletRequest res, HttpServletResponse req) throws Exception {
@ -216,6 +236,10 @@ public class ExcelController extends BaseController{
return modelMap;
}
/** ----
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/findAll")
public ModelMap findAll() throws Exception {
@ -226,6 +250,13 @@ public class ExcelController extends BaseController{
return modelMap;
}
/** ----excel
* @param request
* @param response
* @param fileNameList
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping(produces = "application/json", value = "/importExcel", method = RequestMethod.POST)
public ModelMap importExcel(HttpServletRequest request,

@ -29,6 +29,10 @@ import com.platform.service.IScriptMakeService;
import com.platform.utils.Configs;
import com.platform.utils.ZipCompressUtils;
/** --
* @author chen
*
*/
@Controller
@RequestMapping("/filePackage")
public class FilePackageController extends BaseController {
@ -39,6 +43,12 @@ public class FilePackageController extends BaseController {
@Resource(name = "scriptMakeService")
private IScriptMakeService scriptMakeService;
/** ----
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/download")
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request,
HttpServletResponse response) throws Exception {
@ -67,7 +77,7 @@ public class FilePackageController extends BaseController {
}
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -83,7 +93,7 @@ public class FilePackageController extends BaseController {
}
/**
*
* ----
* @param type
* @param data
* @param res
@ -107,7 +117,7 @@ public class FilePackageController extends BaseController {
}
/**
*
* ----
* @param type
* @param opt
* @param form
@ -131,7 +141,7 @@ public class FilePackageController extends BaseController {
}
/**
*
* ----
* @param type
* @param opt
* @param form
@ -159,7 +169,7 @@ public class FilePackageController extends BaseController {
}
/**
*
* ----
* @param type
* @param opt
* @param form

@ -0,0 +1,95 @@
package com.platform.controller;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
import com.platform.entities.oracleForm;
import com.platform.service.ILogRead;
import com.platform.service.IOracleExtractService;
import com.platform.service.thread.ThreadExtractOracle;
import com.platform.service.thread.ThreadGainOracleConnect;
import com.platform.utils.Configs;
/** oracle
* @author chen
*
*/
@Controller
public class OracleController extends BaseController {
@Resource(name = "OracleExtract")
private IOracleExtractService OracleExtract;
@Resource(name = "logReadService")
private ILogRead logReadService;
@RequestMapping(value = "/oracle/{name}/StandardExtract", method = RequestMethod.POST)
public void oracleStandardExtract(HttpServletRequest res, HttpServletResponse req,
@RequestBody oracleForm form) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/{name}/StandardExtract");
// res.setCharacterEncoding("UTF-8");
boolean isConnect = false;
//5秒内是否能获得oracle连接否则认为超时。
if (null != form.getTarget()) {
ThreadGainOracleConnect thOrcl = new ThreadGainOracleConnect(form, OracleExtract);
thOrcl.start();
for (int i = 0; i < 10; i++) {
Thread.sleep(400);
isConnect = thOrcl.isConnect();
if (isConnect) {
break;
}
else {
if (thOrcl.isExcept()) {
break;
}
Thread.sleep(100);
}
}
}
if (isConnect)
req.setStatus(200);
else
req.setStatus(500);
// 开始抽取数据到汇总库
if (isConnect && null != form.getInneed() && form.getInneed().size() > 0) {
ThreadExtractOracle thExtra = new ThreadExtractOracle(form, OracleExtract);
thExtra.start();
// OracleExtract.extractOracle(form.getName(), form.getInneed(),
// form.getTarget());
}
}
/** sqlserveroracle
* @param name
* @param res
* @param req
* @return
* @throws Exception
*/
@RequestMapping(value = "/StandardExtract/log", method = RequestMethod.POST)
@ResponseBody
public Object getStandardExtractLog(@RequestParam("rcName") String name,
HttpServletRequest res, HttpServletResponse req) throws Exception {
Configs.CONSOLE_LOGGER.info("/oracle/StandardExtract/log");
String result = logReadService.readStandardLog(name);
// StringBuilder sb = new StringBuilder();
// sb.append("查看相应日志").append("\n").append("看到了");
Map<String, String> log = new HashMap<>();
log.put(name, result);
return log;
}
}

@ -22,6 +22,8 @@ public interface DataInfoDao {
List<DataInfoEntity> findAll()throws Exception;
DataInfoEntity findById(int id)throws Exception;
List<DataInfoEntity> findByParam(DataInfoEntity data)throws Exception;
int removes(List<Integer> list)throws Exception;

@ -35,5 +35,19 @@ public interface GatherOracleDao {
* @throws Exception
*/
public int updateOracleById(GatherOracleInfo oracle) throws Exception;
/**
* @param oracle
* @return
* @throws Exception
*/
public int updateAllOracle(GatherOracleInfo oracle) throws Exception;
/**
* @param oracle
* @return
* @throws Exception
*/
public int updateAllOracleExceptId(GatherOracleInfo oracle) throws Exception;
}

@ -11,15 +11,27 @@ public class CheckoutEntity extends PreDataInfo implements Comparable<CheckoutEn
/** 执行信息表 */
private String execResult;
/** 支付信息表校验--汇总 */
/** 支付信息表校验--汇总--校验字段0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成 */
private String payResultLast;
/** 执行信息表校验--汇总 */
/** 执行信息表校验--汇总 --校验字段0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成 */
private String execResultLast;
/** 是否进行了校验 */
/** 是否进行了校验 , 0未校验1已校验,2正则校验,6正在抽取7抽取完成*/
private String checkoutFlag;
/** 数据所在的路径 */
private String path;
/** 数据年度 */
private String year;
/** 是否抽取 0标示为未汇总1标示汇总中2标示汇总完成 */
private int extractStatus;
/** 标准表抽取标记 */
private String standardExtractStatus;
/**
* -
*/
@ -109,6 +121,48 @@ public class CheckoutEntity extends PreDataInfo implements Comparable<CheckoutEn
this.checkoutFlag = checkoutFlag;
}
/**
* @return the path
*/
public String getPath() {
return path;
}
/**
* @param path the path to set
*/
public void setPath(String path) {
this.path = path;
}
/**
* @return the year
*/
public String getYear() {
return year;
}
/**
* @param year the year to set
*/
public void setYear(String year) {
this.year = year;
}
/**
* @return the extractStatus
*/
public int getExtractStatus() {
return extractStatus;
}
/**
* @param extractStatus the extractStatus to set
*/
public void setExtractStatus(int extractStatus) {
this.extractStatus = extractStatus;
}
/**
* @return the mark
*/
@ -123,6 +177,20 @@ public class CheckoutEntity extends PreDataInfo implements Comparable<CheckoutEn
this.mark = mark;
}
/**
* @return the standardExtractStatus
*/
public String getStandardExtractStatus() {
return standardExtractStatus;
}
/**
* @param standardExtractStatus the standardExtractStatus to set
*/
public void setStandardExtractStatus(String standardExtractStatus) {
this.standardExtractStatus = standardExtractStatus;
}
/** 按checkResult的状态排序 */
@Override
public int compareTo(CheckoutEntity arg0) {

@ -37,6 +37,9 @@ public class DataInfoEntity {
private String volumeType;
/** 数据库类型 */
private String dataBaseType;
private String mark;
/** 支付信息表校验--采集 */
@ -54,6 +57,9 @@ public class DataInfoEntity {
/** 是否进行了校验 */
private String checkoutFlag;
/** 是否进行了抽取 */
private String standardExtractStatus;
public DataInfoEntity() {
}
@ -298,6 +304,20 @@ public class DataInfoEntity {
this.mark = mark;
}
/**
* @return the dataBaseType
*/
public String getDataBaseType() {
return dataBaseType;
}
/**
* @param dataBaseType the dataBaseType to set
*/
public void setDataBaseType(String dataBaseType) {
this.dataBaseType = dataBaseType;
}
/**
* @return the payResult
*/
@ -368,6 +388,20 @@ public class DataInfoEntity {
this.checkoutFlag = checkoutFlag;
}
/**
* @return the standardExtractStatus
*/
public String getStandardExtractStatus() {
return standardExtractStatus;
}
/**
* @param standardExtractStatus the standardExtractStatus to set
*/
public void setStandardExtractStatus(String standardExtractStatus) {
this.standardExtractStatus = standardExtractStatus;
}
@Override
public String toString() {
return "id=" + this.id + " ,regionalismCode=" + this.regionalismCode

@ -8,6 +8,8 @@ public class GatherOracleInfo extends OracleConnectorParams {
private String suffix;
private String type;
private int id;
private String remove;
@ -55,6 +57,20 @@ public class GatherOracleInfo extends OracleConnectorParams {
this.suffix = suffix;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
public int getId() {
return id;
}

@ -34,7 +34,7 @@ public class OracleConnector {
Configs.CONSOLE_LOGGER.info("创建oracle连接失败: [" + e.getMessage() + "]");
if (null != oc) {
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ oc.getName(), "创建oracle连接失败: [" + e.getMessage() + "]\r\n");
+ oc.getName()+".log", "创建oracle连接失败: [" + e.getMessage() + "]\r\n");
}
throw new CustomException(Custom4exception.OracleSQL_Except, e);
}

@ -8,15 +8,58 @@ import com.platform.entities.PreDataInfo;
public interface ICheckoutService {
/**
* @return
* @throws Exception
*/
public List<CheckoutEntity> findAll() throws Exception;
/**
* @param list
* @return
* @throws Exception
*/
public List<CheckoutEntity> checkAll(List<CheckoutEntity> list) throws Exception;
/**
* @param list
* @return
* @throws Exception
*/
public List<CheckoutEntity> deleteAll(List<CheckoutEntity> list) throws Exception;
/**
* @param ck
* @return
* @throws Exception
*/
public int updateStandardInfo(PreDataInfo ck) throws Exception;
/**
* @param ck
* @return
* @throws Exception
*/
public Map<String, PreDataInfo> findDetail(CheckoutEntity ck) throws Exception;
/** -
* @param city
* @return
* @throws Exception
*/
public List<CheckoutEntity> findByCity(String city) throws Exception;
/** sqlserver
* @param list
* @return
* @throws Exception
*/
public List<CheckoutEntity> extractSqlServer(List<CheckoutEntity> list) throws Exception;
/**
* @param ck
* @return
* @throws Exception
*/
public Map<String, PreDataInfo> readLog(CheckoutEntity ck) throws Exception;
}

@ -4,4 +4,6 @@ public interface ILogRead {
public String readLog(String filename) throws Exception;
public String readStandardLog(String filename) throws Exception;
}

@ -26,5 +26,15 @@ public interface IOracleExtractService {
* @throws Exception
*/
public boolean isConnectTotalOracle(GatherOracleInfo oracleConnect) throws Exception;
/**
* @param name
* @param dataInfolist
* @param oracleConnect
* @return
* @throws Exception
*/
boolean extractStandardTable(String name, List<OracleConnectorParams> dataInfolist,
GatherOracleInfo oracleConnect) throws Exception;
}

@ -1,5 +1,7 @@
package com.platform.service;
import io.fabric8.kubernetes.api.model.Config;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -142,6 +144,60 @@ public class OracleExtractHelper {
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// grantSql+"\r\n");
}
/**
*
*
* @param conn
* @param oc
*/
public void createOnlyUser(Connection conn, OracleConnectorParams oc, GatherOracleInfo totalOracle) {
String strTUser = Configs.GATHER_STANDARD_USER_NAME;
String sql = "Create user " + strTUser + " default tablespace "
+ totalOracle.getTableName() + " identified by "
+ Configs.GATHER_TABLE_PASSWORD;
String grantSql = "grant connect, resource, dba to " + strTUser;
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// sql+"\r\n");
OracleConnector.execOracleSQL(conn, grantSql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// grantSql+"\r\n");
}
/**
*
*
* @param conn
* @param oc
*/
public void createTable(Connection conn, OracleConnectorParams oc, GatherOracleInfo totalOracle) {
String strTUser = oc.getName() + totalOracle.getSuffix();
String sql = "Create table " + strTUser + " default tablespace "
+ totalOracle.getTableName() + " identified by "
+ Configs.GATHER_TABLE_PASSWORD;
String grantSql = "grant connect, resource, dba to " + strTUser;
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// sql+"\r\n");
OracleConnector.execOracleSQL(conn, grantSql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// grantSql+"\r\n");
}
@ -201,4 +257,60 @@ public class OracleExtractHelper {
}
return flag;
}
/**
* --
*
* @param conn
* @param oc
*/
public void extractStandardPayTable(Connection conn, OracleConnectorParams oc, GatherOracleInfo totalOracle) {
String strTUser = Configs.GATHER_STANDARD_USER_NAME;
createPay(conn, oc);
String sql = "insert into " + strTUser + "." + Configs.GATHER_STANDARD_PAY_TABLE_NAME + "select * from "
+ strTUser + "." + Configs.GATHER_STANDARD_PAY_TABLE_NAME +"'@LINKTO"
+ oc.getName();
String resultSql = sql.replace(";", "");
OracleConnector.execUpdateOracleSQL(conn, resultSql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}
/** --
* @param conn
* @param collectOracle
* @param oracleModel
*/
public void extractStandardExecTable(Connection conn,
OracleConnectorParams collectOracle, GatherOracleInfo oracleModel) {
createExec(conn, collectOracle);
String strTUser = Configs.GATHER_STANDARD_USER_NAME;
String sql = "insert into " + strTUser + "." + Configs.GATHER_STANDARD_EXEC_TABLE_NAME + "select * from "
+ strTUser + "." + Configs.GATHER_STANDARD_EXEC_TABLE_NAME +"'@LINKTO"
+ collectOracle.getName();
String resultSql = sql.replace(";", "");
OracleConnector.execUpdateOracleSQL(conn, resultSql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + collectOracle.getName());
}
private void createPay(Connection conn, OracleConnectorParams oc) {
String payCmd = "CREATE TABLE u_bzbjy.zfxxb(XZQHDM Varchar(255),XZQHMC Varchar(255),PZBH Varchar(255),LYZBKZH Varchar(255),"
+ "ZFDATE Varchar(255),YSDWCODE Varchar(255),YSDWNAME Varchar(255),YWGKCS Varchar(255),XMCODE Varchar(255),XMNAME Varchar(255),"
+"XMLBCODE Varchar(255),XMLBNAME Varchar(255),ZB_NO Varchar(255),GNFLCODE Varchar(255),GNFLNAME Varchar(255),JJFLCODE Varchar(255),"
+"JJFLNAME Varchar(255),ZJXZCODE Varchar(255),ZJXZNAME Varchar(255),JSBFFSNAME Varchar(255),SKR Varchar(255),SKRYH Varchar(255),"
+ "SKRZHZH Varchar(255),FKZHCODE Varchar(255),FKZHNAME Varchar(255),FKYHCODE Varchar(255),FKYHNAME Varchar(255),QSZHCODE Varchar(255),"
+ "QSZHNAME Varchar(255),QSYHCODE Varchar(255),QSYHNAME Varchar(255),JE Numeric(18,2), SFTK Varchar(255),NIAN Varchar(255),ZY Varchar(255))";
OracleConnector.execOracleSQL(conn, payCmd, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}
private void createExec(Connection conn, OracleConnectorParams oc) {
String execCmd = "CREATE TABLE u_bzbjy.kzxzb(XZQHDM Varchar(255),XZQHMC Varchar(255),YSND Varchar(255),ZBCODE Varchar(255),ZB_ID Varchar(255),ZB_NO Varchar(255),"
+ "ZBDJLXCODE Varchar(255),ZBDJLXNAME Varchar(255),ZBLXNAME Varchar(255),DOCNO Varchar(255),ZBSM Varchar(255),ZBFWDATE Varchar(255),ZBYSLXCODE Varchar(255),"
+ "ZBYSLXNAME Varchar(255),ZBYSLYNAME Varchar(255),YSDWCODE Varchar(255),YSDWNAME Varchar(255),GNFLCODE Varchar(255),GNFLNAME Varchar(255),JJFLCODE Varchar(255),"
+ "JJFLNAME Varchar(255),ZBGLCSNAME Varchar(255),SZGLCODE Varchar(255),SZGLNAME Varchar(255),XMCODE Varchar(255),XMNAME Varchar(255),GZBZ Varchar(255),"
+ "JJBZ Varchar(255),CGBZ Varchar(255),ZFFSCODE Varchar(255),ZFFSNAME Varchar(255),JZZFBZ Varchar(255),ZBJE Numeric(18,2),ZBTJJE Numeric(18,2),ZBDJJE Numeric(18,2),"
+ "ZBKYJE Numeric(18,2),ZYZFBZ Varchar(255),BZ Varchar(255))";
OracleConnector.execOracleSQL(conn, execCmd, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}
}

@ -1,6 +1,8 @@
package com.platform.service.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
@ -11,16 +13,26 @@ import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.dao.DataInfoDao;
import com.platform.dao.GatherOracleDao;
import com.platform.dao.PreDataInfoDao;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.PreDataInfo;
import com.platform.oracle.OracleConnector;
import com.platform.service.DataInfoService;
import com.platform.service.ICheckoutService;
import com.platform.service.thread.ThreadCheckoutStandardOracle;
import com.platform.service.thread.ThreadExtractStandardSqlServer;
import com.platform.utils.BeanCopy;
import com.platform.utils.CacheOracleCheckoutEntity;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.DateForm;
import com.platform.utils.FileOperateHelper;
@Service(value = "checkoutService")
public class CheckoutServiceImpl implements ICheckoutService {
@ -33,6 +45,9 @@ public class CheckoutServiceImpl implements ICheckoutService {
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
@Resource(name = "gatherOracleDao")
private GatherOracleDao gatherOracleDao;
@Override
public List<CheckoutEntity> findAll() throws Exception {
@ -84,31 +99,73 @@ public class CheckoutServiceImpl implements ICheckoutService {
@Override
public List<CheckoutEntity> checkAll(List<CheckoutEntity> list) throws Exception {
List<CheckoutEntity> oracleList = new ArrayList<CheckoutEntity>();
List<CheckoutEntity> sqlServerList = new ArrayList<CheckoutEntity>();
for (CheckoutEntity checkoutEntity : list) {
if (checkoutEntity.getDataId() == 0) {
continue;
}
if ("SQL SERVER".equals(checkoutEntity.getDataBaseType())) {
sqlServerList.add(checkoutEntity);
}
else if ("ORACLE".equals(checkoutEntity.getDataBaseType())) {
oracleList.add(checkoutEntity);
}
}
// sql Server校验
for (CheckoutEntity checkoutEntity : sqlServerList) {
if (checkoutEntity.getDataId() == 0) {
continue;
}
DataInfoEntity data = new DataInfoEntity();
this.checkSqlServerOne(checkoutEntity);
data.setId(checkoutEntity.getDataId());
data.setPayResultLast(checkoutEntity.getPayResultLast());
data.setExecResultLast(checkoutEntity.getExecResultLast());
data.setCheckoutFlag(checkoutEntity.getCheckoutFlag());
dataInfoDao.update(data);
}
//oracle 校验
for (CheckoutEntity checkoutEntity : oracleList) {
if (checkoutEntity.getDataId() == 0) {
continue;
}
DataInfoEntity data = new DataInfoEntity();
// 状态改为 正则校验 Constant.CHECKOUTFLAG_TWO
this.checkOracleOne(checkoutEntity);
data.setId(checkoutEntity.getDataId());
data.setPayResultLast(checkoutEntity.getPayResultLast());
data.setExecResultLast(checkoutEntity.getExecResultLast());
data.setCheckoutFlag(checkoutEntity.getCheckoutFlag());
dataInfoDao.update(data);
String kuberTaskName = checkoutEntity.getAreaCode().toLowerCase()+"-"
+ checkoutEntity.getSysCode() + "-" + checkoutEntity.getDataVersion();
if(!CacheOracleCheckoutEntity.getCheckKeys().contains(kuberTaskName)){
CacheOracleCheckoutEntity.putCheck(kuberTaskName, checkoutEntity);
}
}
//TODO 如果 CacheOracleCheckoutEntity.getCheckKeys() 有数据则启动 kuber客户端请求尝试链接oracle并查询标准表是否存在
if ( CacheOracleCheckoutEntity.getCheckKeys().size() > 0) {
new ThreadCheckoutStandardOracle(dataInfoDao).start();
}
List<CheckoutEntity> result = new ArrayList<CheckoutEntity>();
if (list.size() > 0) {
result = findByCity(list.get(0).getCityName());
}
Map<String, CheckoutEntity> map = new HashMap<String, CheckoutEntity>();
for (CheckoutEntity checkoutEntity : list) {
checkOne(checkoutEntity);
map.put(checkoutEntity.getAreaCode()+ "_" +checkoutEntity.getSysCode()+ "_" +checkoutEntity.getDataVersion(),checkoutEntity);
}
for (int i = 0; i < result.size(); i++) {
CheckoutEntity checkoutEntity = result.get(i);
String area_sys = checkoutEntity.getAreaCode()+ "_" +checkoutEntity.getSysCode()+ "_" +checkoutEntity.getDataVersion();
if (map.containsKey(area_sys)) {
result.set(i, map.get(area_sys));
}
}
// Map<String, CheckoutEntity> map = new HashMap<String, CheckoutEntity>();
// for (CheckoutEntity checkoutEntity : list) {
// DataInfoEntity data = new DataInfoEntity();
// //校验当前的数据:
// checkOne(checkoutEntity);
// data.setId(checkoutEntity.getDataId());
// data.setPayResultLast(checkoutEntity.getPayResultLast());
// data.setExecResultLast(checkoutEntity.getExecResultLast());
// data.setCheckoutFlag(checkoutEntity.getCheckoutFlag());
// dataInfoDao.update(data);
// map.put(checkoutEntity.getAreaCode()+ "_" +checkoutEntity.getSysCode()+ "_" +checkoutEntity.getDataVersion(),checkoutEntity);
// }
// for (int i = 0; i < result.size(); i++) {
// CheckoutEntity checkoutEntity = result.get(i);
// String area_sys = checkoutEntity.getAreaCode()+ "_" +checkoutEntity.getSysCode()+ "_" +checkoutEntity.getDataVersion();
// if (map.containsKey(area_sys)) {
// result.set(i, map.get(area_sys));
// }
// }
return result;
}
@ -137,21 +194,6 @@ public class CheckoutServiceImpl implements ICheckoutService {
}
}
/**
* @param ck
* @return
*/
private CheckoutEntity checkOne(CheckoutEntity ck) {
String pay = ck.getPayResult();
String exec = ck.getExecResult();
ck.setPayResultLast(isY(pay));
ck.setExecResultLast(isY(exec));
ck.setCheckResult(isY(pay, exec));
// 1已校验
ck.setCheckoutFlag("1");
return ck;
}
@Override
public List<CheckoutEntity> findByCity(String city) throws Exception {
CheckoutEntity cksql = new CheckoutEntity();
@ -162,18 +204,19 @@ public class CheckoutServiceImpl implements ICheckoutService {
cksql.setCollectingTime(time);
cksql.setCityName(city);
List<CheckoutEntity> resul = new ArrayList<CheckoutEntity>();
Map<String,CheckoutEntity> resul = new HashMap<String,CheckoutEntity>();
Map<String,CheckoutEntity> nodata = new HashMap<String,CheckoutEntity>();
List<CheckoutEntity> list = preDataInfoDao.findByCity(cksql);
int length = list.size();
for (int i = 0; i < length; i++) {
CheckoutEntity preDataInfo = list.get(i);
if (null != preDataInfo.getPayResultLast() &&
preDataInfo.getPayResultLast().equals(preDataInfo.getExecResultLast()) &&
"是".equals(preDataInfo.getExecResultLast())) {
preDataInfo.setCheckResult("是");
}else if(null != preDataInfo.getPayResultLast() && null != preDataInfo.getExecResultLast() && !"-".equals(preDataInfo.getPayResultLast()) && !"-".equals(preDataInfo.getExecResultLast())){
preDataInfo.setCheckResult("否");
}
// if (null != preDataInfo.getPayResultLast() &&
// preDataInfo.getPayResultLast().equals(preDataInfo.getExecResultLast()) &&
// "是".equals(preDataInfo.getExecResultLast())) {
// preDataInfo.setCheckResult("是");
// }else if(null != preDataInfo.getPayResultLast() && null != preDataInfo.getExecResultLast() && !"-".equals(preDataInfo.getPayResultLast()) && !"-".equals(preDataInfo.getExecResultLast())){
// preDataInfo.setCheckResult("否");
// }
preDataInfo.setId(i);
preDataInfo.setCollUpdate(isY(preDataInfo.getCollUpdate()));
if (preDataInfo.getDataVersion() < 1) {
@ -181,14 +224,54 @@ public class CheckoutServiceImpl implements ICheckoutService {
}
if (null != preDataInfo.getCollectingTime()) {
if (c2.getTime().before(DateForm.string2DateByDay(preDataInfo.getCollectingTime()))) {
resul.add(preDataInfo);
resul.put(preDataInfo.getAreaCode()+"_"+preDataInfo.getSysCode()+"_"+preDataInfo.getDataId(), preDataInfo);
}
else {
preDataInfo.setDataId(0);
preDataInfo.setPath(null);
preDataInfo.setDataVersion(0);
preDataInfo.setExecResult(null);
preDataInfo.setExecResultLast(null);
preDataInfo.setPayResult(null);
preDataInfo.setPayResultLast(null);
preDataInfo.setCheckoutFlag(null);
preDataInfo.setCollection("否");
//data_id 已经为 0
nodata.put(preDataInfo.getAreaCode()+"_"+preDataInfo.getSysCode(), preDataInfo);
}
}
else{
resul.add(preDataInfo);
nodata.put(preDataInfo.getAreaCode()+"_"+preDataInfo.getSysCode(), preDataInfo);
}
}
return resul;
List<String> keyList = new ArrayList<String>();
for (String nodatakey : nodata.keySet()) {
keyList.add(nodatakey);
}
List<CheckoutEntity> resultList = new ArrayList<CheckoutEntity>();
for (String key : resul.keySet()) {
//如果有 校验失败的结果则 为否
CheckoutEntity tmp = resul.get(key);
if(!Constant.CHECKOUT_STATUS_ZERO.equals(tmp.getPayResultLast()) && !Constant.CHECKOUT_STATUS_ZERO.equals(tmp.getExecResultLast())){
if (Constant.CHECKOUT_STATUS_FOUR.equals(tmp.getPayResultLast()) || Constant.CHECKOUT_STATUS_FOUR.equals(tmp.getExecResultLast())) {
tmp.setCheckResult(Constant.ORACLE_CHECK_REULT_ONE);
}
else if(!Constant.CHECKOUT_STATUS_TWO.equals(tmp.getPayResultLast()) && !Constant.CHECKOUT_STATUS_TWO.equals(tmp.getExecResultLast())){
tmp.setCheckResult(Constant.ORACLE_CHECK_REULT_ZERO);
}
}
resultList.add(resul.get(key));
for (String nodatakey : keyList) {
if (key.contains(nodatakey)) {
nodata.remove(nodatakey);
}
}
}
for (String key : nodata.keySet()) {
resultList.add(nodata.get(key));
}
return resultList;
}
@Override
@ -333,6 +416,89 @@ public class CheckoutServiceImpl implements ICheckoutService {
return true;
}
/** sqlServer
* @param ck
* @return
*/
private CheckoutEntity checkSqlServerOne(CheckoutEntity ck) {
//TODO 校验: sqlserver数据-查看脚本在不在? 支付standard_pay_地区_系统码.sql ?,支付standard_indicate_地区_系统码.sql ?
//TODO sqlserver校验结果记录进数据库,
String pay = ck.getPayResult();
String exec = ck.getExecResult();
ck.setCheckResult("是");
if (Constant.CHECKOUT_STATUS_ZERO.equals(ck.getPayResultLast())) {
if ("y".equals(pay) || "Y".equals(pay)) {
String payFilePath = FileOperateHelper.addLastSeparator(ck.getPath())+Constant.standard_pay
+ ck.getAreaCode().toLowerCase()+ck.getSysCode()+".sql";
File f = new File(payFilePath);
if(f.exists()){
ck.setPayResultLast(Constant.CHECKOUT_STATUS_THREE);
}
else
{
ck.setPayResultLast(Constant.CHECKOUT_STATUS_FOUR);
}
}
else {
//校验结果:成功或失败 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
ck.setPayResultLast(Constant.CHECKOUT_STATUS_ONE);
}
}
if (Constant.CHECKOUT_STATUS_ZERO.equals(ck.getExecResultLast())){
if ("y".equals(exec) || "Y".equals(exec)) {
String execFilePath = FileOperateHelper.addLastSeparator(ck.getPath())+Constant.standard_indicate
+ ck.getAreaCode().toLowerCase()+ck.getSysCode()+".sql";
File f = new File(execFilePath);
if (f.exists()) {
ck.setExecResultLast(Constant.CHECKOUT_STATUS_THREE);
}
else
{
ck.setExecResultLast(Constant.CHECKOUT_STATUS_FOUR);
}
}
else {
//校验结果:成功或失 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
ck.setExecResultLast(Constant.CHECKOUT_STATUS_ONE);
}
}
// 1已校验--
ck.setCheckoutFlag(Constant.CHECKOUTFLAG_ONE);
return ck;
}
/** ORACLE
* @param ck
* @return
*/
private CheckoutEntity checkOracleOne(CheckoutEntity ck) {
//TODO 校验: Oracle数据-更改为正则校验
//TODO Oracle校验结果记录进数据库,
String pay = ck.getPayResult();
String exec = ck.getExecResult();
if (Constant.CHECKOUT_STATUS_ZERO.equals(ck.getPayResultLast())) {
//校验结果:成功或失败 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
if ("y".equals(pay) || "Y".equals(pay)) {
ck.setPayResultLast(Constant.CHECKOUT_STATUS_TWO);
}
else {
ck.setPayResultLast(Constant.CHECKOUT_STATUS_ONE);
}
}
if (Constant.CHECKOUT_STATUS_ZERO.equals(ck.getExecResultLast())){
if ("y".equals(exec) || "Y".equals(exec)) {
ck.setExecResultLast(Constant.CHECKOUT_STATUS_TWO);
}
else {
//校验结果:成功或失 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
ck.setExecResultLast(Constant.CHECKOUT_STATUS_ONE);
}
}
// 2正在校验--
ck.setCheckoutFlag(Constant.CHECKOUTFLAG_TWO);
return ck;
}
@Override
public List<CheckoutEntity> deleteAll(List<CheckoutEntity> list)
throws Exception {
@ -353,4 +519,84 @@ public class CheckoutServiceImpl implements ICheckoutService {
}
return result;
}
@Override
public List<CheckoutEntity> extractSqlServer(List<CheckoutEntity> list)
throws Exception {
//待抽取标准表 的 SqlServer服务的 数据列表:
List<CheckoutEntity> sqlServer = new ArrayList<CheckoutEntity>();
for (CheckoutEntity checkoutEntity : list) {
if ("SQL SERVER".equals(checkoutEntity.getDataBaseType()) && checkoutEntity.getDataId() > 0) {
sqlServer.add(checkoutEntity);
}
}
//TODO 修改sqlServer 列表对应的 数据--- payResultLast 、execResultLast-> 正在抽取
// 待抽取的集合
List<CheckoutEntity> Extractlist = new ArrayList<CheckoutEntity>();
// TODO 抽取 --- 线程
if (sqlServer.size() > 0) {
for (CheckoutEntity checkoutEntity : sqlServer) {
boolean isTract = false;
//校验结果:成功或失 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
if(Constant.CHECKOUT_STATUS_THREE.equals(checkoutEntity.getPayResultLast())){
isTract = true;
checkoutEntity.setPayResultLast(Constant.CHECKOUT_STATUS_FIVE);
}
if(Constant.CHECKOUT_STATUS_THREE.equals(checkoutEntity.getExecResultLast())){
isTract = true;
checkoutEntity.setPayResultLast(Constant.CHECKOUT_STATUS_FIVE);
}
if (isTract) {
Extractlist.add(checkoutEntity);
}
}
// 汇总库的信息
GatherOracleInfo oracleInfo = null;
List<GatherOracleInfo> oracleConnects = gatherOracleDao.selectAllOracle();
for (GatherOracleInfo info : oracleConnects) {
//抽取标准表的汇总库
if (Constant.ORACLE_EXTRACT_TYPE_ONE.equals(info.getType())) {
oracleInfo = info;
break;
}
}
if (null != oracleInfo) {
// 如果能连接
if(OracleConnector.canConnect("jdbc:oracle:thin:@" + oracleInfo.getIp() + ":" + oracleInfo.getPort() + ":"
+ oracleInfo.getDatabaseName(), oracleInfo.getUser(), oracleInfo.getPassword())){
for (CheckoutEntity check : Extractlist) {
DataInfoEntity data = new DataInfoEntity();
data.setId(check.getDataId());
data.setPayResultLast(check.getPayResultLast());
data.setExecResultLast(check.getExecResultLast());
data.setCheckoutFlag(check.getCheckoutFlag());
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//抽取
new ThreadExtractStandardSqlServer(oracleInfo, Extractlist, dataInfoDao).start();
}
else {
//连接不上标准表汇总库错误
throw new CustomException(Custom4exception.CHECKOUT_EXTRACT_EXCEPT, null);
}
}
}
List<CheckoutEntity> result = new ArrayList<CheckoutEntity>();
//TODO findByCity
if (list.size() > 0) {
result = findByCity(list.get(0).getCityName());
}
return result;
}
@Override
public Map<String, PreDataInfo> readLog(CheckoutEntity ck) throws Exception {
// TODO Auto-generated method stub
return null;
}
}

@ -87,6 +87,9 @@ public class DataInfoServiceImp implements DataInfoService {
log.info(offset);
}
pagerOptions.setOffset(offset + 1);
if (null !=pagerOptions.getSubmittedBatch() && !"".equals(pagerOptions.getSubmittedBatch()) ) {
pagerOptions.setSubmittedBatch("批次"+pagerOptions.getSubmittedBatch());
}
List<DataInfoEntity> result = dfdDao
.getLimitedDataInfoEntities(pagerOptions);
if (null != result) {

@ -15,5 +15,11 @@ public class LogReadServiceImpl implements ILogRead {
String result = FileOperateHelper.fileReader(Configs.EXTRACT_LOG_LOCALTION + "J" + filename.replace("-", "_")+".log");
return result;
}
@Override
public String readStandardLog(String filename) throws Exception {
String result = FileOperateHelper.fileReader(Configs.EXTRACT_STANDARD_LOG_LOCALTION + "CQ" + filename.replace("-", "_")+".log");
return result;
}
}

@ -40,6 +40,12 @@ public class MySqlServiceImpl implements IMySqlService{
public int insertOracle(GatherOracleInfo oracle) throws Exception {
//TODO 连接oracle
//1代表是标准库抽取
if ("1".equals(oracle.getType())) {
GatherOracleInfo ora = new GatherOracleInfo();
ora.setType("0");
gatherOracleDao.updateAllOracle(ora);
}
int result = gatherOracleDao.insertOracle(oracle);
return result;
}
@ -55,10 +61,15 @@ public class MySqlServiceImpl implements IMySqlService{
oracle.setStatus(status);
int result;
if (oracle.getId() > 0) {
if ("1".equals(oracle.getType())) {
GatherOracleInfo ora = new GatherOracleInfo();
ora.setType("0");
gatherOracleDao.updateAllOracleExceptId(ora);
}
result = gatherOracleDao.updateOracleById(oracle);
}
else {
result = gatherOracleDao.insertOracle(oracle);
result = insertOracle(oracle);
}
return result;
}

@ -115,6 +115,81 @@ public class OracleExtractServiceImpl implements IOracleExtractService {
}
return isConnect;
}
@Override
public boolean extractStandardTable(String name, List<OracleConnectorParams> dataInfolist,
GatherOracleInfo oracleConnect) throws Exception {
boolean isSuccess = false;
try{
//map转 bean(汇总库信息-带tableName的)
GatherOracleInfo oracleModel = oracleConnect;
//采集库连接参数
List<OracleConnectorParams> datainfos = dataInfolist;
if (datainfos.size() == 0) {
return false;
}
Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":"
+ oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword(),dataInfolist.get(0));
if (null == conn) {
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ dataInfolist.get(0).getName(), "创建oracle连接失败: [" + conn + "]\r\n");
return false;
}
for (OracleConnectorParams collectOracle : datainfos) {
if(null != collectOracle.getDataId() && !"".equals(collectOracle.getDataId())){
DataInfoEntity data = new DataInfoEntity();
data.setId(Integer.valueOf(collectOracle.getDataId()));
//设置为 标准表 抽取中
data.setCheckoutFlag(Constant.CHECKOUTFLAG_SIX);
data.setStandardExtractStatus("1");
dataInfoDao.update(data);
String replicasName = collectOracle.getName();
collectOracle.setName("CQ" + collectOracle.getName().replace("-", "_"));
String cmd = "kubectl label --overwrite rc "
+ replicasName + " standardExtractStatus=1";
List<String> rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd);
StringBuffer sb = new StringBuffer();
for (String string : rList)
sb.append(string).append("\n");
Configs.CONSOLE_LOGGER.info(sb.toString());
// client.updateOrAddReplicasLabelById(collectOracle.getName(), "isExtract", "1"); //更新oracle汇总状态0标示为未汇总1标示汇总中2标示汇总完成
oracleExtract.createDBLink(conn, collectOracle); //创建dblink
oracleExtract.createTableSpace(conn, collectOracle, oracleModel); //创建表空间
oracleExtract.createOnlyUser(conn, collectOracle, oracleModel);//创建 抽取标准表的 用户并授权
DataInfoEntity tmpdata = dataInfoDao.findById(data.getId());
if (null != tmpdata) {
if (Constant.CHECKOUT_STATUS_THREE.equals(tmpdata.getPayResultLast())
|| Constant.CHECKOUT_STATUS_FIVE.equals(tmpdata.getPayResultLast())
|| Constant.CHECKOUT_STATUS_SIX.equals(tmpdata.getPayResultLast())) {
oracleExtract.extractStandardPayTable(conn, collectOracle, oracleModel);//执行抽取
}
if (Constant.CHECKOUT_STATUS_THREE.equals(tmpdata.getExecResultLast())
|| Constant.CHECKOUT_STATUS_FIVE.equals(tmpdata.getExecResultLast())
|| Constant.CHECKOUT_STATUS_SIX.equals(tmpdata.getExecResultLast())) {
oracleExtract.extractStandardExecTable(conn, collectOracle, oracleModel);//执行抽取
}
// client.updateOrAddReplicasLabelById(collectOracle.getName(), "isExtract", "2"); //更新oracle汇总状态0标示为未汇总1标示汇总中2标示汇总完成
cmd = "kubectl label --overwrite rc "
+ replicasName + " standardExtractStatus=2";
rList = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
sb = new StringBuffer();
for (String string : rList)
sb.append(string).append("\n");
Configs.CONSOLE_LOGGER.info(sb.toString());
data.setCheckoutFlag(Constant.CHECKOUTFLAG_SEVEN);
data.setStandardExtractStatus("2");
dataInfoDao.updateExtract(data);
}
}
}
isSuccess = true;
}catch(Exception e){
new CustomException(Custom4exception.OracleSQL_Except, e);
}
return isSuccess;
}
// @Override
// public boolean extractOracle(String name, List<OracleConnectorParams> dataInfos, GatherOracleInfo oracleConnect) throws Exception {

@ -251,7 +251,12 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
}
//TODO 更新
for (PreDataInfo preEntity : allUpdate) {
preDataInfoDao.update(preEntity);
try{
preDataInfoDao.update(preEntity);
}
catch(Exception e){
log.error(e.getStackTrace());
}
}
}
return errmap;

@ -175,7 +175,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "UserTablespace_" + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.UserTablespace + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
}
lastPath = form.getUserTableStatusPathLast();
break;
@ -185,7 +185,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "Checkout_Indicate_" + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.Checkout_Indicate + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
}
lastPath = form.getCkIndicateStatusPathLast();
break;
@ -195,7 +195,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "Checkout_Pay_" + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.Checkout_Pay + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
}
lastPath = form.getCkPayStatusPathLast();
break;
@ -294,53 +294,53 @@ public class ScriptMakeService implements IScriptMakeService {
BeanCopy.copyBean(preDataInfo, myfile);
//---------- 脚本的位置 ------
// 归档表空间脚本的位置-
String TablePathStandard = getFilePath("UserTablespace_",
String TablePathStandard = getFilePath(Constant.UserTablespace,
sqlFilePathsStandard, myfile, ".sql");
myfile.setUserTableStatusPathStandard(TablePathStandard);
// 归档预算 脚本的位置-
String indicatePathStandard = getFilePath("Checkout_Indicate_",
String indicatePathStandard = getFilePath(Constant.Checkout_Indicate,
sqlFilePathsStandard, myfile, ".sql");
myfile.setCkIndicateStatusPathStandard(indicatePathStandard);
// 归档表空间脚本的位置-
String payPathStandard = getFilePath("Checkout_Pay_",
String payPathStandard = getFilePath(Constant.Checkout_Pay,
sqlFilePathsStandard, myfile, ".sql");
myfile.setCkPayStatusPathStandard(payPathStandard);
// 最新表空间脚本的位置-
String TablePathLast = getFilePath("UserTablespace_",
String TablePathLast = getFilePath(Constant.UserTablespace,
sqlFilePathsLast, myfile, ".sql");
myfile.setUserTableStatusPathLast(TablePathLast);
// 最新预算 脚本的位置-
String indicatePathLast = getFilePath("Checkout_Indicate_",
String indicatePathLast = getFilePath(Constant.Checkout_Indicate,
sqlFilePathsLast, myfile, ".sql");
myfile.setCkIndicateStatusPathLast(indicatePathLast);
// 最新表空间脚本的位置-
String payPathLast = getFilePath("Checkout_Pay_", sqlFilePathsLast,
String payPathLast = getFilePath(Constant.Checkout_Pay, sqlFilePathsLast,
myfile, ".sql");
myfile.setCkPayStatusPathLast(payPathLast);
//-------文件最后更新-时间-------
// 时间
String uttimeStandard = getFilePath("UserTablespace_",
String uttimeStandard = getFilePath(Constant.UserTablespace,
timeMapStandard, myfile, ".sql");
myfile.setUserTableStatusStandardModified(uttimeStandard);
// 归档预算 脚本的时间-
String indicateTimeStandard = getFilePath("Checkout_Indicate_",
String indicateTimeStandard = getFilePath(Constant.Checkout_Indicate,
timeMapStandard, myfile, ".sql");
myfile.setCkIndicateStatusStandardModified(indicateTimeStandard);
// 归档表空间脚本的时间-
String payTimeStandard = getFilePath("Checkout_Pay_",
String payTimeStandard = getFilePath(Constant.Checkout_Pay,
timeMapStandard, myfile, ".sql");
myfile.setCkPayStatusStandardModified(payTimeStandard);
// 最新表空间脚本的时间-
String utTimeLast = getFilePath("UserTablespace_",
String utTimeLast = getFilePath(Constant.UserTablespace,
timeMapLast, myfile, ".sql");
myfile.setUserTableStatusLastModified(utTimeLast);
// 最新预算 脚本的时间-
String indicateTimeLast = getFilePath("Checkout_Indicate_",
String indicateTimeLast = getFilePath(Constant.Checkout_Indicate,
timeMapLast, myfile, ".sql");
myfile.setCkIndicateStatusLastModified(indicateTimeLast);
// 最新表空间脚本的时间-
String payTimeLast = getFilePath("Checkout_Pay_", timeMapLast,
String payTimeLast = getFilePath(Constant.Checkout_Pay, timeMapLast,
myfile, ".sql");
myfile.setCkPayStatusLastModified(payTimeLast);
// 设置 状态
@ -481,7 +481,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "UserTablespace_" + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.UserTablespace + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getUserTableStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
@ -495,7 +495,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "Checkout_Pay_" + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.Checkout_Pay + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getCkPayStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
@ -509,7 +509,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "Checkout_Indicate_" + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.Checkout_Indicate + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getCkIndicateStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
@ -536,7 +536,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "UserTablespace_" + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.UserTablespace + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getUserTableStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
@ -550,7 +550,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "Checkout_Pay_" + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.Checkout_Pay + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getCkPayStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
@ -564,7 +564,7 @@ public class ScriptMakeService implements IScriptMakeService {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + "Checkout_Indicate_" + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.Checkout_Indicate + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getCkIndicateStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){

@ -0,0 +1,234 @@
package com.platform.service.thread;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.ReplicationController;
import java.sql.Connection;
import java.util.List;
import java.util.Set;
import com.base.CustomException;
import com.platform.dao.DataInfoDao;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.OracleConnectorParams;
import com.platform.kubernetes.SimpleKubeClient;
import com.platform.oracle.OracleConnector;
import com.platform.utils.CacheOracleCheckoutEntity;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.FileOperateHelper;
/** oracle
* @author chen
*
*/
public class ThreadCheckoutStandardOracle extends Thread {
/**
* kuber
*/
private SimpleKubeClient client;
/**
* dataInfo
*/
private DataInfoDao dataInfoDao;
public ThreadCheckoutStandardOracle(DataInfoDao dataInfoDao) {
this.client = new SimpleKubeClient();
this.dataInfoDao = dataInfoDao;
}
@Override
public void run() {
//循环11次每次休眠
for (int i = 0; i < 11; i++) {
// 数据的 keys =kuber的应用名称 taskName)
Set<String> taskNames = CacheOracleCheckoutEntity.getCheckKeys();
int lengs = taskNames.size();
if (lengs == 0) {
break;
}
String[] taskNamekeys = taskNames.toArray(new String[lengs]);
for (String key : taskNamekeys) {
// 获得 kuber的 pod
Pod tmpPod = filterPod(key);
if (null == tmpPod) {
CacheOracleCheckoutEntity.checkRemove(key);
continue;
}
// 尝试 连接 oracle
connectOracle(tmpPod, key);
if (i == 10) {
String cmd = "kubectl label --overwrite rc " + key
+ " status=1";
List<String> rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd);
StringBuffer sb = new StringBuffer();
for (String str : rList)
sb.append(str).append("\n");
Configs.CONSOLE_LOGGER.info("更新replicationController标签 "
+ key + "\t[标签更新为: 失败]");
}
}
try {
Thread.sleep(1000*60);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/** pod
* @param taskName
* @return
*/
private Pod filterPod(String taskName) {
Pod pod = null;
ReplicationController replicationController = client
.getReplicationController(taskName);
if (null != replicationController) {
List<Pod> filterPods = client
.getPodsForApplicaList(replicationController);
if (filterPods != null && filterPods.size() > 0) {
pod = filterPods.get(0);
}
}
return pod;
}
/** oracle
* @param tmpPod
* @param key
*/
private void connectOracle(Pod pod, String key) {
if (pod != null) {
String ip = client.getPodHostIp(pod);
int port = client.getPodContainerport(pod);
if (ip != null && port != 0) {
String url = "jdbc:oracle:thin:@" + ip + ":" + port
+ ":" + Configs.ORACLE_ORCL;
boolean flag = OracleConnector.canConnect(url, // 连接结果返回参数true标示连接成功false标示连接失败
Configs.ORACLE_USER, Configs.ORACLE_PSW);
Configs.CONSOLE_LOGGER.info("url:" + url + ",user:"
+ Configs.ORACLE_USER + ",password:"
+ Configs.ORACLE_PSW);
String message = "失败";
String cmd3 = "kubectl annotate --overwrite rc "
+ key + " checkoutFlag=0";
List<String> rList3 = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd3);
StringBuffer sb3 = new StringBuffer();
for (String str : rList3)
sb3.append(str).append("\n");
Configs.CONSOLE_LOGGER.info(sb3.toString());
if (flag) {
String cmd = "kubectl label --overwrite rc "
+ key + " status=2";
// client.updateOrAddReplicasLabelById(taskNSyame,
// "status", "2");
List<String> rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd);
StringBuffer sb = new StringBuffer();
for (String str : rList)
sb.append(str).append("\n");
Configs.CONSOLE_LOGGER.info(sb.toString());
message = "成功";
Configs.CONSOLE_LOGGER
.info("更新replicationController标签 "
+ key + "\t[标签更新为: 成功]");
String cmd2 = "kubectl annotate --overwrite rc "
+ key + " checkoutFlag=2";
List<String> rList2 = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd2);
StringBuffer sb2 = new StringBuffer();
for (String str : rList2)
sb2.append(str).append("\n");
Configs.CONSOLE_LOGGER.info(sb2.toString());
//
CheckoutEntity tmp = CacheOracleCheckoutEntity.getCheck(key);
if (null != tmp) {
CacheOracleCheckoutEntity.putExtract(key, tmp);
}
// TODO 查询 对应的 2 个标准表
OracleConnectorParams oc = new OracleConnectorParams();
String logName = tmp.getAreaCode().toLowerCase()+"_"+tmp.getSysCode()+"_"+tmp.getDataVersion();
oc.setName(logName);
try {
Connection conn = OracleConnector.ConnectionBuilder(url, Configs.ORACLE_USER, Configs.ORACLE_PSW, oc);
//支付--校验
if (Constant.CHECKOUT_STATUS_TWO.equals(tmp.getPayResultLast())) {
String paySql = "select * from dba_tables where owner = '"+Configs.COLLECT_STANDARD_TABLE_USER.toUpperCase()
+ "' and table_name = '"+Configs.COLLECT_PAY_TABLE.toUpperCase() +"'";
if(OracleConnector.execUpdateOracleSQL(conn, paySql,
FileOperateHelper.addLastSeparator(Configs.EXTRACT_STANDARD_LOG_LOCALTION)+ logName +"jy.log")){
tmp.setPayResultLast(Constant.CHECKOUT_STATUS_THREE);
}
else {
tmp.setPayResultLast(Constant.CHECKOUT_STATUS_FOUR);
}
}
//可执行-- 校验
if (Constant.CHECKOUT_STATUS_TWO.equals(tmp.getExecResultLast())) {
String execSql = "select * from dba_tables where owner = '"+Configs.COLLECT_STANDARD_TABLE_USER.toUpperCase()
+ "' and table_name = '"+Configs.COLLECT_EXEC_TABLE.toUpperCase() +"'";
if(OracleConnector.execUpdateOracleSQL(conn, execSql,
FileOperateHelper.addLastSeparator(Configs.EXTRACT_STANDARD_LOG_LOCALTION)+ logName +"jy.log")){
tmp.setExecResultLast(Constant.CHECKOUT_STATUS_THREE);
}else {
tmp.setExecResultLast(Constant.CHECKOUT_STATUS_FOUR);
}
}
tmp.setCheckoutFlag(Constant.CHECKOUTFLAG_ONE);
// 更新数据库data_info
updateDataInfo(tmp);
// 将 CacheOracleCheckoutEntity checkMap中的 数据 放入extractMap中
/*CacheOracleCheckoutEntity.putExtract(key, */CacheOracleCheckoutEntity.checkRemove(key)/*)*/;
// 更新kuber状态
cmd2 = "kubectl annotate --overwrite rc "
+ key + " checkoutFlag=1";
// client.updateOrAddReplicasLabelById(taskNSyame,
// "status", "2");
rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd);
sb = new StringBuffer();
for (String str : rList)
sb.append(str).append("\n");
Configs.CONSOLE_LOGGER.info(sb.toString());
message = "成功";
Configs.CONSOLE_LOGGER
.info("更新replicationController标签 "
+ key + "\t[标签更新为: 成功]");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 成功 就 清除 CacheOracleCheckoutEntity 中 的该条记录
CacheOracleCheckoutEntity.checkRemove(key);
}
Configs.CONSOLE_LOGGER.info("连接到数据库服务: " + key
+ "\t[连接结果: " + message + "]");
}
}
}
/** dataInfo
* @param checkoutEntity
* @throws Exception
*/
private void updateDataInfo(CheckoutEntity checkoutEntity) throws Exception {
DataInfoEntity data = new DataInfoEntity();
// 状态改为 正则校验 Constant.CHECKOUTFLAG_TWO
data.setId(checkoutEntity.getDataId());
data.setPayResultLast(checkoutEntity.getPayResultLast());
data.setExecResultLast(checkoutEntity.getExecResultLast());
data.setCheckoutFlag(checkoutEntity.getCheckoutFlag());
dataInfoDao.update(data);
}
}

@ -0,0 +1,36 @@
package com.platform.service.thread;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.entities.oracleForm;
import com.platform.service.IOracleExtractService;
/** 线
* @author chen
*
*/
public class ThreadExtractStandardOracle extends Thread {
private IOracleExtractService OracleExtract;
private oracleForm form;
/** oracle
* @param form
* @param OracleExtract
*/
public ThreadExtractStandardOracle(oracleForm form, IOracleExtractService OracleExtract) {
this.OracleExtract = OracleExtract;
this.form = form;
}
@Override
public void run() {
try {
OracleExtract.extractStandardTable(form.getName(), form.getInneed(),form.getTarget());
} catch (Exception e) {
new CustomException(Custom4exception.threadVolume_Oracle_Except,e,form,OracleExtract);
}
}
}

@ -0,0 +1,154 @@
package com.platform.service.thread;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.util.List;
import com.base.CustomException;
import com.platform.dao.DataInfoDao;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo;
import com.platform.oracle.OracleConnector;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.FileOperateHelper;
/** sqlServer 线
* @author chen
*
*/
public class ThreadExtractStandardSqlServer extends Thread{
/** 汇总库 */
private GatherOracleInfo oracleConnect;
/** 待抽取的实体 */
private List<CheckoutEntity> Extractlist;
/** 数据管理 DAO */
private DataInfoDao dataInfoDao;
public ThreadExtractStandardSqlServer(GatherOracleInfo oracleConnect, List<CheckoutEntity> Extractlist, DataInfoDao dataInfoDao) {
this.oracleConnect = oracleConnect;
this.Extractlist = Extractlist;
this.dataInfoDao = dataInfoDao;
}
@Override
public void run() {
for (CheckoutEntity element : Extractlist) {
//校验结果:成功或失 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
//TODO 开始抽取
//如果校验成功的 才 进行 抽取----支付标准表
if (Constant.CHECKOUT_STATUS_FIVE.equals(element.getPayResultLast())) {
String payFilePath = FileOperateHelper.addLastSeparator(element.getPath())+Constant.standard_pay
+ element.getAreaCode().toLowerCase() + element.getSysCode()+".sql";
DataInfoEntity data = new DataInfoEntity();
data.setId(element.getDataId());
data.setPayResultLast(Constant.CHECKOUT_STATUS_SIX);
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
File paySql = new File(payFilePath);
try {
FileInputStream fis = new FileInputStream(paySql);
BufferedReader br = new BufferedReader(new InputStreamReader(fis,"GBK"));
String sql = br.readLine();
Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleConnect.getIp() + ":" + oracleConnect.getPort() + ":"
+ oracleConnect.getDatabaseName(), oracleConnect.getUser(), oracleConnect.getPassword(), null);
while (sql != null) {
//TODO 执行sql
sql = br.readLine();
String resultSql = sql.replace(";", "");
OracleConnector.execOracleSQL(conn, resultSql, FileOperateHelper.addLastSeparator(Configs.EXTRACT_STANDARD_LOG_LOCALTION)
+ "CQ"+element.getAreaCode()+"_"+element.getSysCode()+"_"+element.getDataVersion()+".log");
sql = br.readLine();
}
// 抽取完成
data.setPayResultLast(Constant.CHECKOUT_STATUS_SEVEN);
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CustomException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//如果校验成功的 才 进行 抽取----执行标准表
if (Constant.CHECKOUT_STATUS_FIVE.equals(element.getExecResultLast())){
String execFilePath = FileOperateHelper.addLastSeparator(element.getPath())+Constant.standard_indicate
+ element.getAreaCode().toLowerCase() + element.getSysCode()+".sql";
DataInfoEntity data = new DataInfoEntity();
data.setId(element.getDataId());
data.setExecResultLast(Constant.CHECKOUT_STATUS_SIX);
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
File execSql = new File(execFilePath);
try {
FileInputStream fis = new FileInputStream(execSql);
BufferedReader br = new BufferedReader(new InputStreamReader(fis,"GBK"));
String sql = br.readLine();
Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleConnect.getIp() + ":" + oracleConnect.getPort() + ":"
+ oracleConnect.getDatabaseName(), oracleConnect.getUser(), oracleConnect.getPassword(), null);
while (sql != null) {
//TODO 执行sql
//TODO 执行sql
sql = br.readLine();
String resultSql = sql.replace(";", "");
OracleConnector.execOracleSQL(conn, resultSql, FileOperateHelper.addLastSeparator(Configs.EXTRACT_STANDARD_LOG_LOCALTION)
+ "CQ"+element.getAreaCode()+"_"+element.getSysCode()+"_"+element.getDataVersion()+".log");
sql = br.readLine();
}
//抽取完成
data.setExecResultLast(Constant.CHECKOUT_STATUS_SEVEN);
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CustomException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}

@ -0,0 +1,59 @@
package com.platform.utils;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.platform.entities.CheckoutEntity;
public class CacheOracleCheckoutEntity {
private static Map<String, CheckoutEntity> checkMap = new HashMap<String, CheckoutEntity>();
private static Map<String, CheckoutEntity> extractStandardMap = new HashMap<String, CheckoutEntity>();
/**
* @return the checkMap
*/
public static Set<String> getCheckKeys() {
return checkMap.keySet();
}
/**
* @param checkMap the checkMap to set
*/
public static CheckoutEntity putCheck(String key, CheckoutEntity data) {
return checkMap.put(key, data);
}
public static CheckoutEntity getCheck(String key){
return checkMap.get(key);
}
public static CheckoutEntity checkRemove(String key){
return checkMap.remove(key);
}
/**
* @return the extractStandardMap
*/
public static Set<String> getExtractKeys() {
return extractStandardMap.keySet();
}
/**
* @param extractStandardMap the extractStandardMap to set
*/
public static CheckoutEntity putExtract(String key, CheckoutEntity data) {
return extractStandardMap.put(key, data);
}
public static CheckoutEntity getExtract(String key){
return extractStandardMap.get(key);
}
public static CheckoutEntity extractRemove(String key){
return extractStandardMap.remove(key);
}
}

@ -38,12 +38,23 @@ public class Configs {
public static String GATHER_USER_PASSWORD = "1"; //汇总库的登入密码
/** 抽取标准表 的 标准表所在 用户 */
public static String GATHER_STANDARD_USER_NAME = "u_bzbjy";
/** 可执行表名 */
public static String GATHER_STANDARD_EXEC_TABLE_NAME = "kzxzb";
/** 可支付表名 */
public static String GATHER_STANDARD_PAY_TABLE_NAME = "zfxxb";
public static String GATHER_SERVICE_NAME = "orcl"; //汇总库的服务名
public static String TABLE_SUFFIX = "_20152016"; //汇总库汇总表的后缀名
public static String EXTRACT_LOG_LOCALTION = "D:\\log"; //数据汇总日志保存位置
public static String EXTRACT_STANDARD_LOG_LOCALTION = "D:\\log2"; //数据抽取日志保存位置
public static String GATHER_TABLESPACE_NAME=""; //表空间名
public static String GATHER_TABLESPACE_PATH=""; //表空间路径
@ -78,4 +89,35 @@ public class Configs {
*
*/
public static int NUM_ONE_IMPORT_EXCEL = 12;
/**
* docker oracle
*/
public static String ORACLE_ORCL = "orcl";
/**
* docker oracle
*/
public static String ORACLE_USER = "system";
/**
* docker oracle
*/
public static String ORACLE_PSW = "oracle";
/**
*
*/
public static String COLLECT_STANDARD_TABLE_USER = "u_bzbjy";
/**
*
*/
public static String COLLECT_EXEC_TABLE = "kzxzb";
/**
*
*/
public static String COLLECT_PAY_TABLE = "zfxxb";
}

@ -44,6 +44,15 @@ public class ConfigsLoader implements ServletContextListener {
Configs.GATHER_USER_PASSWORD = properties
.getProperty("gather-user-password");
Configs.GATHER_STANDARD_USER_NAME = properties
.getProperty("gather-standard-user-name");
Configs.GATHER_STANDARD_EXEC_TABLE_NAME = properties
.getProperty("gather-standard-exec-table-name");
Configs.GATHER_STANDARD_PAY_TABLE_NAME = properties
.getProperty("gather-standard-pay-table-name");
Configs.GATHER_PORT = properties.getProperty("gather-port");
@ -54,6 +63,9 @@ public class ConfigsLoader implements ServletContextListener {
Configs.EXTRACT_LOG_LOCALTION = properties
.getProperty("extract-log-localtion");
Configs.EXTRACT_STANDARD_LOG_LOCALTION = properties
.getProperty("extract-standard-log-localtion");
Configs.GATHER_TABLESPACE_NAME = properties
.getProperty("gather-tablespace-name");
@ -79,6 +91,14 @@ public class ConfigsLoader implements ServletContextListener {
Configs.NUM_ONE_IMPORT_EXCEL = Integer.valueOf(properties.getProperty("numOneImportExcel"));
Configs.ORACLE_ORCL = properties.getProperty("oracle-orcl");
Configs.ORACLE_USER = properties.getProperty("oracle-user");
Configs.ORACLE_PSW = properties.getProperty("oracle-psw");
Configs.COLLECT_STANDARD_TABLE_USER= properties.getProperty("collect-user-table");
Configs.COLLECT_EXEC_TABLE = properties.getProperty("collect-exec-table");
Configs.COLLECT_PAY_TABLE = properties.getProperty("collect-pay-table");
HttpClientConstant.URL_IP_PORT = properties.getProperty("HttpClientConstant_URL_IP_PORT").trim();
Constant.hostIp=properties.getProperty("gfs_control_ip").trim();

@ -73,5 +73,74 @@ public class Constant {
/** cfg文件的名称 */
public final static String cfgFileName = "system_name_sys_code.cfg";
/** 表空间用户名 */
public final static String UserTablespace = "usertablespace_";
/** 可执行校验脚本 */
public final static String Checkout_Indicate = "checkout_indicate_";
/** 支付的验证脚本 */
public final static String Checkout_Pay = "checkout_pay_";
/** sqlserver支付脚本 */
public final static String standard_indicate = "standard_indicate_";
/** sqlserver支付脚本 */
public final static String standard_pay = "standard_pay_";
//校验 CHECKOUT_STATUS 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
/** 校验状态-0 */
public final static String CHECKOUT_STATUS_ZERO = "0";
/** 校验状态-1 */
public final static String CHECKOUT_STATUS_ONE = "1";
/** 校验状态-2 */
public final static String CHECKOUT_STATUS_TWO = "2";
/** 校验状态-3 */
public final static String CHECKOUT_STATUS_THREE = "3";
/** 校验状态-4 */
public final static String CHECKOUT_STATUS_FOUR = "4";
/** 校验状态-5 */
public final static String CHECKOUT_STATUS_FIVE = "5";
/** 校验状态-6 */
public final static String CHECKOUT_STATUS_SIX = "6";
/** 校验状态-7 */
public final static String CHECKOUT_STATUS_SEVEN = "7";
//校验标识 CHECKOUTFLAG 校验标识符0未校验1已校验,2:正在校验6正在抽取7抽取完成
/** 校验标识-0 */
public final static String CHECKOUTFLAG_ZERO = "0";
/** 校验标识-1 */
public final static String CHECKOUTFLAG_ONE = "1";
/** 校验标识-2 */
public final static String CHECKOUTFLAG_TWO = "2";
/** 校验标识-6 */
public final static String CHECKOUTFLAG_SIX = "6";
/** 校验标识-7 */
public final static String CHECKOUTFLAG_SEVEN = "7";
// 汇总库的 类型 ORACLE_EXTRACT_TYPE 0:总库汇总 1抽取标准表汇总
/** 类型-0 汇总 */
public final static String ORACLE_EXTRACT_TYPE_ZERO = "0";
/** 类型-1 抽取 */
public final static String ORACLE_EXTRACT_TYPE_ONE = "1";
/** 校验结果 是 */
public final static String ORACLE_CHECK_REULT_ZERO = "是";
/** 校验结果 否 */
public final static String ORACLE_CHECK_REULT_ONE = "否";
}

@ -39,6 +39,7 @@ public class ThreadVolume extends Thread {
private GetTreeData gfsTree = new GetTreeData();
public ThreadVolume() {
setName("ThreadVolume");
}
public ThreadVolume(String name) {
@ -89,9 +90,13 @@ public class ThreadVolume extends Thread {
@SuppressWarnings("unchecked")
List<VolumeEntity> volumes = (List<VolumeEntity>)JSONArray.toCollection(json, VolumeEntity.class);
for (VolumeEntity volumeEntity : volumes) {
if (null != volumeEntity.getFolder()) {
folderlist.addAll(volumeEntity.getFolder());
}
// if (null != volumeEntity.getFolder()) {
// JSONArray foldJson = JSONArray.fromObject(volumeEntity.getFolder());
// List<FolderNode> folders = (List<FolderNode>)JSONArray.toCollection(foldJson, FolderNode.class);
// folderlist.addAll(folders);
volumeEntity.setBrick(setBricks(volumeEntity.getBrick()));
volumeEntity.setFolder(setChildFolders(volumeEntity.getFolder()));
// }
}
volumeList = volumes;
@ -181,5 +186,27 @@ public class ThreadVolume extends Thread {
CacheTreeData.setFolders(folderlist);
CacheTreeData.setVolumeList(volumeList);
}
private List<FolderNode> setChildFolders(List<FolderNode> folds) {
List<FolderNode> folders = null;
if (null != folds) {
JSONArray foldJson = JSONArray.fromObject(folds);
folders = (List<FolderNode>)JSONArray.toCollection(foldJson, FolderNode.class);
for (FolderNode folderNode : folders) {
List<FolderNode> childFolds = folderNode.getChildNodes();
folderNode.setChildNodes(setChildFolders(childFolds));
}
}
return folders;
}
private List<Brick> setBricks(List<Brick> bricks) {
List<Brick> bs = null;
if (null != bricks) {
JSONArray bsJson = JSONArray.fromObject(bricks);
bs = (List<Brick>)JSONArray.toCollection(bsJson, Brick.class);
}
return bs;
}
}

@ -2,6 +2,8 @@ package com.platform.utils;
import java.util.List;
import net.sf.json.JSONArray;
import com.platform.entities.FolderNode;
public class getTreeDataByPath {

Loading…
Cancel
Save