| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | private final TErpSupplierWarehousingService erpSupplierWarehousingService; |
| | | private final TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService; |
| | | private final TErpMaintenanceReminderService erpMaintenanceReminderService; |
| | | private final TCrmClinicService crmClinicService; |
| | | private final TCrmSupplierService crmSupplierService; |
| | | |
| | | @Autowired |
| | | public TErpGoodsController(TErpGoodsService erpGoodsService, TokenService tokenService, TErpGoodsTypeService erpGoodsTypeService, TErpGoodsUnitService erpGoodsUnitService, |
| | | TErpSupplierWarehousingBatchService erpSupplierWarehousingBatchService, TErpSupplierWarehousingService erpSupplierWarehousingService, |
| | | TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService, TErpMaintenanceReminderService erpMaintenanceReminderService) { |
| | | TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService, TErpMaintenanceReminderService erpMaintenanceReminderService, TCrmClinicService crmClinicService, TCrmSupplierService crmSupplierService) { |
| | | this.erpGoodsService = erpGoodsService; |
| | | this.tokenService = tokenService; |
| | | this.erpGoodsTypeService = erpGoodsTypeService; |
| | |
| | | this.erpSupplierWarehousingService = erpSupplierWarehousingService; |
| | | this.erpSupplierOutboundGoodsService = erpSupplierOutboundGoodsService; |
| | | this.erpMaintenanceReminderService = erpMaintenanceReminderService; |
| | | this.crmClinicService = crmClinicService; |
| | | this.crmSupplierService = crmSupplierService; |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | query.setSupplierClinicId(crmSupplier.getId()); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | query.setSupplierClinicId(crmClinic.getId()); |
| | | } |
| | | return R.ok(erpGoodsService.pageList(query,user)); |
| | | } |
| | | |
| | |
| | | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber())) { |
| | | return R.fail("erp商品已存在"); |
| | | } |
| | | Integer roleType = user.getRoleType(); |
| | | TErpGoods goods = new TErpGoods(); |
| | | goods.setSupplierClinicId(user.getUserId().toString()); |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | goods.setSupplierClinicId(crmSupplier.getId()); |
| | | goods.setGoodsSource(1); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | goods.setSupplierClinicId(crmClinic.getId()); |
| | | goods.setGoodsSource(2); |
| | | } |
| | | goods.setCreateId(user.getUserId().toString()); |
| | | goods.setGoodsIdCode(dto.getGoodsIdCode()); |
| | | goods.setQuasiNumber(dto.getQuasiNumber()); |
| | |
| | | @PostMapping(value = "/saveDataInfo") |
| | | public R<Boolean> saveDataInfo(@RequestBody @Valid TErpGoodsInfoSaveDto dto) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | String clinicSupplierId=null; |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | clinicSupplierId = crmSupplier.getId(); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | clinicSupplierId =crmClinic.getId(); |
| | | } |
| | | |
| | | TErpGoods goods = erpGoodsService.getById(dto.getId()); |
| | | BeanUtils.copyProperties(dto,goods); |
| | | if(goods.getMaintenanceInterval()!=null){ |
| | |
| | | if (tErpSupplierWarehousingBatch.getWarehousingNumber()-sum>0) { |
| | | // 生成保养单 |
| | | TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder(); |
| | | tErpMaintenanceReminder.setClinicSupplierId(user.getUserId().toString()); |
| | | tErpMaintenanceReminder.setClinicSupplierId(clinicSupplierId); |
| | | tErpMaintenanceReminder.setMaintenanceType(1); |
| | | tErpMaintenanceReminder.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId()); |
| | | Integer day = Integer.valueOf(goods.getMaintenanceInterval()); |
| | |
| | | public void listExport(@RequestBody TErpGoodsQuery query) |
| | | { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | |
| | | Integer roleType = user.getRoleType(); |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | query.setSupplierClinicId(crmSupplier.getId()); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | query.setSupplierClinicId(crmClinic.getId()); |
| | | } |
| | | |
| | | List<TErpGoodsVO> pageList = erpGoodsService.listExport(query,user); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TErpGoodsVO.class, pageList); |
| | | HttpServletResponse response = WebUtils.response(); |
| | |
| | | if (collect.size() != carAnnuallyImportExcels.size()) { |
| | | return AjaxResult.error("导入数据中商品标识码重复"); |
| | | } |
| | | Integer roleType = user.getRoleType(); |
| | | for (TErpGoodsExcel erpGoodsExcel : carAnnuallyImportExcels) { |
| | | TErpGoods goods = new TErpGoods(); |
| | | goods.setSupplierClinicId(user.getUserId().toString()); |
| | | goods.setGoodsSource(1); |
| | | |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | goods.setSupplierClinicId(crmSupplier.getId()); |
| | | goods.setGoodsSource(1); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | goods.setSupplierClinicId(crmClinic.getId()); |
| | | goods.setGoodsSource(2); |
| | | } |
| | | |
| | | // 判空 |
| | | if(erpGoodsExcel.getGoodsName()==null || erpGoodsExcel.getGoodsName().isEmpty()){ |