Ver Fonte

文档列表

há 5 anos atrás
pai
commit
88c43a2b4c

+ 1 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/constant/Constant.java

@@ -40,6 +40,7 @@ public class Constant {
     public static final String MAINTAIN_NOTICE_TEMPLATE_ID = "VcU9E2f3Nn4uR6S1z57VBaLeBAhEO4vfivo3Tug_BKE";//保养通知模板id
     public static final String WECHAT_SECRET = "473ee2fab33e6d8a885800403d777581";//secret
     public static final String WECHAT_APPID = "wx42c0f9d19a4756a7";//appId
+    public static final String PLAN_TYPE = "保养类型";//appId
 //    public static void main(String[] args){
 //        System.out.println("222222");
 //        String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="

+ 19 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldController.java

@@ -12,6 +12,10 @@ import com.hssx.cloudmodel.util.PageUtil;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -24,6 +28,9 @@ import java.util.List;
  */
 @Controller
 @RequestMapping("/mould")
+@Component
+@Configuration      //1.主要用于标记配置类,兼备Component的效果。
+@EnableScheduling
 public class MouldController {
     @Autowired
     private MouldService mouldService;
@@ -95,5 +102,17 @@ public class MouldController {
         HttpRespMsg msg = mouldService.getMoildDetail(mouldVO);
         return msg;
     }
+
+    /**
+     * 模具保养提醒
+     */
+    @ApiOperation("模具保养提醒")
+    @RequestMapping("/maintenanceReminder")
+    @ResponseBody
+    @Scheduled(cron = "0/5 * * * * ?")//配置时间点触发
+    public HttpRespMsg maintenanceReminder() throws Exception {
+        HttpRespMsg msg = mouldService.maintenanceReminder();
+        return msg;
+    }
 }
 

+ 19 - 19
cloud-model/src/main/java/com/hssx/cloudmodel/controller/NewsNoticeUserController.java

@@ -26,25 +26,25 @@ import javax.servlet.http.HttpServletResponse;
 @Controller
 @RequestMapping("/newsnoticeuser")
 public class NewsNoticeUserController {
-    @Autowired
-    private NewsNoticeService newsNoticeService;
-
-    /**
-     * 消息通知列表
-     * 默认显示五条的参数:token 登陆者的用户凭证,flag = 0,(默认显示最近五条)
-     * 查看全部时传的参数:token 登陆者的用户凭证,flag = 0,pageNum 当前页码,pageSize 每页条数,
-     * (筛选字段:notice_type 0-审批,1-告警,2-保养)(默认不传)
-     * @return
-     */
-    @ApiOperation("消息通知列表")
-    @RequestMapping("/list")
-    @ResponseBody
-    public HttpRespMsg deleteRole(NewsNotice newsNotice, HttpServletRequest request,String token,
-                                  HttpServletResponse response, PageUtil page,Integer flag) {
-        HttpRespMsg msg = new HttpRespMsg();
-        msg = newsNoticeService.pageList(newsNotice,page,flag,token);
-        return msg;
-    }
+//    @Autowired
+//    private NewsNoticeService newsNoticeService;
+//
+//    /**
+//     * 消息通知列表
+//     * 默认显示五条的参数:token 登陆者的用户凭证,flag = 0,(默认显示最近五条)
+//     * 查看全部时传的参数:token 登陆者的用户凭证,flag = 0,pageNum 当前页码,pageSize 每页条数,
+//     * (筛选字段:notice_type 0-审批,1-告警,2-保养)(默认不传)
+//     * @return
+//     */
+//    @ApiOperation("消息通知列表")
+//    @RequestMapping("/list")
+//    @ResponseBody
+//    public HttpRespMsg deleteRole(NewsNotice newsNotice, HttpServletRequest request,String token,
+//                                  HttpServletResponse response, PageUtil page,Integer flag) {
+//        HttpRespMsg msg = new HttpRespMsg();
+//        msg = newsNoticeService.pageList(newsNotice,page,flag,token);
+//        return msg;
+//    }
 
 }
 

+ 16 - 4
cloud-model/src/main/java/com/hssx/cloudmodel/entity/User.java

@@ -6,8 +6,6 @@ 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;
 
 /**
@@ -16,7 +14,7 @@ import java.io.Serializable;
  * </p>
  *
  * @author 吴涛涛
- * @since 2019-07-31
+ * @since 2019-08-12
  */
 @TableName("tb_user")
 public class User extends Model<User> {
@@ -99,7 +97,6 @@ public class User extends Model<User> {
      * 创建时间
      */
     @TableField("indate")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
     /**
@@ -120,6 +117,12 @@ public class User extends Model<User> {
     @TableField("subordinate_type")
     private Integer subordinateType;
 
+    /**
+     * 微信平台的唯一身份
+     */
+    @TableField("openid")
+    private String openid;
+
 
     public Integer getId() {
         return id;
@@ -249,6 +252,14 @@ public class User extends Model<User> {
         this.subordinateType = subordinateType;
     }
 
+    public String getOpenid() {
+        return openid;
+    }
+
+    public void setOpenid(String openid) {
+        this.openid = openid;
+    }
+
     @Override
     protected Serializable pkVal() {
         return this.id;
@@ -273,6 +284,7 @@ public class User extends Model<User> {
         ", headImgurl=" + headImgurl +
         ", teamName=" + teamName +
         ", subordinateType=" + subordinateType +
+        ", openid=" + openid +
         "}";
     }
 }

+ 1 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/vo/MouldEquipmentVO.java

@@ -17,6 +17,7 @@ public class MouldEquipmentVO extends MouldEquipment {
     private String emergencyContent;//告警内容
     private String area;//所在科室
     private String planType;//计划类型
+    private String name;
     /**
      * 模具编号
      */

+ 2 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/MouldService.java

@@ -19,4 +19,6 @@ public interface MouldService extends IService<Mould> {
     HttpRespMsg addAndUpdateMould(Mould mould, User user);
 
     HttpRespMsg getMoildDetail(MouldVO mould);
+
+    HttpRespMsg maintenanceReminder() throws Exception;
 }

+ 29 - 2
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldServiceImpl.java

@@ -53,6 +53,8 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
     ProjectApproveMapper projectApproveMapper;
     @Resource
     CustomCompanyMapper customCompanyMapper;
+    @Resource
+    CompanyMapper companyMapper;
 
     @Override
     public HttpRespMsg addAndUpdateMould(Mould mould, User user) {
@@ -61,6 +63,8 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
             //修改
             Mould m = mouldMapper.selectOne(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
             if ((m != null && m.getId() == mould.getId()) || m == null) {
+                Company company = companyMapper.selectById(mould.getProduceCompanyId());
+                mould.setArea(company.getCompanyAddress());
                 mouldMapper.updateById(mould);
             } else {
                 msg.setError("当前模具编号已存在,请重新输入其他模具编号");
@@ -148,6 +152,29 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
         return msg;
     }
 
+    @Override
+    public HttpRespMsg maintenanceReminder() throws Exception {
+        HttpRespMsg msg = new HttpRespMsg();
+        //查询所有被分配到项目的模具
+        List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>().isNotNull("project_id"));
+        for (Mould mould : moulds) {
+            if(mould.getInitialModulus()<mould.getRunTimes()){
+                //提示保养,向模具资产方人员公众号推送消息
+                User user = userMapper.selectOne(new QueryWrapper<User>().eq("parent_id", Constant.SYS_ID).eq("company_id", mould.getCompanyId()));
+                MouldEquipmentVO mouldEquipmentVO = new MouldEquipmentVO();
+                mouldEquipmentVO.setPlanType(Constant.PLAN_TYPE);
+                mouldEquipmentVO.setArea(mould.getArea());
+                mouldEquipmentVO.setName(mould.getModelName());
+                msg = sendMaintainTemplateMessage(Constant.MAINTAIN_NOTICE_TEMPLATE_ID,user.getOpenid(),Constant.WECHAT_APPID,Constant.WECHAT_SECRET,mouldEquipmentVO);
+                //添加通知消息
+                Project project = projectMapper.selectById(mould.getProjectId());
+                //查询到参与该项目的人
+
+            }
+        }
+        return null;
+    }
+
     //告警模板推送通用接口
 
     /**
@@ -245,9 +272,9 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
             data.put("keyword2", value2);
             value3.put("value", sdf.format(new Date()));
             data.put("keyword3", value3);
-            value4.put("value", mouldEquipmentVO.getEmergencyContent());
+            value4.put("value", mouldEquipmentVO.getPlanType());
             data.put("keyword4", value4);
-            remark.put("value", "给水泵内燃力不足");
+            remark.put("value", "模具初始模次不满足运行了");
             data.put("remark", remark);
             wechat.setData(data);
             String jsonString = JSONObject.toJSONString(wechat);

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/util/CodeGenerator.java

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

+ 6 - 6
cloud-model/src/main/resources/mapper/UserMapper.xml

@@ -20,13 +20,9 @@
         <result column="head_imgurl" property="headImgurl" />
         <result column="team_name" property="teamName" />
         <result column="subordinate_type" property="subordinateType" />
+        <result column="openid" property="openid" />
     </resultMap>
 
-    <!-- 通用查询结果列 -->
-    <sql id="Base_Column_List">
-        id, account, username, password, mobile, role_type, company_id, parent_id, sex, role_name, work_state, is_disable, indate, head_imgurl, team_name, subordinate_type
-    </sql>
-
     <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.UserVO">
         <id column="id" property="id" />
         <result column="account" property="account" />
@@ -47,6 +43,11 @@
         <result column="subordinate_type" property="subordinateType" />
     </resultMap>
 
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, account, username, password, mobile, role_type, company_id, parent_id, sex, role_name, work_state, is_disable, indate, head_imgurl, team_name, subordinate_type, openid
+    </sql>
+
     <select id="selectListByCondition" resultMap="BaseResultMapVO">
         SELECT
         u.id id, u.account account, u.username username, u.password password, u.mobile mobile, u.role_type role_type, u.company_id company_id, c.`company_name` company_name,
@@ -73,5 +74,4 @@
         </where>
         Order by u.id desc
     </select>
-
 </mapper>