|
@@ -0,0 +1,183 @@
|
|
|
+package org.jeecg.modules.invoice.controller;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.constant.CommonConstant;
|
|
|
+import org.jeecg.common.dto.invoice.PurchaseReqDTO;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.modules.invoice.entity.InvoiceManagePurchase;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.modules.invoice.service.InvoiceManagePurchaseService;
|
|
|
+import org.jeecg.modules.system.service.ISysSerialPatternService;
|
|
|
+import org.jeecg.modules.system.vo.CallResult;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+
|
|
|
+ * @Author jihaosen
|
|
|
+ * @date 2021/2/26
|
|
|
+ */
|
|
|
+@Api("采购发票和销售发票接口")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/invoice/invoiceManagePurchase")
|
|
|
+@Slf4j
|
|
|
+public class InvoiceManagePurchaseController {
|
|
|
+ @Autowired
|
|
|
+ private InvoiceManagePurchaseService invoiceManagePurchaseService;
|
|
|
+ @Autowired
|
|
|
+ private ISysSerialPatternService sysSerialPatternService;
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ @ApiOperation(value = "分页查询接口", notes = "采购发票和销售发票分页查询")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="type", value="类型(1.采购发票 2.销售发票)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="billcode", value="单据编号",required=false, dataType="String")
|
|
|
+ })
|
|
|
+ public Result<IPage<InvoiceManagePurchase>> queryPageList(InvoiceManagePurchase invoiceManagePurchase,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ Result<IPage<InvoiceManagePurchase>> result = new Result<IPage<InvoiceManagePurchase>>();
|
|
|
+ QueryWrapper<InvoiceManagePurchase> queryWrapper = QueryGenerator.initQueryWrapper(invoiceManagePurchase, req.getParameterMap());
|
|
|
+ Page<InvoiceManagePurchase> page = new Page<InvoiceManagePurchase>(pageNo, pageSize);
|
|
|
+ queryWrapper.eq("del_flag", CommonConstant.STATUS_NORMAL.toString());
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
+ IPage<InvoiceManagePurchase> pageList = invoiceManagePurchaseService.page(page, queryWrapper);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增", notes = "新增采购发票和销售发票")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="type", value="类型(1.采购发票 2.销售发票)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proArchivesId", value="项目档案id)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proCode", value="项目编码",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proName", value="项目名称",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="coArchivesId", value="收款条线档案id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="coArchivesName", value="收付款条线",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proBusinessId", value="项目档案里程碑表id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proArchivesMilestone", value="项目档案里程碑(项目档案—商务,页签中的收款计划)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="price", value="金额 (里程碑与首付款条线对应金额)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="uncoPrice", value="未收票金额",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="coPrice", value="收票金额",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="currentUser", value="填写人(当前用户)",required=true, dataType="String"),
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<InvoiceManagePurchase> add(@RequestBody @Valid InvoiceManagePurchase invoiceManagePurchase, BindingResult bindingResult) {
|
|
|
+ Result<InvoiceManagePurchase> result = new Result<InvoiceManagePurchase>();
|
|
|
+ try {
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ if (bindingResult.hasErrors()){
|
|
|
+
|
|
|
+ bindingResult.getAllErrors().stream().forEach(error -> sb.append(error.getDefaultMessage() + "<br/>"));
|
|
|
+ result.error500(sb.toString());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ CallResult<String> nextSerial = sysSerialPatternService.getNextSerial(invoiceManagePurchase, "invoice_manage_purchase", "billcode", true);
|
|
|
+ if(!nextSerial.isSucceed()){
|
|
|
+ throw new RuntimeException("获取编号失败");
|
|
|
+ }
|
|
|
+ invoiceManagePurchase.setBillcode(nextSerial.getContent());
|
|
|
+ invoiceManagePurchaseService.save(invoiceManagePurchase);
|
|
|
+ result.success("添加成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info(e.getMessage());
|
|
|
+ result.error500("操作失败");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "编辑", notes = "修改采购发票或销售发票的数据")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="type", value="类型(1.采购发票 2.销售发票)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proArchivesId", value="项目档案id)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proCode", value="项目编码",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proName", value="项目名称",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="coArchivesId", value="收款条线档案id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="coArchivesName", value="收付款条线",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proBusinessId", value="项目档案里程碑表id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proArchivesMilestone", value="项目档案里程碑(项目档案—商务,页签中的收款计划)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="price", value="金额 (里程碑与首付款条线对应金额)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="uncoPrice", value="未收票金额",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="coPrice", value="收票金额",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="currentUser", value="填写人(当前用户)",required=true, dataType="String"),
|
|
|
+ })
|
|
|
+ @PutMapping(value = "/edit")
|
|
|
+ public Result<InvoiceManagePurchase> edit(@RequestBody InvoiceManagePurchase invoiceManagePurchase) {
|
|
|
+ Result<InvoiceManagePurchase> result = new Result<InvoiceManagePurchase>();
|
|
|
+ InvoiceManagePurchase invoiceManagePurchaseEntity = invoiceManagePurchaseService.getById(invoiceManagePurchase.getId());
|
|
|
+ if(invoiceManagePurchaseEntity==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ boolean ok = invoiceManagePurchaseService.updateById(invoiceManagePurchase);
|
|
|
+ if(ok) {
|
|
|
+ result.success("修改成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除", notes = "根据id删除采购发票和销售发票")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "组织", required = true, dataType = "String")
|
|
|
+ })
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<InvoiceManagePurchase> delete(@RequestBody PurchaseReqDTO reqDTO) {
|
|
|
+ Result<InvoiceManagePurchase> result = new Result<InvoiceManagePurchase>();
|
|
|
+ InvoiceManagePurchase invoiceManagePurchase = invoiceManagePurchaseService.getById(reqDTO.getId());
|
|
|
+ if(invoiceManagePurchase==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ invoiceManagePurchase.setDelFlag("1");
|
|
|
+ boolean ok = invoiceManagePurchaseService.updateById(invoiceManagePurchase);
|
|
|
+ if(ok) {
|
|
|
+ result.success("删除成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "通过id查询", notes = "通过id查询采购发票和销售发票")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "组织", required = true, dataType = "String")
|
|
|
+ })
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<InvoiceManagePurchase> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ Result<InvoiceManagePurchase> result = new Result<InvoiceManagePurchase>();
|
|
|
+ InvoiceManagePurchase invoiceManagePurchase = invoiceManagePurchaseService.getById(id);
|
|
|
+ if(invoiceManagePurchase==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ result.setResult(invoiceManagePurchase);
|
|
|
+ result.setSuccess(true);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|