diff --git a/src/main/java/com/glxp/api/config/ReplaceBatch.java b/src/main/java/com/glxp/api/config/ReplaceBatch.java index 52babeb5..122fa820 100644 --- a/src/main/java/com/glxp/api/config/ReplaceBatch.java +++ b/src/main/java/com/glxp/api/config/ReplaceBatch.java @@ -42,11 +42,11 @@ public class ReplaceBatch extends AbstractMethod { CustomerSqlMethod sqlMethod = CustomerSqlMethod.REPLACE_ONE; List fieldList = tableInfo.getFieldList(); - String columnScript = SqlScriptUtils.convertTrim(tableInfo.getAllInsertSqlColumnMaybeIf(null), - LEFT_BRACKET, RIGHT_BRACKET, null, COMMA); -// String insertSqlColumn = tableInfo.getKeyInsertSqlColumn(true, true) + -// this.filterTableFieldInfo(fieldList, predicate, TableFieldInfo::getInsertSqlColumn, EMPTY); -// String columnScript = LEFT_BRACKET + insertSqlColumn.substring(0, insertSqlColumn.length() - 1) + RIGHT_BRACKET; +// String columnScript = SqlScriptUtils.convertTrim(tableInfo.getAllInsertSqlColumnMaybeIf(null), +// LEFT_BRACKET, RIGHT_BRACKET, null, COMMA); + String insertSqlColumn = tableInfo.getKeyInsertSqlColumn(true, true) + + this.filterTableFieldInfo(fieldList, predicate, TableFieldInfo::getInsertSqlColumn, EMPTY); + String columnScript = LEFT_BRACKET + insertSqlColumn.substring(0, insertSqlColumn.length() - 1) + RIGHT_BRACKET; String insertSqlProperty = tableInfo.getKeyInsertSqlProperty(true, ENTITY_DOT, true) + this.filterTableFieldInfo(fieldList, predicate, i -> i.getInsertSqlProperty(ENTITY_DOT), EMPTY); insertSqlProperty = LEFT_BRACKET + insertSqlProperty.substring(0, insertSqlProperty.length() - 1) + RIGHT_BRACKET; diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderController.java index 40251efc..9d7d475b 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoOrderController.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; import com.glxp.api.annotation.AuthRuleAnnotation; import com.glxp.api.annotation.Log; @@ -80,6 +81,7 @@ public class IoOrderController extends BaseController { @Resource IoOrderInvoiceService orderInvoiceService; + /** * 查询单据列表 * @@ -784,4 +786,68 @@ public class IoOrderController extends BaseController { return ResultVOUtils.success(); } + @AuthRuleAnnotation("") + @GetMapping("/udiwms/inout/order/filterInvoiceList") + public BaseResponse filterInvoiceList(FilterOrderRequest filterOrderRequest) { + + //这个不等于空表示要查询发票对应的单据 + if (filterOrderRequest.getInvoiceEncode() != null) { + //查询发票详情 + QueryWrapper ew=new QueryWrapper(); + ew.eq("invoiceEncode",filterOrderRequest.getInvoiceEncode()); + List ioOrderInvoiceEntity = orderInvoiceService.list(ew); + List orderIds = ioOrderInvoiceEntity.stream().map(IoOrderInvoiceEntity::getOrderIdFk).collect(Collectors.toList()); + filterOrderRequest.setOrderIds(orderIds); + } + + + if (StrUtil.isNotBlank(filterOrderRequest.getStatusType())) { + orderService.setFilterStatus(filterOrderRequest); + } + if (StrUtil.isNotBlank(filterOrderRequest.getVueType())) { + orderService.setActions(filterOrderRequest); + } + + if (StrUtil.isNotEmpty(filterOrderRequest.getSupInoivceSearch())) { + orderService.setInvoiceFiltes(filterOrderRequest); + } + if (filterOrderRequest.getSourceLocalType() != null) { + if (filterOrderRequest.getSourceLocalType() == 1) { + filterOrderRequest.setSourceTypes(Arrays.asList(1, 2, 3, 4, 5)); + } else { + filterOrderRequest.setSourceTypes(Arrays.asList(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17)); + } + } + String customerId = getCustomerId(); + if (!customerId.equals("110")) { + filterOrderRequest.setFromCorp(customerId); + } + List list = orderService.getfilterOrderList(filterOrderRequest); + + for (IoOrderResponse ioOrderResponse : list) { + if (ioOrderResponse.getCheckStatus() == null) { + ioOrderResponse.setCheckStatus(0 + ""); + } + orderInvoiceService.findRegStausByBillNo(ioOrderResponse); + } + if (filterOrderRequest.getInvoiceEncode() == null) { + //查询已被登记的单据 + List ioOrderInvoiceEntity = orderInvoiceService.list(); + //已被选择的单据做标记 + if (ioOrderInvoiceEntity != null && ioOrderInvoiceEntity.size() > 0) { + for (IoOrderResponse ioOrderResponse : list) { + for (IoOrderInvoiceEntity orderInvoiceEntity : ioOrderInvoiceEntity) { + if (ioOrderResponse.getBillNo().equals(orderInvoiceEntity.getOrderIdFk())) { + ioOrderResponse.setCheckType(true); + break; + } + } + } + } + } + PageInfo pageInfo = new PageInfo<>(list); + return ResultVOUtils.page(pageInfo); + } + + } diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java index 16937ab9..cfa87eb8 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java @@ -252,7 +252,9 @@ public class IoOrderDetailResultController extends BaseController { i++; } - String param = JSON.toJSONString(list); + + data.put("data", list); + String param = JSON.toJSONString(data); JasperUtils.jasperReport(request, response, param, filePath + "pdf/template/" + systemPDFTemplateEntity.getPath(), "pdf"); return ResultVOUtils.success(); } diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderInvoiceController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderInvoiceController.java index 1d2417ac..421176df 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderInvoiceController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoOrderInvoiceController.java @@ -1,6 +1,7 @@ package com.glxp.api.controller.inout; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; @@ -9,15 +10,21 @@ import com.glxp.api.annotation.Log; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.constant.BusinessType; +import com.glxp.api.entity.auth.AuthAdmin; +import com.glxp.api.entity.inout.IoOrderDetailBizEntity; import com.glxp.api.entity.inout.IoOrderDetailCodeEntity; import com.glxp.api.entity.inout.IoOrderEntity; import com.glxp.api.entity.inout.IoOrderInvoiceEntity; +import com.glxp.api.req.inout.FilterOrderDetailCodeRequest; import com.glxp.api.req.inout.IoOrderInvoiceRequest; import com.glxp.api.req.inout.RefreshInoiceRequest; import com.glxp.api.req.system.DeleteRequest; +import com.glxp.api.res.inout.IoOrderDetailCodeResponse; import com.glxp.api.res.inout.IoOrderInvoiceResponse; import com.glxp.api.res.inout.IoOrderResponse; import com.glxp.api.res.inout.RefreshInoiceResponse; +import com.glxp.api.service.auth.CustomerService; +import com.glxp.api.service.inout.IoOrderDetailBizService; import com.glxp.api.service.inout.IoOrderDetailCodeService; import com.glxp.api.service.inout.impl.IoOrderInvoiceService; import org.springframework.beans.BeanUtils; @@ -27,6 +34,9 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; import java.util.List; @RestController @@ -35,7 +45,10 @@ public class IoOrderInvoiceController { IoOrderInvoiceService ioOrderInvoiceService; @Resource IoOrderDetailCodeService orderDetailCodeService; - + @Resource + CustomerService customerService; + @Resource + IoOrderDetailBizService orderDetailBizService; @AuthRuleAnnotation("") @PostMapping("/udiwms/inout/order/refrshInvoice") @@ -64,13 +77,22 @@ public class IoOrderInvoiceController { return ResultVOUtils.page(pageInfo); } + //发票对应产品信息汇总 @AuthRuleAnnotation("") @GetMapping("/udiwms/inout/invoice/product/detail") public BaseResponse productDetail(IoOrderInvoiceRequest orderInvoiceRequest) { if (StrUtil.isEmpty(orderInvoiceRequest.getInvoiceEncode())) return ResultVOUtils.error(500, "发票编码不能为空!"); - List orderInvoiceEntities = ioOrderInvoiceService.filterGroupBy(orderInvoiceRequest); + List orderInvoiceEntities = ioOrderInvoiceService.filterInvoice(orderInvoiceRequest); + + //计算金额 + for (IoOrderInvoiceResponse orderInvoiceEntity : orderInvoiceEntities) { + if (orderInvoiceEntity.getPrice() != null && orderInvoiceEntity.getReCount() != 0) { + orderInvoiceEntity.setAmout(new BigDecimal(orderInvoiceEntity.getPrice()).multiply(new BigDecimal(orderInvoiceEntity.getReCount()))); + } + } + PageInfo pageInfo = new PageInfo<>(orderInvoiceEntities); return ResultVOUtils.page(pageInfo); } @@ -80,6 +102,9 @@ public class IoOrderInvoiceController { @GetMapping("/udiwms/inout/invoice/order/detail") public BaseResponse orderDetail(IoOrderInvoiceRequest orderInvoiceRequest) { List orderInvoiceEntities = ioOrderInvoiceService.filterByInvoiceCode(orderInvoiceRequest); + for (IoOrderResponse orderInvoiceEntity : orderInvoiceEntities) { + ioOrderInvoiceService.findRegStausByBillNo(orderInvoiceEntity); + } PageInfo pageInfo = new PageInfo<>(orderInvoiceEntities); return ResultVOUtils.page(pageInfo); } @@ -98,5 +123,74 @@ public class IoOrderInvoiceController { return ResultVOUtils.error(500, "删除失败!"); } + @AuthRuleAnnotation("") + @PostMapping("/udiwms/inout/invoice/saveInvoice") + @Log(title = "发票增加", businessType = BusinessType.INSERT) + public BaseResponse saveInvoice(@RequestBody IoOrderInvoiceRequest ioOrderInvoiceRequest) { + + List orderFkList = ioOrderInvoiceRequest.getOrderFkList(); + List ioOrderInvoiceEntityList = new ArrayList<>(); + for (String orderFk : orderFkList) { + //查询单据详情 + FilterOrderDetailCodeRequest orderDetailBizRequest = new FilterOrderDetailCodeRequest(); + orderDetailBizRequest.setOrderIdFk(orderFk); + List ioOrderDetailCodeResponses = orderDetailBizService.getfilterOrderList(orderDetailBizRequest); + for (IoOrderDetailCodeResponse ioOrderDetailCodeRespons : ioOrderDetailCodeResponses) { + IoOrderInvoiceEntity ioOrderInvoiceEntity = new IoOrderInvoiceEntity(); + BeanUtils.copyProperties(ioOrderInvoiceRequest, ioOrderInvoiceEntity); + ioOrderInvoiceEntity.setId(IdUtil.getSnowflakeNextId()); + ioOrderInvoiceEntity.setOrderIdFk(orderFk); + ioOrderInvoiceEntity.setUpdateTime(new Date()); + ioOrderInvoiceEntity.setCreateTime(new Date()); + ioOrderInvoiceEntity.setCreateUser(customerService.getUserId() + ""); + ioOrderInvoiceEntity.setUpdateUser(customerService.getUserId() + ""); + ioOrderInvoiceEntity.setBindRlFk(ioOrderDetailCodeRespons.getBindRlFk() + ""); + ioOrderInvoiceEntity.setBatchNo(ioOrderDetailCodeRespons.getBatchNo()); + ioOrderInvoiceEntity.setProductDate(ioOrderDetailCodeRespons.getProductDate()); + ioOrderInvoiceEntity.setExpireDate(ioOrderDetailCodeRespons.getExpireDate()); + ioOrderInvoiceEntityList.add(ioOrderInvoiceEntity); + } + } + + boolean b = ioOrderInvoiceService.saveBatch(ioOrderInvoiceEntityList); + if (b) + return ResultVOUtils.success("选入成功!"); + else + return ResultVOUtils.error(500, "选入失败!"); + } + + + @PostMapping("/udiwms/inout/invoice/uploadInvoice") + @Log(title = "发票管理", businessType = BusinessType.UPDATE) + public BaseResponse uploadInvoice(@RequestBody IoOrderInvoiceEntity ioOrderInvoice) { + List ioOrderInvoiceEntityList=ioOrderInvoiceService.list(new QueryWrapper().eq("invoiceEncode",ioOrderInvoice.getInvoiceEncode())); + for (IoOrderInvoiceEntity ioOrderInvoiceEntity : ioOrderInvoiceEntityList) { + ioOrderInvoiceEntity.setInvoiceDate(ioOrderInvoice.getInvoiceDate()); + ioOrderInvoiceEntity.setPrice(ioOrderInvoice.getPrice()); + ioOrderInvoiceEntity.setLicenseUrl(ioOrderInvoice.getLicenseUrl()); + ioOrderInvoiceEntity.setRemark(ioOrderInvoice.getRemark()); + ioOrderInvoiceEntity.setMachineNo(ioOrderInvoice.getMachineNo()); + ioOrderInvoiceEntity.setInvoiceCode(ioOrderInvoice.getInvoiceCode()); + ioOrderInvoiceEntity.setUpdateTime(new Date()); + } + ioOrderInvoiceService.updateBatchById(ioOrderInvoiceEntityList); + + return ResultVOUtils.success("成功"); + + } + + @AuthRuleAnnotation("") + @PostMapping("/udiwms/inout/invoice/deleteInvoiceByOrderFk") + @Log(title = "发票删除", businessType = BusinessType.DELETE) + public BaseResponse deleteInvoiceByOrderFk(@RequestBody DeleteRequest deleteRequest) { + if (StrUtil.isEmpty(deleteRequest.getInvoiceEncode())) + return ResultVOUtils.error(500, "发票编码不能为空"); + + boolean b = ioOrderInvoiceService.remove(new QueryWrapper().eq("invoiceEncode", deleteRequest.getInvoiceEncode()).eq("orderIdFk",deleteRequest.getBillNo())); + if (b) + return ResultVOUtils.success("删除成功!"); + else + return ResultVOUtils.error(500, "删除失败!"); + } } diff --git a/src/main/java/com/glxp/api/dao/inout/IoOrderInvoiceMapper.java b/src/main/java/com/glxp/api/dao/inout/IoOrderInvoiceMapper.java index bcda280a..a69d9f4a 100644 --- a/src/main/java/com/glxp/api/dao/inout/IoOrderInvoiceMapper.java +++ b/src/main/java/com/glxp/api/dao/inout/IoOrderInvoiceMapper.java @@ -19,6 +19,8 @@ public interface IoOrderInvoiceMapper extends BaseMapperPlus filterGroupBy(IoOrderInvoiceRequest orderInvoiceRequest); + List filterInvoice(IoOrderInvoiceRequest orderInvoiceRequest); + List filterByInvoiceCode(IoOrderInvoiceRequest orderInvoiceRequest); } diff --git a/src/main/java/com/glxp/api/req/inout/FilterOrderRequest.java b/src/main/java/com/glxp/api/req/inout/FilterOrderRequest.java index b84784f3..4974cf72 100644 --- a/src/main/java/com/glxp/api/req/inout/FilterOrderRequest.java +++ b/src/main/java/com/glxp/api/req/inout/FilterOrderRequest.java @@ -190,4 +190,6 @@ public class FilterOrderRequest extends ListPageRequest { private List invoiceActions2; private String orderBy; + private String invoiceEncode; + } diff --git a/src/main/java/com/glxp/api/req/inout/IoOrderInvoiceRequest.java b/src/main/java/com/glxp/api/req/inout/IoOrderInvoiceRequest.java index 35c617fc..430de6ec 100644 --- a/src/main/java/com/glxp/api/req/inout/IoOrderInvoiceRequest.java +++ b/src/main/java/com/glxp/api/req/inout/IoOrderInvoiceRequest.java @@ -70,6 +70,18 @@ public class IoOrderInvoiceRequest extends ListPageRequest { private Long bizIdFk; + List orderFkList; + + /** + * 开始时间 + */ + private String startTime; + + /** + * 结束时间 + */ + private String endTime; + public static final String COL_ID = "id"; public static final String COL_ORDERIDFK = "orderIdFk"; diff --git a/src/main/java/com/glxp/api/res/inout/IoOrderInvoiceResponse.java b/src/main/java/com/glxp/api/res/inout/IoOrderInvoiceResponse.java index ca0a1670..defce740 100644 --- a/src/main/java/com/glxp/api/res/inout/IoOrderInvoiceResponse.java +++ b/src/main/java/com/glxp/api/res/inout/IoOrderInvoiceResponse.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import java.math.BigDecimal; import java.util.Date; @Data @@ -88,6 +89,16 @@ public class IoOrderInvoiceResponse { private Long bizIdFk; + private String coName; + private String spec; + private String measname; + private String manufacturer; + private String certCode; + private int reCount; + private int count; + private BigDecimal amout; + + public static final String COL_ID = "id"; public static final String COL_ORDERIDFK = "orderIdFk"; diff --git a/src/main/java/com/glxp/api/res/inout/IoOrderResponse.java b/src/main/java/com/glxp/api/res/inout/IoOrderResponse.java index f8a383fb..3562d89f 100644 --- a/src/main/java/com/glxp/api/res/inout/IoOrderResponse.java +++ b/src/main/java/com/glxp/api/res/inout/IoOrderResponse.java @@ -255,6 +255,9 @@ public class IoOrderResponse { private int invoiceStatus;//发票登记状态0:未登记,1:未全部登记;2:已全部登记 + private boolean checkType; + + public String getFromName() { diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoOrderInvoiceService.java b/src/main/java/com/glxp/api/service/inout/impl/IoOrderInvoiceService.java index 0f4d9b7c..1f0cbcd5 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoOrderInvoiceService.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoOrderInvoiceService.java @@ -117,6 +117,14 @@ public class IoOrderInvoiceService extends ServiceImpl filterInvoice(IoOrderInvoiceRequest orderInvoiceRequest) { + if (orderInvoiceRequest.getPage() != null) { + int offset = (orderInvoiceRequest.getPage() - 1) * orderInvoiceRequest.getLimit(); + PageHelper.offsetPage(offset, orderInvoiceRequest.getLimit()); + } + return ioOrderInvoiceMapper.filterInvoice(orderInvoiceRequest); + } + public List filterByInvoiceCode(IoOrderInvoiceRequest orderInvoiceRequest) { if (orderInvoiceRequest.getPage() != null) { diff --git a/src/main/resources/mybatis/mapper/inout/IoOrderInvoiceMapper.xml b/src/main/resources/mybatis/mapper/inout/IoOrderInvoiceMapper.xml index c2e92f89..277671b6 100644 --- a/src/main/resources/mybatis/mapper/inout/IoOrderInvoiceMapper.xml +++ b/src/main/resources/mybatis/mapper/inout/IoOrderInvoiceMapper.xml @@ -37,12 +37,89 @@ + + + + +