|  |  |  | 
|---|
|  |  |  | import com.ruoyi.system.dto.*; | 
|---|
|  |  |  | import com.ruoyi.system.importExcel.TErpGoodsExcel; | 
|---|
|  |  |  | import com.ruoyi.system.model.*; | 
|---|
|  |  |  | import com.ruoyi.system.query.PageAddListQuery; | 
|---|
|  |  |  | import com.ruoyi.system.query.TErpGoodsAdminQuery; | 
|---|
|  |  |  | import com.ruoyi.system.query.TErpGoodsQuery; | 
|---|
|  |  |  | import com.ruoyi.system.service.*; | 
|---|
|  |  |  | import com.ruoyi.system.vo.TErpGoodsVO; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(erpGoodsService.pageList(query,user)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取erp问题上报管理列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation(value = "平台获取商品分页列表") | 
|---|
|  |  |  | @PostMapping(value = "/pageAdminList") | 
|---|
|  |  |  | public R<PageInfo<TErpGoodsVO>> pageAdminList(@RequestBody TErpGoodsAdminQuery query) { | 
|---|
|  |  |  | SysUser user = tokenService.getLoginUser().getUser(); | 
|---|
|  |  |  | Integer roleType = user.getRoleType(); | 
|---|
|  |  |  | if(roleType == 1){ | 
|---|
|  |  |  | // 平台 | 
|---|
|  |  |  | return R.ok(erpGoodsService.pageAdminList(query)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取erp问题上报管理列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation(value = "诊所 一键获取商品分页列表") | 
|---|
|  |  |  | @PostMapping(value = "/pageAddList") | 
|---|
|  |  |  | public R<Page<TErpGoods>> pageAddList(BasePage query) { | 
|---|
|  |  |  | public R<Page<TErpGoods>> pageAddList(@RequestBody PageAddListQuery query) { | 
|---|
|  |  |  | SysUser user = tokenService.getLoginUser().getUser(); | 
|---|
|  |  |  | Integer roleType = user.getRoleType(); | 
|---|
|  |  |  | String clinicSupplierId=null; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Page<TErpGoods> tErpGoodsPage = new Page<>(query.getPageNum(), query.getPageSize()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Page<TErpGoods> page = erpGoodsService.page(tErpGoodsPage, new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource, 1).eq(BaseModel::getDisabled, 0).isNotNull(TErpGoods::getPlatformCommissionPrice).last("and (NOT FIND_IN_SET(" + clinicSupplierId + ",clinic_ids) or  clinic_ids is null)")); | 
|---|
|  |  |  | for (TErpGoods record : page.getRecords()) { | 
|---|
|  |  |  | TCrmSupplier byId = crmSupplierService.getById(record.getSupplierClinicId()); | 
|---|
|  |  |  | record.setSupplierName(byId.getSupplierName()); | 
|---|
|  |  |  | List<TErpGoods> page = erpGoodsService.pageAddList(tErpGoodsPage,clinicSupplierId,query); | 
|---|
|  |  |  | tErpGoodsPage.setRecords(page); | 
|---|
|  |  |  | return R.ok(tErpGoodsPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取erp问题上报管理列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation(value = "诊所 一键获取商品 获取全部") | 
|---|
|  |  |  | @PostMapping(value = "/getAllGoodsList") | 
|---|
|  |  |  | public R<?> getAllGoodsList() { | 
|---|
|  |  |  | SysUser user = tokenService.getLoginUser().getUser(); | 
|---|
|  |  |  | Integer roleType = user.getRoleType(); | 
|---|
|  |  |  | String clinicSupplierId=null; | 
|---|
|  |  |  | if(roleType == 5){ | 
|---|
|  |  |  | // 诊所 | 
|---|
|  |  |  | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) | 
|---|
|  |  |  | .eq(TCrmClinic::getUserId, user.getUserId()) | 
|---|
|  |  |  | .last("LIMIT 1")); | 
|---|
|  |  |  | clinicSupplierId = crmClinic.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TErpGoodsType byId1 = erpGoodsTypeService.getById(record.getTypeId()); | 
|---|
|  |  |  | record.setTypeName(byId1.getTypeName()); | 
|---|
|  |  |  | 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()){ | 
|---|
|  |  |  | goods.setClinicIds(clinicSupplierId); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | String[] split = clinicIds.split(","); | 
|---|
|  |  |  | ArrayList<String> split1 = new ArrayList<>(); | 
|---|
|  |  |  | for (String s : split) { | 
|---|
|  |  |  | split1.add(s); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!split1.contains(clinicSupplierId)){ | 
|---|
|  |  |  | split1.add(clinicSupplierId); | 
|---|
|  |  |  | goods.setClinicIds(String.join(",",split1)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(page); | 
|---|
|  |  |  | erpGoodsService.updateBatchById(list); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public R<Boolean> clinicAdd(@Validated @RequestBody TErpClinicGoodsAddDto dto) { | 
|---|
|  |  |  | SysUser user = tokenService.getLoginUser().getUser(); | 
|---|
|  |  |  | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) { | 
|---|
|  |  |  | return R.fail("erp商品已存在"); | 
|---|
|  |  |  | return R.fail("erp商品已存在,商品条码重复"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (erpGoodsService.isExitOne(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) { | 
|---|
|  |  |  | return R.fail("erp商品已存在,国药准字号重复"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer roleType = user.getRoleType(); | 
|---|
|  |  |  | TErpGoods goods = new TErpGoods(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | goods.setCreateId(user.getUserId().toString()); | 
|---|
|  |  |  | goods.setGoodsIdCode(dto.getGoodsIdCode()); | 
|---|
|  |  |  | //        goods.setClinicPurchasePrice(dto.getSalesAmount()); | 
|---|
|  |  |  | return R.ok(erpGoodsService.save(goods)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "诊所 一键添加商品") | 
|---|
|  |  |  | @PostMapping(value = "/addSupplierGoods") | 
|---|
|  |  |  | public R<Boolean> addSupplierGoods(String goodsIds) { | 
|---|
|  |  |  | List<String> split = Arrays.asList(goodsIds.split(",")); | 
|---|
|  |  |  | List<TErpGoods> list = erpGoodsService.list(new LambdaQueryWrapper<TErpGoods>().in(TErpGoods::getId, split)); | 
|---|
|  |  |  | public R<Boolean> addSupplierGoods(@RequestBody AddSupplierGoodsDto dto) { | 
|---|
|  |  |  | //        List<String> split = Arrays.asList(goodsIds.split(",")); | 
|---|
|  |  |  | List<TErpGoods> list = erpGoodsService.list(new LambdaQueryWrapper<TErpGoods>().in(TErpGoods::getId, dto.getGoodsIds())); | 
|---|
|  |  |  | SysUser user = tokenService.getLoginUser().getUser(); | 
|---|
|  |  |  | String cid = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | cid = crmClinic.getId(); | 
|---|
|  |  |  | for (TErpGoods goods : list) { | 
|---|
|  |  |  | String clinicIds = goods.getClinicIds(); | 
|---|
|  |  |  | List<String> split1 = Arrays.asList(clinicIds.split(",")); | 
|---|
|  |  |  | if(!split1.contains(cid)){ | 
|---|
|  |  |  | split1.add(cid); | 
|---|
|  |  |  | goods.setClinicIds(String.join(",",split1)); | 
|---|
|  |  |  | 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)){ | 
|---|
|  |  |  | split1.add(cid); | 
|---|
|  |  |  | goods.setClinicIds(String.join(",",split1)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | erpGoodsService.updateBatchById(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(erpGoodsService.updateById(goods)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "供应商商品详情") | 
|---|
|  |  |  | @ApiOperation(value = "商品详情") | 
|---|
|  |  |  | @GetMapping(value = "/detail/{id}") | 
|---|
|  |  |  | public R<TErpGoods> detail( @PathVariable String  id) { | 
|---|
|  |  |  | TErpGoods goods = erpGoodsService.getById(id); | 
|---|