|
|
|
@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
|
import com.ruoyi.common.utils.bean.BeanValidators;
|
|
|
|
|
import com.ruoyi.ehsMaterialDetail.domain.EhsMaterialDetail;
|
|
|
|
|
import com.ruoyi.ehsMaterialDetail.service.IEhsMaterialDetailService;
|
|
|
|
|
import com.ruoyi.ehsRisk.domain.EhsRisk;
|
|
|
|
|
import com.ruoyi.materialClass.domain.MaterialClassMaster;
|
|
|
|
|
import com.ruoyi.materialClass.domain.MaterialClassSub;
|
|
|
|
@ -14,6 +16,9 @@ import com.ruoyi.materialClass.mapper.MaterialClassSubMapper;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -21,6 +26,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
import com.ruoyi.ehsMaterial.mapper.EhsMaterialMapper;
|
|
|
|
|
import com.ruoyi.ehsMaterial.domain.EhsMaterial;
|
|
|
|
|
import com.ruoyi.ehsMaterial.service.IEhsMaterialService;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.validation.Validator;
|
|
|
|
|
|
|
|
|
@ -38,6 +44,8 @@ public class EhsMaterialServiceImpl extends ServiceImpl<EhsMaterialMapper, EhsMa
|
|
|
|
|
@Autowired
|
|
|
|
|
private MaterialClassSubMapper materialClassSubMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IEhsMaterialDetailService ehsMaterialDetailService;
|
|
|
|
|
@Autowired
|
|
|
|
|
protected Validator validator;
|
|
|
|
|
/**
|
|
|
|
|
* 查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”
|
|
|
|
@ -75,6 +83,39 @@ public class EhsMaterialServiceImpl extends ServiceImpl<EhsMaterialMapper, EhsMa
|
|
|
|
|
return ehsMaterialMapper.selectEhsMateriallExportList(ehsMaterial);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查物资新增时, 物资是否重复
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<EhsMaterial> checkMaterialRepeat(EhsMaterial ehsMaterial) {
|
|
|
|
|
return ehsMaterialMapper.checkMaterialRepeat(ehsMaterial);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public boolean mergeMaterial(EhsMaterial ehsMaterial) {
|
|
|
|
|
ehsMaterial.setDeptId(SecurityUtils.getDeptId());
|
|
|
|
|
// 1.先根据部门,物资的一级、二级、三级分类查询数据库,取出数量最多的那条重复物资,与前端传来的数量相加
|
|
|
|
|
List<EhsMaterial> ehsMaterials = ehsMaterialMapper.checkMaterialRepeat(ehsMaterial);
|
|
|
|
|
EhsMaterial databaseMaterial = ehsMaterials.get(0);
|
|
|
|
|
Integer materialQuantity = 0;
|
|
|
|
|
if (StringUtils.isNotBlank(databaseMaterial.getMaterialQuantity())) {
|
|
|
|
|
materialQuantity = Integer.valueOf(databaseMaterial.getMaterialQuantity()) + Integer.valueOf(ehsMaterial.getMaterialQuantity());
|
|
|
|
|
}
|
|
|
|
|
// 2.数量相加后更新数据库中该物资的数量
|
|
|
|
|
databaseMaterial.setMaterialQuantity(materialQuantity.toString());
|
|
|
|
|
boolean b = this.updateById(databaseMaterial);
|
|
|
|
|
// 3.插入出入库明细,合并算入库
|
|
|
|
|
EhsMaterialDetail ehsMaterialDetail = new EhsMaterialDetail();
|
|
|
|
|
ehsMaterialDetail.setMaterialId(databaseMaterial.getMaterialId());
|
|
|
|
|
ehsMaterialDetail.setOutboundQuantity(ehsMaterial.getMaterialQuantity());
|
|
|
|
|
ehsMaterialDetail.setOutboundTime(new Date());
|
|
|
|
|
ehsMaterialDetail.setOutboundUserId(SecurityUtils.getUserId());
|
|
|
|
|
ehsMaterialDetail.setOperateType(1);
|
|
|
|
|
ehsMaterialDetail.setInventory(new BigDecimal(materialQuantity));
|
|
|
|
|
return ehsMaterialDetailService.save(ehsMaterialDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<EhsMaterial> buildQueryWrapper(EhsMaterial query) {
|
|
|
|
|
Map<String, Object> params = query.getParams();
|
|
|
|
|
LambdaQueryWrapper<EhsMaterial> lqw = Wrappers.lambdaQuery();
|
|
|
|
|