From e0613d9a7d3047fadd97ce9ee9012b68ee829801 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 11 Jul 2022 15:57:50 +0800
Subject: [PATCH] 溯源扫描基础接口新增,统计查询接口新增,用户农场绑定,地块农场绑定
---
src/main/java/org/springblade/modules/traceability/service/impl/SweepRecordServiceImpl.java | 52 +++++
src/main/java/org/springblade/modules/traceability/mapper/SweepRecordMapper.java | 34 +++
src/main/java/org/springblade/modules/lang/entity/Land.java | 6
src/main/java/org/springblade/modules/traceability/entity/SweepRecord.java | 48 +++++
src/main/java/org/springblade/modules/traceability/service/SweepRecordService.java | 32 +++
src/main/java/org/springblade/modules/system/entity/User.java | 5
src/main/java/org/springblade/modules/lang/mapper/LandMapper.xml | 16 +
src/main/java/org/springblade/modules/traceability/mapper/SweepRecordMapper.xml | 49 +++++
src/main/java/org/springblade/modules/traceability/controller/SweepRecordController.java | 121 +++++++++++++
src/main/java/org/springblade/modules/farm/controller/FarmController.java | 3
src/main/java/org/springblade/modules/traceability/service/impl/TraceabilityServiceImpl.java | 17 +
src/main/java/org/springblade/modules/traceability/dto/SweepRecordDTO.java | 42 ++++
src/main/java/org/springblade/modules/traceability/vo/SweepRecordVO.java | 21 ++
src/main/java/org/springblade/modules/farm/service/impl/FarmServiceImpl.java | 1
src/main/java/org/springblade/modules/lang/controller/LandController.java | 52 +++--
src/main/resources/application.yml | 1
16 files changed, 470 insertions(+), 30 deletions(-)
diff --git a/src/main/java/org/springblade/modules/farm/controller/FarmController.java b/src/main/java/org/springblade/modules/farm/controller/FarmController.java
index 9538d35..a2c1b71 100644
--- a/src/main/java/org/springblade/modules/farm/controller/FarmController.java
+++ b/src/main/java/org/springblade/modules/farm/controller/FarmController.java
@@ -24,11 +24,13 @@
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.farm.entity.Farm;
import org.springblade.modules.farm.service.FarmService;
import org.springblade.modules.farm.vo.FarmVO;
+import org.springblade.modules.system.vo.RoleVO;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@@ -178,5 +180,4 @@
map.put("rynum", integer1);
return R.data(map);
}
-
}
diff --git a/src/main/java/org/springblade/modules/farm/service/impl/FarmServiceImpl.java b/src/main/java/org/springblade/modules/farm/service/impl/FarmServiceImpl.java
index 05371cf..970c673 100644
--- a/src/main/java/org/springblade/modules/farm/service/impl/FarmServiceImpl.java
+++ b/src/main/java/org/springblade/modules/farm/service/impl/FarmServiceImpl.java
@@ -5,6 +5,7 @@
import org.springblade.modules.farm.mapper.FarmMapper;
import org.springblade.modules.farm.service.FarmService;
import org.springblade.modules.farm.vo.FarmVO;
+import org.springblade.modules.system.entity.Dept;
import org.springframework.stereotype.Service;
import java.util.List;
diff --git a/src/main/java/org/springblade/modules/lang/controller/LandController.java b/src/main/java/org/springblade/modules/lang/controller/LandController.java
index 88d098c..9720cf3 100644
--- a/src/main/java/org/springblade/modules/lang/controller/LandController.java
+++ b/src/main/java/org/springblade/modules/lang/controller/LandController.java
@@ -123,29 +123,33 @@
//替换分号为逗号
String replaceAll = sNull.replaceAll(";", ",");
land.setLandRange("'POLYGON((" + replaceAll + "))'");
- }
- List<Point2D.Double> points = new ArrayList<Point2D.Double>();
- double v1;
- String landRange = range;
- String[] s1 = landRange.split(";");
- for (String ss : s1) {
- String[] temp = ss.split(",");
- Point2D.Double point = new Point2D.Double(Double.parseDouble(temp[0]),
- Double.parseDouble(temp[1]));
- points.add(point);
- }
- PolyginArea tp = new PolyginArea();
- double area = tp.getAreaByxy(points);
- Integer landUnit = land.getLandUnit();
- //(0: 亩 1:分 2:平方米
- if (landUnit == 0) {
- double v = area * 0.0015;
- v1 = (double) Math.round(v * 100) / 100;
- } else if (landUnit == 1) {
- double v = area * 0.015;
- v1 = (double) Math.round(v * 100) / 100;
- } else {
- v1 = (double) Math.round(area * 100) / 100;
+
+ List<Point2D.Double> points = new ArrayList<Point2D.Double>();
+ double v1;
+ String landRange = range;
+ String[] s1 = landRange.split(";");
+ for (String ss : s1) {
+ String[] temp = ss.split(",");
+ Point2D.Double point = new Point2D.Double(Double.parseDouble(temp[0]),
+ Double.parseDouble(temp[1]));
+ points.add(point);
+ }
+ PolyginArea tp = new PolyginArea();
+ double area = tp.getAreaByxy(points);
+ Integer landUnit = land.getLandUnit();
+ //(0: 亩 1:分 2:平方米
+ if (landUnit == 0) {
+ double v = area * 0.0015;
+ v1 = (double) Math.round(v * 100) / 100;
+ } else if (landUnit == 1) {
+ double v = area * 0.015;
+ v1 = (double) Math.round(v * 100) / 100;
+ } else {
+ v1 = (double) Math.round(area * 100) / 100;
+ }
+ land.setLandArea(String.valueOf(v1));
+ }else {
+ land.setLandArea("0");
}
//图片转换上传
@@ -159,7 +163,7 @@
e.printStackTrace();
}
}
- land.setLandArea(String.valueOf(v1));
+
land.setType(1);
return R.status(landService.saveLandInfo(land));
}
diff --git a/src/main/java/org/springblade/modules/lang/entity/Land.java b/src/main/java/org/springblade/modules/lang/entity/Land.java
index 993473d..cca0463 100644
--- a/src/main/java/org/springblade/modules/lang/entity/Land.java
+++ b/src/main/java/org/springblade/modules/lang/entity/Land.java
@@ -54,6 +54,7 @@
* 地块面积
*/
private String landArea;
+
private String url;
/**
* 地块范围
@@ -72,4 +73,9 @@
*/
private String deptId;
+ /**
+ * 农场id
+ */
+ private String farmId;
+
}
diff --git a/src/main/java/org/springblade/modules/lang/mapper/LandMapper.xml b/src/main/java/org/springblade/modules/lang/mapper/LandMapper.xml
index 0ae8857..482ea63 100644
--- a/src/main/java/org/springblade/modules/lang/mapper/LandMapper.xml
+++ b/src/main/java/org/springblade/modules/lang/mapper/LandMapper.xml
@@ -85,13 +85,18 @@
<insert id="saveLandInfo">
insert into sys_land
- (user_id,land_name,land_type,land_area,land_range,type,land_unit,dept_id,url)
+ (user_id,land_name,land_type,land_area,land_range,type,land_unit,dept_id,url,farm_id)
values
(#{land.userId},#{land.landName},#{land.landType},#{land.landArea},
- <if test="land.landRange!=null and land.landRange!=''">
- ST_GeomFromText(${land.landRange}),
- </if>
- #{land.type},#{land.landUnit},#{land.deptId},#{land.url})
+ <choose>
+ <when test="land.landRange!=null and land.landRange!=''">
+ ST_GeomFromText(${land.landRange}),
+ </when>
+ <otherwise>
+ null,
+ </otherwise>
+ </choose>
+ #{land.type},#{land.landUnit},#{land.deptId},#{land.url},#{land.farmId})
</insert>
<!--详情信息(自定义查询)-->
@@ -121,6 +126,7 @@
</if>
type = #{land.type},
land_unit = #{land.landUnit},
+ farm_id = #{land.farmId},
url = #{land.url},
where id = #{land.id}
</update>
diff --git a/src/main/java/org/springblade/modules/system/entity/User.java b/src/main/java/org/springblade/modules/system/entity/User.java
index 2d6f517..cf342f2 100644
--- a/src/main/java/org/springblade/modules/system/entity/User.java
+++ b/src/main/java/org/springblade/modules/system/entity/User.java
@@ -92,5 +92,10 @@
*/
private String postId;
+ /**
+ * 农场id(负责的农场)
+ */
+ private String farmId;
+
}
diff --git a/src/main/java/org/springblade/modules/traceability/controller/SweepRecordController.java b/src/main/java/org/springblade/modules/traceability/controller/SweepRecordController.java
new file mode 100644
index 0000000..7d78861
--- /dev/null
+++ b/src/main/java/org/springblade/modules/traceability/controller/SweepRecordController.java
@@ -0,0 +1,121 @@
+package org.springblade.modules.traceability.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.traceability.entity.SweepRecord;
+import org.springblade.modules.traceability.service.SweepRecordService;
+import org.springblade.modules.traceability.vo.SweepRecordVO;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import javax.validation.Valid;
+import java.util.Date;
+
+/**
+ * 溯源扫描记录控制器
+ * @since 2022-05-19
+ * @author zhongrj
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/sweepRecord")
+public class SweepRecordController extends BladeController {
+
+ private final SweepRecordService sweepRecordService;
+
+ /**
+ * 详情
+ */
+ @GetMapping("/detail")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "详情", notes = "传入sweepRecord")
+ public R<SweepRecord> detail(SweepRecord sweepRecord) {
+ SweepRecord detail = sweepRecordService.getOne(Condition.getQueryWrapper(sweepRecord));
+ return R.data(detail);
+ }
+
+ /**
+ * 分页
+ */
+ @GetMapping("/list")
+ @ApiOperationSupport(order = 2)
+ @ApiOperation(value = "分页", notes = "传入sweepRecord")
+ public R<IPage<SweepRecord>> list(SweepRecord sweepRecord, Query query) {
+ IPage<SweepRecord> pages = sweepRecordService.page(Condition.getPage(query), Condition.getQueryWrapper(sweepRecord));
+ return R.data(pages);
+ }
+
+ /**
+ * 自定义分页
+ */
+ @GetMapping("/page")
+ @ApiOperationSupport(order = 3)
+ @ApiOperation(value = "分页", notes = "传入sweepRecord")
+ public R<IPage<SweepRecordVO>> page(SweepRecordVO sweepRecord, Query query) {
+ IPage<SweepRecordVO> pages = sweepRecordService.selectSweepRecordPage(Condition.getPage(query), sweepRecord);
+ return R.data(pages);
+ }
+
+ /**
+ * 新增
+ */
+ @PostMapping("/save")
+ @ApiOperationSupport(order = 4)
+ @Transactional(rollbackFor = Exception.class)
+ public R save(@Valid @RequestBody SweepRecord sweepRecord) {
+ sweepRecord.setCreateTime(new Date());
+ //新增
+ return R.status(sweepRecordService.save(sweepRecord));
+ }
+
+ /**
+ * 修改
+ */
+ @PostMapping("/update")
+ @ApiOperationSupport(order = 5)
+ @ApiOperation(value = "修改", notes = "传入sweepRecord")
+ @Transactional(rollbackFor = Exception.class)
+ public R update(@Valid @RequestBody SweepRecord sweepRecord) {
+ //更新并返回
+ return R.status(sweepRecordService.updateById(sweepRecord));
+ }
+
+ /**
+ * 新增或修改
+ */
+ @PostMapping("/submit")
+ @ApiOperationSupport(order = 6)
+ @ApiOperation(value = "新增或修改", notes = "传入sweepRecord")
+ public R submit(@Valid @RequestBody SweepRecord sweepRecord) {
+ return R.status(sweepRecordService.saveOrUpdate(sweepRecord));
+ }
+
+
+ /**
+ * 删除
+ */
+ @PostMapping("/remove")
+ @ApiOperationSupport(order = 7)
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+ return R.status(sweepRecordService.removeByIds(Func.toLongList(ids)));
+ }
+
+ /**
+ * 获取扫描次数统计数据
+ * @param sweepRecord
+ * @return
+ */
+ @GetMapping("/getSweepRecordStatistics")
+ public R getSweepRecordStatistics(SweepRecordVO sweepRecord){
+ return R.data(sweepRecordService.getSweepRecordStatistics(sweepRecord));
+ }
+
+}
diff --git a/src/main/java/org/springblade/modules/traceability/dto/SweepRecordDTO.java b/src/main/java/org/springblade/modules/traceability/dto/SweepRecordDTO.java
new file mode 100644
index 0000000..26abe0a
--- /dev/null
+++ b/src/main/java/org/springblade/modules/traceability/dto/SweepRecordDTO.java
@@ -0,0 +1,42 @@
+package org.springblade.modules.traceability.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author zhongrj
+ */
+@Data
+public class SweepRecordDTO implements Serializable {
+ /**
+ * 本日扫描总次数
+ */
+ private Integer todayNum;
+
+ /**
+ * 昨日扫描总次数
+ */
+ private Integer yesterdayNum;
+
+ /**
+ * 本周扫描总次数
+ */
+ private Integer thisWeekNum;
+
+ /**
+ * 去周扫描总次数
+ */
+ private Integer lastWeekNum;
+
+ /**
+ * 本月扫描总次数
+ */
+ private Integer thisMonthNum;
+
+ /**
+ * 上个月扫描总次数
+ */
+ private Integer lastMonthNum;
+
+}
diff --git a/src/main/java/org/springblade/modules/traceability/entity/SweepRecord.java b/src/main/java/org/springblade/modules/traceability/entity/SweepRecord.java
new file mode 100644
index 0000000..e4628be
--- /dev/null
+++ b/src/main/java/org/springblade/modules/traceability/entity/SweepRecord.java
@@ -0,0 +1,48 @@
+package org.springblade.modules.traceability.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 溯源扫描记录表实体类
+ * @since 2022-07-11
+ * @author zhongrj
+ */
+@Data
+@TableName("sys_sweep_record")
+public class SweepRecord implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @TableId(value = "id",type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 溯源码编号
+ */
+ private String code;
+
+ /**
+ * 创建时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+
+ /**
+ * 单位id
+ */
+ private String deptId;
+
+}
diff --git a/src/main/java/org/springblade/modules/traceability/mapper/SweepRecordMapper.java b/src/main/java/org/springblade/modules/traceability/mapper/SweepRecordMapper.java
new file mode 100644
index 0000000..143838a
--- /dev/null
+++ b/src/main/java/org/springblade/modules/traceability/mapper/SweepRecordMapper.java
@@ -0,0 +1,34 @@
+package org.springblade.modules.traceability.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.modules.traceability.dto.SweepRecordDTO;
+import org.springblade.modules.traceability.entity.SweepRecord;
+import org.springblade.modules.traceability.vo.SweepRecordVO;
+
+import java.util.List;
+
+/**
+ * 溯源扫描记录Mapper 接口
+ * @since 2022-07-11
+ * @author zhongrj
+ */
+public interface SweepRecordMapper extends BaseMapper<SweepRecord> {
+
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param sweepRecord
+ * @return
+ */
+ List<SweepRecordVO> selectSweepRecordPage(@Param("page") IPage page, @Param("sweepRecord") SweepRecordVO sweepRecord);
+
+ /**
+ * 获取扫描次数统计数据
+ * @param sweepRecord
+ * @return
+ */
+ List<Integer> getSweepRecordStatistics(@Param("sweepRecord") SweepRecordVO sweepRecord);
+}
diff --git a/src/main/java/org/springblade/modules/traceability/mapper/SweepRecordMapper.xml b/src/main/java/org/springblade/modules/traceability/mapper/SweepRecordMapper.xml
new file mode 100644
index 0000000..058a0f4
--- /dev/null
+++ b/src/main/java/org/springblade/modules/traceability/mapper/SweepRecordMapper.xml
@@ -0,0 +1,49 @@
+<?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="org.springblade.modules.traceability.mapper.SweepRecordMapper">
+
+ <!--自定义查询溯源码扫描记录分页数据-->
+ <select id="selectSweepRecordPage" resultType="org.springblade.modules.traceability.vo.SweepRecordVO">
+ select * from sys_sweep_record
+ where 1=1
+ </select>
+
+ <!--获取扫描次数统计数据-->
+ <select id="getSweepRecordStatistics" resultType="java.lang.Integer">
+ select count(*) from sys_sweep_record ssr left join sys_traceability st on ssr.code = st.id
+ left join sys_recovery sr on sr.id = st.recovery_id
+ left join sys_land sl on sl.id = sr.land_id
+ WHERE DAY(ssr.create_time) = NOW()
+ and sl.farm_id = #{sweepRecord.farmId}
+ union all
+ select count(*) from sys_sweep_record ssr left join sys_traceability st on ssr.code = st.id
+ left join sys_recovery sr on sr.id = st.recovery_id
+ left join sys_land sl on sl.id = sr.land_id
+ WHERE TO_DAYS( NOW( ) ) - TO_DAYS( ssr.create_time) = 1
+ and sl.farm_id = #{sweepRecord.farmId}
+ union all
+ select count(*) from sys_sweep_record ssr left join sys_traceability st on ssr.code = st.id
+ left join sys_recovery sr on sr.id = st.recovery_id
+ left join sys_land sl on sl.id = sr.land_id
+ WHERE YEARWEEK(date_format(ssr.create_time,'%Y-%m-%d')) = YEARWEEK(now())
+ and sl.farm_id = #{sweepRecord.farmId}
+ union all
+ select count(*) from sys_sweep_record ssr left join sys_traceability st on ssr.code = st.id
+ left join sys_recovery sr on sr.id = st.recovery_id
+ left join sys_land sl on sl.id = sr.land_id
+ WHERE YEARWEEK(date_format(ssr.create_time,'%Y-%m-%d')) = YEARWEEK(now())-1
+ and sl.farm_id = #{sweepRecord.farmId}
+ union all
+ select count(*) from sys_sweep_record ssr left join sys_traceability st on ssr.code = st.id
+ left join sys_recovery sr on sr.id = st.recovery_id
+ left join sys_land sl on sl.id = sr.land_id
+ WHERE DATE_FORMAT( ssr.create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
+ and sl.farm_id = #{sweepRecord.farmId}
+ union all
+ select count(*) from sys_sweep_record ssr left join sys_traceability st on ssr.code = st.id
+ left join sys_recovery sr on sr.id = st.recovery_id
+ left join sys_land sl on sl.id = sr.land_id
+ WHERE PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( ssr.create_time, '%Y%m' ) ) =1
+ and sl.farm_id = #{sweepRecord.farmId}
+ </select>
+</mapper>
diff --git a/src/main/java/org/springblade/modules/traceability/service/SweepRecordService.java b/src/main/java/org/springblade/modules/traceability/service/SweepRecordService.java
new file mode 100644
index 0000000..2a6282f
--- /dev/null
+++ b/src/main/java/org/springblade/modules/traceability/service/SweepRecordService.java
@@ -0,0 +1,32 @@
+
+package org.springblade.modules.traceability.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.modules.traceability.dto.SweepRecordDTO;
+import org.springblade.modules.traceability.entity.SweepRecord;
+import org.springblade.modules.traceability.vo.SweepRecordVO;
+
+/**
+ * 溯源码扫描记录表服务类
+ * @since 2022-07-11
+ * @author zhongrj
+ */
+public interface SweepRecordService extends IService<SweepRecord> {
+
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param sweepRecord
+ * @return
+ */
+ IPage<SweepRecordVO> selectSweepRecordPage(IPage<SweepRecordVO> page, SweepRecordVO sweepRecord);
+
+ /**
+ * 获取扫描次数统计数据
+ * @param sweepRecord
+ * @return
+ */
+ SweepRecordDTO getSweepRecordStatistics(SweepRecordVO sweepRecord);
+}
diff --git a/src/main/java/org/springblade/modules/traceability/service/impl/SweepRecordServiceImpl.java b/src/main/java/org/springblade/modules/traceability/service/impl/SweepRecordServiceImpl.java
new file mode 100644
index 0000000..fabe867
--- /dev/null
+++ b/src/main/java/org/springblade/modules/traceability/service/impl/SweepRecordServiceImpl.java
@@ -0,0 +1,52 @@
+package org.springblade.modules.traceability.service.impl;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.modules.traceability.dto.SweepRecordDTO;
+import org.springblade.modules.traceability.entity.SweepRecord;
+import org.springblade.modules.traceability.mapper.SweepRecordMapper;
+import org.springblade.modules.traceability.service.SweepRecordService;
+import org.springblade.modules.traceability.vo.SweepRecordVO;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 溯源码扫描记录表服务实现类
+ * @since 2022-05-19
+ * @author zhongrj
+ */
+@Service
+public class SweepRecordServiceImpl extends ServiceImpl<SweepRecordMapper, SweepRecord> implements SweepRecordService {
+
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param sweepRecord
+ * @return
+ */
+ @Override
+ public IPage<SweepRecordVO> selectSweepRecordPage(IPage<SweepRecordVO> page, SweepRecordVO sweepRecord) {
+ return page.setRecords(baseMapper.selectSweepRecordPage(page, sweepRecord));
+ }
+
+ /**
+ * 获取扫描次数统计数据
+ * @param sweepRecord
+ * @return
+ */
+ @Override
+ public SweepRecordDTO getSweepRecordStatistics(SweepRecordVO sweepRecord) {
+ List<Integer> statistics = baseMapper.getSweepRecordStatistics(sweepRecord);
+ //数据装换
+ SweepRecordDTO dto = new SweepRecordDTO();
+ dto.setTodayNum(statistics.get(0));
+ dto.setYesterdayNum(statistics.get(1));
+ dto.setThisWeekNum(statistics.get(2));
+ dto.setLastWeekNum(statistics.get(3));
+ dto.setThisMonthNum(statistics.get(4));
+ dto.setLastMonthNum(statistics.get(5));
+ //返回
+ return dto;
+ }
+}
diff --git a/src/main/java/org/springblade/modules/traceability/service/impl/TraceabilityServiceImpl.java b/src/main/java/org/springblade/modules/traceability/service/impl/TraceabilityServiceImpl.java
index b12d779..d021771 100644
--- a/src/main/java/org/springblade/modules/traceability/service/impl/TraceabilityServiceImpl.java
+++ b/src/main/java/org/springblade/modules/traceability/service/impl/TraceabilityServiceImpl.java
@@ -21,8 +21,10 @@
import org.springblade.modules.recovery.vo.RecoveryVO;
import org.springblade.modules.traceability.dto.TraceabilityDTO;
import org.springblade.modules.traceability.dto.TraceabilityDetailDTO;
+import org.springblade.modules.traceability.entity.SweepRecord;
import org.springblade.modules.traceability.entity.Traceability;
import org.springblade.modules.traceability.mapper.TraceabilityMapper;
+import org.springblade.modules.traceability.service.SweepRecordService;
import org.springblade.modules.traceability.service.TraceabilityService;
import org.springblade.modules.traceability.vo.TraceabilityVO;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +35,7 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.util.Date;
import java.util.List;
/**
@@ -57,6 +60,9 @@
@Autowired
private ILandService landService;
+
+ @Autowired
+ private SweepRecordService sweepRecordService;
/**
* 自定义分页
@@ -114,10 +120,21 @@
*/
@Override
public TraceabilityDetailDTO getTraceabilityDetailInfo(Traceability traceability) {
+
TraceabilityDetailDTO dto = new TraceabilityDetailDTO();
int count = 0;
//根据溯源码编号查询溯源信息
Traceability traceability1 = baseMapper.selectOne(new QueryWrapper<>(traceability));
+ //记录扫描记录
+ if (null!=traceability.getBind() && traceability.equals("1")){
+ //插入扫描记录
+ SweepRecord sweepRecord = new SweepRecord();
+ sweepRecord.setCreateTime(new Date());
+ sweepRecord.setCode(traceability.getId().toString());
+ sweepRecord.setDeptId(traceability1.getDeptId());
+ //新增
+ sweepRecordService.save(sweepRecord);
+ }
//1. 查询农产品采收记录信息
RecoveryVO recoveryVO = recoveryService.getRecoveryDetail(traceability1.getRecoveryId());
//2. 查询相关检测信息
diff --git a/src/main/java/org/springblade/modules/traceability/vo/SweepRecordVO.java b/src/main/java/org/springblade/modules/traceability/vo/SweepRecordVO.java
new file mode 100644
index 0000000..6343945
--- /dev/null
+++ b/src/main/java/org/springblade/modules/traceability/vo/SweepRecordVO.java
@@ -0,0 +1,21 @@
+package org.springblade.modules.traceability.vo;
+
+import lombok.Data;
+import org.springblade.modules.traceability.entity.SweepRecord;
+import org.springblade.modules.traceability.entity.Traceability;
+
+/**
+ * 溯源码扫描记录表VO
+ * @since 2022-07-11
+ * @author zhongrj
+ */
+@Data
+public class SweepRecordVO extends SweepRecord {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 农场id
+ */
+ private String farmId;
+
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 765db94..340b4d3 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -207,6 +207,7 @@
- /strain/**
- /blade-user/**
- /traceability/**
+ - /sweepRecord/**
#授权认证配置
auth:
- method: ALL
--
Gitblit v1.9.3