zyf 2 éve
szülő
commit
9a0f6c590d

+ 18 - 1
src/main/java/com/steerinfo/dil/controller/DilNoticeController.java

@@ -210,6 +210,17 @@ public class DilNoticeController extends BaseRESTfulController {
         return success(dilNoticeService.deleteNotice(id));
     }
 
+    /**
+     * 根据userId获取用户名字
+     * @param userId
+     * @return
+     */
+    @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
+    @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "Short")
+    @PostMapping(value = "/queryName/{userId}")
+    public RESTfulResult queryName(@PathVariable("userId") String userId){
+        return success(dilNoticeService.queryName(userId));
+    }
 
 
     /**
@@ -274,7 +285,13 @@ public class DilNoticeController extends BaseRESTfulController {
     @PostMapping(value = "/getNotice")
     public RESTfulResult getNotice(@RequestBody(required = false) Map<String, Object> mapValue){
         //String orgcode= (String) mapValue.get("orgcodezs");
-        String userId=(String) mapValue.get("userId");
+        String userId="";
+        if (mapValue!=null){
+            userId=(String) mapValue.get("userId");
+        }
+        if ("".equals(userId)){
+            return failed();
+        }
         List<Map<String, Object>> noticeData = dilNoticeService.getNoticeData(userId);
         return success(noticeData);
         //return null;

+ 23 - 0
src/main/java/com/steerinfo/dil/mapper/DilNoticeMapper.java

@@ -75,6 +75,14 @@ public interface DilNoticeMapper extends IBaseMapper<DilNotice, BigDecimal> {
      * @Date:2022-09-23
      * @Description:删除与该通知有关用户中间表的信息
     */
+    int deleteNoticeUsers(BigDecimal id);
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-23
+     * @Description:删除与该通知表的信息
+     */
     int deleteNotice(BigDecimal id);
 
     /**
@@ -85,6 +93,13 @@ public interface DilNoticeMapper extends IBaseMapper<DilNotice, BigDecimal> {
     */
     String getorgCode(BigDecimal noticeid);
 
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-26
+     * @Description:根据通知ID来查询历史orgcode
+     */
+    String gethistoryorgCode(BigDecimal noticeid);
 
     /**
      * @author:zyf
@@ -93,4 +108,12 @@ public interface DilNoticeMapper extends IBaseMapper<DilNotice, BigDecimal> {
      * @Description:根据用户id来更新状态
     */
     int updatestatus(String userId);
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-26
+     * @Description:根据用户ID来查询名字
+    */
+    String queryName(String userId);
 }

+ 11 - 0
src/main/java/com/steerinfo/dil/model/DilNotice.java

@@ -79,6 +79,17 @@ public class DilNotice implements IBasePO<BigDecimal> {
     @ApiModelProperty(value="存放用户名ID",required=false)
     private String userId;
 
+    @ApiModelProperty(value="存放历史信息",required=false)
+    private String historicalChanges;
+
+    public String getHistoricalChanges() {
+        return historicalChanges;
+    }
+
+    public void setHistoricalChanges(String historicalChanges) {
+        this.historicalChanges = historicalChanges;
+    }
+
     public String getUserId() {
         return userId;
     }

+ 2 - 0
src/main/java/com/steerinfo/dil/service/IDilNoticeService.java

@@ -33,6 +33,8 @@ public interface IDilNoticeService {
 
     int deleteNotice(BigDecimal id);
 
+    String queryName(String userId);
+
     List<Map<String, Object>> getNoticeById(BigDecimal id);
 
     List<Map<String, Object>> getCarrierNoticeList(Map<String, Object> mapVal);

+ 46 - 11
src/main/java/com/steerinfo/dil/service/impl/DilNoticeServiceImpl.java

@@ -93,29 +93,53 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
                 dilNotice.setPermission("shouhuokehu");
             }else{
                 dilNotice.setPermission("qita");
-                dilNoticeMapper.insertSelective(dilNotice);
+                /*dilNoticeMapper.insertSelective(dilNotice);
                 result +=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
-                return result;
+                return result;*/
             }
         }
         //需要手动设置发布人
         /*dilNotice.setInsertUsername("admin");*/
-        dilNoticeMapper.insertSelective(dilNotice);
-        if (result==0){
+        result+=dilNoticeMapper.insertSelective(dilNotice);
+        /*if (result==0){
             dilNoticeMapper.insertIntoNoticeUser(dilNotice);
-        }
+        }*/
         return result;
     }
 
     @Override
     public int releaseNotice(DilNotice dilNotice) {
         //发布通知
+        //1.先判断permission是否有值
+        //2.看notice有无历史的修改数据
+        //3.发布
+        int result=0;
         if (dilNotice.getPermission()!=null){
-
+            //查询是否有历史修改数据
+            String code = dilNoticeMapper.gethistoryorgCode(dilNotice.getNoticeId());
+            //历史数据有值与否
+            if (code!=null&&!("".equals(code))){
+                if (!code.equals(dilNotice.getPermission())){
+                    dilNoticeMapper.deleteNoticeUsers(dilNotice.getNoticeId());
+                    if ("qita".equals(dilNotice.getPermission())){
+                        //全部要单独
+                        result+=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
+                    }else {
+                        result+=dilNoticeMapper.insertIntoNoticeUser(dilNotice);
+                    }
+                }
+            }else {
+                if ("qita".equals(dilNotice.getPermission())){
+                    //全部要单独
+                    result+=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
+                }else {
+                    result+=dilNoticeMapper.insertIntoNoticeUser(dilNotice);
+                }
+            }
         }else {
             return 0;
         }
-        return 0;
+        return result;
     }
 
     /**
@@ -134,8 +158,10 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
         }else {
             dilNotice.setPermission("qita");
         }
-        //查询orgcode是否一致
         String code = dilNoticeMapper.getorgCode(dilNotice.getNoticeId());
+        dilNotice.setHistoricalChanges(code);
+        //查询orgcode是否一致
+        /*String code = dilNoticeMapper.getorgCode(dilNotice.getNoticeId());
         if (!code.equals(dilNotice.getPermission())){
             dilNoticeMapper.deleteNotice(dilNotice.getNoticeId());
             if ("qita".equals(dilNotice.getPermission())){
@@ -144,8 +170,7 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
             }else {
                 dilNoticeMapper.insertIntoNoticeUser(dilNotice);
             }
-        }
-        //修改中间表
+        }*/
         return dilNoticeMapper.updateByPrimaryKeySelective(dilNotice);
     }
 
@@ -170,9 +195,19 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
         dilNotice.setDeleted(new BigDecimal(1));
         //删除中间表信息
         dilNoticeMapper.deleteNotice(id);
-        return dilNoticeMapper.updateByPrimaryKeySelective(dilNotice);
+        //删除通知表的数据
+        return dilNoticeMapper.deleteNotice(id);
     }
 
+    //根据用户ID获取用户名字
+    @Override
+    public String queryName(String userId) {
+        return dilNoticeMapper.queryName(userId);
+    }
+
+
+
+
     /**
      * 根据id获取运力信息
      * @param id

+ 109 - 8
src/main/resources/com/steerinfo/dil/mapper/DilNoticeMapper.xml

@@ -12,15 +12,29 @@
     <result column="INSERT_UPDATE_REMARK" jdbcType="VARCHAR" property="insertUpdateRemark" />
     <result column="DELETED" jdbcType="DECIMAL" property="deleted" />
     <result column="PERMISSION" jdbcType="VARCHAR" property="permission" />
+    <result column="HISTORICAL_CHANGES" jdbcType="VARCHAR" property="historicalChanges"></result>
   </resultMap>
   <sql id="columns">
     NOTICE_ID, NOTICE_TITLE, NOTICE_CONTENT, INSERT_USERNAME, INSERT_TIME, UPDATE_USERNAME, 
-    UPDATE_TIME, INSERT_UPDATE_REMARK, DELETED, PERMISSION
+    UPDATE_TIME, INSERT_UPDATE_REMARK, DELETED, PERMISSION,HISTORICAL_CHANGES
   </sql>
   <sql id="columns_alias">
     t.NOTICE_ID, t.NOTICE_TITLE, t.NOTICE_CONTENT, t.INSERT_USERNAME, t.INSERT_TIME, 
-    t.UPDATE_USERNAME, t.UPDATE_TIME, t.INSERT_UPDATE_REMARK, t.DELETED, t.PERMISSION
+    t.UPDATE_USERNAME, t.UPDATE_TIME, t.INSERT_UPDATE_REMARK, t.DELETED, t.PERMISSION,
+    t.HISTORICAL_CHANGES
   </sql>
+  <sql id="orderBy">
+    <if test="orderField != null and orderField != ''">
+      order by "${orderField}"
+      <if test="orderType != null and orderType != ''">
+        ${orderType}
+      </if>
+    </if>
+    <if test="orderField == null  ">
+      order by "insertTime" desc
+    </if>
+  </sql>
+
   <sql id="select">
     SELECT <include refid="columns"/> FROM DIL_NOTICE
   </sql>
@@ -250,6 +264,9 @@
       <if test="permission != null">
         PERMISSION = #{permission,jdbcType=DECIMAL},
       </if>
+      <if test="historicalChanges != null">
+        HISTORICAL_CHANGES = #{historicalChanges,jdbcType=DECIMAL},
+      </if>
     </set>
     where NOTICE_ID = #{noticeId,jdbcType=DECIMAL}
   </update>
@@ -401,7 +418,8 @@
     DN.NOTICE_TITLE AS "noticeTitle",
     DN.NOTICE_CONTENT AS "noticeContent",
     DN.INSERT_TIME AS "insertTime",
-    DN.INSERT_USERNAME AS "insertUsername"
+    DN.INSERT_USERNAME AS "insertUsername",
+    DN.PERMISSION AS "permission"
     FROM DIL_NOTICE DN
     WHERE DN.DELETED !=1 and (DN.PERMISSION='qita' or DN.PERMISSION='chengyunshang')
     <if test="con!=null">
@@ -441,9 +459,8 @@
           "insertUsername" in #{item}
         </foreach>
       </if>
-
     </where>
-
+    <include refid="orderBy"></include>
   </select>
 
 
@@ -457,7 +474,8 @@
   DN.NOTICE_TITLE AS "noticeTitle",
   DN.NOTICE_CONTENT AS "noticeContent",
   DN.INSERT_TIME AS "insertTime",
-  DN.INSERT_USERNAME AS "insertUsername"
+  DN.INSERT_USERNAME AS "insertUsername",
+  DN.PERMISSION AS "permission"
   FROM DIL_NOTICE DN
   WHERE DN.DELETED !=1 and (DN.PERMISSION='qita' or DN.PERMISSION='wuliuyunshubu')
   <if test="con!=null">
@@ -465,6 +483,40 @@
   </if>
   ORDER BY DN.INSERT_TIME DESC
   )
+    <where>
+      <if test="noticeId!= null">
+        and
+        <foreach collection="noticeId" item="item" open="(" separator="," close=")">
+          "noticeId" in #{item}
+        </foreach>
+      </if>
+      <if test="noticeTitle!= null">
+        and
+        <foreach collection="noticeTitle" item="item" open="(" separator="," close=")">
+          "noticeTitle" in #{item}
+        </foreach>
+      </if>
+      <if test="noticeContent!= null">
+        and
+        <foreach collection="noticeContent" item="item" open="(" separator="," close=")">
+          "noticeContent" in #{item}
+        </foreach>
+      </if>
+      <if test="insertTime!= null">
+        and
+        <foreach collection="insertTime" item="item" open="(" separator="," close=")">
+          "insertTime" in #{item}
+        </foreach>
+      </if>
+
+      <if test="insertUsername!= null">
+        and
+        <foreach collection="insertUsername" item="item" open="(" separator="," close=")">
+          "insertUsername" in #{item}
+        </foreach>
+      </if>
+    </where>
+    <include refid="orderBy"></include>
   </select>
 
   <!--收货用户查询通知-->
@@ -477,7 +529,8 @@
           DN.NOTICE_TITLE AS "noticeTitle",
           DN.NOTICE_CONTENT AS "noticeContent",
           DN.INSERT_TIME AS "insertTime",
-          DN.INSERT_USERNAME AS "insertUsername"
+          DN.INSERT_USERNAME AS "insertUsername",
+          DN.PERMISSION AS "permission"
         FROM DIL_NOTICE DN
         WHERE DN.DELETED !=1 and (DN.PERMISSION='qita' or DN.PERMISSION='shouhuokehu')
         <if test="con!=null">
@@ -485,6 +538,40 @@
         </if>
         ORDER BY DN.INSERT_TIME DESC
       )
+    <where>
+      <if test="noticeId!= null">
+        and
+        <foreach collection="noticeId" item="item" open="(" separator="," close=")">
+          "noticeId" in #{item}
+        </foreach>
+      </if>
+      <if test="noticeTitle!= null">
+        and
+        <foreach collection="noticeTitle" item="item" open="(" separator="," close=")">
+          "noticeTitle" in #{item}
+        </foreach>
+      </if>
+      <if test="noticeContent!= null">
+        and
+        <foreach collection="noticeContent" item="item" open="(" separator="," close=")">
+          "noticeContent" in #{item}
+        </foreach>
+      </if>
+      <if test="insertTime!= null">
+        and
+        <foreach collection="insertTime" item="item" open="(" separator="," close=")">
+          "insertTime" in #{item}
+        </foreach>
+      </if>
+
+      <if test="insertUsername!= null">
+        and
+        <foreach collection="insertUsername" item="item" open="(" separator="," close=")">
+          "insertUsername" in #{item}
+        </foreach>
+      </if>
+    </where>
+    <include refid="orderBy"></include>
   </select>
 
 
@@ -585,6 +672,10 @@
         where NOTICE_ID=#{noticeId}
   </update>
   <delete id="deleteNotice">
+    delete from DIL_NOTICE DN
+    where DN.notice_id=#{noticeId}
+  </delete>
+  <delete id="deleteNoticeUsers">
     delete from DIL_NOTICE_USERS DNU
     where DNU.notice_id=#{noticeId}
   </delete>
@@ -593,10 +684,20 @@
     SET STATUS=1
     WHERE DNU.USER_ID=#{userId}
   </update>
+  <select id="queryName" resultType="java.lang.String">
+    select SU.USER_NAME "userName"
+    from "SSO".SYS_USER SU
+    where SU.USER_ID=#{userId}
+  </select>
   <select id="getorgCode" resultType="java.lang.String">
-    select DN.PERMISSION "orgCode"
+    select DN.PERMISSION "permission"
     from DIL_NOTICE DN
     where  DN.NOTICE_ID=#{noticeid}
   </select>
 
+  <select id="gethistoryorgCode" resultType="java.lang.String">
+    select DN.HISTORICAL_CHANGES "historicalChanges"
+    from DIL_NOTICE DN
+    where  DN.NOTICE_ID=#{noticeid}
+  </select>
 </mapper>