zyf 2 سال پیش
والد
کامیت
a58eed1f2d

+ 41 - 7
src/main/java/com/steerinfo/dil/controller/DilNoticeController.java

@@ -85,9 +85,12 @@ public class DilNoticeController extends BaseRESTfulController {
     public RESTfulResult getMarketingNoticeList(@RequestBody(required = false) Map<String,Object> mapVal,
                                        Integer pageNum,
                                        Integer pageSize,
-                                       Integer apiId){
+                                       Integer apiId,String con){
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据
+        if (con!=null&&!(con.equals("undefined"))){
+            mapVal.put("con", "%" + con + "%");
+        }
         List<Map<String, Object>> columnList = dilNoticeService.getMarketingNoticeList(mapVal);
         PageListAdd data = columnDataUtil.tableColumnData(apiId, null, columnList);
         return success(data);
@@ -105,9 +108,13 @@ public class DilNoticeController extends BaseRESTfulController {
     public RESTfulResult getCarrierNoticeList(@RequestBody(required = false) Map<String,Object> mapVal,
                                               Integer pageNum,
                                               Integer pageSize,
-                                              Integer apiId){
+                                              Integer apiId,
+                                              String con){
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据
+        if (con!=null&&!(con.equals("undefined"))){
+            mapVal.put("con", "%" + con + "%");
+        }
         List<Map<String, Object>> columnList = dilNoticeService.getCarrierNoticeList(mapVal);
         PageListAdd data = columnDataUtil.tableColumnData(apiId, null, columnList);
         return success(data);
@@ -124,9 +131,13 @@ public class DilNoticeController extends BaseRESTfulController {
     public RESTfulResult getClientNoticeList(@RequestBody(required = false) Map<String,Object> mapVal,
                                                 Integer pageNum,
                                                 Integer pageSize,
-                                                Integer apiId){
+                                                Integer apiId,
+                                             String con){
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据
+        if (con!=null&&!(con.equals("undefined"))){
+            mapVal.put("con", "%" + con + "%");
+        }
         List<Map<String, Object>> columnList = dilNoticeService.getClientNoticeList(mapVal);
         PageListAdd data = columnDataUtil.tableColumnData(apiId, null, columnList);
         return success(data);
@@ -146,6 +157,22 @@ public class DilNoticeController extends BaseRESTfulController {
         return success(result);
     }
 
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-26
+     * @Description:发布通知
+    */
+    @ApiOperation(value="发布通知", notes="根据DilNotice对象发布通知")
+    @ApiImplicitParam(name = "dilNotice", value = "详细实体dilNotice", required = true, dataType = "DilNotice")
+    @PostMapping(value = "/releaseNotice")
+    public RESTfulResult releaseNotice(@RequestBody DilNotice dilNotice){
+        int result = dilNoticeService.releaseNotice(dilNotice);
+        if (result==0){
+            return failed("失败");
+        }
+        return success(result);
+    }
 
 
     /**
@@ -164,6 +191,12 @@ public class DilNoticeController extends BaseRESTfulController {
         return success(result);
     }
 
+    @PostMapping(value = "/updateNoticeStatus")
+    public RESTfulResult updateNoticeStatus(@RequestBody(required = false) Map<String, Object> map){
+        String userId = (String) map.get("userId");
+        int result = dilNoticeService.updateNoticeStatus(userId);
+        return success(result);
+    }
 
     /**
      * 根据id删除通知信息
@@ -240,10 +273,11 @@ public class DilNoticeController extends BaseRESTfulController {
     @ApiOperation(value = "查询通知信息", notes = "根据传过来的orgcode查询")
     @PostMapping(value = "/getNotice")
     public RESTfulResult getNotice(@RequestBody(required = false) Map<String, Object> mapValue){
-        /*String orgcode= (String) mapValue.get("orgcodezs");
-        List<Map<String, Object>> noticeData = dilNoticeService.getNoticeData(orgcode);
-        return success(noticeData);*/
-        return null;
+        //String orgcode= (String) mapValue.get("orgcodezs");
+        String userId=(String) mapValue.get("userId");
+        List<Map<String, Object>> noticeData = dilNoticeService.getNoticeData(userId);
+        return success(noticeData);
+        //return null;
     }
 
 

+ 50 - 1
src/main/java/com/steerinfo/dil/mapper/DilNoticeMapper.java

@@ -36,7 +36,7 @@ public interface DilNoticeMapper extends IBaseMapper<DilNotice, BigDecimal> {
      * @Date:
      * @Description: 根据不同的用户发放通知
     */
-    List<Map<String, Object>> getNoticeData(BigDecimal permission);
+    List<Map<String, Object>> getNoticeData(String userId);
     /**
      * @author:zyf
      * @version:1.0
@@ -44,4 +44,53 @@ public interface DilNoticeMapper extends IBaseMapper<DilNotice, BigDecimal> {
      * @Description: 根据不同的用户发放通知1
      */
     List<Map<String, Object>> getNoticeData1();
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-23
+     * @Description:新增通知(承运商,销售客户,收货客户)
+    */
+    int insertIntoNoticeUser(DilNotice dilNotice);
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-23
+     * @Description:新增通知(所有人)
+    */
+    int insertIntoNoticeUser1(DilNotice dilNotice);
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-23
+     * @Description:更新通知的相关信息
+    */
+    int updateNotice(DilNotice dilNotice);
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-23
+     * @Description:删除与该通知有关用户中间表的信息
+    */
+    int deleteNotice(BigDecimal id);
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-24
+     * @Description:根据通知ID来查询orgcode
+    */
+    String getorgCode(BigDecimal noticeid);
+
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-24
+     * @Description:根据用户id来更新状态
+    */
+    int updatestatus(String userId);
 }

+ 20 - 8
src/main/java/com/steerinfo/dil/model/DilNotice.java

@@ -68,7 +68,7 @@ public class DilNotice implements IBasePO<BigDecimal> {
      * 查看权限状态码(PERMISSION,DECIMAL,38)
      */
     @ApiModelProperty(value="查看权限状态码",required=false)
-    private BigDecimal permission;
+    private String permission;
 
     /**
      * 查看权限状态描述(PERMISSION,DECIMAL,38)
@@ -76,6 +76,17 @@ public class DilNotice implements IBasePO<BigDecimal> {
     @ApiModelProperty(value="查看权限状态码描述",required=false)
     private String permissions;
 
+    @ApiModelProperty(value="存放用户名ID",required=false)
+    private String userId;
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
     private static final long serialVersionUID = 1L;
 
     @Override
@@ -112,6 +123,14 @@ public class DilNotice implements IBasePO<BigDecimal> {
         this.noticeContent = noticeContent == null ? null : noticeContent.trim();
     }
 
+    public String getPermission() {
+        return permission;
+    }
+
+    public void setPermission(String permission) {
+        this.permission = permission;
+    }
+
     public String getInsertUsername() {
         return insertUsername;
     }
@@ -160,13 +179,6 @@ public class DilNotice implements IBasePO<BigDecimal> {
         this.deleted = deleted;
     }
 
-    public BigDecimal getPermission() {
-        return permission;
-    }
-
-    public void setPermission(BigDecimal permission) {
-        this.permission = permission;
-    }
 
     public String getPermissions() {
         return permissions;

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

@@ -25,8 +25,12 @@ public interface IDilNoticeService {
 
     int insertNotice(DilNotice dilNotice);
 
+    int releaseNotice(DilNotice dilNotice);
+
     int updateNotice(DilNotice dilNotice);
 
+    int updateNoticeStatus(String userId);
+
     int deleteNotice(BigDecimal id);
 
     List<Map<String, Object>> getNoticeById(BigDecimal id);

+ 66 - 14
src/main/java/com/steerinfo/dil/service/impl/DilNoticeServiceImpl.java

@@ -78,27 +78,44 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
     @Override
     /*这里是解决前端毛病所妥协的结果,前端拿不到value值,只能拿到name也就是key值,这里在后端强行将key转为value值QAQ*/
     public int insertNotice(DilNotice dilNotice) {
+        int result=0;
         dilNotice.setDeleted(new BigDecimal(0));
         dilNotice.setInsertTime(new Date());
+        dilNotice.setNoticeId(dilNoticeMapper.selectNoticeId());
         if(dilNotice.getPermissions()!=null){
             if(dilNotice.getPermissions().equals("承运商")){
-                dilNotice.setPermission(BigDecimal.valueOf(1));
+                dilNotice.setPermission("chengyunshang");
             }
             else if(dilNotice.getPermissions().equals("销售商")){
-                dilNotice.setPermission(BigDecimal.valueOf(2));
+                dilNotice.setPermission("wuliuyunshubu");
             }
             else if(dilNotice.getPermissions().equals("收货客户")){
-                dilNotice.setPermission(BigDecimal.valueOf(3));
+                dilNotice.setPermission("shouhuokehu");
+            }else{
+                dilNotice.setPermission("qita");
+                dilNoticeMapper.insertSelective(dilNotice);
+                result +=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
+                return result;
             }
         }
+        //需要手动设置发布人
+        /*dilNotice.setInsertUsername("admin");*/
+        dilNoticeMapper.insertSelective(dilNotice);
+        if (result==0){
+            dilNoticeMapper.insertIntoNoticeUser(dilNotice);
+        }
+        return result;
+    }
 
-        {
+    @Override
+    public int releaseNotice(DilNotice dilNotice) {
+        //发布通知
+        if (dilNotice.getPermission()!=null){
 
+        }else {
+            return 0;
         }
-        //需要手动设置发布人
-        /*dilNotice.setInsertUsername("admin");*/
-        dilNotice.setNoticeId(dilNoticeMapper.selectNoticeId());
-        return dilNoticeMapper.insertSelective(dilNotice);
+        return 0;
     }
 
     /**
@@ -106,11 +123,44 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
      * */
     @Override
     public int updateNotice(DilNotice dilNotice) {
-        /*dilNotice.setUpdateTime(new Date());*/
-        /*dilNotice.setUpdateUsername("admin");*/
+        dilNotice.setUpdateTime(new Date());
+        dilNotice.setUpdateUsername("admin");
+        if ("承运商".equals(dilNotice.getPermission())){
+            dilNotice.setPermission("chengyunshang");
+        }else if ("销售商".equals(dilNotice.getPermission())){
+            dilNotice.setPermission("wuliuyunshubu");
+        }else if ("收货用户".equals(dilNotice.getPermission())){
+            dilNotice.setPermission("shouhuokehu");
+        }else {
+            dilNotice.setPermission("qita");
+        }
+        //查询orgcode是否一致
+        String code = dilNoticeMapper.getorgCode(dilNotice.getNoticeId());
+        if (!code.equals(dilNotice.getPermission())){
+            dilNoticeMapper.deleteNotice(dilNotice.getNoticeId());
+            if ("qita".equals(dilNotice.getPermission())){
+                //全部要单独
+                dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
+            }else {
+                dilNoticeMapper.insertIntoNoticeUser(dilNotice);
+            }
+        }
+        //修改中间表
         return dilNoticeMapper.updateByPrimaryKeySelective(dilNotice);
     }
 
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:2022-09-24
+     * @Description:修改用户通知的相关信息
+     */
+    @Override
+    public int updateNoticeStatus(String userId) {
+        return dilNoticeMapper.updatestatus(userId);
+    }
+
+
     /**
      * 删除通知信息
      * */
@@ -118,6 +168,8 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
     public int deleteNotice(BigDecimal id) {
         DilNotice dilNotice = dilNoticeMapper.selectByPrimaryKey(id);
         dilNotice.setDeleted(new BigDecimal(1));
+        //删除中间表信息
+        dilNoticeMapper.deleteNotice(id);
         return dilNoticeMapper.updateByPrimaryKeySelective(dilNotice);
     }
 
@@ -137,9 +189,9 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
      * @Date:
      * @Description: 获取通知信息数据
     */
-    public List<Map<String,Object>> getNoticeData(String orgcode){
+    public List<Map<String,Object>> getNoticeData(String userId){
         List<Map<String, Object>> noticeData=new ArrayList<>();
-        if ("chengyunshang".equals(orgcode)){
+        /*if ("chengyunshang".equals(orgcode)){
             BigDecimal permission=BigDecimal.valueOf(1);
             noticeData = dilNoticeMapper.getNoticeData(permission);
         }else if ("xiaoshougongsi".equals(orgcode)){
@@ -150,8 +202,8 @@ public class DilNoticeServiceImpl  implements IDilNoticeService {
             noticeData = dilNoticeMapper.getNoticeData(permission);
         }else {
             noticeData = dilNoticeMapper.getNoticeData1();
-        }
-        return noticeData;
+        }*/
+        return dilNoticeMapper.getNoticeData(userId);
     }
     /*
      * 获取下拉框

+ 81 - 19
src/main/resources/com/steerinfo/dil/mapper/DilNoticeMapper.xml

@@ -11,7 +11,7 @@
     <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
     <result column="INSERT_UPDATE_REMARK" jdbcType="VARCHAR" property="insertUpdateRemark" />
     <result column="DELETED" jdbcType="DECIMAL" property="deleted" />
-    <result column="PERMISSION" jdbcType="DECIMAL" property="permission" />
+    <result column="PERMISSION" jdbcType="VARCHAR" property="permission" />
   </resultMap>
   <sql id="columns">
     NOTICE_ID, NOTICE_TITLE, NOTICE_CONTENT, INSERT_USERNAME, INSERT_TIME, UPDATE_USERNAME, 
@@ -403,7 +403,10 @@
     DN.INSERT_TIME AS "insertTime",
     DN.INSERT_USERNAME AS "insertUsername"
     FROM DIL_NOTICE DN
-    WHERE DN.DELETED !=1 and (DN.PERMISSION=0 or DN.PERMISSION=1)
+    WHERE DN.DELETED !=1 and (DN.PERMISSION='qita' or DN.PERMISSION='chengyunshang')
+    <if test="con!=null">
+    and DN.NOTICE_TITLE || DN.INSERT_USERNAME like #{con}
+    </if>
     ORDER BY DN.INSERT_TIME DESC
     )
     <where>
@@ -456,7 +459,10 @@
   DN.INSERT_TIME AS "insertTime",
   DN.INSERT_USERNAME AS "insertUsername"
   FROM DIL_NOTICE DN
-  WHERE DN.DELETED !=1 and (DN.PERMISSION=0 or DN.PERMISSION=2)
+  WHERE DN.DELETED !=1 and (DN.PERMISSION='qita' or DN.PERMISSION='wuliuyunshubu')
+  <if test="con!=null">
+    and DN.NOTICE_TITLE || DN.INSERT_USERNAME like #{con}
+  </if>
   ORDER BY DN.INSERT_TIME DESC
   )
   </select>
@@ -473,7 +479,10 @@
           DN.INSERT_TIME AS "insertTime",
           DN.INSERT_USERNAME AS "insertUsername"
         FROM DIL_NOTICE DN
-        WHERE DN.DELETED !=1 and (DN.PERMISSION=0 or DN.PERMISSION=3)
+        WHERE DN.DELETED !=1 and (DN.PERMISSION='qita' or DN.PERMISSION='shouhuokehu')
+        <if test="con!=null">
+         and DN.NOTICE_TITLE || DN.INSERT_USERNAME like #{con}
+        </if>
         ORDER BY DN.INSERT_TIME DESC
       )
   </select>
@@ -486,8 +495,11 @@
       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",
+      decode(DN.PERMISSION,'qita','全部可见',
+      'chengyunshang','承运商',
+      'wuliuyunshubu','销售商',
+      'shouhuokehu','收货客户') "permission"
     FROM DIL_NOTICE DN
     WHERE DN.NOTICE_ID=#{id}
 
@@ -510,17 +522,17 @@
 <!--  /*   DN.INSERT_TIME =  DN.PERMISSION =#{permission} OR DN.PERMISSION =0 AND*/-->
 
   <!--获取信息-->
-  <select id="getNoticeData" parameterType="java.math.BigDecimal" resultType="java.util.Map">
-    select t.NOTICE_TITLE AS "noticetitle",
-    t.NOTICE_CONTENT AS "noticecontent",
-    t.INSERT_USERNAME AS "insertusername",
-    t.INSERT_TIME AS "inserttime",
-    (select count(*) INSERT_USERNAME from DIL_NOTICE
-    where PERMISSION=#{permission} and Deleted =0 or PERMISSION is null) AS "taskAllNum"
-    from DIL_NOTICE t
-    where t.PERMISSION=#{permission}
-    and t.Deleted =0
-    or t.PERMISSION is null
+  <select id="getNoticeData" parameterType="java.lang.String" resultType="java.util.Map">
+    SELECT DN.NOTICE_TITLE AS "noticetitle",
+    DN.NOTICE_CONTENT AS "noticecontent",
+    DN.INSERT_USERNAME AS "insertusername",
+    DN.INSERT_TIME AS "inserttime",
+    (select count(*) from DIL_NOTICE_USERS where STATUS =0
+    and USER_ID=#{userId}) "taskAllNum"
+    FROM DIL_NOTICE_USERS DNU
+    LEFT JOIN DIL_NOTICE DN
+    ON DN.NOTICE_ID=DNU.NOTICE_ID
+    WHERE DNU.USER_ID=#{userId}
   </select>
 
   <!--获取信息-->
@@ -530,9 +542,59 @@
     t.NOTICE_CONTENT AS "noticecontent",
     t.INSERT_USERNAME AS "insertusername",
     t.INSERT_TIME AS "inserttime",
-    (select count(*) INSERT_USERNAME from DIL_NOTICE where PERMISSION is null) AS "taskAllNum"
+    (select count(*) INSERT_USERNAME from DIL_NOTICE where PERMISSION = 0) AS "taskAllNum"
     from DIL_NOTICE t
-    where t.PERMISSION is null
+    where t.PERMISSION = 0
     and t.Deleted =0
   </select>
+
+  <!--向通知与用户中间表存储数据-->
+  <insert id="insertIntoNoticeUser">
+      INSERT INTO DIL_NOTICE_USERS
+      (select DN.NOTICE_ID ,
+              SU.USER_ID,
+              SU.USER_NAME,
+              SU.ORG_CODE,
+              0 "STATUS"
+              from DIL_NOTICE DN ,"SSO".SYS_USER SU
+              WHERE DN.NOTICE_ID=#{noticeId}
+              AND SU.ORG_CODE=#{permission})
+  </insert>
+
+  <insert id="insertIntoNoticeUser1">
+    INSERT INTO DIL_NOTICE_USERS
+      (select DN.NOTICE_ID ,
+              SU.USER_ID,
+              SU.USER_NAME,
+              SU.ORG_CODE,
+              0 "STATUS"
+              from DIL_NOTICE DN ,"SSO".SYS_USER SU
+              WHERE DN.NOTICE_ID=#{noticeId}
+              AND SU.ORG_CODE != 'yunli')
+  </insert>
+  <update id="updateNotice">
+    update DIL_NOTICE
+    set NOTICE_TITLE= #{noticeTitle},
+        NOTICE_CONTENT=#{noticeContent},
+        INSERT_USERNAME=#{insertUsername},
+        PERMISSION=#{permission},
+        UPDATE_USERNAME=#{updateUsername},
+        UPDATE_TIME=#{updateTime}
+        where NOTICE_ID=#{noticeId}
+  </update>
+  <delete id="deleteNotice">
+    delete from DIL_NOTICE_USERS DNU
+    where DNU.notice_id=#{noticeId}
+  </delete>
+  <update id="updatestatus">
+    update DIL_NOTICE_USERS DNU
+    SET STATUS=1
+    WHERE DNU.USER_ID=#{userId}
+  </update>
+  <select id="getorgCode" resultType="java.lang.String">
+    select DN.PERMISSION "orgCode"
+    from DIL_NOTICE DN
+    where  DN.NOTICE_ID=#{noticeid}
+  </select>
+
 </mapper>