Преглед на файлове

开门的https接口调用

wutt преди 5 години
родител
ревизия
56a85558d1

+ 11 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/IdeaCommentServiceImpl.java

@@ -3,17 +3,21 @@ package com.hssx.pcbms.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.hssx.pcbms.entity.Idea;
 import com.hssx.pcbms.entity.IdeaComment;
+import com.hssx.pcbms.entity.Score;
 import com.hssx.pcbms.entity.User;
 import com.hssx.pcbms.mapper.IdeaCommentMapper;
 import com.hssx.pcbms.mapper.IdeaMapper;
+import com.hssx.pcbms.mapper.ScoreMapper;
 import com.hssx.pcbms.mapper.UserMapper;
 import com.hssx.pcbms.service.IdeaCommentService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hssx.pcbms.service.ScoreService;
 import com.hssx.pcbms.util.HttpRespMsg;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * @author 吴涛涛
@@ -28,6 +32,8 @@ public class IdeaCommentServiceImpl extends ServiceImpl<IdeaCommentMapper, IdeaC
     private IdeaMapper ideaMapper;
     @Resource
     private UserMapper userMapper;
+    @Resource
+    private ScoreMapper scoreMapper;
 
     @Override
     public HttpRespMsg addOrUpdate(IdeaComment ideaComment,Double score,Integer scoreId) {
@@ -42,6 +48,11 @@ public class IdeaCommentServiceImpl extends ServiceImpl<IdeaCommentMapper, IdeaC
             idea.setIsEvaluated(1);
             idea.setScoreId(scoreId);
             ideaMapper.update(idea,new QueryWrapper<Idea>().eq("id",ideaComment.getIdeaId()));
+            List<Idea> ideaList = ideaMapper.selectList(new QueryWrapper<Idea>().eq("score_id", scoreId));
+            Score scoreEntiry = new Score();
+            scoreEntiry.setScoreId(scoreId);
+            scoreEntiry.setIdeaScore(ideaList.stream().mapToDouble(Idea::getScore).sum()+0);
+            scoreMapper.update(scoreEntiry,new QueryWrapper<Score>().eq("score_id",scoreId));
         } else {
             //修改评论
             Idea idea = ideaMapper.selectOne(new QueryWrapper<Idea>().eq("id", ideaComment.getIdeaId()));

+ 5 - 1
pcbms/src/main/java/com/hssx/pcbms/service/impl/RackDataServiceImpl.java

@@ -39,10 +39,14 @@ public class RackDataServiceImpl extends ServiceImpl<RackDataMapper, RackData> i
         rackDataMapper.update(rackData,new QueryWrapper<RackData>().eq("goods_id",rackData.getGoodsId()));
         //调用远程开门接口
         try {
-            String s = HttpKit.get(url+"?"+rackData.getGoodsId(), true);
+            System.out.println("开始调用开门接口");
+            //goodsId
+            System.out.println("访问的路径"+url+"?goodsId="+rackData.getGoodsId());
+            String s = HttpKit.get(url+"?goodsId="+rackData.getGoodsId());
             //取出多余的\
             s = StringEscapeUtils.unescapeJava(s);
             JSONObject json = (JSONObject) JSON.parse(s);
+            System.out.println("调用成功,返回的json"+json);
             if(!json.containsValue("ok")){
                 msg.setError("开门失败");
                 return msg;

+ 3 - 3
pcbms/src/main/resources/application-prod.properties

@@ -16,7 +16,7 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 # 云模服务器对应的数据库
 #spring.datasource.url=jdbc:mysql://118.190.47.230:3306/cloud_model?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
 # 我们测试的自己服务器数据库
-spring.datasource.url=jdbc:mysql://118.190.47.230:3306/lishui_app?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+spring.datasource.url=jdbc:mysql://localhost:3306/lishui_app?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
 spring.datasource.username=root
 spring.datasource.password=p011430seya1026
 #spring.datasource.druid.test-on-borrow=true
@@ -54,6 +54,6 @@ spring.datasource.hikari.max-lifetime =30000
 spring.datasource.hikari.connection-test-query=SELECT 1
 ########################################################################################################
 # 日志
-logging.path=E:/staticproject/cloudmodel/
-open.door.url=https://118.190.47.230:8080/racksystem/openDoor.do
+logging.path=E:/staticproject/lsbms/
+open.door.url=http://localhost:8080/racksystem/openDoor.do
 

+ 2 - 2
pcbms/src/main/resources/application.properties

@@ -1,6 +1,6 @@
 # ####################################################################################################
 # 督昢傷饜离
-server.port=8091
+server.port=8098
 server.servlet.context-path=/
 server.tomcat.uri-encoding=UTF-8
 server.tomcat.max-http-post-size=-1
@@ -63,5 +63,5 @@ spring.datasource.hikari.max-lifetime =30000
 spring.datasource.hikari.connection-test-query=SELECT 1
 logging.path=E:/
 ##################羲藷諉諳腔華硊####################################################
-open.door.url=https://118.190.47.230:8080/racksystem/openDoor.do
+open.door.url=http://localhost:8080/racksystem/openDoor.do
 

+ 12 - 8
pcbms/src/main/resources/mapper/GoodsMapper.xml

@@ -43,8 +43,8 @@
         <result column="pic" property="pic"/>
         <result column="service_life" property="serviceLife"/>
         <result column="next_indate" property="nextIndate"/>
-        <collection property="goodsNos" select="selectGoodsNoByGoodsId" javaType="java.util.List" column="{goodId = id}"
-                    ofType="com.hssx.pcbms.entity.GoodsNo">
+        <collection property="goodsNosVO" select="selectGoodsNoByGoodsId" javaType="java.util.List" column="{goodId = id}"
+                    ofType="com.hssx.pcbms.entity.vo.GoodsNoVO">
         </collection>
     </resultMap>
     <!-- 我的资产查询映射结果 -->
@@ -160,8 +160,8 @@
         </where>
         order by id desc
     </select>
-    <resultMap id="GoodsNoMap" type="com.hssx.pcbms.entity.GoodsNo">
-        <id column="id" property="id" />
+    <resultMap id="GoodsNoMap" type="com.hssx.pcbms.entity.vo.GoodsNoVO">
+        <id column="nid" property="id"/>
         <result column="model_no" property="modelNo" />
         <result column="division_code" property="divisionCode" />
         <result column="suffix_code" property="suffixCode" />
@@ -207,14 +207,18 @@
         <result column="column_place" property="columnPlace" />
         <result column="region" property="region" />
         <result column="is_rack" property="isRack" />
+        <result column="username" property="username" />
+        <result column="phone" property="phone" />
     </resultMap>
     <select id="selectGoodsNoByGoodsId" resultMap="GoodsNoMap">
         select
-            id, model_no, state,indate, goods_id,user_id, update_indate,
-            is_maintain, good_sn_no,
-            label_id,model_id, u_bit_num, current_state, alarm_level,is_rack
+            gn.id, gn.model_no, gn.state,gn.indate, gn.goods_id,gn.user_id, gn.update_indate,
+            gn.is_maintain, gn.good_sn_no,gn.user_id,u.name username,gn.is_maintain,u.phone,
+            gn.label_id,gn.model_id, gn.u_bit_num, gn.current_state, gn.alarm_level,gn.is_rack
         from
-            goods_no
+        goods_no gn
+        left join user u
+        on u.id = gn.user_id
         where
             goods_id = #{goodId}
     </select>