弄餐检测功能上传
This commit is contained in:
parent
45ab22e797
commit
b8cdc9d125
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.bonus.canteen.core.device.controller;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.device.domain.SampleDetail;
|
||||||
|
import com.bonus.canteen.core.device.domain.UploadModel;
|
||||||
|
import com.bonus.canteen.core.device.service.IDeviceInfoService;
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 10752
|
||||||
|
*/
|
||||||
|
@Api(tags = "食品安全检测接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/detection")
|
||||||
|
public class DeviceDetectionController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IDeviceInfoService deviceInfoService;
|
||||||
|
|
||||||
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
@PostMapping("/uploadData")
|
||||||
|
public String uploadData(@RequestParam("modelJson") String modelJson) {
|
||||||
|
try {
|
||||||
|
// 将字符串反序列化为对象
|
||||||
|
UploadModel model = objectMapper.readValue(modelJson, UploadModel.class);
|
||||||
|
// 保存 details
|
||||||
|
deviceInfoService.saveDetails(model.getDetails());
|
||||||
|
// TODO: 保存数据库 或 业务处理
|
||||||
|
System.out.println("接收到的数据:" + model.getUsername() + " - " + model.getDwmc());
|
||||||
|
|
||||||
|
if (model.getDetails() != null) {
|
||||||
|
model.getDetails().forEach(d -> {
|
||||||
|
System.out.println("样品:" + d.getYangpinmingcheng() + " -> 检测结果:" + d.getJiancejieguo());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return "{\"code\":200, \"msg\":\"上传成功\"}";
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "{\"code\":500, \"msg\":\"数据解析失败\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 根据条件查询
|
||||||
|
@GetMapping("/listByCondition")
|
||||||
|
public TableDataInfo listByCondition(SampleDetail sampleDetail) {
|
||||||
|
startPage();
|
||||||
|
List<SampleDetail> detailsByCondition = deviceInfoService.getDetailsByCondition(sampleDetail);
|
||||||
|
return getDataTable(detailsByCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.bonus.canteen.core.device.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SampleDetail {
|
||||||
|
|
||||||
|
private String yangpinmingcheng;
|
||||||
|
private String jiancejieguo;
|
||||||
|
private String jiancejieguoCode;
|
||||||
|
private String jianceleixingCode;
|
||||||
|
private String lianxidianhua;
|
||||||
|
private String jianceren;
|
||||||
|
private String jiancezhi;
|
||||||
|
private String jiancedidian;
|
||||||
|
private String jiancexiangmu;
|
||||||
|
private String yangpinbianhao;
|
||||||
|
private String jianceriqi;
|
||||||
|
private String shanghumingcheng;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.bonus.canteen.core.device.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UploadModel {
|
||||||
|
private String yqbh;
|
||||||
|
private String password;
|
||||||
|
private String dwmc;
|
||||||
|
private String username;
|
||||||
|
private List<SampleDetail> details;
|
||||||
|
}
|
||||||
|
|
@ -2,18 +2,19 @@ package com.bonus.canteen.core.device.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.canteen.core.device.domain.DeviceInfo;
|
import com.bonus.canteen.core.device.domain.DeviceInfo;
|
||||||
|
import com.bonus.canteen.core.device.domain.SampleDetail;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备资料Mapper接口
|
* 设备资料Mapper接口
|
||||||
*
|
*
|
||||||
* @author xsheng
|
* @author xsheng
|
||||||
* @date 2025-05-25
|
* @date 2025-05-25
|
||||||
*/
|
*/
|
||||||
public interface DeviceInfoMapper {
|
public interface DeviceInfoMapper {
|
||||||
/**
|
/**
|
||||||
* 查询设备资料
|
* 查询设备资料
|
||||||
*
|
*
|
||||||
* @param deviceId 设备资料主键
|
* @param deviceId 设备资料主键
|
||||||
* @return 设备资料
|
* @return 设备资料
|
||||||
*/
|
*/
|
||||||
|
|
@ -21,7 +22,7 @@ public interface DeviceInfoMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备资料列表
|
* 查询设备资料列表
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 设备资料集合
|
* @return 设备资料集合
|
||||||
*/
|
*/
|
||||||
|
|
@ -29,7 +30,7 @@ public interface DeviceInfoMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增设备资料
|
* 新增设备资料
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -37,7 +38,7 @@ public interface DeviceInfoMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改设备资料
|
* 修改设备资料
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -45,7 +46,7 @@ public interface DeviceInfoMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除设备资料
|
* 删除设备资料
|
||||||
*
|
*
|
||||||
* @param deviceId 设备资料主键
|
* @param deviceId 设备资料主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -53,7 +54,7 @@ public interface DeviceInfoMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除设备资料
|
* 批量删除设备资料
|
||||||
*
|
*
|
||||||
* @param deviceIds 需要删除的数据主键集合
|
* @param deviceIds 需要删除的数据主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -146,4 +147,8 @@ public interface DeviceInfoMapper {
|
||||||
int updateTimeBySn(String sn);
|
int updateTimeBySn(String sn);
|
||||||
|
|
||||||
int updateTimeByKitchenSn(String sn);
|
int updateTimeByKitchenSn(String sn);
|
||||||
|
|
||||||
|
void saveDetails(List<SampleDetail> details);
|
||||||
|
|
||||||
|
List<SampleDetail> getDetailsByCondition(SampleDetail sampleDetail);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,18 @@ package com.bonus.canteen.core.device.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.canteen.core.device.domain.DeviceInfo;
|
import com.bonus.canteen.core.device.domain.DeviceInfo;
|
||||||
|
import com.bonus.canteen.core.device.domain.SampleDetail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备资料Service接口
|
* 设备资料Service接口
|
||||||
*
|
*
|
||||||
* @author xsheng
|
* @author xsheng
|
||||||
* @date 2025-05-25
|
* @date 2025-05-25
|
||||||
*/
|
*/
|
||||||
public interface IDeviceInfoService {
|
public interface IDeviceInfoService {
|
||||||
/**
|
/**
|
||||||
* 查询设备资料
|
* 查询设备资料
|
||||||
*
|
*
|
||||||
* @param deviceId 设备资料主键
|
* @param deviceId 设备资料主键
|
||||||
* @return 设备资料
|
* @return 设备资料
|
||||||
*/
|
*/
|
||||||
|
|
@ -20,7 +21,7 @@ public interface IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备资料列表
|
* 查询设备资料列表
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 设备资料集合
|
* @return 设备资料集合
|
||||||
*/
|
*/
|
||||||
|
|
@ -28,7 +29,7 @@ public interface IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增设备资料
|
* 新增设备资料
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -36,7 +37,7 @@ public interface IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改设备资料
|
* 修改设备资料
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -44,7 +45,7 @@ public interface IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除设备资料
|
* 批量删除设备资料
|
||||||
*
|
*
|
||||||
* @param deviceIds 需要删除的设备资料主键集合
|
* @param deviceIds 需要删除的设备资料主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -52,7 +53,7 @@ public interface IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除设备资料信息
|
* 删除设备资料信息
|
||||||
*
|
*
|
||||||
* @param deviceId 设备资料主键
|
* @param deviceId 设备资料主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -65,4 +66,8 @@ public interface IDeviceInfoService {
|
||||||
void updateTimeBySn(String deviceSn);
|
void updateTimeBySn(String deviceSn);
|
||||||
|
|
||||||
void updateTimeByKitchenSn(String deviceSn);
|
void updateTimeByKitchenSn(String deviceSn);
|
||||||
|
|
||||||
|
void saveDetails(List<SampleDetail> details);
|
||||||
|
|
||||||
|
List<SampleDetail> getDetailsByCondition(SampleDetail sampleDetail);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package com.bonus.canteen.core.device.service.impl;
|
package com.bonus.canteen.core.device.service.impl;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.device.domain.SampleDetail;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
|
|
@ -15,7 +18,7 @@ import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备资料Service业务层处理
|
* 设备资料Service业务层处理
|
||||||
*
|
*
|
||||||
* @author xsheng
|
* @author xsheng
|
||||||
* @date 2025-05-25
|
* @date 2025-05-25
|
||||||
*/
|
*/
|
||||||
|
|
@ -28,7 +31,7 @@ public class DeviceInfoServiceImpl implements IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备资料
|
* 查询设备资料
|
||||||
*
|
*
|
||||||
* @param deviceId 设备资料主键
|
* @param deviceId 设备资料主键
|
||||||
* @return 设备资料
|
* @return 设备资料
|
||||||
*/
|
*/
|
||||||
|
|
@ -39,7 +42,7 @@ public class DeviceInfoServiceImpl implements IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备资料列表
|
* 查询设备资料列表
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 设备资料
|
* @return 设备资料
|
||||||
*/
|
*/
|
||||||
|
|
@ -50,7 +53,7 @@ public class DeviceInfoServiceImpl implements IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增设备资料
|
* 新增设备资料
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -70,7 +73,7 @@ public class DeviceInfoServiceImpl implements IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改设备资料
|
* 修改设备资料
|
||||||
*
|
*
|
||||||
* @param deviceInfo 设备资料
|
* @param deviceInfo 设备资料
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -140,7 +143,7 @@ public class DeviceInfoServiceImpl implements IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除设备资料
|
* 批量删除设备资料
|
||||||
*
|
*
|
||||||
* @param deviceIds 需要删除的设备资料主键
|
* @param deviceIds 需要删除的设备资料主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -154,7 +157,7 @@ public class DeviceInfoServiceImpl implements IDeviceInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除设备资料信息
|
* 删除设备资料信息
|
||||||
*
|
*
|
||||||
* @param deviceId 设备资料主键
|
* @param deviceId 设备资料主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -183,4 +186,14 @@ public class DeviceInfoServiceImpl implements IDeviceInfoService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveDetails(List<SampleDetail> details) {
|
||||||
|
deviceInfoMapper.saveDetails(details);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SampleDetail> getDetailsByCondition(SampleDetail sampleDetail) {
|
||||||
|
return deviceInfoMapper.getDetailsByCondition(sampleDetail);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ public class ZhhqCookRecipeController extends BaseController {
|
||||||
@ApiOperation("获取一周菜谱详情")
|
@ApiOperation("获取一周菜谱详情")
|
||||||
@PostMapping({"/getWeekRecipe"})
|
@PostMapping({"/getWeekRecipe"})
|
||||||
public AjaxResult getWeekRecipeDetailList(@RequestHeader Map<String, String> requestHeader, @RequestBody @Valid WeekRecipeDTO dto) {
|
public AjaxResult getWeekRecipeDetailList(@RequestHeader Map<String, String> requestHeader, @RequestBody @Valid WeekRecipeDTO dto) {
|
||||||
/* if (!(GlobalConstants.JYY + getCurrentDateStr()).equals(Sm4Utils.decrypt(HeaderFetchUtil.getSign(requestHeader)))) {
|
if (!(GlobalConstants.JYY + getCurrentDateStr()).equals(Sm4Utils.decrypt(HeaderFetchUtil.getSign(requestHeader)))) {
|
||||||
throw new ServiceException("访问缺少认证信息");
|
throw new ServiceException("访问缺少认证信息");
|
||||||
}*/
|
}
|
||||||
try {
|
try {
|
||||||
return AjaxResult.success(this.zhhqCookRecipeService.getWeekRecipeDetailList(dto));
|
return AjaxResult.success(this.zhhqCookRecipeService.getWeekRecipeDetailList(dto));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
order by di.create_time desc
|
order by di.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDeviceInfoByDeviceId" parameterType="Long" resultMap="DeviceInfoResult">
|
<select id="selectDeviceInfoByDeviceId" parameterType="Long" resultMap="DeviceInfoResult">
|
||||||
<include refid="selectDeviceInfoVo"/>
|
<include refid="selectDeviceInfoVo"/>
|
||||||
where di.device_id = #{deviceId}
|
where di.device_id = #{deviceId}
|
||||||
|
|
@ -115,6 +115,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select recipe_id from cook_recipe_bind_device where stall_id = #{stallId} and recipe_id is not null
|
select recipe_id from cook_recipe_bind_device where stall_id = #{stallId} and recipe_id is not null
|
||||||
limit 1
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getDetailsByCondition" resultType="com.bonus.canteen.core.device.domain.SampleDetail">
|
||||||
|
SELECT *
|
||||||
|
FROM kitchen_device_detection
|
||||||
|
WHERE 1=1
|
||||||
|
<if test="yangpinmingcheng != null and yangpinmingcheng != ''">
|
||||||
|
AND yangpinmingcheng LIKE CONCAT('%', #{yangpinmingcheng}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="jiancejieguo != null and jiancejieguo != ''">
|
||||||
|
AND jiancejieguo = #{jiancejieguo}
|
||||||
|
</if>
|
||||||
|
ORDER BY jianceriqi DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertDeviceInfo" parameterType="com.bonus.canteen.core.device.domain.DeviceInfo" useGeneratedKeys="true" keyProperty="deviceId">
|
<insert id="insertDeviceInfo" parameterType="com.bonus.canteen.core.device.domain.DeviceInfo" useGeneratedKeys="true" keyProperty="deviceId">
|
||||||
insert into device_info
|
insert into device_info
|
||||||
|
|
@ -217,6 +229,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
values (#{deviceId}, #{canteenId}, #{stallId},#{recipeId},
|
values (#{deviceId}, #{canteenId}, #{stallId},#{recipeId},
|
||||||
#{createBy}, #{createTime})
|
#{createBy}, #{createTime})
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="saveDetails" parameterType="java.util.List">
|
||||||
|
INSERT INTO kitchen_device_detection (
|
||||||
|
yangpinbianhao, yangpinmingcheng, shanghumingcheng,
|
||||||
|
jianceleixing_code, jiancexiangmu, jiancezhi,
|
||||||
|
jiancejieguo, jiancejieguo_code, jianceren,
|
||||||
|
lianxidianhua, jiancedidian, jianceriqi
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(
|
||||||
|
#{item.yangpinbianhao}, #{item.yangpinmingcheng}, #{item.shanghumingcheng},
|
||||||
|
#{item.jianceleixingCode}, #{item.jiancexiangmu}, #{item.jiancezhi},
|
||||||
|
#{item.jiancejieguo}, #{item.jiancejieguoCode}, #{item.jianceren},
|
||||||
|
#{item.lianxidianhua}, #{item.jiancedidian}, #{item.jianceriqi}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateDeviceInfo" parameterType="com.bonus.canteen.core.device.domain.DeviceInfo">
|
<update id="updateDeviceInfo" parameterType="com.bonus.canteen.core.device.domain.DeviceInfo">
|
||||||
update device_info
|
update device_info
|
||||||
|
|
@ -299,7 +328,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteDeviceInfoByDeviceIds" parameterType="String">
|
<delete id="deleteDeviceInfoByDeviceIds" parameterType="String">
|
||||||
delete from device_info where device_id in
|
delete from device_info where device_id in
|
||||||
<foreach item="deviceId" collection="deviceIds" open="(" separator="," close=")">
|
<foreach item="deviceId" collection="deviceIds" open="(" separator="," close=")">
|
||||||
#{deviceId}
|
#{deviceId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
@ -322,4 +351,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
set last_update_time = unix_timestamp()
|
set last_update_time = unix_timestamp()
|
||||||
where device_sn = #{sn}
|
where device_sn = #{sn}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue