| | |
| | | @Override |
| | | public CommonPage selectEntryRecordList(HzProductEntryRecord entryRecord) { |
| | | SysUser currentUser = SecurityUtils.getLoginUser().getUser(); |
| | | if (!currentUser.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())) { |
| | | if (!currentUser.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())&&!currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())) { |
| | | entryRecord.setCompanyId(currentUser.getCompanyId()); |
| | | } |
| | | PageUtils.startPage(); |
| | |
| | | if(existEr.getState().equals(EntryStateEnum.ENTER.getCode())){ |
| | | throw new ApiException("已经入库,不能再修改"); |
| | | } |
| | | |
| | | if (!Objects.equals(existEr.getNum(),entryRecord.getNum())){ |
| | | generateCode2(entryRecord); |
| | | } |
| | | entryRecord.setUpdateBy(currentUser.getUsername()); |
| | | int row=baseMapper.updateById(entryRecord); |
| | | if(row<1){ |
| | |
| | | return row; |
| | | } |
| | | |
| | | private void generateCode2(HzProductEntryRecord 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.GOOD.getCode()) |
| | | .append(code) |
| | | .append(currentDate); |
| | | HzProductEntryRecord per=baseMapper.selectLastEndCodeEntryRecord(prefixBuilder.toString(),entryRecord.getCompanyId()); |
| | | int startCode=1; |
| | | int endCode=startCode+entryRecord.getNum()-1; |
| | | if(per!=null){ |
| | | startCode=per.getEndCode()+1; |
| | | endCode=startCode+entryRecord.getNum()-1; |
| | | } |
| | | entryRecord.setCodePrex(prefixBuilder.toString()); |
| | | entryRecord.setStartCode(startCode); |
| | | entryRecord.setEndCode(endCode); |
| | | entryRecord.setState(EntryStateEnum.UNENTER.getCode()); |
| | | } |
| | | |
| | | @Override |
| | | public CommonPage selectProductListByEntryId(Long entryId) { |
| | | public CommonPage selectProductListByEntryId(Long entryId,Long companyId) { |
| | | SysUser currentUser = SecurityUtils.getLoginUser().getUser(); |
| | | HzProductEntryRecord entryRecord=getById(entryId); |
| | | if(entryRecord==null){ |
| | | throw new ApiException("入库信息不存在"); |
| | | } |
| | | checkUserAllowed(entryRecord,currentUser); |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){ |
| | | IdTableNameHandler.setCurrentId(companyId); |
| | | }else { |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | } |
| | | PageUtils.startPage(); |
| | | List<HzProduct> productList = productMapper.selectProductList(new HzProduct().setEntryId(entryId)); |
| | | IdTableNameHandler.removeCurrentId(); |
| | |
| | | throw new ApiException("管理员不能操作"); |
| | | } |
| | | if(entryRecord!=null){ |
| | | if(!Objects.equals(user.getCompanyId(), entryRecord.getCompanyId())){ |
| | | throw new ApiException("无权限操作其他企业数据"); |
| | | if (!user.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){ |
| | | if(!Objects.equals(user.getCompanyId(), entryRecord.getCompanyId())){ |
| | | throw new ApiException("无权限操作其他企业数据"); |
| | | } |
| | | } |
| | | } |
| | | } |