| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取erp问题上报管理列表 |
| | | */ |
| | |
| | | public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | if(roleType == 4){ |
| | | if (roleType == 4) { |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmSupplier)){ |
| | | if (Objects.isNull(crmSupplier)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmSupplier = crmSupplierService.getById(sysUser.getObjectId()); |
| | | } |
| | | |
| | | query.setSupplierClinicId(crmSupplier.getId()); |
| | | } |
| | | if(roleType == 5){ |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | | query.setSupplierClinicId(crmClinic.getId()); |
| | | } |
| | | |
| | | return R.ok(erpGoodsService.pageList(query,user)); |
| | | return R.ok(erpGoodsService.pageList(query, user)); |
| | | } |
| | | |
| | | /** |
| | |
| | | public R<PageInfo<TErpGoodsVO>> pageAdminList(@RequestBody TErpGoodsAdminQuery query) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | if(roleType == 1){ |
| | | if (roleType == 1) { |
| | | // 平台 |
| | | return R.ok(erpGoodsService.pageAdminList(query)); |
| | | } |
| | |
| | | @ApiOperation(value = "平台审核商品内容") |
| | | @PostMapping(value = "/adminAudit") |
| | | @Log(title = "商品管理-平台审核商品内容", businessType = BusinessType.UPDATE) |
| | | public R<?> adminAudit(@RequestBody AdminAuditDto dto) { |
| | | public R<?> adminAudit(@RequestBody AdminAuditDto dto) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | List<TErpGoods> tErpGoods = erpGoodsService.listByIds(dto.getIds()); |
| | | if(roleType == 1){ |
| | | tErpGoods.stream().forEach(e->e.setContentState(dto.getContentState())); |
| | | if (roleType == 1) { |
| | | tErpGoods.stream().forEach(e -> { |
| | | e.setContentState(dto.getContentState()); |
| | | e.setContentRemark(dto.getContentRemark()); |
| | | } |
| | | ); |
| | | erpGoodsService.updateBatchById(tErpGoods); |
| | | // 平台 |
| | | return R.ok(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "供应商提交商品内容") |
| | | @PostMapping(value = "/supplierSubmitContent") |
| | | @Log(title = "商品管理-供应商提交商品内容", businessType = BusinessType.UPDATE) |
| | | public R<?> adminAudit(@RequestBody SupplierSubmitContentDto dto) { |
| | | public R<?> adminAudit(@RequestBody SupplierSubmitContentDto dto) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | TErpGoods erpGoods = erpGoodsService.getById(dto.getId()); |
| | | if(roleType == 4){ |
| | | if (roleType == 4) { |
| | | erpGoods.setContent(dto.getContent()); |
| | | erpGoods.setContentState(0); |
| | | erpGoodsService.updateById(erpGoods); |
| | | return R.ok(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | public R<Page<TErpGoods>> pageAddList(@RequestBody PageAddListQuery query) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | String clinicSupplierId=null; |
| | | if(roleType == 5){ |
| | | String clinicSupplierId = null; |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | |
| | | } |
| | | Page<TErpGoods> tErpGoodsPage = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | |
| | | List<TErpGoods> page = erpGoodsService.pageAddList(tErpGoodsPage,clinicSupplierId,query); |
| | | List<TErpGoods> page = erpGoodsService.pageAddList(tErpGoodsPage, clinicSupplierId, query); |
| | | tErpGoodsPage.setRecords(page); |
| | | return R.ok(tErpGoodsPage); |
| | | } |
| | |
| | | public R<?> getAllGoodsList() { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | String clinicSupplierId=null; |
| | | if(roleType == 5){ |
| | | String clinicSupplierId = null; |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | | clinicSupplierId = crmClinic.getId(); |
| | | } |
| | | |
| | | List<TErpGoods> list = erpGoodsService.list(new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource, 1).eq(TErpGoods::getState,1).eq(BaseModel::getDisabled, 0).isNotNull(TErpGoods::getPlatformCommissionPrice).last("and (NOT FIND_IN_SET(" + clinicSupplierId + ",clinic_ids) or clinic_ids is null)")); |
| | | List<TErpGoods> list = erpGoodsService.list(new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource, 1).eq(TErpGoods::getState, 1).eq(BaseModel::getDisabled, 0).isNotNull(TErpGoods::getPlatformCommissionPrice).last("and (NOT FIND_IN_SET(" + clinicSupplierId + ",clinic_ids) or clinic_ids is null)")); |
| | | for (TErpGoods goods : list) { |
| | | String clinicIds = goods.getClinicIds(); |
| | | if(clinicIds == null || clinicIds.isEmpty()){ |
| | | if (clinicIds == null || clinicIds.isEmpty()) { |
| | | goods.setClinicIds(clinicSupplierId); |
| | | }else { |
| | | } else { |
| | | String[] split = clinicIds.split(","); |
| | | ArrayList<String> split1 = new ArrayList<>(); |
| | | for (String s : split) { |
| | | split1.add(s); |
| | | } |
| | | if(!split1.contains(clinicSupplierId)){ |
| | | if (!split1.contains(clinicSupplierId)) { |
| | | split1.add(clinicSupplierId); |
| | | goods.setClinicIds(String.join(",",split1)); |
| | | goods.setClinicIds(String.join(",", split1)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "供应商添加商品") |
| | | @PostMapping(value = "/add") |
| | | @Log(title = "商品管理-供应商添加", businessType = BusinessType.INSERT) |
| | | public R<Boolean> add(@Validated @RequestBody TErpGoodsAddDto dto) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) { |
| | | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(), null)) { |
| | | return R.fail("erp商品已存在"); |
| | | } |
| | | Integer roleType = user.getRoleType(); |
| | | TErpGoods goods = new TErpGoods(); |
| | | if(roleType == 4){ |
| | | if (roleType == 4) { |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmSupplier)){ |
| | | if (Objects.isNull(crmSupplier)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmSupplier = crmSupplierService.getById(sysUser.getObjectId()); |
| | | } |
| | | goods.setSupplierClinicId(crmSupplier.getId()); |
| | | goods.setGoodsSource(1); |
| | | } |
| | | if(roleType == 5){ |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | |
| | | goods.setPackingSpec(dto.getPackingSpec()); |
| | | goods.setGoodsName(dto.getGoodsName()); |
| | | goods.setIsPrescriptionDrug(null); |
| | | goods.setGoodsSpec(dto.getFormulationSpec()+"*"+dto.getPackingSpec()); |
| | | goods.setGoodsSpec(dto.getFormulationSpec() + "*" + dto.getPackingSpec()); |
| | | return R.ok(erpGoodsService.save(goods)); |
| | | } |
| | | |
| | | @ApiOperation(value = "诊所添加商品") |
| | | @PostMapping(value = "/clinicAdd") |
| | | @Log(title = "商品管理-诊所添加", businessType = BusinessType.INSERT) |
| | | public R<Boolean> clinicAdd(@Validated @RequestBody TErpClinicGoodsAddDto dto) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) { |
| | | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(), null)) { |
| | | return R.fail("erp商品已存在,商品条码重复"); |
| | | } |
| | | if (erpGoodsService.isExitOne(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) { |
| | | if (erpGoodsService.isExitOne(dto.getGoodsIdCode(), dto.getQuasiNumber(), null)) { |
| | | return R.fail("erp商品已存在,国药准字号重复"); |
| | | } |
| | | Integer roleType = user.getRoleType(); |
| | | TErpGoods goods = new TErpGoods(); |
| | | BeanUtils.copyProperties(dto,goods); |
| | | goods.setGoodsSpec(dto.getFormulationSpec()+"*"+dto.getPackingSpec()); |
| | | if(roleType == 5){ |
| | | BeanUtils.copyProperties(dto, goods); |
| | | goods.setGoodsSpec(dto.getFormulationSpec() + "*" + dto.getPackingSpec()); |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | |
| | | } |
| | | goods.setCreateId(user.getUserId().toString()); |
| | | goods.setGoodsIdCode(dto.getGoodsIdCode()); |
| | | goods.setGoodsSpec(dto.getFormulationSpec()+"*"+dto.getPackingSpec()); |
| | | goods.setGoodsSpec(dto.getFormulationSpec() + "*" + dto.getPackingSpec()); |
| | | // goods.setClinicPurchasePrice(dto.getSalesAmount()); |
| | | if(goods.getIsPrescriptionDrug()!=null && goods.getIsPrescriptionDrug()==3){ |
| | | if (goods.getIsPrescriptionDrug() != null && goods.getIsPrescriptionDrug() == 3) { |
| | | goods.setIsPrescriptionDrug(null); |
| | | } |
| | | return R.ok(erpGoodsService.save(goods)); |
| | |
| | | @Log(title = "商品管理-诊所编辑", businessType = BusinessType.UPDATE) |
| | | public R<Boolean> clinicUpdate(@Validated @RequestBody TErpClinicGoodsUpdateDto dto) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(),dto.getId())) { |
| | | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(), dto.getId())) { |
| | | return R.fail("erp商品已存在"); |
| | | } |
| | | Integer roleType = user.getRoleType(); |
| | | TErpGoods goods = new TErpGoods(); |
| | | BeanUtils.copyProperties(dto,goods); |
| | | if(roleType == 5){ |
| | | BeanUtils.copyProperties(dto, goods); |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | |
| | | goods.setCreateId(user.getUserId().toString()); |
| | | goods.setGoodsIdCode(dto.getGoodsIdCode()); |
| | | goods.setId(dto.getId()); |
| | | goods.setGoodsSpec(dto.getFormulationSpec()+"*"+dto.getPackingSpec()); |
| | | if(goods.getIsPrescriptionDrug()!=null && goods.getIsPrescriptionDrug()==3){ |
| | | goods.setGoodsSpec(dto.getFormulationSpec() + "*" + dto.getPackingSpec()); |
| | | if (goods.getIsPrescriptionDrug() != null && goods.getIsPrescriptionDrug() == 3) { |
| | | goods.setIsPrescriptionDrug(null); |
| | | } |
| | | return R.ok(erpGoodsService.updateById(goods)); |
| | |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | String cid = null; |
| | | |
| | | if(user.getRoleType() == 5){ |
| | | if (user.getRoleType() == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | | cid = crmClinic.getId(); |
| | | if(goods.getGoodsSource()==1){ |
| | | if (goods.getGoodsSource() == 1) { |
| | | String clinicIds = goods.getClinicIds(); |
| | | String[] split = clinicIds.split(","); |
| | | // clinicIds 移除cid |
| | | ArrayList<String> strings = new ArrayList<>(); |
| | | for (String s : split) { |
| | | if(!s.equals(cid)){ |
| | | if (!s.equals(cid)) { |
| | | strings.add(s); |
| | | } |
| | | } |
| | | goods.setClinicIds(String.join(",",strings)); |
| | | goods.setClinicIds(String.join(",", strings)); |
| | | erpGoodsService.updateById(goods); |
| | | }else { |
| | | } else { |
| | | erpGoodsService.removeById(id); |
| | | } |
| | | return R.ok(); |
| | |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | String cid = null; |
| | | |
| | | if(user.getRoleType() == 5){ |
| | | if (user.getRoleType() == 5) { |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | | cid = crmClinic.getId(); |
| | | for (TErpGoods goods : list) { |
| | | String clinicIds = goods.getClinicIds(); |
| | | if(clinicIds==null || clinicIds.isEmpty()){ |
| | | goods.setClinicIds( cid); |
| | | }else { |
| | | if (clinicIds == null || clinicIds.isEmpty()) { |
| | | goods.setClinicIds(cid); |
| | | } else { |
| | | String[] split = clinicIds.split(","); |
| | | List<String> split1 = new ArrayList<>(); |
| | | for (String s : split) { |
| | | split1.add(s); |
| | | } |
| | | if(!split1.contains(cid)){ |
| | | if (!split1.contains(cid)) { |
| | | split1.add(cid); |
| | | goods.setClinicIds(String.join(",",split1)); |
| | | goods.setClinicIds(String.join(",", split1)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | TErpGoods goods = erpGoodsService.getById(dto.getId()); |
| | | if(goods.getState()==2 && dto.getState()==2){ |
| | | if (goods.getState() == 2 && dto.getState() == 2) { |
| | | return R.fail("操作失败,该商品已是禁用状态"); |
| | | } |
| | | if(dto.getState()==1 && goods.getTypeId()==null){ |
| | | if (dto.getState() == 1 && goods.getTypeId() == null) { |
| | | return R.fail("操作失败,请先完善商品信息"); |
| | | } |
| | | if(dto.getState()==1 && goods.getClinicPurchasePrice()==null){ |
| | | if (dto.getState() == 1 && goods.getClinicPurchasePrice() == null) { |
| | | return R.fail("操作失败,请设置供应商分佣比例后再启用"); |
| | | } |
| | | if(dto.getState()==1 && Objects.nonNull(goods.getStateUser()) && goods.getStateUser()==1 && user.getRoleType()==5){ |
| | | if (dto.getState() == 1 && goods.getStateUser() == 1 && user.getRoleType() == 5) { |
| | | return R.fail("操作失败,平台禁用商品不可启用"); |
| | | } |
| | | if(user.getRoleType()==1){ |
| | | if (user.getRoleType() == 1) { |
| | | goods.setStateUser(1); |
| | | }else if(user.getRoleType()==5){ |
| | | } else if (user.getRoleType() == 5) { |
| | | goods.setStateUser(2); |
| | | } |
| | | goods.setStateRemark(dto.getStateRemark()); |
| | |
| | | public R<Boolean> saveDataInfo(@RequestBody @Valid TErpGoodsInfoSaveDto dto) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | String clinicSupplierId=null; |
| | | if(roleType == 4){ |
| | | String clinicSupplierId = null; |
| | | if (roleType == 4) { |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmSupplier)){ |
| | | if (Objects.isNull(crmSupplier)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmSupplier = crmSupplierService.getById(sysUser.getObjectId()); |
| | | } |
| | | clinicSupplierId = crmSupplier.getId(); |
| | | } |
| | | if(roleType == 5){ |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | | clinicSupplierId =crmClinic.getId(); |
| | | clinicSupplierId = crmClinic.getId(); |
| | | } |
| | | |
| | | TErpGoods goods = erpGoodsService.getById(dto.getId()); |
| | | BeanUtils.copyProperties(dto,goods); |
| | | if(goods.getMaintenanceInterval()!=null){ |
| | | BeanUtils.copyProperties(dto, goods); |
| | | if (goods.getMaintenanceInterval() != null) { |
| | | |
| | | List<TErpSupplierWarehousing> list = erpSupplierWarehousingService.list(new LambdaQueryWrapper<TErpSupplierWarehousing>().eq(TErpSupplierWarehousing::getGoodsId, dto.getId())); |
| | | if(!list.isEmpty()){ |
| | | if (!list.isEmpty()) { |
| | | List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchService.list(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().in(TErpSupplierWarehousingBatch::getWarehousingId, list.stream().map(TErpSupplierWarehousing::getId).collect(Collectors.toList()))); |
| | | for (TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch : tErpSupplierWarehousingBatches) { |
| | | List<TErpSupplierOutboundGoods> list1 = erpSupplierOutboundGoodsService.list(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, tErpSupplierWarehousingBatch.getId())); |
| | | if(!list1.isEmpty()){ |
| | | if (!list1.isEmpty()) { |
| | | int sum = list1.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum(); |
| | | if (tErpSupplierWarehousingBatch.getWarehousingNumber()-sum>0) { |
| | | if (tErpSupplierWarehousingBatch.getWarehousingNumber() - sum > 0) { |
| | | // 生成保养单 |
| | | TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder(); |
| | | tErpMaintenanceReminder.setClinicSupplierId(clinicSupplierId); |
| | |
| | | } |
| | | |
| | | } |
| | | if(goods.getIsPrescriptionDrug()!=null && goods.getIsPrescriptionDrug()==3){ |
| | | if (goods.getIsPrescriptionDrug() != null && goods.getIsPrescriptionDrug() == 3) { |
| | | goods.setIsPrescriptionDrug(null); |
| | | } |
| | | |
| | |
| | | |
| | | @ApiOperation(value = "商品详情") |
| | | @GetMapping(value = "/detail/{id}") |
| | | public R<TErpGoods> detail( @PathVariable String id) { |
| | | public R<TErpGoods> detail(@PathVariable String id) { |
| | | TErpGoods goods = erpGoodsService.getById(id); |
| | | return R.ok(goods); |
| | | } |
| | |
| | | @ApiOperation(value = "商品管理信息导出--导出") |
| | | @PostMapping("/export") |
| | | @Log(title = "商品管理-导出", businessType = BusinessType.EXPORT) |
| | | public void listExport(@RequestBody TErpGoodsQuery query) |
| | | { |
| | | public void listExport(@RequestBody TErpGoodsQuery query) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | |
| | | Integer roleType = user.getRoleType(); |
| | | if(roleType == 4){ |
| | | if (roleType == 4) { |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmSupplier)){ |
| | | if (Objects.isNull(crmSupplier)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmSupplier = crmSupplierService.getById(sysUser.getObjectId()); |
| | | } |
| | | query.setSupplierClinicId(crmSupplier.getId()); |
| | | } |
| | | if(roleType == 5){ |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | | query.setSupplierClinicId(crmClinic.getId()); |
| | | } |
| | | |
| | | List<TErpGoodsVO> pageList = erpGoodsService.listExport(query,user); |
| | | List<TErpGoodsVO> pageList = erpGoodsService.listExport(query, user); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TErpGoodsVO.class, pageList); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | |
| | | @ApiOperation(value = "商品管理信息导入") |
| | | @PostMapping("/importFile") |
| | | @Log(title = "商品管理-导入", businessType = BusinessType.IMPORT) |
| | | public AjaxResult importFile(@RequestParam(value = "file") MultipartFile file ) { |
| | | public AjaxResult importFile(@RequestParam(value = "file") MultipartFile file) { |
| | | |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | |
| | | for (TErpGoodsExcel erpGoodsExcel : carAnnuallyImportExcels) { |
| | | TErpGoods goods = new TErpGoods(); |
| | | |
| | | if(roleType == 4){ |
| | | if (roleType == 4) { |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmSupplier)){ |
| | | if (Objects.isNull(crmSupplier)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmSupplier = crmSupplierService.getById(sysUser.getObjectId()); |
| | | } |
| | | goods.setSupplierClinicId(crmSupplier.getId()); |
| | | goods.setGoodsSource(1); |
| | | } |
| | | if(roleType == 5){ |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | |
| | | } |
| | | |
| | | // 判空 |
| | | if(erpGoodsExcel.getGoodsName()==null || erpGoodsExcel.getGoodsName().isEmpty()){ |
| | | if (erpGoodsExcel.getGoodsName() == null || erpGoodsExcel.getGoodsName().isEmpty()) { |
| | | names.add("商品名称不能为空"); |
| | | continue; |
| | | } |
| | | if(erpGoodsExcel.getGoodsIdCode()==null || erpGoodsExcel.getGoodsIdCode().isEmpty() |
| | | || erpGoodsExcel.getQuasiNumber() ==null || erpGoodsExcel.getQuasiNumber().isEmpty() |
| | | || erpGoodsExcel.getManufacturer()==null || erpGoodsExcel.getManufacturer().isEmpty() |
| | | || erpGoodsExcel.getFormulationSpec()==null || erpGoodsExcel.getFormulationSpec().isEmpty() |
| | | || erpGoodsExcel.getPackingSpec()==null || erpGoodsExcel.getPackingSpec().isEmpty() |
| | | || erpGoodsExcel.getClinicPurchasePrice()==null|| erpGoodsExcel.getClinicPurchasePrice().isEmpty() |
| | | || erpGoodsExcel.getWarningInventory()==null|| erpGoodsExcel.getWarningInventory().isEmpty() |
| | | || erpGoodsExcel.getTypeName()==null|| erpGoodsExcel.getTypeName().isEmpty()){ |
| | | names.add(erpGoodsExcel.getGoodsName()+" :信息有误,请检查后重新提交。"); |
| | | if (erpGoodsExcel.getGoodsIdCode() == null || erpGoodsExcel.getGoodsIdCode().isEmpty() |
| | | || erpGoodsExcel.getQuasiNumber() == null || erpGoodsExcel.getQuasiNumber().isEmpty() |
| | | || erpGoodsExcel.getManufacturer() == null || erpGoodsExcel.getManufacturer().isEmpty() |
| | | || erpGoodsExcel.getFormulationSpec() == null || erpGoodsExcel.getFormulationSpec().isEmpty() |
| | | || erpGoodsExcel.getPackingSpec() == null || erpGoodsExcel.getPackingSpec().isEmpty() |
| | | || erpGoodsExcel.getClinicPurchasePrice() == null || erpGoodsExcel.getClinicPurchasePrice().isEmpty() |
| | | || erpGoodsExcel.getWarningInventory() == null || erpGoodsExcel.getWarningInventory().isEmpty() |
| | | || erpGoodsExcel.getTypeName() == null || erpGoodsExcel.getTypeName().isEmpty()) { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :信息有误,请检查后重新提交。"); |
| | | continue; |
| | | } |
| | | goods.setGoodsName(erpGoodsExcel.getGoodsName()); |
| | | // 判断数据是否正确 |
| | | // 判断条码是否重复 |
| | | long count = erpGoodsService.count(new QueryWrapper<TErpGoods>().eq("goods_id_code", erpGoodsExcel.getGoodsIdCode())); |
| | | if(count>0){ |
| | | if (count > 0) { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :条码重复"); |
| | | continue; |
| | | } |
| | |
| | | |
| | | // 商品类型 |
| | | TErpGoodsType one = erpGoodsTypeService.getOne(new LambdaQueryWrapper<TErpGoodsType>().eq(TErpGoodsType::getTypeName, erpGoodsExcel.getTypeName())); |
| | | if(one==null){ |
| | | if (one == null) { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :商品类型不存在"); |
| | | continue; |
| | | } |
| | |
| | | // 采购价 |
| | | try { |
| | | goods.setClinicPurchasePrice(new BigDecimal(erpGoodsExcel.getClinicPurchasePrice()).setScale(2, RoundingMode.HALF_UP)); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :采购价有误"); |
| | | continue; |
| | | } |
| | | // 预警库存 |
| | | try { |
| | | goods.setWarningInventory(Integer.valueOf(erpGoodsExcel.getWarningInventory())); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :预警库存有误"); |
| | | continue; |
| | | } |
| | | goods.setGoodsYards(erpGoodsExcel.getGoodsYards()); |
| | | try { |
| | | if(erpGoodsExcel.getMaintenanceInterval()!=null && !erpGoodsExcel.getMaintenanceInterval().isEmpty()){ |
| | | if (erpGoodsExcel.getMaintenanceInterval() != null && !erpGoodsExcel.getMaintenanceInterval().isEmpty()) { |
| | | Integer i = Integer.valueOf(erpGoodsExcel.getMaintenanceInterval()); |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :保养周期有误"); |
| | | continue; |
| | | } |
| | | goods.setMaintenanceInterval(erpGoodsExcel.getMaintenanceInterval()); |
| | | |
| | | try { |
| | | if(erpGoodsExcel.getLowPurchaseQuantity()!=null && !erpGoodsExcel.getLowPurchaseQuantity().isEmpty()){ |
| | | if (erpGoodsExcel.getLowPurchaseQuantity() != null && !erpGoodsExcel.getLowPurchaseQuantity().isEmpty()) { |
| | | goods.setLowPurchaseQuantity(Integer.valueOf(erpGoodsExcel.getLowPurchaseQuantity())); |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :最低采购数量有误"); |
| | | continue; |
| | | } |
| | | |
| | | if(erpGoodsExcel.getLowUnitName()!=null && !erpGoodsExcel.getLowUnitName().isEmpty()){ |
| | | if (erpGoodsExcel.getLowUnitName() != null && !erpGoodsExcel.getLowUnitName().isEmpty()) { |
| | | TErpGoodsUnit one1 = erpGoodsUnitService.getOne(new LambdaQueryWrapper<TErpGoodsUnit>().eq(TErpGoodsUnit::getUnitName, erpGoodsExcel.getLowUnitName())); |
| | | if (one1 == null) { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :最低采购单位有误"); |
| | |
| | | } |
| | | |
| | | |
| | | if(erpGoodsExcel.getIsPrescriptionDrug() !=null && !erpGoodsExcel.getIsPrescriptionDrug().isEmpty()){ |
| | | if(erpGoodsExcel.getIsPrescriptionDrug().equals("是")){ |
| | | if (erpGoodsExcel.getIsPrescriptionDrug() != null && !erpGoodsExcel.getIsPrescriptionDrug().isEmpty()) { |
| | | if (erpGoodsExcel.getIsPrescriptionDrug().equals("是")) { |
| | | goods.setIsPrescriptionDrug(1); |
| | | }else if (erpGoodsExcel.getIsPrescriptionDrug().equals("否")){ |
| | | } else if (erpGoodsExcel.getIsPrescriptionDrug().equals("否")) { |
| | | goods.setIsPrescriptionDrug(2); |
| | | }else { |
| | | } else { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :是否为处方药有误"); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if(erpGoodsExcel.getPackingUnitName() !=null && !erpGoodsExcel.getPackingUnitName().isEmpty()){ |
| | | if (erpGoodsExcel.getPackingUnitName() != null && !erpGoodsExcel.getPackingUnitName().isEmpty()) { |
| | | TErpGoodsUnit unit = erpGoodsUnitService.getOne(new LambdaQueryWrapper<TErpGoodsUnit>().eq(TErpGoodsUnit::getUnitName, erpGoodsExcel.getPackingUnitName())); |
| | | if(unit != null){ |
| | | if (unit != null) { |
| | | goods.setPackingUnitId(unit.getId()); |
| | | }else { |
| | | } else { |
| | | names.add(erpGoodsExcel.getGoodsName() + " :包装单位有误"); |
| | | continue; |
| | | } |
| | |
| | | goods.setPrecautions(erpGoodsExcel.getPrecautions()); |
| | | goods.setInteraction(erpGoodsExcel.getInteraction()); |
| | | goods.setStorage(erpGoodsExcel.getStorage()); |
| | | tErpGoods.add( goods); |
| | | tErpGoods.add(goods); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error("记录导入失败!"); |
| | | }finally { |
| | | } finally { |
| | | try { |
| | | inputStream.close(); |
| | | } catch (IOException e) { |
| | | throw new ServiceException(e.getMessage()); |
| | | } |
| | | } |
| | | if(names.size()>0){ |
| | | return AjaxResult.error("导入失败记录如下:",names); |
| | | if (names.size() > 0) { |
| | | return AjaxResult.error("导入失败记录如下:", names); |
| | | } |
| | | erpGoodsService.saveBatch(tErpGoods); |
| | | return AjaxResult.success(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "平台设置分佣") |
| | |
| | | public R<Boolean> setCommission(@RequestBody @Valid TErpGoodsSetCommissionDto dto) { |
| | | |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | if(user.getRoleType()==1){ |
| | | if (user.getRoleType() == 1) { |
| | | TErpGoods goods = erpGoodsService.getById(dto.getId()); |
| | | goods.setClinicPurchasePrice(BigDecimal.valueOf(dto.getClinicPurchasePrice()).setScale(2,RoundingMode.HALF_UP)); |
| | | goods.setPlatformCommissionPrice(BigDecimal.valueOf(dto.getPlatformCommissionPrice()).setScale(2,RoundingMode.HALF_UP)); |
| | | erpGoodsService.updateById( goods); |
| | | goods.setClinicPurchasePrice(BigDecimal.valueOf(dto.getClinicPurchasePrice()).setScale(2, RoundingMode.HALF_UP)); |
| | | goods.setPlatformCommissionPrice(BigDecimal.valueOf(dto.getPlatformCommissionPrice()).setScale(2, RoundingMode.HALF_UP)); |
| | | erpGoodsService.updateById(goods); |
| | | } |
| | | return R.ok(); |
| | | } |