gaodd преди 3 години
родител
ревизия
3f67937b69

+ 104 - 0
src/main/java/com/unissoft/interaction/controller/DensityDataController.java

@@ -0,0 +1,104 @@
1
+package com.unissoft.interaction.controller;
2
+
3
+
4
+import java.util.Date;
5
+
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.web.bind.annotation.DeleteMapping;
8
+import org.springframework.web.bind.annotation.PathVariable;
9
+import org.springframework.web.bind.annotation.PostMapping;
10
+import org.springframework.web.bind.annotation.RequestBody;
11
+import org.springframework.web.bind.annotation.RequestMapping;
12
+
13
+import org.springframework.web.bind.annotation.RestController;
14
+
15
+import com.baomidou.mybatisplus.core.metadata.IPage;
16
+import com.unissoft.common.PageParam;
17
+import com.unissoft.common.ResultView;
18
+import com.unissoft.common.SystemLog;
19
+import com.unissoft.interaction.entity.DensityData;
20
+import com.unissoft.interaction.service.DensityDataService;
21
+
22
+import io.swagger.annotations.ApiOperation;
23
+
24
+/**
25
+ * <p>
26
+ *  前端控制器
27
+ * </p>
28
+ *
29
+ * @author MySunshine
30
+ * @since 2022-05-17
31
+ */
32
+@RestController
33
+@RequestMapping("/density-data")
34
+public class DensityDataController {
35
+
36
+	private DensityDataService densityDataService;
37
+
38
+    @Autowired
39
+    public void setDensityDataController(DensityDataService densityDataService) {
40
+        this.densityDataService = densityDataService;
41
+    }
42
+    
43
+    /**
44
+     * 分页查询列表
45
+     * @param pageParam
46
+     * @return
47
+     */
48
+    @SystemLog(operModul = "参数设置", operType = "密度参数", operDesc = "查询分页密度参数")
49
+    @PostMapping("/getPage")
50
+    public ResultView getPage(@RequestBody PageParam pageParam) {
51
+        IPage<DensityData> page = densityDataService.getPage(pageParam);
52
+        return ResultView.success(page);
53
+    }
54
+    
55
+   
56
+
57
+    /**
58
+     * 新增
59
+     * @param densityData
60
+     * @return
61
+     */
62
+    @SystemLog(operModul = "参数设置", operType = "密度参数", operDesc = "密度参数新增")
63
+    @PostMapping("/save")
64
+    public ResultView saveUser(@RequestBody DensityData densityData) {
65
+    	densityData.setEditTime(new Date());
66
+        boolean save = densityDataService.save(densityData);
67
+        if (save)
68
+            return ResultView.success();
69
+        else
70
+            return ResultView.error();
71
+    }
72
+
73
+    /**
74
+     * 修改
75
+     * @param densityData
76
+     * @return
77
+     */
78
+    @SystemLog(operModul = "参数设置", operType = "密度参数", operDesc = "密度参数修改")
79
+    @PostMapping("/update")
80
+    public ResultView updateUser(@RequestBody DensityData densityData) {
81
+        boolean b = densityDataService.updateById(densityData);
82
+        if (b)
83
+            return ResultView.success();
84
+        else
85
+            return ResultView.error();
86
+    }
87
+    
88
+    
89
+    /**
90
+	 * 删除
91
+	 * @param id
92
+	 * @return
93
+	 */
94
+    @SystemLog(operModul = "参数设置", operType = "密度参数", operDesc = "密度参数删除")
95
+    @ApiOperation(value = "根据id删除", notes = "")
96
+    @DeleteMapping("/deleteById/{id}")
97
+    public ResultView deleteById(@PathVariable Integer id) {
98
+    	boolean b = densityDataService.removeById(id);
99
+    	if (b)
100
+            return ResultView.success();
101
+        else
102
+            return ResultView.error();
103
+    }
104
+}

+ 50 - 0
src/main/java/com/unissoft/interaction/entity/DensityData.java

@@ -0,0 +1,50 @@
1
+package com.unissoft.interaction.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import com.baomidou.mybatisplus.annotation.IdType;
5
+import java.util.Date;
6
+import com.baomidou.mybatisplus.annotation.TableId;
7
+import com.baomidou.mybatisplus.annotation.TableField;
8
+import java.io.Serializable;
9
+import io.swagger.annotations.ApiModel;
10
+import io.swagger.annotations.ApiModelProperty;
11
+import lombok.Data;
12
+import lombok.EqualsAndHashCode;
13
+
14
+/**
15
+ * <p>
16
+ * 
17
+ * </p>
18
+ *
19
+ * @author MySunshine
20
+ * @since 2022-05-17
21
+ */
22
+@Data
23
+@EqualsAndHashCode(callSuper = false)
24
+@TableName("density_data")
25
+@ApiModel(value="DensityData对象", description="")
26
+public class DensityData implements Serializable {
27
+
28
+    private static final long serialVersionUID = 1L;
29
+
30
+    @TableId(value = "id", type = IdType.AUTO)
31
+    private Integer id;
32
+
33
+    @ApiModelProperty(value = "仓房")
34
+    @TableField("house_id")
35
+    private Integer houseId;
36
+
37
+    @ApiModelProperty(value = "密度(千克/立方米)")
38
+    @TableField("density")
39
+    private String density;
40
+
41
+    @ApiModelProperty(value = "单位id")
42
+    @TableField("org_id")
43
+    private Integer orgId;
44
+
45
+    @ApiModelProperty(value = "编辑时间")
46
+    @TableField("edit_time")
47
+    private Date editTime;
48
+
49
+
50
+}

+ 16 - 0
src/main/java/com/unissoft/interaction/mapper/DensityDataMapper.java

@@ -0,0 +1,16 @@
1
+package com.unissoft.interaction.mapper;
2
+
3
+import com.unissoft.interaction.entity.DensityData;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+
6
+/**
7
+ * <p>
8
+ *  Mapper 接口
9
+ * </p>
10
+ *
11
+ * @author MySunshine
12
+ * @since 2022-05-17
13
+ */
14
+public interface DensityDataMapper extends BaseMapper<DensityData> {
15
+
16
+}

+ 19 - 0
src/main/java/com/unissoft/interaction/mapper/DensityDataMapper.xml

@@ -0,0 +1,19 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.unissoft.interaction.mapper.DensityDataMapper">
4
+
5
+    <!-- 通用查询映射结果 -->
6
+    <resultMap id="BaseResultMap" type="com.unissoft.interaction.entity.DensityData">
7
+        <id column="id" property="id" />
8
+        <result column="house_id" property="houseId" />
9
+        <result column="density" property="density" />
10
+        <result column="org_id" property="orgId" />
11
+        <result column="edit_time" property="editTime" />
12
+    </resultMap>
13
+
14
+    <!-- 通用查询结果列 -->
15
+    <sql id="Base_Column_List">
16
+        id, house_id, density, org_id, edit_time
17
+    </sql>
18
+
19
+</mapper>

+ 20 - 0
src/main/java/com/unissoft/interaction/service/DensityDataService.java

@@ -0,0 +1,20 @@
1
+package com.unissoft.interaction.service;
2
+
3
+import com.unissoft.common.PageParam;
4
+import com.unissoft.interaction.entity.DensityData;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.service.IService;
7
+
8
+/**
9
+ * <p>
10
+ *  服务类
11
+ * </p>
12
+ *
13
+ * @author MySunshine
14
+ * @since 2022-05-17
15
+ */
16
+public interface DensityDataService extends IService<DensityData> {
17
+
18
+	IPage<DensityData> getPage(PageParam pageParam);
19
+
20
+}

+ 50 - 0
src/main/java/com/unissoft/interaction/service/impl/DensityDataServiceImpl.java

@@ -0,0 +1,50 @@
1
+package com.unissoft.interaction.service.impl;
2
+
3
+import com.unissoft.common.PageParam;
4
+import com.unissoft.interaction.entity.DensityData;
5
+import com.unissoft.interaction.mapper.DensityDataMapper;
6
+import com.unissoft.interaction.service.DensityDataService;
7
+import com.unissoft.parameter.mapper.HardwareParameterMapper;
8
+import com.unissoft.parameter.model.HardwareParameter;
9
+import com.alibaba.fastjson.JSON;
10
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
11
+import com.baomidou.mybatisplus.core.metadata.IPage;
12
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
13
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
14
+
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.stereotype.Service;
17
+import org.springframework.util.StringUtils;
18
+
19
+/**
20
+ * <p>
21
+ *  服务实现类
22
+ * </p>
23
+ *
24
+ * @author MySunshine
25
+ * @since 2022-05-17
26
+ */
27
+@Service
28
+public class DensityDataServiceImpl extends ServiceImpl<DensityDataMapper, DensityData> implements DensityDataService {
29
+
30
+	private DensityDataMapper densityDataMapper;
31
+	@Autowired
32
+	public void setDensityDataService(DensityDataMapper densityDataMapper) {
33
+        this.densityDataMapper = densityDataMapper;
34
+    }
35
+	
36
+	
37
+	@Override
38
+	public IPage<DensityData> getPage(PageParam pageParam) {
39
+		// TODO Auto-generated method stub
40
+		Integer pageIndex = pageParam.getPageIndex();
41
+        Integer pageSize = pageParam.getPageSize();
42
+        // 分页对象
43
+        IPage<DensityData> page = new Page<>(pageIndex, pageSize);
44
+        
45
+        QueryWrapper<DensityData> ew = new QueryWrapper<>();
46
+       
47
+        return densityDataMapper.selectPage(page, ew);
48
+	}
49
+
50
+}

+ 31 - 19
src/main/java/com/unissoft/interaction/service/impl/TeDataServiceImpl.java

@@ -3,9 +3,11 @@ package com.unissoft.interaction.service.impl;
3 3
 import com.alibaba.fastjson.JSONArray;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.unissoft.interaction.algorithm.CylinderAlg;
6
+import com.unissoft.interaction.entity.DensityData;
6 7
 import com.unissoft.interaction.entity.ReMsg;
7 8
 import com.unissoft.interaction.entity.STask;
8 9
 import com.unissoft.interaction.entity.TeData;
10
+import com.unissoft.interaction.mapper.DensityDataMapper;
9 11
 import com.unissoft.interaction.mapper.ReMsgMapper;
10 12
 import com.unissoft.interaction.mapper.STaskMapper;
11 13
 import com.unissoft.interaction.mapper.TeDataMapper;
@@ -47,16 +49,6 @@ public class TeDataServiceImpl implements TeDataService {
47 49
     private TeDataMapper teDataMapper;
48 50
     private ReMsgMapper reMsgMapper;
49 51
     
50
-    @Resource
51
-    private NBasicEdgeMapper nBasicEdgeMapper;
52
-    @Resource
53
-    private PointDataMapper pointDataMapper;
54
-    @Resource
55
-    private HardwareParameterMapper hardwareParameterMapper;
56
-    @Resource
57
-    private OrgInfoMapper orgInfoMapper;
58
-
59
-
60 52
     @Autowired
61 53
     public void setsTaskMapper(STaskMapper sTaskMapper) {
62 54
         this.sTaskMapper = sTaskMapper;
@@ -71,6 +63,19 @@ public class TeDataServiceImpl implements TeDataService {
71 63
     public void setReMsgMapper(ReMsgMapper reMsgMapper) {
72 64
         this.reMsgMapper = reMsgMapper;
73 65
     }
66
+    
67
+    
68
+    @Resource
69
+    private NBasicEdgeMapper nBasicEdgeMapper;
70
+    @Resource
71
+    private PointDataMapper pointDataMapper;
72
+    @Resource
73
+    private HardwareParameterMapper hardwareParameterMapper;
74
+    @Resource
75
+    private OrgInfoMapper orgInfoMapper;
76
+    @Resource
77
+    private DensityDataMapper densityDataMapper;
78
+    
74 79
 
75 80
     /**
76 81
      * todo-----------暂时不用
@@ -288,16 +293,24 @@ public class TeDataServiceImpl implements TeDataService {
288 293
      */
289 294
     public void  addNBasicEdge(double lkVolume,String taskId){
290 295
     	NBasicEdge nBasicEdge = new NBasicEdge(); 
291
-    	String density = "500"; //密度 千克/立方米
296
+    	
297
+    	String houseId = taskId.split(",")[0];//仓房id
298
+    	
299
+    	//获取密度
300
+    	QueryWrapper<DensityData> densityQueryWrapper = new QueryWrapper<>();
301
+        List<DensityData> densityDataList = null;
302
+        densityQueryWrapper.eq("house_id", houseId);
303
+        densityDataList = densityDataMapper.selectList(densityQueryWrapper);
304
+        String density = "0"; //密度 千克/立方米
305
+        if(densityDataList.size()>0){
306
+        	density = densityDataList.get(0).getDensity();
307
+        }
292 308
 		//质量
293 309
 	    BigDecimal big_density = new BigDecimal(density); 
294 310
 	    BigDecimal big_lkVolume = new BigDecimal(lkVolume); //保留两位小数的体积
295 311
 	    BigDecimal quality = big_density.multiply(big_lkVolume).divide(new BigDecimal(1000));
296 312
 		nBasicEdge.setLkWeight(Double.parseDouble(quality+""));//单位 吨
297 313
 		
298
-		/*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
299
-		Date beginTime = sdf.parse(startTime);*/
300
-		
301 314
 		QueryWrapper<TeData> queryWrapper = new QueryWrapper<>();
302 315
         List<TeData> teDataList = null;
303 316
         queryWrapper.eq("taskID", taskId);
@@ -308,7 +321,6 @@ public class TeDataServiceImpl implements TeDataService {
308 321
         }
309 322
         
310 323
         
311
-        String houseId = taskId.split(",")[0];//仓房id
312 324
         //获取仓房信息
313 325
     	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
314 326
     	
@@ -323,11 +335,11 @@ public class TeDataServiceImpl implements TeDataService {
323 335
 		
324 336
 		
325 337
 		//取上次的数据 如果大于上次的数据 则入库 否则出库
326
-		QueryWrapper<NBasicEdge> queryWrapper1 = new QueryWrapper<>();
327
-        queryWrapper1.eq("fk", orgInfo.getId());
328
-        queryWrapper1.orderByDesc("id");
338
+		QueryWrapper<NBasicEdge> nQueryWrapper = new QueryWrapper<>();
339
+		nQueryWrapper.eq("fk", orgInfo.getId());
340
+		nQueryWrapper.orderByDesc("id");
329 341
         // 分页对象
330
-        List<NBasicEdge> nList = nBasicEdgeMapper.selectList(queryWrapper1);
342
+        List<NBasicEdge> nList = nBasicEdgeMapper.selectList(nQueryWrapper);
331 343
         double v = 0 ;
332 344
         if(nList.size()>0){
333 345
              v =Double.parseDouble(nList.get(0).getLkVolume());