瀏覽代碼

定时任务处理维护资产(0)

5 年之前
父節點
當前提交
92a28085dd

+ 1 - 0
pcbms/src/main/java/com/hssx/pcbms/constant/Constant.java

@@ -10,5 +10,6 @@ public class Constant {
     public static final String HANDLE_CONTENT = "将状态 oldState 改为 newState ";//处理资产类容前缀
     public static final String APP_ID = "";//appid
     public static final String SCORING_DEADLINE_CODE = "scoringDeadline";//打分日期截止
+    public static final String GOODS_MATAIN_CONTENT = "资产: name,num 需要维护。";
 
 }

+ 21 - 0
pcbms/src/main/java/com/hssx/pcbms/controller/NewsNoticeController.java

@@ -0,0 +1,21 @@
+package com.hssx.pcbms.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+@RestController
+@RequestMapping("/news-notice")
+public class NewsNoticeController {
+
+}
+

+ 21 - 0
pcbms/src/main/java/com/hssx/pcbms/controller/NewsNoticeUserController.java

@@ -0,0 +1,21 @@
+package com.hssx.pcbms.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+@RestController
+@RequestMapping("/news-notice-user")
+public class NewsNoticeUserController {
+
+}
+

+ 3 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/InstitutionFile.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 
 /**
@@ -47,6 +49,7 @@ public class InstitutionFile extends Model<InstitutionFile> {
      * 制度文件保存的日期
      */
     @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
 

+ 126 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/NewsNotice.java

@@ -0,0 +1,126 @@
+package com.hssx.pcbms.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+public class NewsNotice extends Model<NewsNotice> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 消息盒子表主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 资产名称(只对资产有效)
+     */
+    @TableField("raf_name")
+    private String rafName;
+
+    /**
+     * 引用的外部表id type=0 资产id
+     */
+    @TableField("ref_id")
+    private Integer refId;
+
+    /**
+     * 消息提醒类型0-维护,1-打分
+     */
+    @TableField("notice_type")
+    private Integer noticeType;
+
+    /**
+     * 内容
+     */
+    @TableField("content")
+    private String content;
+
+    /**
+     * 时间
+     */
+    @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime indate;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getRafName() {
+        return rafName;
+    }
+
+    public void setRafName(String rafName) {
+        this.rafName = rafName;
+    }
+
+    public Integer getRefId() {
+        return refId;
+    }
+
+    public void setRefId(Integer refId) {
+        this.refId = refId;
+    }
+
+    public Integer getNoticeType() {
+        return noticeType;
+    }
+
+    public void setNoticeType(Integer noticeType) {
+        this.noticeType = noticeType;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public LocalDateTime getIndate() {
+        return indate;
+    }
+
+    public void setIndate(LocalDateTime indate) {
+        this.indate = indate;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+    @Override
+    public String toString() {
+        return "NewsNotice{" +
+        "id=" + id +
+        ", rafName=" + rafName +
+        ", refId=" + refId +
+        ", noticeType=" + noticeType +
+        ", content=" + content +
+        ", indate=" + indate +
+        "}";
+    }
+}

+ 92 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/NewsNoticeUser.java

@@ -0,0 +1,92 @@
+package com.hssx.pcbms.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+public class NewsNoticeUser extends Model<NewsNoticeUser> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 消息通知者表主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 通知者id
+     */
+    @TableField("user_id")
+    private Integer userId;
+
+    /**
+     * 是否已读 0-未读,1-已读
+     */
+    @TableField("is_read")
+    private Integer isRead;
+
+    /**
+     * 消息通知表id
+     */
+    @TableField("news_id")
+    private Integer newsId;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getIsRead() {
+        return isRead;
+    }
+
+    public void setIsRead(Integer isRead) {
+        this.isRead = isRead;
+    }
+
+    public Integer getNewsId() {
+        return newsId;
+    }
+
+    public void setNewsId(Integer newsId) {
+        this.newsId = newsId;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+    @Override
+    public String toString() {
+        return "NewsNoticeUser{" +
+        "id=" + id +
+        ", userId=" + userId +
+        ", isRead=" + isRead +
+        ", newsId=" + newsId +
+        "}";
+    }
+}

+ 3 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/User.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 
 /**
@@ -59,6 +61,7 @@ public class User extends Model<User> {
      * 创建时间
      */
     @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
     /**

+ 16 - 0
pcbms/src/main/java/com/hssx/pcbms/mapper/NewsNoticeMapper.java

@@ -0,0 +1,16 @@
+package com.hssx.pcbms.mapper;
+
+import com.hssx.pcbms.entity.NewsNotice;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+public interface NewsNoticeMapper extends BaseMapper<NewsNotice> {
+
+}

+ 16 - 0
pcbms/src/main/java/com/hssx/pcbms/mapper/NewsNoticeUserMapper.java

@@ -0,0 +1,16 @@
+package com.hssx.pcbms.mapper;
+
+import com.hssx.pcbms.entity.NewsNoticeUser;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+public interface NewsNoticeUserMapper extends BaseMapper<NewsNoticeUser> {
+
+}

+ 2 - 0
pcbms/src/main/java/com/hssx/pcbms/mapper/UserMapper.java

@@ -23,4 +23,6 @@ public interface UserMapper extends BaseMapper<User> {
     List<UserVO> selectListByCondition(@Param("userVO") UserVO userVO);
 
     List<DepartmentVO> selectDeptUserListByCondition(UserVO userVO);
+
+    List<User> selectOperateUsersListByCondition();
 }

+ 16 - 0
pcbms/src/main/java/com/hssx/pcbms/service/NewsNoticeService.java

@@ -0,0 +1,16 @@
+package com.hssx.pcbms.service;
+
+import com.hssx.pcbms.entity.NewsNotice;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+public interface NewsNoticeService extends IService<NewsNotice> {
+
+}

+ 16 - 0
pcbms/src/main/java/com/hssx/pcbms/service/NewsNoticeUserService.java

@@ -0,0 +1,16 @@
+package com.hssx.pcbms.service;
+
+import com.hssx.pcbms.entity.NewsNoticeUser;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+public interface NewsNoticeUserService extends IService<NewsNoticeUser> {
+
+}

+ 28 - 2
pcbms/src/main/java/com/hssx/pcbms/service/impl/GoodsServiceImpl.java

@@ -17,6 +17,7 @@ import com.hssx.pcbms.service.MaintainRecordService;
 import com.hssx.pcbms.service.OperateRecordService;
 import com.hssx.pcbms.util.*;
 import com.sun.deploy.net.HttpResponse;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -26,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Date;
@@ -40,6 +42,7 @@ import java.util.List;
  * @since 2019-10-25
  */
 @Service
+@Slf4j
 public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
     @Resource
     private GoodsMapper goodsMapper;
@@ -61,6 +64,10 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     private MaintainRecordMapper maintainRecordMapper;
     @Resource
     private GoodsTagsMapper goodsTagsMapper;
+    @Resource
+    private NewsNoticeMapper newsNoticeMapper;
+    @Resource
+    private NewsNoticeUserMapper newsNoticeUserMapper;
 
     @Override
     public HttpRespMsg add(GoodsVO goodsVO) {
@@ -435,8 +442,27 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
 
     @Override
     public HttpRespMsg goodsMaintainChecking(Goods goods, HttpServletResponse response) {
-        List<Goods> goodsLists = goodsMapper.selectList(new QueryWrapper<>());
-
+        log.info("处理维护资产的定时任务启动了");
+//        List<Goods> goodsLists = goodsMapper.selectList(new QueryWrapper<>());
+        List<GoodsVO> goodsLists = goodsMapper.getListBycondition(null, null, null);
+        String nowDate = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDate.now());
+        for (GoodsVO good : goodsLists) {
+            if(nowDate.equals(good.getNextIndate())){
+                GoodsNo no = new GoodsNo();
+                no.setGoodsId(good.getId());
+                no.setIsMaintain(1);
+                //此处利用update配合修改条件和条件构造器来实现批量修改数据
+                goodsNoMapper.update(no, new QueryWrapper<GoodsNo>().eq("goods_id", good.getId()));
+                List<User> users = userMapper.selectOperateUsersListByCondition();
+                //条件通知消息
+                NewsNotice newsNotice = new NewsNotice();
+                String content = Constant.GOODS_MATAIN_CONTENT;
+                content = content.replace("name",good.getName()).replace("num",good.getGoodsNos().size()+good.getUnit());
+                newsNotice.setContent(content);
+                newsNoticeMapper.insert(newsNotice);
+            }
+            
+        }
         return null;
     }
 

+ 20 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/NewsNoticeServiceImpl.java

@@ -0,0 +1,20 @@
+package com.hssx.pcbms.service.impl;
+
+import com.hssx.pcbms.entity.NewsNotice;
+import com.hssx.pcbms.mapper.NewsNoticeMapper;
+import com.hssx.pcbms.service.NewsNoticeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+@Service
+public class NewsNoticeServiceImpl extends ServiceImpl<NewsNoticeMapper, NewsNotice> implements NewsNoticeService {
+
+}

+ 20 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/NewsNoticeUserServiceImpl.java

@@ -0,0 +1,20 @@
+package com.hssx.pcbms.service.impl;
+
+import com.hssx.pcbms.entity.NewsNoticeUser;
+import com.hssx.pcbms.mapper.NewsNoticeUserMapper;
+import com.hssx.pcbms.service.NewsNoticeUserService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-11-06
+ */
+@Service
+public class NewsNoticeUserServiceImpl extends ServiceImpl<NewsNoticeUserMapper, NewsNoticeUser> implements NewsNoticeUserService {
+
+}

+ 1 - 1
pcbms/src/main/java/com/hssx/pcbms/util/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("department");
+        strategy.setInclude("news_notice","news_notice_user");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 20 - 0
pcbms/src/main/resources/mapper/NewsNoticeMapper.xml

@@ -0,0 +1,20 @@
+<?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.hssx.pcbms.mapper.NewsNoticeMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.hssx.pcbms.entity.NewsNotice">
+        <id column="id" property="id" />
+        <result column="raf_name" property="rafName" />
+        <result column="ref_id" property="refId" />
+        <result column="notice_type" property="noticeType" />
+        <result column="content" property="content" />
+        <result column="indate" property="indate" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, raf_name, ref_id, notice_type, content, indate
+    </sql>
+
+</mapper>

+ 18 - 0
pcbms/src/main/resources/mapper/NewsNoticeUserMapper.xml

@@ -0,0 +1,18 @@
+<?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.hssx.pcbms.mapper.NewsNoticeUserMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.hssx.pcbms.entity.NewsNoticeUser">
+        <id column="id" property="id" />
+        <result column="user_id" property="userId" />
+        <result column="is_read" property="isRead" />
+        <result column="news_id" property="newsId" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, user_id, is_read, news_id
+    </sql>
+
+</mapper>

+ 12 - 0
pcbms/src/main/resources/mapper/UserMapper.xml

@@ -77,4 +77,16 @@
         LEFT JOIN sys_role sr
         ON sr.id = ur.role_id
     </select>
+    
+    <select id="selectOperateUsersListByCondition" resultMap="BaseResultMap">
+        select
+            u.id,u.head_url,u.name
+        from
+            USER u
+        LEFT JOIN user_role ur
+        ON u.id = ur.user_id
+        LEFT JOIN sys_role sr
+        ON sr.id = ur.role_id
+        where sr.id=2
+    </select>
 </mapper>