退料联调

This commit is contained in:
mashuai 2025-05-30 13:26:45 +08:00
parent 6227766ec3
commit 4b7d3db28a
19 changed files with 491 additions and 58 deletions

View File

@ -22,6 +22,13 @@ import java.util.List;
public class LeaseOutDetails extends BaseEntity { public class LeaseOutDetails extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "是否app, 0 是1 否")
private Integer isApp;
/** 是否新增出库 */
@ApiModelProperty(value = "是否新增出库 0 是1 否")
private Integer isNew;
/** ID */ /** ID */
private Long id; private Long id;

View File

@ -390,6 +390,13 @@ public interface BackApplyInfoMapper {
*/ */
List<BackMaCodeVo> getSecondBackInfo(BackApplyTotalInfo info); List<BackMaCodeVo> getSecondBackInfo(BackApplyTotalInfo info);
/**
* 根据类型id和父级id查询详情
* @param details
* @return
*/
BackApplyDetails getBackApplyDetailsByTypeIdAndParentId(BackApplyDetails details);
/** /**
* 删除详情 * 删除详情
* @param id * @param id

View File

@ -455,7 +455,14 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
details.setCreateBy(SecurityUtils.getUsername()); details.setCreateBy(SecurityUtils.getUsername());
details.setCreateTime(DateUtils.getNowDate()); details.setCreateTime(DateUtils.getNowDate());
// 保存退料详情 // 保存退料详情
result += backApplyInfoMapper.insertBackApplyDetails(details); // 先根据typeId和parentId查询该类型是否存在
BackApplyDetails backApplyDetails = backApplyInfoMapper.getBackApplyDetailsByTypeIdAndParentId(details);
if (backApplyDetails != null) {
backApplyDetails.setPreNum(details.getPreNum());
result += backApplyInfoMapper.updateDetails(backApplyDetails);
} else {
result += backApplyInfoMapper.insertBackApplyDetails(details);
}
// 处理附件 // 处理附件
result = saveBmFileInfo(details, backApplyInfo.getId(), result); result = saveBmFileInfo(details, backApplyInfo.getId(), result);
// 判断是否为编码设备并处理附件 // 判断是否为编码设备并处理附件
@ -936,7 +943,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
// 插入 CheckDetails // 插入 CheckDetails
result += backApplyInfoMapper.insertCheckDetails(details); result += backApplyInfoMapper.insertCheckDetails(details);
//更新ma_machine表状态为11退料暂存 //更新ma_machine表状态为11退料暂存
result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.RETURNED_MATERIAL.getStatus()); //result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.RETURNED_MATERIAL.getStatus());
if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) { if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) {
for (BmFileInfo bmFileInfo : details.getBmFileInfos()) { for (BmFileInfo bmFileInfo : details.getBmFileInfos()) {
bmFileInfo.setCreateBy(SecurityUtils.getUsername()); bmFileInfo.setCreateBy(SecurityUtils.getUsername());
@ -1050,7 +1057,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
result += backApplyInfoMapper.insertCheckDetails(details); result += backApplyInfoMapper.insertCheckDetails(details);
} }
//更新ma_machine表状态为3退料检修 //更新ma_machine表状态为3退料检修
result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus()); //result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus());
if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) { if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) {
for (BmFileInfo bmFileInfo : details.getBmFileInfos()) { for (BmFileInfo bmFileInfo : details.getBmFileInfos()) {
bmFileInfo.setCreateBy(SecurityUtils.getUsername()); bmFileInfo.setCreateBy(SecurityUtils.getUsername());
@ -1181,7 +1188,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
} }
return AjaxResult.success(list); return AjaxResult.success(list);
} }
return AjaxResult.error(HttpCodeEnum.SYSTEM_ERROR.getCode(), "编码检索为空"); return AjaxResult.error(HttpCodeEnum.SYSTEM_ERROR.getCode(), "该编码设备非该班组和工程所领");
} }
/** /**

View File

@ -2,7 +2,6 @@ package com.bonus.material.lease.controller;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.annotation.StoreLog;
import com.bonus.common.biz.config.ListPagingUtil; import com.bonus.common.biz.config.ListPagingUtil;
import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.core.utils.ServletUtils;
@ -13,12 +12,12 @@ import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType; import com.bonus.common.log.enums.OperaType;
import com.bonus.material.back.domain.vo.MaCodeVo; import com.bonus.material.back.domain.vo.MaCodeVo;
import com.bonus.material.basic.domain.BmQrcodeInfo; import com.bonus.material.basic.domain.BmQrcodeInfo;
import com.bonus.material.basic.domain.RetainedEquipmentInfo;
import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo; import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.material.lease.domain.LeaseApplyDetails; import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.LeaseApplyDetailsInfo; import com.bonus.material.lease.domain.LeaseApplyDetailsInfo;
import com.bonus.material.lease.domain.LeaseOutDetailsInfo; import com.bonus.material.lease.domain.LeaseOutDetailsInfo;
import com.bonus.material.lease.domain.vo.CriticalData;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo; import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
import com.bonus.common.biz.domain.lease.LeaseOutRequestVo; import com.bonus.common.biz.domain.lease.LeaseOutRequestVo;
import com.bonus.material.lease.domain.vo.LeaseTotalInfo; import com.bonus.material.lease.domain.vo.LeaseTotalInfo;
@ -111,6 +110,12 @@ public class LeaseApplyInfoController extends BaseController {
return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyWord, publishTask)); return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyWord, publishTask));
} }
@ApiOperation(value = "获取领料任务详细信息")
@GetMapping(value = "/getOutNum")
public AjaxResult getOutNum(LeaseApplyDetails leaseApplyDetails) {
return success(leaseApplyInfoService.getOutNum(leaseApplyDetails));
}
/** /**
* 获取工器具领料出库详情 * 获取工器具领料出库详情
* @param leaseApplyInfo * @param leaseApplyInfo
@ -324,7 +329,7 @@ public class LeaseApplyInfoController extends BaseController {
* 领料出库 * 领料出库
*/ */
@ApiOperation(value = "领料出库") @ApiOperation(value = "领料出库")
@PreventRepeatSubmit //@PreventRepeatSubmit
//@RequiresPermissions("lease:info:leaseOut") //@RequiresPermissions("lease:info:leaseOut")
@SysLog(title = "领料出库", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->领料出库") @SysLog(title = "领料出库", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->领料出库")
//@StoreLog(title = "领料出库", module = "仓储管理->领料出库") //@StoreLog(title = "领料出库", module = "仓储管理->领料出库")
@ -452,4 +457,16 @@ public class LeaseApplyInfoController extends BaseController {
ExcelUtil<MaCodeVo> util = new ExcelUtil<>(MaCodeVo.class); ExcelUtil<MaCodeVo> util = new ExcelUtil<>(MaCodeVo.class);
util.exportExcel(response, list, "综合查询--工器具领料二级页面查询"); util.exportExcel(response, list, "综合查询--工器具领料二级页面查询");
} }
/**
* 查询app首页关键数据
* @return
*/
@ApiOperation(value = "查询app首页关键数据")
@GetMapping("/getCriticalData")
public AjaxResult getCriticalData()
{
CriticalData data = leaseApplyInfoService.getCriticalData();
return success(data);
}
} }

View File

@ -133,6 +133,9 @@ public class LeaseApplyDetails extends BaseEntity {
@ApiModelProperty(value = "编码类型集合") @ApiModelProperty(value = "编码类型集合")
private List<MaCodeVo> maCodeVoList; private List<MaCodeVo> maCodeVoList;
@ApiModelProperty(value = "领料出库编码类型集合")
private List<MaCodeVo> outMaCodeVoList;
@ApiModelProperty(value = "往来单位id") @ApiModelProperty(value = "往来单位id")
private Long unitId; private Long unitId;

View File

@ -0,0 +1,57 @@
package com.bonus.material.lease.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* app首页领退料数据
* @Author ma_sh
* @create 2025/5/26 9:28
*/
@Data
public class CriticalData {
/** 当日领料 */
@ApiModelProperty(value = "当日领料")
private int dayLeaseNum;
/** 当日退料 */
@ApiModelProperty(value = "当日退料")
private int dayBackNum;
/** 当日入库 */
@ApiModelProperty(value = "当日入库")
private int dayInputNum;
/** 当日出库 */
@ApiModelProperty(value = "当日出库")
private int dayOutNum;
/** 工器具领料 */
@ApiModelProperty(value = "工器具领料")
private int toolLeaseNum;
/** 工器具退料 */
@ApiModelProperty(value = "工器具退料")
private int toolBackNum;
/** 材料领料 */
@ApiModelProperty(value = "材料领料")
private int materialLeaseNum;
/** 材料退料 */
@ApiModelProperty(value = "材料退料")
private int materialBackNum;
@ApiModelProperty(value="开始时间")
private String startTime;
@ApiModelProperty(value="结束时间")
private String endTime;
@ApiModelProperty(value = "领料方式0 材料领料1 工器具领料)")
private String leaseStyle;
@ApiModelProperty(value = "退料方式0 材料退料1 工器具退料)")
private String backStyle;
}

View File

@ -34,6 +34,9 @@ public class LeaseApplyRequestVo extends BaseEntity {
private List<LeaseOutVo> leaseOutVoList; private List<LeaseOutVo> leaseOutVoList;
@ApiModelProperty(value = "领料单详情")
private List<LeaseApplyDetails> leaseOutDetailsList;
private int statusFlag; private int statusFlag;
} }

View File

@ -186,4 +186,17 @@ public interface LeaseApplyDetailsMapper {
* @return * @return
*/ */
List<MaCodeVo> getSecondLeaseInfo(LeaseTotalInfo info); List<MaCodeVo> getSecondLeaseInfo(LeaseTotalInfo info);
/**
* 工器具领料出库详情
* @param id
* @return
*/
List<LeaseApplyDetails> selectLeaseOutList(Long id);
LeaseApplyDetails selectLeaseApplyDetailsByTypeId(LeaseOutDetails record);
List<LeaseApplyDetails> getOutNum(LeaseApplyDetails leaseApplyDetails);
List<LeaseApplyDetails> getOutNumList(LeaseApplyDetails leaseApplyDetails);
} }

View File

@ -3,6 +3,7 @@ package com.bonus.material.lease.mapper;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo; import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.material.lease.domain.vo.CriticalData;
import com.bonus.material.lease.domain.vo.LeaseTotalInfo; import com.bonus.material.lease.domain.vo.LeaseTotalInfo;
/** /**
@ -112,4 +113,18 @@ public interface LeaseApplyInfoMapper {
* @return * @return
*/ */
BigDecimal getNumList(LeaseApplyInfo applyInfo); BigDecimal getNumList(LeaseApplyInfo applyInfo);
/**
* 获取当日退料数量
* @param data
* @return
*/
int getDayBackNum(CriticalData data);
/**
* 获取当日领料数量
* @param data
* @return
*/
int getDayLeaseNum(CriticalData data);
} }

View File

@ -10,6 +10,7 @@ import com.bonus.material.basic.domain.BmQrcodeInfo;
import com.bonus.material.lease.domain.LeaseApplyDetails; import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.LeaseApplyDetailsInfo; import com.bonus.material.lease.domain.LeaseApplyDetailsInfo;
import com.bonus.material.lease.domain.LeaseOutDetailsInfo; import com.bonus.material.lease.domain.LeaseOutDetailsInfo;
import com.bonus.material.lease.domain.vo.CriticalData;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo; import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
import com.bonus.common.biz.domain.lease.LeaseOutRequestVo; import com.bonus.common.biz.domain.lease.LeaseOutRequestVo;
import com.bonus.material.lease.domain.vo.LeaseTotalInfo; import com.bonus.material.lease.domain.vo.LeaseTotalInfo;
@ -192,4 +193,17 @@ public interface ILeaseApplyInfoService {
* @return * @return
*/ */
List<MaCodeVo> getSecondLeaseInfo(LeaseTotalInfo info); List<MaCodeVo> getSecondLeaseInfo(LeaseTotalInfo info);
/**
* 查询app首页关键数据
* @return
*/
CriticalData getCriticalData();
/**
* 获取领料任务详细信息
* @param leaseApplyDetails
* @return
*/
List<LeaseApplyDetails> getOutNum(LeaseApplyDetails leaseApplyDetails);
} }

View File

@ -5,6 +5,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -31,6 +32,7 @@ import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.material.lease.domain.LeaseApplyDetailsInfo; import com.bonus.material.lease.domain.LeaseApplyDetailsInfo;
import com.bonus.material.lease.domain.LeaseOutDetailsInfo; import com.bonus.material.lease.domain.LeaseOutDetailsInfo;
import com.bonus.material.lease.domain.vo.CriticalData;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo; import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
import com.bonus.common.biz.domain.lease.LeaseOutRequestVo; import com.bonus.common.biz.domain.lease.LeaseOutRequestVo;
import com.bonus.material.lease.domain.vo.LeaseOutVo; import com.bonus.material.lease.domain.vo.LeaseOutVo;
@ -110,6 +112,8 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
leaseApplyRequestVo.setLeaseApplyInfo(info); leaseApplyRequestVo.setLeaseApplyInfo(info);
// 获取领料单详情 // 获取领料单详情
List<LeaseApplyDetails> details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, null)); List<LeaseApplyDetails> details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, null));
//根据id查询领料单详情
List<LeaseApplyDetails> outDetailsList = leaseApplyDetailsMapper.selectLeaseOutList(id);
if (!CollectionUtils.isEmpty(details)) { if (!CollectionUtils.isEmpty(details)) {
leaseApplyRequestVo.setLeaseApplyDetailsList(details); leaseApplyRequestVo.setLeaseApplyDetailsList(details);
for (LeaseApplyDetails detail : details) { for (LeaseApplyDetails detail : details) {
@ -120,9 +124,17 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
} }
} }
} }
if (!CollectionUtils.isEmpty(outDetailsList)) {
leaseApplyRequestVo.setLeaseOutDetailsList(outDetailsList);
for (LeaseApplyDetails detail : outDetailsList) {
List<MaCodeVo> maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId());
if (!CollectionUtils.isEmpty(maCodeVoList)) {
detail.setOutMaCodeVoList(maCodeVoList);
}
}
}
}); });
return leaseApplyRequestVo; return leaseApplyRequestVo;
} catch (Exception e) { } catch (Exception e) {
// 记录异常日志 // 记录异常日志
@ -573,6 +585,95 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
return leaseApplyDetailsMapper.getSecondLeaseInfo(info); return leaseApplyDetailsMapper.getSecondLeaseInfo(info);
} }
/**
* 查询app首页关键数据
* @return
*/
@Override
public CriticalData getCriticalData() {
CriticalData data = new CriticalData();
LocalDate currentDate = LocalDate.now();
String startTime = currentDate + " 00:00:00";
String endTime = currentDate + " 23:59:59";
// 工器具领料数量
data.setLeaseStyle("1");
int toolLeaseNum = leaseApplyInfoMapper.getDayLeaseNum(data);
// 材料领料数量
data.setLeaseStyle("0");
int materialLeaseNum = leaseApplyInfoMapper.getDayLeaseNum(data);
// 工器具退料数量
data.setBackStyle("1");
int toolBackNum = leaseApplyInfoMapper.getDayBackNum(data);
// 材料退料数量
data.setBackStyle("0");
int materialBackNum = leaseApplyInfoMapper.getDayBackNum(data);
// 当日领料数量
data.setStartTime(startTime);
data.setEndTime(endTime);
data.setLeaseStyle(null);
data.setBackStyle(null);
int dayLeaseNum = leaseApplyInfoMapper.getDayLeaseNum(data);
// 当日退料数量
int dayBackNum = leaseApplyInfoMapper.getDayBackNum(data);
//int dayInputNum = leaseApplyInfoMapper.getDayInputNum(startTime,endTime);
//int dayOutNum = leaseApplyInfoMapper.getDayOutNum(startTime,endTime);
data.setDayLeaseNum(dayLeaseNum);
data.setDayBackNum(dayBackNum);
//data.setDayInputNum(dayInputNum);
//data.setDayOutNum(dayOutNum);
data.setToolLeaseNum(toolLeaseNum);
data.setToolBackNum(toolBackNum);
data.setMaterialLeaseNum(materialLeaseNum);
data.setMaterialBackNum(materialBackNum);
return data;
}
/**
* 获取领料任务详细信息
* @param leaseApplyDetails
* @return
*/
@Override
public List<LeaseApplyDetails> getOutNum(LeaseApplyDetails leaseApplyDetails) {
List<LeaseApplyDetails> list = leaseApplyDetailsMapper.getOutNum(leaseApplyDetails);
// 根据id去出库表查询数据进行数据拼接
List<LeaseApplyDetails> outNumList = leaseApplyDetailsMapper.getOutNumList(leaseApplyDetails);
// 构建typeId到LeaseApplyDetails的映射用于快速查找
Map<Long, LeaseApplyDetails> outNumMap = outNumList.stream()
.collect(Collectors.toMap(LeaseApplyDetails::getTypeId, details -> details, (existing, replacement) -> existing));
if (!CollectionUtils.isEmpty(list)) {
// 处理已有数据的状态
list.forEach(applyDetails -> {
if (outNumMap.containsKey(applyDetails.getTypeId())) {
applyDetails.setStatus("1");
outNumMap.remove(applyDetails.getTypeId()); // 移除已匹配的项
}
});
// 添加outNumList中剩余的typeId对应数据
if (!outNumMap.isEmpty()) {
list.addAll(outNumMap.values());
}
}
if (StringUtils.isNotBlank(leaseApplyDetails.getKeyword())) {
return list.stream().filter(item -> {
return containsNumKeyword(item, leaseApplyDetails.getKeyword());
}).collect(Collectors.toList());
}
return list;
}
/**
* 总站点领料记录数据过滤
* @param item
* @param keyWord
* @return
*/
private boolean containsNumKeyword(LeaseApplyDetails item, String keyWord) {
return (item.getMaTypeName() != null && item.getMaTypeName().contains(keyWord)) ||
(item.getTypeName() != null && item.getTypeName().contains(keyWord));
}
/** /**
* 总站点领料记录数据过滤 * 总站点领料记录数据过滤
* @param item * @param item

View File

@ -2,7 +2,10 @@ package com.bonus.material.lease.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo; import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.biz.domain.lease.LeaseMaCodeDto; import com.bonus.common.biz.domain.lease.LeaseMaCodeDto;
@ -168,6 +171,14 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
try { try {
// 1判断库存是否足够 // 1判断库存是否足够
//boolean isEnough = checkStorageIsEnough(record); //boolean isEnough = checkStorageIsEnough(record);
// 针对于app进行判断出库新增时判断此设备是否已经领料申请过
if (record.getIsNew() != null && record.getIsNew() == 0){
// 根据typeId去lease_apply_details表查询设备是否存在
LeaseApplyDetails leaseApplyDetails = leaseApplyDetailsMapper.selectLeaseApplyDetailsByTypeId(record);
if (leaseApplyDetails != null) {
return AjaxResult.error("此设备已经申请领料,请勿重复申请");
}
}
record.setPreStoreNum(getStorageNum(record)); record.setPreStoreNum(getStorageNum(record));
res = checkStorageNum(record); res = checkStorageNum(record);
if (res > 0) { if (res > 0) {
@ -177,7 +188,36 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
throw new RuntimeException("出库失败,更新设备规格库存数量时出错!"); throw new RuntimeException("出库失败,更新设备规格库存数量时出错!");
} }
// 4修改任务状态tm_task // 4修改任务状态tm_task
res = updateTaskStatus(record); if (record.getIsApp() != null && record.getIsApp() == 0) {
LeaseApplyDetails leaseApplyDetails = new LeaseApplyDetails();
leaseApplyDetails.setId(record.getParentId());
List<LeaseApplyDetails> list = leaseApplyDetailsMapper.getOutNum(leaseApplyDetails);
// 根据id去出库表查询数据进行数据拼接
List<LeaseApplyDetails> outNumList = leaseApplyDetailsMapper.getOutNumList(leaseApplyDetails);
// 构建typeId到LeaseApplyDetails的映射用于快速查找
Map<Long, LeaseApplyDetails> outNumMap = outNumList.stream()
.collect(Collectors.toMap(LeaseApplyDetails::getTypeId, details -> details, (existing, replacement) -> existing));
if (!CollectionUtils.isEmpty(list)) {
// 处理已有数据的状态
list.forEach(applyDetails -> {
if (outNumMap.containsKey(applyDetails.getTypeId())) {
applyDetails.setStatus("1");
outNumMap.remove(applyDetails.getTypeId()); // 移除已匹配的项
}
});
// 添加outNumList中剩余的typeId对应数据
if (!outNumMap.isEmpty()) {
list.addAll(outNumMap.values());
}
}
// 判断list中status状态是否全部为1则修改任务状态为完成
if (list.size() == list.stream().filter(item -> "1".equals(item.getStatus())).count()) {
res = updateTaskStatus(record);
}
} else {
res = updateTaskStatus(record);
}
if (res == 0) { if (res == 0) {
throw new RuntimeException("出库失败,修改任务状态失败"); throw new RuntimeException("出库失败,修改任务状态失败");
} }

View File

@ -319,7 +319,6 @@ public class TypeController extends BaseController {
/** /**
* 根据左列表类型id查询右表格 --- 暂未启用代码有问题!! * 根据左列表类型id查询右表格 --- 暂未启用代码有问题!!
* TODO: 待完善 * TODO: 待完善
* @param typeId 左列表类型id
@ApiOperation(value = "根据左列表类型id查询右表格") @ApiOperation(value = "根据左列表类型id查询右表格")
@GetMapping("/getListByMaType") @GetMapping("/getListByMaType")

View File

@ -318,6 +318,8 @@ public class MachineServiceImpl implements IMachineService
dto.setMaStatus("在用"); dto.setMaStatus("在用");
} else if ("3".equals(dto.getMaStatus())) { } else if ("3".equals(dto.getMaStatus())) {
dto.setMaStatus("退回"); dto.setMaStatus("退回");
} else {
dto.setMaStatus("退回");
} }
} }
} }

View File

@ -41,7 +41,7 @@ public class StatisticTask {
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
//@Scheduled(cron = "0 * * * * ?") //@Scheduled(cron = "0 * * * * ?")
public void setTypeInfoToMaType() { public void setTypeInfoToMaType() {
System.err.println("-----------开始计算四类未结算费用定时器-----------"); System.err.println("-----------开始处理机具推送数据定时器-----------");
// 首先查询当天ma_station_push表推送的数据 // 首先查询当天ma_station_push表推送的数据
LocalDate today = LocalDate.now(); LocalDate today = LocalDate.now();
String formDate = today.format(DateTimeFormatter.ISO_LOCAL_DATE); String formDate = today.format(DateTimeFormatter.ISO_LOCAL_DATE);

View File

@ -48,7 +48,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP_CONCAT(DISTINCT mt2.type_id) as typeId, GROUP_CONCAT(DISTINCT mt2.type_id) as typeId,
GROUP_CONCAT(DISTINCT mt2.type_name) AS typeName, GROUP_CONCAT(DISTINCT mt2.type_name) AS typeName,
bai.`status` AS status, bai.`status` AS status,
bai.print_status as printStatus bai.print_status as printStatus,
SUM(IFNULL(bad.pre_num, 0)) AS backNum
FROM FROM
back_apply_info bai back_apply_info bai
LEFT JOIN back_apply_details bad on bad.parent_id = bai.id LEFT JOIN back_apply_details bad on bad.parent_id = bai.id
@ -320,8 +321,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
LEFT JOIN bm_project bp on bp.pro_id = ba.project_id LEFT JOIN bm_project bp on bp.pro_id = ba.project_id
AND bp.del_flag = '0' AND bp.del_flag = '0'
LEFT JOIN bm_team bt on bt.team_id = ba.team_id LEFT JOIN bm_team bt on bt.id = ba.team_id
AND bu.del_flag = '0' AND bt.del_flag = '0'
WHERE WHERE
mm.ma_status = '2' and mm.ma_code = #{maCode} mm.ma_status = '2' and mm.ma_code = #{maCode}
AND ba.team_id = #{teamId} AND ba.team_id = #{teamId}
@ -401,6 +402,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM FROM
lease_out_details lod lease_out_details lod
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
LEFT JOIN ma_station_code ms ON mm.ma_code = ms.ma_code
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
AND mt.del_flag = '0' AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
@ -412,10 +414,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
LEFT JOIN bm_project bp on bp.pro_id = ba.project_id LEFT JOIN bm_project bp on bp.pro_id = ba.project_id
AND bp.del_flag = '0' AND bp.del_flag = '0'
LEFT JOIN bm_team bt on bt.team_id = ba.team_id LEFT JOIN bm_team bt on bt.id = ba.team_id
AND bt.del_flag = '0' AND bt.del_flag = '0'
WHERE WHERE
mm.ma_status = '2' and mm.qr_code = #{qrCode} mm.ma_status = '2' and ms.ma_qrcode = #{qrCode}
AND ba.team_id = #{teamId}
AND ba.project_id = #{proId}
</select> </select>
<select id="getDetailsById" resultType="com.bonus.material.back.domain.BackApplyDetails"> <select id="getDetailsById" resultType="com.bonus.material.back.domain.BackApplyDetails">
@ -429,7 +433,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bcd.parent_id as parentId, bcd.parent_id as parentId,
bcd.create_by as createBy, bcd.create_by as createBy,
bcd.create_time as createTime, bcd.create_time as createTime,
bai.task_id as taskId bai.task_id as taskId,
bcd.ap_detection as apDetection
FROM FROM
back_check_details bcd back_check_details bcd
LEFT JOIN ma_type mt ON bcd.type_id = mt.type_id LEFT JOIN ma_type mt ON bcd.type_id = mt.type_id
@ -689,7 +694,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<update id="updateDetails"> <update id="updateDetails">
update back_apply_details set pre_num = pre_num + COALESCE(#{preNum} ,0) where id = #{id} update back_apply_details set pre_num = pre_num + COALESCE(#{preNum} ,0),
audit_num = audit_num + COALESCE(#{preNum} ,0)
where id = #{id}
</update> </update>
<update id="updateCheck"> <update id="updateCheck">
@ -1001,7 +1008,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_team bt ON bt.id = bagi.team_id LEFT JOIN bm_team bt ON bt.id = bagi.team_id
AND bt.del_flag = '0' AND bt.del_flag = '0'
WHERE WHERE
1 = 1 bcd.is_finished = 1
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[and DATE_FORMAT( bcd.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]> <![CDATA[and DATE_FORMAT( bcd.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if> </if>
@ -1021,6 +1028,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bt.id, bt.id,
bp.pro_id, bp.pro_id,
bai.`code` bai.`code`
ORDER BY
bcd.create_time DESC
</select> </select>
<select id="getSecondBackInfo" resultType="com.bonus.material.back.domain.vo.BackMaCodeVo"> <select id="getSecondBackInfo" resultType="com.bonus.material.back.domain.vo.BackMaCodeVo">
@ -1055,4 +1064,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bcd.create_time DESC bcd.create_time DESC
</select> </select>
<select id="getBackApplyDetailsByTypeIdAndParentId"
resultType="com.bonus.material.back.domain.BackApplyDetails">
SELECT
id AS id,
type_id AS typeId,
parent_id AS parentId
FROM
back_apply_details
WHERE
type_id = #{typeId}
AND parent_id = #{parentId}
</select>
</mapper> </mapper>

View File

@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
IFNULL(lad.pre_num,0) as pre_num, IFNULL(lad.pre_num,0) as pre_num,
IFNULL(lad.audit_num,0) as audit_num, IFNULL(lad.audit_num,0) as audit_num,
IFNULL(lad.al_num,0) as al_num, IFNULL(lad.al_num,0) as al_num,
IFNULL(lad.status,0) as status, mt.unit_name as unitName,mt.unit_value, IFNULL(lad.status,0) as status, mt.unit_name ,mt.unit_value,
lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark as remark, lad.company_id lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark as remark, lad.company_id
from from
lease_apply_details lad lease_apply_details lad
@ -261,22 +261,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getInfoByQrcode" resultType="com.bonus.common.biz.domain.lease.LeaseOutDetails"> <select id="getInfoByQrcode" resultType="com.bonus.common.biz.domain.lease.LeaseOutDetails">
SELECT SELECT
mt1.type_name as typeName, mt1.type_name as typeName,
mt.type_name as typeModelName, mt.type_name as typeModelName,
mm.ma_id as maId, mm.ma_id as maId,
mm.ma_code as maCode, mm.ma_code as maCode,
mm.type_id as typeId, mm.type_id as typeId,
mm.ma_status as maStatus, mm.ma_status as maStatus,
mm.qr_code as qrCode, ms.ma_qrcode as qrCode,
case when mm.ma_status = '1' then '在库' case when mm.ma_status = '1' then '在库'
else '' else ''
end as statusName, end as statusName,
mt.manage_type as manageType mt.manage_type as manageType
FROM ma_machine mm FROM ma_machine mm
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0' LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0'
LEFT JOIN ma_station_code ms ON mm.ma_code = ms.ma_code
where where
mm.qr_code = #{qrCode} ms.ma_qrcode = #{qrCode}
</select> </select>
<select id="getCodeList" resultType="com.bonus.material.back.domain.vo.MaCodeVo"> <select id="getCodeList" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
@ -596,7 +597,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.unit_name as unitName, mt.unit_name as unitName,
mt.unit_value as unitValue, mt.unit_value as unitValue,
SUM(lad.out_num) as outNum, SUM(lad.out_num) as outNum,
SUM(IFNULL( lod.pre_num, 0 )) as preNum, IFNULL( lod.pre_num, 0 ) as preNum,
lad.remark as remark lad.remark as remark
FROM FROM
lease_out_details lad lease_out_details lad
@ -657,4 +658,97 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
lod.create_time DESC lod.create_time DESC
</select> </select>
<select id="selectLeaseOutList" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
mt1.type_name AS maTypeName,
mt.type_name AS typeName,
mt.unit_name AS unitName,
SUM( IFNULL(lod.out_num, 0) ) AS preNum,
mt.manage_type AS manageType,
mt.type_id AS typeId,
lod.parent_id AS parentId
FROM
lease_out_details lod
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
WHERE
lod.parent_id = #{id}
GROUP BY
mt.type_id
</select>
<select id="selectLeaseApplyDetailsByTypeId"
resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
parent_id as parentId,
type_id as typeId
FROM
lease_apply_details
WHERE
parent_id = #{parentId}
and type_id = #{typeId}
</select>
<select id="getOutNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
lad.parent_id as parentId,
lad.type_id as typeId,
COALESCE(lad.pre_num, 0) AS preNum,
COALESCE(SUM(lod.out_num), 0) AS alNum,
GREATEST(COALESCE(lad.pre_num, 0) - COALESCE(SUM(lod.out_num), 0), 0) AS outNum,
mt1.type_name as maTypeName,
mt.type_name as typeName,
mt.manage_type as manageType,
'0' as status,
mt.unit_name as unitName,
CASE mt.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(mt.storage_num, 0)
END as storageNum
FROM
lease_apply_details lad
LEFT JOIN lease_out_details lod ON lad.parent_id = lod.parent_id
AND lad.type_id = lod.type_id
LEFT JOIN ma_type mt ON lad.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (1)
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
WHERE
lad.parent_id = #{id}
GROUP BY
lad.parent_id,
lad.type_id;
</select>
<select id="getOutNumList" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
lod.parent_id as parentId,
lod.type_id as typeId,
0 AS preNum,
COALESCE(SUM(lod.out_num), 0) AS alNum,
0 AS outNum,
mt1.type_name as maTypeName,
mt.type_name as typeName,
mt.manage_type as manageType,
mt.unit_name as unitName,
'1' as status
FROM
lease_out_details lod
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
WHERE
lod.parent_id = #{id}
GROUP BY
lod.type_id
</select>
</mapper> </mapper>

View File

@ -335,7 +335,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ma_name AS typeCode, ma_name AS typeCode,
ma_model AS modelCode, ma_model AS modelCode,
ma_unit AS unitNames, ma_unit AS unitNames,
NUM AS preCountNum NUM AS preCountNum,
ma_code AS maCode
FROM FROM
ma_station_push ma_station_push
WHERE WHERE
@ -393,6 +394,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
GROUP BY GROUP BY
mt.type_id,lai.team_id,lai.pro_id,lai.`code` mt.type_id,lai.team_id,lai.pro_id,lai.`code`
ORDER BY
lai.create_time DESC
</select> </select>
<select id="getTotalInfo" resultType="com.bonus.material.lease.domain.vo.LeaseTotalInfo"> <select id="getTotalInfo" resultType="com.bonus.material.lease.domain.vo.LeaseTotalInfo">
@ -415,4 +418,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parent_id = #{id} parent_id = #{id}
</select> </select>
<select id="getDayBackNum" resultType="java.lang.Integer">
SELECT COALESCE(sum(pre_num), 0)
FROM back_apply_info bai
LEFT JOIN back_apply_details bad ON bai.id = bad.parent_id
WHERE
1 = 1
<if test="backStyle != null and backStyle != '' ">
AND bai.back_style = #{backStyle}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[AND bai.create_time &gt;= #{startTime} AND bai.create_time &lt;= #{endTime} ]]>
</if>
</select>
<select id="getDayLeaseNum" resultType="java.lang.Integer">
SELECT COALESCE(sum(pre_num), 0)
FROM lease_apply_info lai
LEFT JOIN lease_apply_details lad ON lai.id = lad.parent_id
WHERE
1 = 1
<if test="leaseStyle != null and leaseStyle != '' ">
AND lai.lease_style = #{leaseStyle}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[AND lai.create_time &gt;= #{startTime} AND lai.create_time &lt;= #{endTime} ]]>
</if>
</select>
</mapper> </mapper>

View File

@ -338,7 +338,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UPDATE UPDATE
ma_machine ma_machine
SET SET
ma_status = #{status},create_time = NOW() ma_status = #{status},update_time = NOW()
<where> <where>
type_id = #{record.typeId} type_id = #{record.typeId}
<if test="record.maId != null and record.maId != ''"> <if test="record.maId != null and record.maId != ''">
@ -495,40 +495,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getMachineInfo" resultType="com.bonus.material.ma.domain.Machine"> <select id="getMachineInfo" resultType="com.bonus.material.ma.domain.Machine">
SELECT SELECT
ma_material AS materialName, ms.ma_material AS materialName,
ma_type AS typeName, ms.ma_type AS typeName,
ma_name AS typeCode, ms.ma_name AS typeCode,
ma_model AS maModel, ms.ma_model AS maModel,
ma_code AS maCode, ms.ma_code AS maCode,
ma_qrcode AS qrCode, ms.ma_qrcode AS qrCode,
ma_status AS maStatus, mm.ma_status AS maStatus,
this_check_time AS thisCheckTime, ms.this_check_time AS thisCheckTime,
next_check_time AS nextCheckTime, ms.next_check_time AS nextCheckTime,
check_man AS checkMan, ms.check_man AS checkMan,
out_fac_time AS outFacTime, ms.out_fac_time AS outFacTime,
input_time AS inputTime ms.input_time AS inputTime
FROM FROM
ma_station_code ma_station_code ms
LEFT JOIN ma_machine mm ON ms.ma_code = mm.ma_code
WHERE 1 = 1 WHERE 1 = 1
<if test="keyWord != null and keyWord != ''"> <if test="keyWord != null and keyWord != ''">
and ( and (
ma_code like concat('%', #{keyWord}, '%') or ms.ma_code like concat('%', #{keyWord}, '%') or
ma_qrcode like concat('%', #{keyWord}, '%') or ms.ma_qrcode like concat('%', #{keyWord}, '%') or
check_man like concat('%', #{keyWord}, '%') or ms.check_man like concat('%', #{keyWord}, '%') or
ma_material like concat('%', #{keyWord}, '%') or ms.ma_material like concat('%', #{keyWord}, '%') or
ma_type like concat('%', #{keyWord}, '%') or ms.ma_type like concat('%', #{keyWord}, '%') or
ma_name like concat('%', #{keyWord}, '%') or ms.ma_name like concat('%', #{keyWord}, '%') or
ma_model like concat('%', #{keyWord}, '%') ms.ma_model like concat('%', #{keyWord}, '%')
) )
</if> </if>
<if test="typeCode != null and typeCode != ''"> <if test="typeCode != null and typeCode != ''">
and ma_name like concat('%', #{typeCode}, '%') and ms.ma_name like concat('%', #{typeCode}, '%')
</if> </if>
<if test="maModel != null and maModel != ''"> <if test="maModel != null and maModel != ''">
and ma_model like concat('%', #{maModel}, '%') and ms.ma_model like concat('%', #{maModel}, '%')
</if> </if>
GROUP BY GROUP BY
ma_code ms.ma_code
</select> </select>
<delete id="deleteMachineByMaCodeAndTypeId"> <delete id="deleteMachineByMaCodeAndTypeId">