Browse Source

咨询统计开发

anderx 2 years ago
parent
commit
5381153445

+ 1 - 1
src/main/java/com/goafanti/admin/service/AdminService.java

@@ -85,5 +85,5 @@ public interface AdminService {
 	DepCountBo selectAllUser(String depId, String startTime, String endTime, String aName);
 
 
-    Object pushStatistics();
+    Object pushStatistics() ;
 }

+ 33 - 15
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -1,6 +1,7 @@
 package com.goafanti.admin.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.goafanti.admin.bo.*;
 import com.goafanti.admin.service.AdminService;
 import com.goafanti.admin.service.DepartmentService;
@@ -581,38 +582,55 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 //		System.out.println("list="+list.size());
 //		}
 		List<TOrderTask> allTimeRecord = taskTimeMapper.getAllTimeRecord();
+		List<TaskTime> list=new ArrayList<>();
 		for (TOrderTask e : allTimeRecord) {
 			String timeRecord = e.getTimeRecord();
-			Map<String,Object> map = JSON.parseObject(timeRecord, Map.class);
-			if (!map.isEmpty()){
+			System.out.println(e.getTimeRecord());
+			if (StringUtils.isNotBlank(e.getTimeRecord())){
+				Map<String,Object> map = JSON.parseObject(timeRecord, Map.class);
 				for (String s : map.keySet()) {
 					if (s.equals("2")||s.equals("3")||s.equals("29")||s.equals("19")||(s.equals("27"))){
+						JSONObject js = JSON.parseObject(map.get(s).toString());
+						Object date = js.get("date");
+						Object suspendImg  = js.get("suspendImg") ;
+						Object title = js.get("title") ;
+						Object certificateNumber = js.get("certificateNumber") ;
+						Object setUpAmount = js.get("setUpAmount") ;
+						Object appropriation = js.get("appropriation") ;
 						TaskTime tt=new TaskTime();
 						tt.setTid(e.getId());
-						tt.setProjectStatus(Integer.valueOf(s));
-						Map<String,Object> map1 = JSON.parseObject(map.get(s).toString(), Map.class);
-						if (null!=map1.get("date")){
-							String date = map1.get("date").toString();
-							if (StringUtils.isNotBlank(date)){
-								System.out.println(date);
-								tt.setDateTime(DateUtils.StringToDate(date,AFTConstants.YYYYMMDD));
-								int i = taskTimeMapper.updateByTidAndProjectSelective(tt);
-								if (i==0){
-									taskTimeMapper.insertSelective(tt);
-								}
+						tt.setProjectStatus(Integer.parseInt(s));
+						if (!Objects.isNull(date)){
+							String dates=date.toString();
+							if (StringUtils.isNotBlank(dates)){
+								Date date1 = DateUtils.StringToDate(dates, AFTConstants.YYYYMMDD);
+								tt.setDateTime(date1);
 							}
 						}
+						if (!Objects.isNull(setUpAmount))tt.setSetUpAmount(setUpAmount.toString());
+						if (!Objects.isNull(suspendImg))tt.setSuspendImg(suspendImg.toString());
+						if (!Objects.isNull(title))tt.setTitle(title.toString());
+						if (!Objects.isNull(certificateNumber))tt.setCertificateNumber(certificateNumber.toString());
+						if (!Objects.isNull(appropriation))tt.setAppropriation(appropriation.toString());
+						list.add(tt);
+//					taskTimeMapper.insertSelective(tt);
 					}
 				}
+			}
+		}
+		List<TaskTime> addList = new ArrayList<>();
+		for (int i = 0; i <list.size(); i++) {
+			addList.add(list.get(i));
+			if (addList.size()==50|| i==list.size() -1){
+				taskTimeMapper.insertBatch(addList);
 				try {
+					addList.clear();
 					Thread.sleep(500);
 				} catch (InterruptedException exception) {
 					exception.printStackTrace();
 				}
 			}
 		}
-
-
 		return 1;
 	}
 

+ 2 - 0
src/main/java/com/goafanti/common/dao/TaskTimeMapper.java

@@ -23,4 +23,6 @@ public interface TaskTimeMapper {
     List<TaskTime> selectByTidAndProject(TaskTime tt);
 
     List<TOrderTask> getAllTimeRecord();
+
+    void insertBatch(List<TaskTime> addList);
 }

+ 91 - 4
src/main/java/com/goafanti/common/mapper/TaskTimeMapper.xml

@@ -6,10 +6,16 @@
     <result column="tid" jdbcType="INTEGER" property="tid" />
     <result column="project_status" jdbcType="INTEGER" property="projectStatus" />
     <result column="date_time" jdbcType="DATE" property="dateTime" />
+    <result column="suspend_img" jdbcType="VARCHAR" property="suspendImg" />
+    <result column="title" jdbcType="VARCHAR" property="title" />
+    <result column="certificate_number" jdbcType="VARCHAR" property="certificateNumber" />
+    <result column="set_up_amount" jdbcType="VARCHAR" property="setUpAmount" />
+    <result column="appropriation" jdbcType="VARCHAR" property="appropriation" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, tid, project_status, date_time, create_time
+    id, tid, project_status, date_time, suspend_img, title, certificate_number, set_up_amount,
+    appropriation, create_time
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
@@ -17,16 +23,19 @@
     from task_time
     where id = #{id,jdbcType=INTEGER}
   </select>
-
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
     delete from task_time
     where id = #{id,jdbcType=INTEGER}
   </delete>
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TaskTime" useGeneratedKeys="true">
     insert into task_time (tid, project_status, date_time,
-      create_time)
+      suspend_img, title, certificate_number,
+      set_up_amount, appropriation, create_time
+      )
     values (#{tid,jdbcType=INTEGER}, #{projectStatus,jdbcType=INTEGER}, #{dateTime,jdbcType=DATE},
-      #{createTime,jdbcType=TIMESTAMP})
+      #{suspendImg,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{certificateNumber,jdbcType=VARCHAR},
+      #{setUpAmount,jdbcType=VARCHAR}, #{appropriation,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
+      )
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TaskTime" useGeneratedKeys="true">
     insert into task_time
@@ -40,6 +49,21 @@
       <if test="dateTime != null">
         date_time,
       </if>
+      <if test="suspendImg != null">
+        suspend_img,
+      </if>
+      <if test="title != null">
+        title,
+      </if>
+      <if test="certificateNumber != null">
+        certificate_number,
+      </if>
+      <if test="setUpAmount != null">
+        set_up_amount,
+      </if>
+      <if test="appropriation != null">
+        appropriation,
+      </if>
       <if test="createTime != null">
         create_time,
       </if>
@@ -54,6 +78,21 @@
       <if test="dateTime != null">
         #{dateTime,jdbcType=DATE},
       </if>
+      <if test="suspendImg != null">
+        #{suspendImg,jdbcType=VARCHAR},
+      </if>
+      <if test="title != null">
+        #{title,jdbcType=VARCHAR},
+      </if>
+      <if test="certificateNumber != null">
+        #{certificateNumber,jdbcType=VARCHAR},
+      </if>
+      <if test="setUpAmount != null">
+        #{setUpAmount,jdbcType=VARCHAR},
+      </if>
+      <if test="appropriation != null">
+        #{appropriation,jdbcType=VARCHAR},
+      </if>
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -71,6 +110,21 @@
       <if test="dateTime != null">
         date_time = #{dateTime,jdbcType=DATE},
       </if>
+      <if test="suspendImg != null">
+        suspend_img = #{suspendImg,jdbcType=VARCHAR},
+      </if>
+      <if test="title != null">
+        title = #{title,jdbcType=VARCHAR},
+      </if>
+      <if test="certificateNumber != null">
+        certificate_number = #{certificateNumber,jdbcType=VARCHAR},
+      </if>
+      <if test="setUpAmount != null">
+        set_up_amount = #{setUpAmount,jdbcType=VARCHAR},
+      </if>
+      <if test="appropriation != null">
+        appropriation = #{appropriation,jdbcType=VARCHAR},
+      </if>
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -82,6 +136,11 @@
     set tid = #{tid,jdbcType=INTEGER},
       project_status = #{projectStatus,jdbcType=INTEGER},
       date_time = #{dateTime,jdbcType=DATE},
+      suspend_img = #{suspendImg,jdbcType=VARCHAR},
+      title = #{title,jdbcType=VARCHAR},
+      certificate_number = #{certificateNumber,jdbcType=VARCHAR},
+      set_up_amount = #{setUpAmount,jdbcType=VARCHAR},
+      appropriation = #{appropriation,jdbcType=VARCHAR},
       create_time = #{createTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -91,6 +150,21 @@
         <if test="dateTime != null">
           date_time = #{dateTime,jdbcType=DATE},
         </if>
+        <if test="suspendImg != null">
+          suspend_img = #{suspendImg,jdbcType=VARCHAR},
+        </if>
+        <if test="title != null">
+          title = #{title,jdbcType=VARCHAR},
+        </if>
+        <if test="certificateNumber != null">
+          certificate_number = #{certificateNumber,jdbcType=VARCHAR},
+        </if>
+        <if test="setUpAmount != null">
+          set_up_amount = #{setUpAmount,jdbcType=VARCHAR},
+        </if>
+        <if test="appropriation != null">
+          appropriation = #{appropriation,jdbcType=VARCHAR},
+        </if>
       </set>
       where tid = #{tid,jdbcType=INTEGER} and project_status =  #{projectStatus,jdbcType=INTEGER}
     </update>
@@ -105,4 +179,17 @@
       from t_order_task
       where time_record is not null and split_status in (0,2)
   </select>
+
+  <insert id="insertBatch">
+  insert into task_time (tid, project_status, date_time,
+  suspend_img, title, certificate_number,
+  set_up_amount, appropriation
+  ) values
+  <foreach collection="list" index="index" item="item" separator=",">
+    ( #{item.tid}, #{item.projectStatus},#{item.dateTime,jdbcType=DATE},
+    #{item.suspendImg},#{item.title},#{item.certificateNumber},
+    #{item.setUpAmount},#{item.appropriation}
+    )
+  </foreach>
+  </insert>
 </mapper>

+ 65 - 0
src/main/java/com/goafanti/common/model/TaskTime.java

@@ -23,6 +23,31 @@ public class TaskTime implements Serializable {
     private Date dateTime;
 
     /**
+     * 暂停图片
+     */
+    private String suspendImg;
+
+    /**
+     * 标题
+     */
+    private String title;
+
+    /**
+     * 证书编号
+     */
+    private String certificateNumber;
+
+    /**
+     * 立项金额
+     */
+    private String setUpAmount;
+
+    /**
+     * 拨款
+     */
+    private String appropriation;
+
+    /**
      * 创建时间
      */
     private Date createTime;
@@ -61,6 +86,46 @@ public class TaskTime implements Serializable {
         this.dateTime = dateTime;
     }
 
+    public String getSuspendImg() {
+        return suspendImg;
+    }
+
+    public void setSuspendImg(String suspendImg) {
+        this.suspendImg = suspendImg;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getCertificateNumber() {
+        return certificateNumber;
+    }
+
+    public void setCertificateNumber(String certificateNumber) {
+        this.certificateNumber = certificateNumber;
+    }
+
+    public String getSetUpAmount() {
+        return setUpAmount;
+    }
+
+    public void setSetUpAmount(String setUpAmount) {
+        this.setUpAmount = setUpAmount;
+    }
+
+    public String getAppropriation() {
+        return appropriation;
+    }
+
+    public void setAppropriation(String appropriation) {
+        this.appropriation = appropriation;
+    }
+
     public Date getCreateTime() {
         return createTime;
     }

+ 6 - 6
src/main/java/com/goafanti/common/utils/DateUtils.java

@@ -1,16 +1,15 @@
 package com.goafanti.common.utils;
 
+import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.error.BusinessException;
+import org.apache.commons.lang3.time.DateFormatUtils;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.*;
 import java.util.Calendar;
 import java.util.Date;
 
-
-import com.goafanti.common.constant.AFTConstants;
-import com.goafanti.common.error.BusinessException;
-import org.apache.commons.lang3.time.DateFormatUtils;
-
 public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
 	public static final String	YEAR_SPAN		= "yearSpan";
@@ -464,7 +463,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 		try {
 			 date2=new SimpleDateFormat(format).parse(date);
 		} catch (ParseException e) {
-			throw new BusinessException("时间转换失败",e);
+			throw new BusinessException("时间转换失败,date="+date,e);
 		}
 		return date2;
 	}
@@ -527,4 +526,5 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 		int days=(int)((now.getTime()-date.getTime())/(1000*3600*24));
 		return days;
 	}
+
 }