数据推送功能开发
This commit is contained in:
parent
0982fb226d
commit
6b4ca45b4a
|
|
@ -239,6 +239,10 @@ public class MaMachine extends BaseEntity {
|
|||
|
||||
@ApiModelProperty(value = "1:二维码绑定标识 2:rfid绑定标识")
|
||||
private Integer flag;
|
||||
@ApiModelProperty(value = "数据来源(0新购 1盘点 2数据推送)")
|
||||
private Integer souceBy;
|
||||
@ApiModelProperty(value = "数据推送id")
|
||||
private Integer dataReceiveId;
|
||||
|
||||
/** 导出选中列表 */
|
||||
private List<Long> dataCondition;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
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;
|
||||
|
|
@ -69,9 +68,32 @@ public class MaReceiveController extends BaseController {
|
|||
|
||||
@ApiOperation(value = "获取推送详情")
|
||||
@GetMapping("/getDataReceiveDetails")
|
||||
public TableDataInfo getDataReceiveDetails(Integer receiveId) {
|
||||
public TableDataInfo getDataReceiveDetails(DataReceiveDetail dataReceiveDetail) {
|
||||
startPage();
|
||||
List<DataReceiveDetail> dataReceiveDetails = maReceiveService.getDataReceiveDetails(receiveId);
|
||||
List<DataReceiveDetail> dataReceiveDetails = maReceiveService.getDataReceiveDetails(dataReceiveDetail);
|
||||
return getDataTable(dataReceiveDetails);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "数据接收")
|
||||
@PostMapping("/saveMachine")
|
||||
public AjaxResult saveMachine(@RequestBody DataReceiveInfo dataReceiveInfo) {
|
||||
if (CollUtil.isEmpty(dataReceiveInfo.getDataReceiveDetailList())) {
|
||||
return AjaxResult.error("接收数据为空");
|
||||
}
|
||||
int res = maReceiveService.saveMachine(dataReceiveInfo);
|
||||
if (res == 0) {
|
||||
return AjaxResult.error("接收失败");
|
||||
} else {
|
||||
return AjaxResult.success("接收成功");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "数据接收")
|
||||
@GetMapping("/getDateReceiveMachine")
|
||||
public TableDataInfo getDateReceiveMachine(DataReceiveDetail dataReceiveDetail) {
|
||||
startPage();
|
||||
List<DataReceiveDetail> dateReceiveMachine = maReceiveService.getDateReceiveMachine(dataReceiveDetail);
|
||||
return getDataTable(dateReceiveMachine);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,17 @@ public class DataReceiveDetail {
|
|||
@ApiModelProperty(value = "机具编码ID")
|
||||
private Integer maId;
|
||||
|
||||
@ApiModelProperty(value = "机具编码")
|
||||
private String maCode;
|
||||
@ApiModelProperty(value = "机具名称")
|
||||
private String machineName;
|
||||
@ApiModelProperty(value = "机具类型")
|
||||
private String typeName;
|
||||
@ApiModelProperty(value = "机具类型")
|
||||
private String modelName;
|
||||
@ApiModelProperty(value = "机具状态")
|
||||
private String maStatus;
|
||||
|
||||
@ApiModelProperty(value = "租赁日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
|
@ -66,7 +77,12 @@ public class DataReceiveDetail {
|
|||
@ApiModelProperty(value = "机手姓名")
|
||||
private String maUserName;
|
||||
|
||||
@ApiModelProperty(value = "关键字")
|
||||
private String keyWord;
|
||||
|
||||
@ApiModelProperty(value = "状态(0 未接收 1已接收)")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "数据来源(0新购 1盘点 2数据推送)")
|
||||
private Integer souceBy;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import lombok.Data;
|
|||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
|
|
@ -35,4 +36,11 @@ public class DataReceiveInfo {
|
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "推送日期")
|
||||
private Date receiveDate;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private String startTime;
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
private List<DataReceiveDetail> dataReceiveDetailList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,5 +17,12 @@ public interface MaReceiveMapper {
|
|||
int saveDataReceiveDetails(DataReceiveDetail dataReceiveDetail);
|
||||
List<DataReceiveInfo> getDataReceive(DataReceiveInfo dataReceiveInfo);
|
||||
|
||||
List<DataReceiveDetail> getDataReceiveDetails(Integer receiveId);
|
||||
List<DataReceiveDetail> getDataReceiveDetails(DataReceiveDetail dataReceiveDetail);
|
||||
List<DataReceiveDetail> getDataReceiveDetailsById(Integer receiveId);
|
||||
|
||||
int updateStatus(DataReceiveDetail dataReceiveDetail);
|
||||
|
||||
List<DataReceiveDetail> getDateReceiveMachine(DataReceiveDetail dataReceiveDetail);
|
||||
|
||||
int updateInfoStatus(Integer id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.sgzb.base.mapper;
|
||||
|
||||
import com.bonus.sgzb.base.api.domain.MaMachine;
|
||||
import com.bonus.sgzb.base.api.domain.MaType;
|
||||
import com.bonus.sgzb.base.domain.MaPropSet;
|
||||
import com.bonus.sgzb.base.domain.MaTypeKeeper;
|
||||
|
|
@ -81,4 +82,6 @@ public interface MaTypeMapper {
|
|||
int deleteKeeperByTypeId(Long typeId);
|
||||
|
||||
int deletePropSetByTypeId(Long typeId);
|
||||
|
||||
int updateTypeNum(MaMachine maMachine);
|
||||
}
|
||||
|
|
@ -15,5 +15,9 @@ public interface MaReceiveService {
|
|||
int saveDataReceiveDetails(DataReceiveDetail dataReceiveDetail);
|
||||
|
||||
List<DataReceiveInfo> getDataReceive(DataReceiveInfo dataReceiveInfo);
|
||||
List<DataReceiveDetail> getDataReceiveDetails(Integer receiveId);
|
||||
List<DataReceiveDetail> getDataReceiveDetails(DataReceiveDetail dataReceiveDetail);
|
||||
|
||||
int saveMachine(DataReceiveInfo dataReceiveInfo);
|
||||
|
||||
List<DataReceiveDetail> getDateReceiveMachine(DataReceiveDetail dataReceiveDetail);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
package com.bonus.sgzb.base.service.impl;
|
||||
|
||||
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.mapper.MaMachineMapper;
|
||||
import com.bonus.sgzb.base.mapper.MaReceiveMapper;
|
||||
import com.bonus.sgzb.base.mapper.MaTypeMapper;
|
||||
import com.bonus.sgzb.base.service.MaMachineService;
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -20,6 +25,12 @@ public class MaReceiveServiceImpl implements MaReceiveService {
|
|||
@Resource
|
||||
private MaReceiveMapper maReceiveMapper;
|
||||
|
||||
@Resource
|
||||
private MaMachineMapper maMachineMapper;
|
||||
|
||||
@Resource
|
||||
private MaTypeMapper maTypeMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int saveDataReceiveInfo(DataReceiveInfo dataReceiveInfo) {
|
||||
|
|
@ -44,11 +55,64 @@ public class MaReceiveServiceImpl implements MaReceiveService {
|
|||
|
||||
@Override
|
||||
public List<DataReceiveInfo> getDataReceive(DataReceiveInfo dataReceiveInfo) {
|
||||
return maReceiveMapper.getDataReceive(dataReceiveInfo);
|
||||
List<DataReceiveInfo> dataReceive = maReceiveMapper.getDataReceive(dataReceiveInfo);
|
||||
for (DataReceiveInfo receiveInfo : dataReceive) {
|
||||
List<DataReceiveDetail> dataReceiveDetails = maReceiveMapper.getDataReceiveDetailsById(receiveInfo.getId());
|
||||
long num = dataReceiveDetails.stream()
|
||||
.filter(t -> t.getStatus() == 1)
|
||||
.count();
|
||||
receiveInfo.setReceiveNum((int) num);
|
||||
}
|
||||
return dataReceive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataReceiveDetail> getDataReceiveDetails(Integer receiveId) {
|
||||
return maReceiveMapper.getDataReceiveDetails(receiveId);
|
||||
public List<DataReceiveDetail> getDataReceiveDetails(DataReceiveDetail dataReceiveDetail) {
|
||||
return maReceiveMapper.getDataReceiveDetails(dataReceiveDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveMachine(DataReceiveInfo dataReceiveInfo) {
|
||||
for (DataReceiveDetail dataReceiveDetail : dataReceiveInfo.getDataReceiveDetailList()) {
|
||||
MaMachine maMachine = new MaMachine();
|
||||
maMachine.setMaCode(dataReceiveDetail.getMaCode());
|
||||
maMachine.setTypeId(dataReceiveDetail.getTypeId());
|
||||
maMachine.setMaCode(dataReceiveDetail.getMaCode());
|
||||
maMachine.setMaStatus("15");
|
||||
maMachine.setCreateTime(new Date());
|
||||
maMachine.setSouceBy(2);
|
||||
maMachine.setDataReceiveId(dataReceiveInfo.getId());
|
||||
// 添加机具
|
||||
int i = maMachineMapper.maMachineAdd(maMachine);
|
||||
if (i == 0) {
|
||||
return i;
|
||||
}
|
||||
// 增加库存
|
||||
int j = maTypeMapper.updateTypeNum(maMachine);
|
||||
if (j == 0) {
|
||||
return j;
|
||||
}
|
||||
// 修改状态为已接收
|
||||
dataReceiveDetail.setMaId((int) maMachine.getMaId());
|
||||
int k = maReceiveMapper.updateStatus(dataReceiveDetail);
|
||||
if (k == 0) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
List<DataReceiveDetail> dataReceiveDetails = maReceiveMapper.getDataReceiveDetailsById(dataReceiveInfo.getId());
|
||||
if (dataReceiveDetails.stream().allMatch(t -> t.getStatus() == 1)) {
|
||||
int i = maReceiveMapper.updateInfoStatus(dataReceiveInfo.getId());
|
||||
if (i == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataReceiveDetail> getDateReceiveMachine(DataReceiveDetail dataReceiveDetail) {
|
||||
List<DataReceiveDetail> dateReceiveMachine = maReceiveMapper.getDateReceiveMachine(dataReceiveDetail);
|
||||
return dateReceiveMachine;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,8 +212,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="inOutNum != null and inOutNum != ''">in_out_num,</if>
|
||||
<if test="buyTask != null and buyTask != ''">buy_task,</if>
|
||||
<if test="ownHouse != null and ownHouse != ''">own_house,</if>
|
||||
<if test="companyId != null and companyId != ''">company_id</if>
|
||||
<if test="companyId != null and companyId != ''">create_time</if>
|
||||
<if test="companyId != null and companyId != ''">company_id,</if>
|
||||
<if test="createTime != null and createTime != ''">create_time,</if>
|
||||
<if test="souceBy != null">souce_by</if>
|
||||
<if test="dataReceiveId != null">data_receive_id</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="typeId != null and typeId != ''">#{typeId},</if>
|
||||
|
|
@ -236,8 +238,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="inOutNum != null and inOutNum != ''">#{inOutNum},</if>
|
||||
<if test="buyTask != null and buyTask != ''">#{buyTask},</if>
|
||||
<if test="ownHouse != null and ownHouse != ''">#{ownHouse},</if>
|
||||
<if test="companyId != null and companyId != ''">#{companyId}</if>
|
||||
<if test="companyId != null and companyId != ''">#{createTime}</if>
|
||||
<if test="companyId != null and companyId != ''">#{companyId},</if>
|
||||
<if test="createTime != null and createTime != ''">#{createTime},</if>
|
||||
<if test="souceBy != null">#{souceBy}</if>
|
||||
<if test="dataReceiveId != null">#{dataReceiveId}</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
|
|||
|
|
@ -307,6 +307,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="updatePropSetByTypeId">
|
||||
update ma_prop_set set prop_id = #{propId} where type_id = #{typeId}
|
||||
</update>
|
||||
<update id="updateTypeNum">
|
||||
update ma_type set num = IFNULL( num, 0 ) + 1 where type_id = #{typeId}
|
||||
</update>
|
||||
|
||||
<select id="selectTypeByTypeId" parameterType="long" resultMap="MaTypeResult">
|
||||
<include refid="selectMaTypeVo"/>
|
||||
|
|
|
|||
|
|
@ -9,12 +9,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
values(#{pushNum},now())
|
||||
</insert>
|
||||
<insert id="saveDataReceiveDetails">
|
||||
insert into data_receive_detail(receive_id,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 into data_receive_detail(receive_id,check_code,check_unit,check_date,is_new,ma_code,ma_user_name,next_check_date,out_factory_time,rent_price,rent_time,supplier,type_id,unit_id)
|
||||
values(#{receiveId},#{checkCode},#{checkUnit},#{checkDate},#{isNew},#{maCode},#{maUserName},#{nextCheckDate},#{outFactoryTime},#{rentPrice},#{rentTime},#{supplier},#{typeId},#{unitId})
|
||||
</insert>
|
||||
<update id="updateStatus">
|
||||
UPDATE data_receive_detail
|
||||
SET STATUS = 1,
|
||||
ma_id = #{maId}
|
||||
where receive_id = #{receiveId} and type_id = #{typeId}
|
||||
AND ma_code = #{maCode}
|
||||
</update>
|
||||
<update id="updateInfoStatus">
|
||||
UPDATE data_receive_info
|
||||
SET receive_status = 1
|
||||
where id = #{receiveId}
|
||||
</update>
|
||||
<select id="getDataReceive" resultType="com.bonus.sgzb.base.domain.DataReceiveInfo">
|
||||
select * from data_receive_info where 1=1
|
||||
<if test="receiveStatus != null and receiveStatus != ''">
|
||||
<if test="receiveStatus != null">
|
||||
AND receive_status = #{receiveStatus}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
|
|
@ -22,6 +34,54 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
<select id="getDataReceiveDetails" resultType="com.bonus.sgzb.base.domain.DataReceiveDetail">
|
||||
select * from data_receive_detail where receive_id = #{receiveId}
|
||||
SELECT
|
||||
drd.*,
|
||||
mt.type_name modelName,
|
||||
mt1.type_name typeName,
|
||||
mt2.type_name machineName
|
||||
FROM
|
||||
data_receive_detail drd
|
||||
LEFT JOIN ma_type mt ON drd.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||
WHERE
|
||||
drd.receive_id = #{receiveId}
|
||||
<if test="modelName != null and modelName != ''">
|
||||
AND mt.type_name like concat('%', #{modelName}, '%')
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
AND mt1.type_name like concat('%', #{typeName}, '%')
|
||||
</if>
|
||||
<if test="machineName != null and machineName != ''">
|
||||
AND mt2.type_name like concat('%', #{machineName}, '%')
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (drd.ma_code like concat('%', #{keyWord}, '%') or
|
||||
drd.check_code like concat('%', #{keyWord}, '%'))
|
||||
</if>
|
||||
</select>
|
||||
<select id="getDateReceiveMachine" resultType="com.bonus.sgzb.base.domain.DataReceiveDetail">
|
||||
SELECT
|
||||
mm.ma_code maCode,
|
||||
mt2.type_name machineName,
|
||||
mt1.type_name typeName,
|
||||
mt.type_name modelName,
|
||||
drd.rent_time rentTime,
|
||||
drd.check_date checkDate,
|
||||
drd.next_check_date nextCheckDate,
|
||||
mm.souce_by souceBy,
|
||||
sd.NAME maStatus
|
||||
FROM
|
||||
data_receive_detail drd
|
||||
LEFT JOIN ma_type mt ON drd.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||
LEFT JOIN ma_machine mm ON drd.type_id = mm.type_id
|
||||
LEFT JOIN sys_dic sd ON sd.id = mm.ma_status
|
||||
WHERE
|
||||
mm.souce_by = 2
|
||||
</select>
|
||||
<select id="getDataReceiveDetailsById" resultType="com.bonus.sgzb.base.domain.DataReceiveDetail">
|
||||
SELECT * FROM data_receive_detail WHERE receive_id = #{receiveId}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue