|
|
|
|
@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.lims.capital.entity.ProductStoreDetial; |
|
|
|
|
import org.springblade.lims.capital.service.IProductStoreDetialService; |
|
|
|
|
import org.springblade.lims.goods.entity.Apply; |
|
|
|
|
import org.springblade.lims.goods.entity.ApplyDetail; |
|
|
|
|
import org.springblade.lims.goods.entity.Goods; |
|
|
|
|
@ -14,9 +16,13 @@ import org.springblade.lims.goods.mapper.GoodsMapper; |
|
|
|
|
import org.springblade.lims.goods.service.IApplyDetailService; |
|
|
|
|
import org.springblade.lims.goods.service.IApplyService; |
|
|
|
|
import org.springblade.lims.goods.service.IGoodsService; |
|
|
|
|
import org.springblade.resource.feign.IMessageClient; |
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
@ -35,6 +41,10 @@ public class ApplyServiceImpl extends BaseServiceImpl<ApplyMapper, Apply> implem |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IApplyDetailService applyDetailService; |
|
|
|
|
@Autowired |
|
|
|
|
private IGoodsService goodsService; |
|
|
|
|
@Autowired |
|
|
|
|
private IProductStoreDetialService productStoreDetialService; |
|
|
|
|
|
|
|
|
|
@Value("${print}") |
|
|
|
|
private String print; |
|
|
|
|
@ -55,21 +65,31 @@ public class ApplyServiceImpl extends BaseServiceImpl<ApplyMapper, Apply> implem |
|
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>(); |
|
|
|
|
for (ApplyDetail detail : details) { |
|
|
|
|
HashMap<String, Object> map = new HashMap<>(5); |
|
|
|
|
// 物品名称
|
|
|
|
|
map.put("goodsName", detail.getProductName()); |
|
|
|
|
// 物品型号
|
|
|
|
|
map.put("xh", detail.getXh()); |
|
|
|
|
// 物品规格
|
|
|
|
|
map.put("gg", detail.getRule()); |
|
|
|
|
// 申领数量
|
|
|
|
|
map.put("count", detail.getApplyNum()); |
|
|
|
|
// 物品单位
|
|
|
|
|
map.put("unit", detail.getUnit()); |
|
|
|
|
resultList.add(map); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
// 申领人
|
|
|
|
|
result.put("applyUser", apply.getApplyUser()); |
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
// 申领时间
|
|
|
|
|
result.put("applyTime", format.format(apply.getApplyTime())); |
|
|
|
|
// 审批人
|
|
|
|
|
result.put("approvalUser", apply.getApproveUser()); |
|
|
|
|
// 审批时间
|
|
|
|
|
result.put("approvalTime", format.format(apply.getApproveTime())); |
|
|
|
|
result.put("applyRemark", apply.getReason()); |
|
|
|
|
// 申领备注
|
|
|
|
|
result.put("applyRemark", apply.getRemark()); |
|
|
|
|
result.put("resultList", resultList); |
|
|
|
|
|
|
|
|
|
// String handleUrl = "C://Users//AAA//Desktop//烁今//打印模板//出库单(模板).docx";
|
|
|
|
|
@ -114,4 +134,94 @@ public class ApplyServiceImpl extends BaseServiceImpl<ApplyMapper, Apply> implem |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public void reture(Apply apply) { |
|
|
|
|
// 设置一个判断申领单状态的变量
|
|
|
|
|
boolean isComplete = true; |
|
|
|
|
// 前端传过来的申领详情
|
|
|
|
|
List<ApplyDetail> applyDetails = apply.getApplyDetails(); |
|
|
|
|
// 如果申领详情不为空
|
|
|
|
|
if (applyDetails != null && applyDetails.size() > 0) { |
|
|
|
|
// 遍历该集合,对每条需要归还的物品做归还操作
|
|
|
|
|
for (ApplyDetail detail : applyDetails) { |
|
|
|
|
// 归还时间不为空即需要归还的物品
|
|
|
|
|
if (detail.getReturnTime() != null) { |
|
|
|
|
// 修改该物品的总库存数量
|
|
|
|
|
Goods goods = goodsService.getById(detail.getProductId()); |
|
|
|
|
goods.setNum(goods.getNum() + detail.getReturnNum()); |
|
|
|
|
goodsService.updateById(goods); |
|
|
|
|
|
|
|
|
|
//批次数量回填(批次数量入库)
|
|
|
|
|
LambdaQueryWrapper<ProductStoreDetial> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(ProductStoreDetial::getGoodsId, detail.getProductId()) |
|
|
|
|
.eq(ProductStoreDetial::getPNum, detail.getBatchNum()); |
|
|
|
|
// 条件查询该物品指定批次的数据
|
|
|
|
|
ProductStoreDetial productStoreDetail = productStoreDetialService.getOne(wrapper); |
|
|
|
|
// 修改该物品批次的库存数量
|
|
|
|
|
productStoreDetail.setNum(productStoreDetail.getNum() + detail.getReturnNum()); |
|
|
|
|
productStoreDetialService.updateById(productStoreDetail); |
|
|
|
|
// 对需要归还的物品数据做修改
|
|
|
|
|
if (detail.getIsReturn() != 1) { |
|
|
|
|
ApplyDetail byId = applyDetailService.getById(detail.getId()); |
|
|
|
|
if (byId != null) { |
|
|
|
|
// 计算总归还数量
|
|
|
|
|
Integer total = byId.getReturnNum() + detail.getReturnNum(); |
|
|
|
|
// 如果归还数量和实际出库数量一致,证明全部归还
|
|
|
|
|
if (detail.getOutNum().equals(total)) { |
|
|
|
|
// 修改状态为已归还(1)
|
|
|
|
|
detail.setIsReturn(1); |
|
|
|
|
} |
|
|
|
|
// 修改归还数量
|
|
|
|
|
detail.setReturnNum(total); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 遍历该集合,看需要归还的物品是否全部归还
|
|
|
|
|
for (ApplyDetail detail : applyDetails) { |
|
|
|
|
// 如果需要归还的物品,还未全部归还
|
|
|
|
|
if (detail.getReturnTime() != null && detail.getIsReturn() == 0) { |
|
|
|
|
isComplete = false; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 根据变量isComplete设置申领单状态,4已完成,3待归还
|
|
|
|
|
apply.setStatus(isComplete ? 4 : 3); |
|
|
|
|
this.updateById(apply); |
|
|
|
|
applyDetailService.updateBatchById(applyDetails); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean updateApplyOrDetails(Apply apply) { |
|
|
|
|
// List<ApplyDetail> applyDetails = apply.getApplyDetails();
|
|
|
|
|
// if (applyDetails != null && applyDetails.size() > 0) {
|
|
|
|
|
// for (ApplyDetail applyDetail : applyDetails) {
|
|
|
|
|
// applyDetail.setOutNum(applyDetail.getNewOutNum());
|
|
|
|
|
// }
|
|
|
|
|
// applyDetailService.updateBatchById(applyDetails);
|
|
|
|
|
// }
|
|
|
|
|
// return applyService.updateById(apply);
|
|
|
|
|
LambdaQueryWrapper<ApplyDetail> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(ApplyDetail::getApplyId, apply.getId()); |
|
|
|
|
// 条件查询申领相关物品信息
|
|
|
|
|
List<ApplyDetail> details = applyDetailService.list(wrapper); |
|
|
|
|
// 申领单修改状态
|
|
|
|
|
for (ApplyDetail detail : details) { |
|
|
|
|
// 如果归还时间不为null
|
|
|
|
|
if (detail.getReturnTime() != null) { |
|
|
|
|
// 设置申领单状态为待归还(3)
|
|
|
|
|
apply.setStatus(3); |
|
|
|
|
break; |
|
|
|
|
} else { |
|
|
|
|
// 反之,设置申领单状态为已完成(4)
|
|
|
|
|
apply.setStatus(4); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 修改申领单
|
|
|
|
|
return this.updateById(apply); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|