数据推送功能
This commit is contained in:
parent
c100796028
commit
a5f1b1a391
|
|
@ -0,0 +1,77 @@
|
|||
package com.bonus.sgzb.base.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.sgzb.base.api.domain.MaMachine;
|
||||
import com.bonus.sgzb.base.domain.DataReceiveDetail;
|
||||
import com.bonus.sgzb.base.domain.DataReceiveInfo;
|
||||
import com.bonus.sgzb.base.service.MaReceiveService;
|
||||
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.sgzb.common.core.web.controller.BaseController;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2024/7/24 - 10:47
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/receive")
|
||||
public class MaReceiveController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private MaReceiveService maReceiveService;
|
||||
|
||||
/**
|
||||
* 数据推送接收
|
||||
*/
|
||||
@ApiOperation(value = "获取推送数据")
|
||||
@PostMapping("/dataReceive")
|
||||
public AjaxResult getProjectInfoAll(@RequestBody List<DataReceiveDetail> dataReceiveDetails) {
|
||||
if (CollUtil.isEmpty(dataReceiveDetails)) {
|
||||
return AjaxResult.error("推送数据为空");
|
||||
}
|
||||
DataReceiveInfo dataReceiveInfo = new DataReceiveInfo();
|
||||
dataReceiveInfo.setPushNum(dataReceiveDetails.size());
|
||||
int id = maReceiveService.saveDataReceiveInfo(dataReceiveInfo);
|
||||
if (id == 0) {
|
||||
return AjaxResult.error("推送数据失败");
|
||||
}
|
||||
for (DataReceiveDetail dataReceiveDetail : dataReceiveDetails) {
|
||||
dataReceiveDetail.setReceiveId(id);
|
||||
maReceiveService.saveDataReceiveDetails(dataReceiveDetail);
|
||||
}
|
||||
return AjaxResult.success("数据推送成功");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取推送数据")
|
||||
@GetMapping("/getDataReceive")
|
||||
public TableDataInfo getDataReceive(DataReceiveInfo dataReceiveInfo) {
|
||||
startPage();
|
||||
List<DataReceiveInfo> list = maReceiveService.getDataReceive(dataReceiveInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出推送数据")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DataReceiveInfo dataReceiveInfo) {
|
||||
List<DataReceiveInfo> list = maReceiveService.getDataReceive(dataReceiveInfo);
|
||||
ExcelUtil<DataReceiveInfo> util = new ExcelUtil<>(DataReceiveInfo.class);
|
||||
util.exportExcel(response, list, "推送数据列表");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取推送详情")
|
||||
@GetMapping("/getDataReceiveDetails")
|
||||
public TableDataInfo getDataReceiveDetails(Integer receiveId) {
|
||||
startPage();
|
||||
List<DataReceiveDetail> dataReceiveDetails = maReceiveService.getDataReceiveDetails(receiveId);
|
||||
return getDataTable(dataReceiveDetails);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.bonus.sgzb.base.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2024/7/24 - 10:53
|
||||
*/
|
||||
@Data
|
||||
public class DataReceiveDetail {
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "推送ID")
|
||||
private Integer receiveId;
|
||||
|
||||
@ApiModelProperty(value = "机具类型id")
|
||||
private Integer typeId;
|
||||
|
||||
@ApiModelProperty(value = "机具编码ID")
|
||||
private Integer maId;
|
||||
|
||||
@ApiModelProperty(value = "租赁日期")
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date rentTime;
|
||||
|
||||
@ApiModelProperty(value = "租赁价格")
|
||||
private String rentPrice;
|
||||
|
||||
@ApiModelProperty(value = "所属单位")
|
||||
private Integer unitId;
|
||||
|
||||
@ApiModelProperty(value = "生产厂家")
|
||||
private String supplier;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期")
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date outFactoryTime;
|
||||
|
||||
@ApiModelProperty(value = "是否新装备(0 是 1否)")
|
||||
private Integer isNew;
|
||||
|
||||
@ApiModelProperty(value = "检验证编号")
|
||||
private String checkCode;
|
||||
|
||||
@ApiModelProperty(value = "检验单位")
|
||||
private String checkUnit;
|
||||
|
||||
@ApiModelProperty(value = "检验日期")
|
||||
private Date checkDate;
|
||||
|
||||
@ApiModelProperty(value = "下次检验日期")
|
||||
private Date nextCheckDate;
|
||||
|
||||
@ApiModelProperty(value = "机手姓名")
|
||||
private String maUserName;
|
||||
|
||||
@ApiModelProperty(value = "状态(0 未接收 1已接收)")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.bonus.sgzb.base.domain;
|
||||
|
||||
import com.bonus.sgzb.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2024/7/24 - 13:11
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DataReceiveInfo {
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "接收状态(0 未完成 1已完成)")
|
||||
@Excel(name = "接收状态", readConverterExp = "0=未完成,1=已完成")
|
||||
private Integer receiveStatus;
|
||||
|
||||
@ApiModelProperty(value = "推送数量")
|
||||
@Excel(name = "推送数量")
|
||||
private Integer pushNum;
|
||||
|
||||
@ApiModelProperty(value = "接收数量")
|
||||
@Excel(name = "接收数量")
|
||||
private Integer receiveNum;
|
||||
|
||||
@ApiModelProperty(value = "接收日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "推送日期")
|
||||
private Date receiveDate;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.bonus.sgzb.base.mapper;
|
||||
|
||||
import com.bonus.sgzb.base.domain.DataReceiveDetail;
|
||||
import com.bonus.sgzb.base.domain.DataReceiveInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2024/7/24 - 13:21
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface MaReceiveMapper {
|
||||
int saveDataReceiveInfo(DataReceiveInfo dataReceiveInfo);
|
||||
int saveDataReceiveDetails(DataReceiveDetail dataReceiveDetail);
|
||||
List<DataReceiveInfo> getDataReceive(DataReceiveInfo dataReceiveInfo);
|
||||
|
||||
List<DataReceiveDetail> getDataReceiveDetails(Integer receiveId);
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.bonus.sgzb.base.service;
|
||||
|
||||
import com.bonus.sgzb.base.domain.DataReceiveDetail;
|
||||
import com.bonus.sgzb.base.domain.DataReceiveInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2024/7/24 - 13:20
|
||||
*/
|
||||
public interface MaReceiveService {
|
||||
int saveDataReceiveInfo(DataReceiveInfo dataReceiveInfo);
|
||||
|
||||
int saveDataReceiveDetails(DataReceiveDetail dataReceiveDetail);
|
||||
|
||||
List<DataReceiveInfo> getDataReceive(DataReceiveInfo dataReceiveInfo);
|
||||
List<DataReceiveDetail> getDataReceiveDetails(Integer receiveId);
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.bonus.sgzb.base.service.impl;
|
||||
|
||||
import com.bonus.sgzb.base.domain.DataReceiveDetail;
|
||||
import com.bonus.sgzb.base.domain.DataReceiveInfo;
|
||||
import com.bonus.sgzb.base.mapper.MaReceiveMapper;
|
||||
import com.bonus.sgzb.base.service.MaReceiveService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2024/7/24 - 13:20
|
||||
*/
|
||||
@Service
|
||||
public class MaReceiveServiceImpl implements MaReceiveService {
|
||||
|
||||
@Resource
|
||||
private MaReceiveMapper maReceiveMapper;
|
||||
|
||||
@Override
|
||||
public int saveDataReceiveInfo(DataReceiveInfo dataReceiveInfo) {
|
||||
maReceiveMapper.saveDataReceiveInfo(dataReceiveInfo);
|
||||
if (dataReceiveInfo.getId() != null) {
|
||||
return dataReceiveInfo.getId();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int saveDataReceiveDetails(DataReceiveDetail dataReceiveDetail) {
|
||||
int i = 0;
|
||||
i = maReceiveMapper.saveDataReceiveDetails(dataReceiveDetail);
|
||||
if (i == 0) {
|
||||
throw new RuntimeException("保存失败");
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataReceiveInfo> getDataReceive(DataReceiveInfo dataReceiveInfo) {
|
||||
return maReceiveMapper.getDataReceive(dataReceiveInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataReceiveDetail> getDataReceiveDetails(Integer receiveId) {
|
||||
return maReceiveMapper.getDataReceiveDetails(receiveId);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?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="com.bonus.sgzb.base.mapper.MaReceiveMapper">
|
||||
|
||||
<insert id="saveDataReceiveInfo" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into data_receive_info(push_num,receive_date)
|
||||
values(#{pushNum},now())
|
||||
</insert>
|
||||
<insert id="saveDataReceiveDetails">
|
||||
insert into data_receive_detail(receiveId,check_code,check_unit,check_date,is_new,ma_id,ma_user_name,next_check_date,out_factory_time,rent_price,rent_time,supplier,type_id,unit_id)
|
||||
values(#{receiveId},#{checkCode},#{checkUnit},#{checkDate},#{isNew},#{maId},#{maUserName},#{nextCheckDate},#{outFactoryTime},#{rentPrice},#{rentTime},#{supplier},#{typeId},#{unitId})
|
||||
</insert>
|
||||
<select id="getDataReceive" resultType="com.bonus.sgzb.base.domain.DataReceiveInfo">
|
||||
select * from data_receive_info where 1=1
|
||||
<if test="receiveStatus != null and receiveStatus != ''">
|
||||
AND receive_status = #{receiveStatus}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
AND receive_date BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||
</if>
|
||||
</select>
|
||||
<select id="getDataReceiveDetails" resultType="com.bonus.sgzb.base.domain.DataReceiveDetail">
|
||||
select * from data_receive_detail where receive_id = #{receiveId}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue