Commit 49dafb8d by liu_xiaoxu

公安部发送数据后更新人员采集表、新增日志表

parent 433c794e
package com.founder.dao;
import com.founder.model.SysLogJccjXxbs;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
@Component
@Mapper
public interface LogDao {
int insertLog(SysLogJccjXxbs sysLogJccjXxbs);
}
......@@ -15,5 +15,6 @@ public interface RycjDao {
int insertRycj(Rycj rycj);
Rycj selectByPrimaryKey(String taskid);
int updateByPrimaryKey(Rycj Rycj);
int insertLog(Rycj rycj);
List<Rycj> selectRycj();
int updateStatusByPrimaryKey(Rycj Rycj);
}
package com.founder.model;
import java.util.Date;
public class SysLogJccjXxbs {
private String taskid ;
private String userid ;
private String status_code ;
private String zxjgdm ;
private Date djsj ;
public String getTaskid() {
return taskid;
}
public void setTaskid(String taskid) {
this.taskid = taskid;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getStatus_code() {
return status_code;
}
public void setStatus_code(String status_code) {
this.status_code = status_code;
}
public String getZxjgdm() {
return zxjgdm;
}
public void setZxjgdm(String zxjgdm) {
this.zxjgdm = zxjgdm;
}
public Date getDjsj() {
return djsj;
}
public void setDjsj(Date djsj) {
this.djsj = djsj;
}
}
package com.founder.service;
import com.founder.model.Rycj;
public interface LogService {
boolean insertLog(Rycj rycj);
}
......@@ -11,4 +11,6 @@ import java.util.Map;
public interface RycjService {
boolean insertRycj(Jccj jccj);
List<Rycj> selectRycj();
boolean updateStatusByPrimaryKey(Rycj rycj);
}
package com.founder.service.impl;
import com.founder.dao.LogDao;
import com.founder.model.Rycj;
import com.founder.model.SysLogJccjXxbs;
import com.founder.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class LogServiceImpl implements LogService {
@Autowired
private LogDao logDao;
@Override
public boolean insertLog(Rycj rycj) {
SysLogJccjXxbs sysLogJccjXxbs = new SysLogJccjXxbs();
sysLogJccjXxbs.setTaskid(rycj.getTaskid());
sysLogJccjXxbs.setUserid(rycj.getUser_id());
sysLogJccjXxbs.setStatus_code(rycj.getStatus_code());
sysLogJccjXxbs.setDjsj(new Date());
boolean bool = false;
try {
int rows=logDao.insertLog(sysLogJccjXxbs);
if(rows>0){
bool = true;
}
}catch (Exception e){
System.out.print("日志增加或更新失败"+e.getMessage());
}
return bool;
}
}
......@@ -4,6 +4,7 @@ import com.founder.dao.RycjDao;
import com.founder.model.Jccj;
import com.founder.model.Rycj;
import com.founder.service.AutoSeqService;
import com.founder.service.LogService;
import com.founder.service.RycjService;
import com.founder.util.FtpUtil;
import com.founder.util.RequertUtil;
......@@ -15,15 +16,18 @@ import org.springframework.util.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;
@Service
public class RycjServiceImpl implements RycjService {
@Autowired
private RycjDao rycjDao;
@Autowired
private LogService logService;
@Value(value = "${ftpfilePath}")
private String ftpfilePath;
......@@ -78,13 +82,33 @@ public class RycjServiceImpl implements RycjService {
bool = true;
}
}
rycjDao.insertLog(rycj);
logService.insertLog(rycj);
}catch (Exception e){
System.out.print("增加或更新失败"+e.getMessage());
}
return bool;
}
@Override
public List<Rycj> selectRycj() {
return rycjDao.selectRycj();
}
@Override
public boolean updateStatusByPrimaryKey(Rycj rycj) {
boolean bool = false;
try {
int rows = rycjDao.updateStatusByPrimaryKey(rycj);
if(rows>0){
bool=true;
}
}catch (Exception e){
System.out.print("人员采集状态更新失败"+e.getMessage());
}
return bool;
}
}
......@@ -9,27 +9,42 @@ import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.founder.model.Rycj;
import com.founder.model.Jccj;
import com.founder.service.RycjService;
import com.founder.service.LogService;
@Component
public class ScheduleTask {
@Autowired
private RycjService rycjService;
@Autowired
private LogService logService;
private SimpleDateFormat format=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
private Logger logger= LoggerFactory.getLogger(ScheduleTask.class);
@Scheduled(cron = "1 1 1 1/1 * ? ")
@Scheduled(cron = "0 */1 * * * ?")
public void taskForDictUpdate(){
logger.info("This is a say method!"+format.format(new Date()));
xxbsSerevice();
xxbsSerevice();
}
private void xxbsSerevice(){
logger.info("This is a say method!"+format.format(new Date()));
//1.从表中获取未上报的信息
/*直接从服务器获取zip包并转成base64
List<Rycj> list= rycjService.selectRycj();
if(list!=null&&list.size()>0){
for(Rycj r:list) {
r.getRycj_dzwjwz();//url
Rycj rycj =new Rycj();
rycj.setTaskid(r.getTaskid());
rycj.setUser_id(r.getUser_id());
/*//直接从服务器获取zip包并转成base64
Jccj jccj =new Jccj();
URL url = new URL(r.getRycj_dzwjwz());
URL url = new URL("http://47.92.129.99/neimeng/FZXZ/201909/JCXX-R1100000500002014070008.zip");
InputStream inStream = url.openStream();
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
......@@ -40,15 +55,22 @@ public class ScheduleTask {
}
byte[] in_b = swapStream.toByteArray(); //in_b为转换之后的结果
final String encodedText = encoder.encodeToString(in_b);
jccj.setXxsb_zip(encodedText);
jccj.setXxsb_zip(encodedText);
jccj.setTaskid("JCXX-R1100000500002014070008");
jccj.setUser_id("142728188997588823");
jccj.setUser_dept("1400000000");
jccj.setVersion("1.00");
*/
jccj.setVersion("1.00");*/
//2..将从采集平台获取的信息,在发送给公安部
// JSONObject jsonResult= requestByPost("http://api.xz.xz.ga/jccj/xxbs",jccj);
//更新写日志
//2..将从采集平台获取的信息,在发送给公安部
// JSONObject jsonResult= requestByPost("http://api.xz.xz.ga/jccj/xxbs",jccj);
//更新写日志
//公安部接口开通后Status_code等在jsonResult中解析
rycj.setStatus_code("10102");
rycj.setZxjgdm("00000");
rycj.setStatus_message("大西瓜");
rycjService.updateStatusByPrimaryKey(rycj);
logService.insertLog(rycj);
}
}
}
}
......@@ -27,7 +27,6 @@
</update>
<insert id="insertRycj" parameterType="com.founder.model.Rycj">
INSERT INTO TB_ST_RYCJ (
RYCJ_BT,
RYCJ_DZWJBT,
RYCJ_DZWJGS,
......@@ -131,44 +130,17 @@
</if>
)
</insert>
<insert id="insertLog" parameterType="com.founder.model.Rycj">
INSERT INTO SYS_LOG_JCCJ_XXBS (
TASKID,
USERID,
STATUS_CODE,
ZXJGDM,
DJSJ
)VALUES (
<if test="taskid != null">
#{taskid},
</if>
<if test="taskid == null">
NULL ,
</if>
<if test="user_id != null">
#{user_id},
</if>
<if test="user_id == null">
NULL ,
</if>
<if test="status_code != null">
#{status_code},
</if>
<if test="status_code == null">
NULL,
</if>
<if test="zxjgdm != null">
#{zxjgm},
</if>
<if test="zxjgdm == null">
NULL,
</if>
<if test="rycj_jlsj != null">
#{rycj_jlsj}
</if>
<if test="rycj_jlsj == null">
NULL
</if>
)
</insert>
<select id="selectRycj" resultMap="rycj" parameterType="java.lang.String" resultType="com.founder.model.Rycj">
select
TASKID,USER_ID
from TB_ST_RYCJ WHERE STATUS_CODE is NULL
</select>
<update id="updateStatusByPrimaryKey" parameterType="com.founder.model.Rycj" >
update TB_ST_RYCJ
set
ZXJGDM = #{ zxjgdm , jdbcType=VARCHAR }
, STATUS_CODE = #{ status_code , jdbcType=VARCHAR }
, STATUS_MESSAGE = #{ status_message , jdbcType=VARCHAR }
where TASKID = #{ taskid,jdbcType=VARCHAR }
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.founder.dao.LogDao">
<insert id="insertLog" parameterType="com.founder.model.SysLogJccjXxbs">
INSERT INTO SYS_LOG_JCCJ_XXBS (
TASKID,
USERID,
STATUS_CODE,
ZXJGDM,
DJSJ
)VALUES (
<if test="taskid != null">
#{taskid},
</if>
<if test="taskid == null">
NULL ,
</if>
<if test="userid != null">
#{userid},
</if>
<if test="userid == null">
NULL ,
</if>
<if test="status_code != null">
#{status_code},
</if>
<if test="status_code == null">
NULL,
</if>
<if test="zxjgdm != null">
#{zxjgm},
</if>
<if test="zxjgdm == null">
NULL,
</if>
<if test="djsj != null">
#{djsj}
</if>
<if test="djsj == null">
NULL
</if>
)
</insert>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment