危化品全生命周期管理后端
git
heheng
2025-03-06 07a6e79342c381d4d8c98a92a216c41dc9502a09
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatBasicServiceImpl.java
@@ -16,9 +16,12 @@
import com.gkhy.hazmat.common.utils.SecurityUtils;
import com.gkhy.hazmat.common.utils.StringUtils;
import com.gkhy.hazmat.system.domain.HzHazmatBasic;
import com.gkhy.hazmat.system.domain.vo.HzSecientificVo;
import com.gkhy.hazmat.system.mapper.HzHazmatBasicMapper;
import com.gkhy.hazmat.system.mapper.HzSecientificMapper;
import com.gkhy.hazmat.system.service.HzHazmatBasicService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -39,6 +42,10 @@
 */
@Service
public class HzHazmatBasicServiceImpl extends ServiceImpl<HzHazmatBasicMapper, HzHazmatBasic> implements HzHazmatBasicService {
    @Autowired
    private HzSecientificMapper secientificMapper;
    @Override
    public CommonPage selectHazmatBasicList(HzHazmatBasic hazmatBasic) {
@@ -73,6 +80,11 @@
        }
        checkUserAllowed(null,currentUser);
        HzSecientificVo hzSecientificVo = secientificMapper.selectBySecientificName(hazmatBasic.getName());
        hazmatBasic.setPeculiarityType(hzSecientificVo!=null? hzSecientificVo.getPeculiarityType() : null);
        hazmatBasic.setPeculiarityNumber(hzSecientificVo!=null? hzSecientificVo.getPeculiarityNumber() : 0);
        hazmatBasic.setSecientificId(hzSecientificVo!=null? hzSecientificVo.getId() : null);
        int row = baseMapper.insert(hazmatBasic);
        if (row < 1) {
            throw new ApiException("新增危化品基础信息失败");
@@ -88,6 +100,10 @@
        SysUser currentUser = SecurityUtils.getLoginUser().getUser();
        checkUserAllowed(hazmatBasic,currentUser);
        hazmatBasic.setUpdateBy(currentUser.getUsername());
        HzSecientificVo hzSecientificVo = secientificMapper.selectBySecientificName(hazmatBasic.getName());
        hazmatBasic.setPeculiarityType(hzSecientificVo!=null? hzSecientificVo.getPeculiarityType() : null);
        hazmatBasic.setPeculiarityNumber(hzSecientificVo!=null? hzSecientificVo.getPeculiarityNumber() : 0);
        hazmatBasic.setSecientificId(hzSecientificVo!=null? hzSecientificVo.getId() : null);
        int row=baseMapper.updateById(hazmatBasic);
        if(row<1){
            throw new ApiException("更新危化品基础信息失败");
@@ -155,6 +171,12 @@
            if(minPackage==null){
                throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"最小包装类型填写不正确");
            }
            HzSecientificVo hzSecientificVo = secientificMapper.selectBySecientificName(hazmatBasic.getName());
            hazmatBasic.setPeculiarityType(hzSecientificVo!=null? hzSecientificVo.getPeculiarityType() : "");
            hazmatBasic.setPeculiarityNumber(hzSecientificVo!=null? hzSecientificVo.getPeculiarityNumber() : 0);
            hazmatBasic.setSecientificId(hzSecientificVo!=null? hzSecientificVo.getId() : null);
            hazmatBasic.setKind(kind);
            hazmatBasic.setMinPackage(minPackage);
            hazmatBasic.setCompanyId(currentUser.getCompanyId());