Procházet zdrojové kódy

公出统计修改

anderx před 4 roky
rodič
revize
72e8ef6467

+ 23 - 0
.idea/free-mybatis-generator-config.xml

@@ -96,6 +96,29 @@
             </Config>
           </value>
         </entry>
+        <entry key="public_release_count">
+          <value>
+            <Config>
+              <option name="comment" value="true" />
+              <option name="daoMvnPath" value="src/main/java" />
+              <option name="daoName" value="PublicReleaseCountMapper" />
+              <option name="daoPackage" value="com.goafanti.common.dao" />
+              <option name="daoPostfix" value="Mapper" />
+              <option name="modelMvnPath" value="src/main/java" />
+              <option name="modelName" value="PublicReleaseCount" />
+              <option name="modelPackage" value="com.goafanti.common.model" />
+              <option name="name" value="public_release_count" />
+              <option name="overrideJava" value="true" />
+              <option name="overrideXML" value="true" />
+              <option name="primaryKey" value="" />
+              <option name="projectFolder" value="$PROJECT_DIR$" />
+              <option name="tableName" value="public_release_count" />
+              <option name="useSchemaPrefix" value="true" />
+              <option name="xmlMvnPath" value="src/main/java" />
+              <option name="xmlPackage" value="com.goafanti.common.mapper" />
+            </Config>
+          </value>
+        </entry>
         <entry key="user_data">
           <value>
             <Config>

+ 1 - 1
src/main/java/com/goafanti/common/constant/AFTConstants.java

@@ -4,7 +4,7 @@ public class AFTConstants {
 	public static final String	YYYYMMDDHHMMSS						= "yyyy-MM-dd HH:mm:ss";
 	public static final String	YMDHMS_CHINESE						= "yyyy年MM月dd日 HH:mm:ss";
 	public static final String	YYYYMMDD							= "yyyy-MM-dd";
-
+	public static final String	YYYYMM								= "yyyy-MM";
 	public static final String	YYYY								= "yyyy";
 
 	public static final String	MMDDYYYY							= "MM/dd/yyyy";

+ 92 - 71
src/main/java/com/goafanti/common/mapper/PublicReleaseCountMapper.xml

@@ -10,9 +10,10 @@
     <result column="new_user" jdbcType="INTEGER" property="newUser" />
     <result column="total" jdbcType="DECIMAL" property="total" />
     <result column="date" jdbcType="VARCHAR" property="date" />
+    <result column="sign" jdbcType="INTEGER" property="sign" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, province, dep_id, `uid`, quantity, new_user, total, `date`
+    id, province, dep_id, `uid`, quantity, new_user, total, `date`, sign
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select 
@@ -20,71 +21,24 @@
     from public_release_count
     where id = #{id,jdbcType=INTEGER}
   </select>
-  <select id="followStatisticsList" resultType="com.goafanti.user.bo.outFollowStatisticsList">
-    select z.*,(z.totalQuantity/z.totalInterview)totalRatio from(select name,use_interview useInterview,
-      use_quantity useQuantity,use_total useTotal,(use_quantity/use_interview)useRatio,
-      new_interview newInterview,new_quantity newQuantity,new_total newTotal,(new_quantity/new_interview)newRatio,
-      (use_interview+new_interview)totalInterview,(use_quantity+new_quantity)totalQuantity,(use_total+new_total)total
-   from (select dg.name,sum(use_interview)use_interview,sum(use_quantity)use_quantity,sum(use_total)use_total,
-         sum(new_interview)new_interview,sum(new_quantity)new_quantity,sum(new_total)new_total
-   from (select province,if(new_user=1,1,0)use_interview,if(new_user=1,a.quantity ,0)use_quantity,
-    if(new_user=1,a.total ,0)use_total,if(new_user=0,1,0)new_interview,if(new_user=0,a.quantity ,0)new_quantity,
-    if(new_user=0,a.total ,0)new_total from public_release_count a
-   where a.`date` = #{date}
-     <if test="depId !=null">
-     and a.dep_id= #{depId}
-     </if>
-    <if test="province !=null">
-      and a.province= #{province}
-    </if>
-    )x
-    left join district_glossory dg on x.province=dg.id group by dg.id )y )z
-    order by
-    <if test="sort==0">
-      totalQuantity
-    </if>
-    <if test="sort==1">
-      total
-    </if>
-    <if test="sort==2">
-      totalInterview
-    </if>
-    desc
-  </select>
-  <select id="provinceFollowStatisticsList" resultType="com.goafanti.user.bo.outProvinceFollowStatistic">
-    select x.name,c.nickname ,x.new_user newUser,d.counts interviewCount,x.quantity
-    from (select b.name,a.new_user,a.uid,sum(a.quantity)quantity from public_release_count a left join department b on a.dep_id =b.id
-          where a.date= #{date} and a.province = #{province}
-            <if test="depId !=null">
-            and a.dep_id = #{depId}
-            </if>
-          group by b.name ,a.uid ,a.new_user )x
-           left join `user` c on x.uid =c.id left join (select uid,count(*)counts from public_release group by uid) d on x.uid =d.uid
-    order by
-             <if test="sort==0">
-             d.counts
-             </if>
-    <if test="sort==1">
-             x.quantity
-    </if>
-    desc
-  </select>
-
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
     delete from public_release_count
     where id = #{id,jdbcType=INTEGER}
   </delete>
-  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.PublicReleaseCount" useGeneratedKeys="true">
-    insert into public_release_count (province, dep_id, `uid`, 
-      quantity, new_user, total, 
-      `date`)
-    values (#{province,jdbcType=INTEGER}, #{depId,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, 
-      #{quantity,jdbcType=INTEGER}, #{newUser,jdbcType=INTEGER}, #{total,jdbcType=DECIMAL}, 
-      #{date,jdbcType=VARCHAR})
+  <insert id="insert" parameterType="com.goafanti.common.model.PublicReleaseCount">
+    insert into public_release_count (id, province, dep_id, 
+      `uid`, quantity, new_user, 
+      total, `date`, sign)
+    values (#{id,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{depId,jdbcType=VARCHAR}, 
+      #{uid,jdbcType=VARCHAR}, #{quantity,jdbcType=INTEGER}, #{newUser,jdbcType=INTEGER}, 
+      #{total,jdbcType=DECIMAL}, #{date,jdbcType=VARCHAR}, #{sign,jdbcType=INTEGER})
   </insert>
-  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.PublicReleaseCount" useGeneratedKeys="true">
+  <insert id="insertSelective" parameterType="com.goafanti.common.model.PublicReleaseCount">
     insert into public_release_count
     <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
       <if test="province != null">
         province,
       </if>
@@ -106,8 +60,14 @@
       <if test="date != null">
         `date`,
       </if>
+      <if test="sign != null">
+        sign,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=INTEGER},
+      </if>
       <if test="province != null">
         #{province,jdbcType=INTEGER},
       </if>
@@ -129,19 +89,11 @@
       <if test="date != null">
         #{date,jdbcType=VARCHAR},
       </if>
+      <if test="sign != null">
+        #{sign,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
-  <insert id="insertBatch">
-    insert into public_release_count (province, dep_id, `uid`,
-                                      quantity, new_user, total,
-                                      `date`)
-    values
-    <foreach collection="list" index="index" item="item" separator=",">
-           (#{item.province,jdbcType=INTEGER}, #{item.depId,jdbcType=VARCHAR}, #{item.uid,jdbcType=VARCHAR},
-            #{item.quantity,jdbcType=INTEGER}, #{item.newUser,jdbcType=INTEGER}, #{item.total,jdbcType=DECIMAL},
-            #{item.date,jdbcType=VARCHAR})
-    </foreach>
-  </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.PublicReleaseCount">
     update public_release_count
     <set>
@@ -166,6 +118,9 @@
       <if test="date != null">
         `date` = #{date,jdbcType=VARCHAR},
       </if>
+      <if test="sign != null">
+        sign = #{sign,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -177,7 +132,73 @@
       quantity = #{quantity,jdbcType=INTEGER},
       new_user = #{newUser,jdbcType=INTEGER},
       total = #{total,jdbcType=DECIMAL},
-      `date` = #{date,jdbcType=VARCHAR}
+      `date` = #{date,jdbcType=VARCHAR},
+      sign = #{sign,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
+
+  <select id="followStatisticsList" resultType="com.goafanti.user.bo.outFollowStatisticsList">
+    select z.name,z.use_interview useInterview,z.use_quantity useQuantity,z.use_total useTotal,ifnull(z.useRatio,0)useRatio,
+    z.new_interview newInterview,z.new_quantity newQuantity,z.new_total newTotal,ifnull(z.newRatio,0)newRatio,
+    z.totalInterview,z.totalQuantity,z.total,ifnull((z.totalQuantity/z.totalInterview),0)totalRatio
+    from(select name,use_interview , use_quantity ,use_total ,(use_quantity/use_interview)useRatio,
+    new_interview ,new_quantity ,new_total ,(new_quantity/new_interview)newRatio,
+    (use_interview+new_interview)totalInterview,(use_quantity+new_quantity)totalQuantity,(use_total+new_total)total
+    from (select dg.name,sum(use_interview)use_interview,sum(use_quantity)use_quantity,sum(use_total)use_total,
+    sum(new_interview)new_interview,sum(new_quantity)new_quantity,sum(new_total)new_total
+    from (select province,if(new_user=1,1,0)use_interview,if(new_user=1,a.quantity ,0)use_quantity,
+    if(new_user=1,a.total ,0)use_total,if(new_user=0,1,0)new_interview,if(new_user=0,a.quantity ,0)new_quantity,
+    if(new_user=0,a.total ,0)new_total from public_release_count a
+    where a.`date` = #{date}
+    <if test="depId !=null">
+      and a.dep_id= #{depId}
+    </if>
+    <if test="province !=null">
+      and a.province= #{province}
+    </if>
+    )x
+    left join district_glossory dg on x.province=dg.id group by dg.id )y )z
+    order by
+    <if test="sort==0">
+      totalQuantity
+    </if>
+    <if test="sort==1">
+      total
+    </if>
+    <if test="sort==2">
+      totalInterview
+    </if>
+    desc
+  </select>
+  <select id="provinceFollowStatisticsList" resultType="com.goafanti.user.bo.outProvinceFollowStatistic">
+    select x.name,c.nickname ,x.new_user newUser,d.counts interviewCount,x.quantity
+    from (select b.name,a.new_user,a.uid,sum(a.quantity)quantity from public_release_count a left join department b on a.dep_id =b.id
+    where a.date= #{date} and a.province = #{province}
+    <if test="depId !=null">
+      and a.dep_id = #{depId}
+    </if>
+    group by b.name ,a.uid ,a.new_user )x
+    left join `user` c on x.uid =c.id left join (select uid,count(*)counts from public_release group by uid) d on x.uid =d.uid
+    order by
+    <if test="sort==0">
+      d.counts
+    </if>
+    <if test="sort==1">
+      x.quantity
+    </if>
+    desc
+  </select>
+
+  <insert id="insertBatch">
+    insert into public_release_count (province, dep_id, `uid`,
+    quantity, new_user, total,
+    `date`,sign)
+    values
+    <foreach collection="list" index="index" item="item" separator=",">
+      (#{item.province,jdbcType=INTEGER}, #{item.depId,jdbcType=VARCHAR}, #{item.uid,jdbcType=VARCHAR},
+      #{item.quantity,jdbcType=INTEGER}, #{item.newUser,jdbcType=INTEGER}, #{item.total,jdbcType=DECIMAL},
+      #{item.date,jdbcType=VARCHAR},#{item.sign,jdbcType=INTEGER})
+    </foreach>
+  </insert>
+
 </mapper>

+ 1 - 1
src/main/java/com/goafanti/common/mapper/PublicReleaseMapper.xml

@@ -680,7 +680,7 @@
   or  (release_start &lt; #{end} and release_end &gt; #{end}))
   </select>
   <select id="getTimeUserFollow" resultType="com.goafanti.common.model.OutPublicReleaseCount">
-    select e.id province,d.id depId,a.aid,a.uid,a.new_user newUser from (select aid,uid,new_user from public_release
+    select e.id province,d.id depId,a.aid,a.uid,a.new_user newUser ,1 quantity from (select aid,uid,new_user from public_release
      where main_status =1 and create_time between #{date} and #{now}
      group by aid,uid,new_user)a left join admin c on a.aid=c.id
     left join department d on c.department_id =d.id left join district_glossory e on d.province =e.id

+ 13 - 0
src/main/java/com/goafanti/common/model/PublicReleaseCount.java

@@ -48,6 +48,11 @@ public class PublicReleaseCount implements Serializable {
      */
     private String date;
 
+    /**
+     * 签单
+     */
+    private Integer sign;
+
     private static final long serialVersionUID = 1L;
 
     public Integer getId() {
@@ -113,4 +118,12 @@ public class PublicReleaseCount implements Serializable {
     public void setDate(String date) {
         this.date = date;
     }
+
+    public Integer getSign() {
+        return sign;
+    }
+
+    public void setSign(Integer sign) {
+        this.sign = sign;
+    }
 }

+ 3 - 3
src/main/java/com/goafanti/common/task/UserFollowTask.java

@@ -48,13 +48,13 @@ public class UserFollowTask {
         date.set(Calendar.MONTH,now.get(Calendar.MONTH)-1);
         List<OutPublicReleaseCount> list =publicReleaseMapper.getTimeUserFollow(date.getTime(),now.getTime());
         for (OutPublicReleaseCount out : list) {
-            out.setDate(ym);
-            out.setQuantity(1);
+            out.setDate(DateUtils.formatDate(date.getTime(),AFTConstants.YYYYMM));
             List<BigDecimal> aList=tOrderNewMapper.selectByUidAndNewUser(out.getUid(),out.getAid(),out.getNewUser(),date.getTime(),now.getTime());
             if (aList.isEmpty()){
+                out.setSign(0);
                 out.setTotal(new BigDecimal(0));
             }else{
-                out.setQuantity(aList.size());
+                out.setSign(aList.size());
                 BigDecimal total=new BigDecimal(0);
                 for (BigDecimal bigDecimal : aList) {
                     total=total.add(bigDecimal);

+ 1 - 0
src/main/java/com/goafanti/user/service/impl/UserFollowServiceImpl.java

@@ -77,6 +77,7 @@ public class UserFollowServiceImpl extends BaseMybatisDao<UserFollowMapper>  imp
     @Override
     public List<outFollowStatisticsList> followStatisticsList(String depId, String date,Integer province, Integer sort) {
         if(sort==null)sort=0;
+        if (date==null)return new ArrayList<>();
         return publicReleaseCountMapper.followStatisticsList(depId,date,province,sort);
     }
 

+ 5 - 5
src/main/resources/props/config_local.properties

@@ -1,11 +1,11 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-jdbc.username=root
-jdbc.password=123456
-#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.username=root
-#jdbc.password=aftdev
+#jdbc.password=123456
+jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.username=root
+jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20