| | |
| | | import com.gkhy.hazmat.common.utils.PageUtils; |
| | | import com.gkhy.hazmat.common.utils.SecurityUtils; |
| | | import com.gkhy.hazmat.common.utils.StringUtils; |
| | | import com.gkhy.hazmat.system.domain.HzEntryRecord; |
| | | import com.gkhy.hazmat.system.domain.HzHazmat; |
| | | import com.gkhy.hazmat.system.domain.HzHazmatBasic; |
| | | import com.gkhy.hazmat.system.domain.HzWarehouseRecord; |
| | | import com.gkhy.hazmat.system.mapper.HzEntryRecordMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzHazmatBasicMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzHazmatMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzWarehouseRecordMapper; |
| | | import com.gkhy.hazmat.system.domain.*; |
| | | import com.gkhy.hazmat.system.mapper.*; |
| | | import com.gkhy.hazmat.system.service.HzEntryRecordService; |
| | | import com.gkhy.hazmat.system.service.HzHazmatService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private HzWarehouseRecordMapper warehouseRecordMapper; |
| | | @Autowired |
| | | private CustomEventPublisher customEventPublisher; |
| | | @Autowired |
| | | private SysCompanyMapper companyMapper; |
| | | |
| | | @Override |
| | | public CommonPage selectEntryRecordList(HzEntryRecord entryRecord) { |
| | |
| | | if(hazmatBasic==null){ |
| | | throw new ApiException("危化品基础数据不存在"); |
| | | } |
| | | if(entryRecord.getNum()>hazmatBasic.getMaxEntry()){ |
| | | throw new ApiException("数量超过单次入库最大数量<"+hazmatBasic.getMaxEntry()+">"); |
| | | } |
| | | entryRecord.setCompanyId(currentUser.getCompanyId()); |
| | | entryRecord.setCreateBy(currentUser.getUsername()); |
| | | checkUserAllowed(null,currentUser); |
| | |
| | | } |
| | | |
| | | public void generateCode(HzEntryRecord entryRecord){ |
| | | SysCompany company=companyMapper.selectById(entryRecord.getCompanyId()); |
| | | String code=company.getCode(); |
| | | if(StringUtils.isBlank(code)){ |
| | | throw new ApiException("公司两位编码为空"); |
| | | } |
| | | String currentDate= DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT); |
| | | StringBuilder prefixBuilder=new StringBuilder().append(CodePrexEnum.MATERIAL.getCode()) |
| | | .append(code) |
| | | .append(currentDate); |
| | | |
| | | HzEntryRecord er=baseMapper.selectLastEntryRecord(prefixBuilder.toString(),entryRecord.getCompanyId()); |
| | | int startCode=0; |
| | | int startCode=1; |
| | | int endCode=startCode+entryRecord.getNum()-1; |
| | | if(er!=null){ |
| | | startCode=er.getEndCode()+1; |
| | |
| | | public int updateEntryRecord(HzEntryRecord entryRecord) { |
| | | SysUser currentUser = SecurityUtils.getLoginUser().getUser(); |
| | | checkUserAllowed(entryRecord,currentUser); |
| | | HzHazmatBasic hazmatBasic=hazmatBasicMapper.selectById(entryRecord.getBasicId()); |
| | | if(hazmatBasic==null){ |
| | | throw new ApiException("危化品基础数据不存在"); |
| | | } |
| | | HzEntryRecord existEr=baseMapper.selectById(entryRecord.getId()); |
| | | if(existEr.getState().equals(EntryStateEnum.ENTER.getCode())){ |
| | | throw new ApiException("已经入库,不能再修改"); |
| | | } |
| | | if(entryRecord.getNum()>hazmatBasic.getMaxEntry()){ |
| | | throw new ApiException("数量超过单次入库最大数量<"+hazmatBasic.getMaxEntry()+">"); |
| | | } |
| | | entryRecord.setUpdateBy(currentUser.getUsername()); |
| | | int row=baseMapper.updateById(entryRecord); |
| | | if(row<1){ |