|
|
@ -1,20 +1,19 @@ |
|
|
|
package digital.laboratory.platform.reagent.controller; |
|
|
|
package digital.laboratory.platform.reagent.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; |
|
|
|
|
|
|
|
import digital.laboratory.platform.common.core.util.R; |
|
|
|
import digital.laboratory.platform.common.core.util.R; |
|
|
|
import digital.laboratory.platform.common.log.annotation.SysLog; |
|
|
|
import digital.laboratory.platform.common.log.annotation.SysLog; |
|
|
|
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
|
|
|
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
|
|
|
|
|
|
|
import digital.laboratory.platform.reagent.dto.AuditAndApproveDto; |
|
|
|
import digital.laboratory.platform.reagent.dto.PurchaseCatalogueDto; |
|
|
|
import digital.laboratory.platform.reagent.dto.PurchaseCatalogueDto; |
|
|
|
import digital.laboratory.platform.reagent.entity.CatalogueDetails; |
|
|
|
import digital.laboratory.platform.reagent.entity.CatalogueDetails; |
|
|
|
import digital.laboratory.platform.reagent.entity.PurchaseCatalogue; |
|
|
|
import digital.laboratory.platform.reagent.entity.PurchaseCatalogue; |
|
|
|
import digital.laboratory.platform.reagent.service.CatalogueDetailsService; |
|
|
|
import digital.laboratory.platform.reagent.service.CatalogueDetailsService; |
|
|
|
import digital.laboratory.platform.reagent.service.PurchaseCatalogueService; |
|
|
|
import digital.laboratory.platform.reagent.service.PurchaseCatalogueService; |
|
|
|
import digital.laboratory.platform.reagent.vo.PurchaseCatalogueVo; |
|
|
|
import digital.laboratory.platform.reagent.vo.PurchaseCatalogueVO; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
@ -24,10 +23,7 @@ import org.springframework.security.oauth2.provider.OAuth2Authentication; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.security.Principal; |
|
|
|
import java.security.Principal; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -69,9 +65,14 @@ public class PurchaseCatalogueController { |
|
|
|
|
|
|
|
|
|
|
|
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
|
|
|
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
PurchaseCatalogueVo catalogueVo = purchaseCatalogueService.getCatalogue(purchaseCatalogueId); |
|
|
|
PurchaseCatalogueVO catalogueVo = purchaseCatalogueService.getPurchaseCatalogueVO(purchaseCatalogueId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (catalogueVo != null) { |
|
|
|
|
|
|
|
return R.ok(catalogueVo); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return R.failed("未查询到该信息"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return R.ok(catalogueVo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -85,15 +86,16 @@ public class PurchaseCatalogueController { |
|
|
|
@ApiOperation(value = "分页查询", notes = "分页查询") |
|
|
|
@ApiOperation(value = "分页查询", notes = "分页查询") |
|
|
|
@GetMapping("/page") |
|
|
|
@GetMapping("/page") |
|
|
|
@PreAuthorize("@pms.hasPermission('reagent_purchase_catalogue_get')") |
|
|
|
@PreAuthorize("@pms.hasPermission('reagent_purchase_catalogue_get')") |
|
|
|
public R<IPage<PurchaseCatalogue>> getPurchaseCataloguePage(Page<PurchaseCatalogue> page, PurchaseCatalogue purchaseCatalogue, HttpServletRequest theHttpServletRequest) { |
|
|
|
public R<IPage<PurchaseCatalogueVO>> getPurchaseCataloguePage(Page<PurchaseCatalogue> page, PurchaseCatalogue purchaseCatalogue, HttpServletRequest theHttpServletRequest) { |
|
|
|
|
|
|
|
|
|
|
|
Principal principal = theHttpServletRequest.getUserPrincipal(); |
|
|
|
Principal principal = theHttpServletRequest.getUserPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
|
|
|
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
IPage<PurchaseCatalogue> purchaseCatalogueSList = purchaseCatalogueService.page(page, Wrappers.<PurchaseCatalogue>query() |
|
|
|
IPage<PurchaseCatalogueVO> purchaseCatalogueVOPage = purchaseCatalogueService.getPurchaseCatalogueVOPage(page, Wrappers.<PurchaseCatalogue>query().eq("create_by", dlpUser.getId()) |
|
|
|
.eq("create_by", dlpUser.getId()) |
|
|
|
.orderByDesc("create_time")); |
|
|
|
.orderByDesc("create_time") |
|
|
|
|
|
|
|
); |
|
|
|
return R.ok(purchaseCatalogueVOPage); |
|
|
|
return R.ok(purchaseCatalogueSList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -119,7 +121,6 @@ public class PurchaseCatalogueController { |
|
|
|
List<CatalogueDetails> catalogueDetailsList = purchaseCatalogueService.addCatalogue(dlpUser, purchaseCatalogueDtoList, purchaseCatalogue); |
|
|
|
List<CatalogueDetails> catalogueDetailsList = purchaseCatalogueService.addCatalogue(dlpUser, purchaseCatalogueDtoList, purchaseCatalogue); |
|
|
|
|
|
|
|
|
|
|
|
if (purchaseCatalogueService.save(purchaseCatalogue) & catalogueDetailsService.saveBatch(catalogueDetailsList)) { |
|
|
|
if (purchaseCatalogueService.save(purchaseCatalogue) & catalogueDetailsService.saveBatch(catalogueDetailsList)) { |
|
|
|
|
|
|
|
|
|
|
|
return R.ok(purchaseCatalogue, "保存成功"); |
|
|
|
return R.ok(purchaseCatalogue, "保存成功"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return R.failed(purchaseCatalogue, "保存失败"); |
|
|
|
return R.failed(purchaseCatalogue, "保存失败"); |
|
|
@ -167,22 +168,116 @@ public class PurchaseCatalogueController { |
|
|
|
|
|
|
|
|
|
|
|
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
|
|
|
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
if (purchaseCatalogueService.getById(purchaseCatalogueId)!=null){ |
|
|
|
PurchaseCatalogue oldPurchaseCatalogue = purchaseCatalogueService.getById(purchaseCatalogueId); |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
if (oldPurchaseCatalogue != null) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
return R.failed("未能查到当前id数据,请重新输入"); |
|
|
|
return R.failed("未能查到当前id数据,请重新输入"); |
|
|
|
} |
|
|
|
} |
|
|
|
PurchaseCatalogue oldPurchaseCatalogue = purchaseCatalogueService.getById(purchaseCatalogueId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CatalogueDetails> list = purchaseCatalogueService.delCatalogue(purchaseCatalogueId); |
|
|
|
List<CatalogueDetails> list = purchaseCatalogueService.delCatalogue(purchaseCatalogueId); |
|
|
|
|
|
|
|
|
|
|
|
if (purchaseCatalogueService.removeById(purchaseCatalogueId)&catalogueDetailsService.removeBatchByIds(list)) { |
|
|
|
if (list!=null) { |
|
|
|
|
|
|
|
catalogueDetailsService.removeBatchByIds(list); |
|
|
|
|
|
|
|
purchaseCatalogueService.removeById(oldPurchaseCatalogue); |
|
|
|
return R.ok(oldPurchaseCatalogue, "目录删除成功"); |
|
|
|
return R.ok(oldPurchaseCatalogue, "目录删除成功"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return R.failed(oldPurchaseCatalogue, "目录删除失败"); |
|
|
|
purchaseCatalogueService.removeById(oldPurchaseCatalogue); |
|
|
|
|
|
|
|
return R.ok(oldPurchaseCatalogue, "目录删除成功"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 通过id删除采购目录明细 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param catalogueDetailsId |
|
|
|
|
|
|
|
* @return R |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@ApiOperation(value = "通过id删除采购目录明细", notes = "通过id删除采购目录明细") |
|
|
|
|
|
|
|
@SysLog("通过id删除采购目录") |
|
|
|
|
|
|
|
@DeleteMapping("details/{catalogueDetailsId}") |
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('reagent_purchase_catalogue_del')") |
|
|
|
|
|
|
|
public R<CatalogueDetails> deleteDetailsById(@PathVariable String catalogueDetailsId, HttpServletRequest theHttpServletRequest) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Principal principal = theHttpServletRequest.getUserPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CatalogueDetails byId = catalogueDetailsService.getById(catalogueDetailsId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (catalogueDetailsService.removeById(byId)){ |
|
|
|
|
|
|
|
return R.ok(byId,"删除明细成功"); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
return R.failed("删除失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 提交采购目录 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param purchaseCatalogueId |
|
|
|
|
|
|
|
* @return R |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@ApiOperation(value = "提交采购目录", notes = "提交采购目录") |
|
|
|
|
|
|
|
@SysLog("提交采购目录") |
|
|
|
|
|
|
|
@PutMapping("/commit/{purchaseCatalogueId}") |
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('reagent_purchase_catalogue_edit')") |
|
|
|
|
|
|
|
public R<PurchaseCatalogue> commitById(@PathVariable String purchaseCatalogueId, HttpServletRequest theHttpServletRequest) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PurchaseCatalogue purchaseCatalogue = purchaseCatalogueService.commitById(purchaseCatalogueId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (purchaseCatalogue!=null&purchaseCatalogueService.updateById(purchaseCatalogue)){ |
|
|
|
|
|
|
|
return R.ok(purchaseCatalogue,"提交成功"); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
return R.failed("提交失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 审核采购目录 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param auditAndApproveDto |
|
|
|
|
|
|
|
* @return R |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@ApiOperation(value = "审核采购目录", notes = "审核采购目录") |
|
|
|
|
|
|
|
@SysLog("审核采购目录") |
|
|
|
|
|
|
|
@PutMapping("/check") |
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('reagent_purchase_catalogue_edit')") |
|
|
|
|
|
|
|
public R<PurchaseCatalogue> checkCatalogue(@RequestBody AuditAndApproveDto auditAndApproveDto, HttpServletRequest theHttpServletRequest) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Principal principal = theHttpServletRequest.getUserPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PurchaseCatalogue purchaseCatalogue = purchaseCatalogueService.checkCatalogue(auditAndApproveDto,dlpUser); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (purchaseCatalogue!=null&purchaseCatalogueService.updateById(purchaseCatalogue)){ |
|
|
|
|
|
|
|
return R.ok(purchaseCatalogue,"审核成功"); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
return R.failed("审核失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 发布采购目录 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param purchaseCatalogueId |
|
|
|
|
|
|
|
* @return R |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@ApiOperation(value = "发布采购目录", notes = "发布采购目录") |
|
|
|
|
|
|
|
@SysLog("发布采购目录") |
|
|
|
|
|
|
|
@PutMapping("/release/{purchaseCatalogueId}") |
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('reagent_purchase_catalogue_edit')") |
|
|
|
|
|
|
|
public R<PurchaseCatalogue> releaseById(@PathVariable String purchaseCatalogueId, HttpServletRequest theHttpServletRequest) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PurchaseCatalogue purchaseCatalogue = purchaseCatalogueService.releaseCatalogue(purchaseCatalogueId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (purchaseCatalogue!=null&purchaseCatalogueService.updateById(purchaseCatalogue)){ |
|
|
|
|
|
|
|
return R.ok(purchaseCatalogue,"发布成功"); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
return R.failed("发布失败"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|