Commit 828c45ecccb85b042e6c477f00ae9a26bdb184e8
Merge branch 'master_after0506_report02' into master_after0506
Showing
34 changed files
with
1772 additions
and
9 deletions
| ... | ... | @@ -1462,3 +1462,6 @@ ALTER TABLE tbl_contract_distributor_standard |
| 1462 | 1462 | ADD COLUMN foreign_destination varchar(200) COMMENT '目的地(外贸)'; |
| 1463 | 1463 | |
| 1464 | 1464 | ALTER TABLE tbl_purchase_order_line ADD COLUMN production_process text COMMENT '生产工艺'; |
| 1465 | + | |
| 1466 | +ALTER TABLE tbl_contract_distributor_standard | |
| 1467 | + ADD COLUMN change_reason varchar(50) DEFAULT NULL COMMENT '变更原因'; | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/contract/GetContractDistributorStandardBo.java
| ... | ... | @@ -437,6 +437,12 @@ public class GetContractDistributorStandardBo extends BaseBo<ContractDistributor |
| 437 | 437 | @ApiModelProperty(value = "是否已完成锁价/锁规") |
| 438 | 438 | private Boolean priceSpecLocked; |
| 439 | 439 | |
| 440 | + @ApiModelProperty(value = "变更原因") | |
| 441 | + private String changeReason; | |
| 442 | + | |
| 443 | + @ApiModelProperty(value = "剩余数量") | |
| 444 | + private BigDecimal remainingQuantity; | |
| 445 | + | |
| 440 | 446 | /** |
| 441 | 447 | * 合同名称(销售合同、销售订单) |
| 442 | 448 | */ | ... | ... |
| ... | ... | @@ -216,6 +216,12 @@ public class QueryContractDistributorStandardBo extends BaseBo<ContractDistribut |
| 216 | 216 | @ApiModelProperty(value = "是否已完成锁价/锁规") |
| 217 | 217 | private Boolean priceSpecLocked; |
| 218 | 218 | |
| 219 | + @ApiModelProperty(value = "变更原因") | |
| 220 | + private String changeReason; | |
| 221 | + | |
| 222 | + @ApiModelProperty(value = "剩余数量") | |
| 223 | + private BigDecimal remainingQuantity; | |
| 224 | + | |
| 219 | 225 | /** |
| 220 | 226 | * 双方盖章合同ID |
| 221 | 227 | */ | ... | ... |
| 1 | +package com.lframework.xingyun.sc.bo.statistics.shipmentQuantity; | |
| 2 | + | |
| 3 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDto; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import java.math.BigDecimal; | |
| 8 | +import java.time.LocalDate; | |
| 9 | + | |
| 10 | +@Data | |
| 11 | +public class QueryShipmentQuantityStatisticsBo { | |
| 12 | + | |
| 13 | + public QueryShipmentQuantityStatisticsBo(ShipmentQuantityStatisticsDto dto) { | |
| 14 | + this.shipmentDate = dto.getShipmentDate(); | |
| 15 | + this.deptName = dto.getDeptName(); | |
| 16 | + this.workshopName = dto.getWorkshopName(); | |
| 17 | + this.shipmentQuantity = dto.getShipmentQuantity(); | |
| 18 | + } | |
| 19 | + | |
| 20 | + @ApiModelProperty("发货日期") | |
| 21 | + private LocalDate shipmentDate; | |
| 22 | + | |
| 23 | + @ApiModelProperty("办事处") | |
| 24 | + private String deptName; | |
| 25 | + | |
| 26 | + @ApiModelProperty("分厂") | |
| 27 | + private String workshopName; | |
| 28 | + | |
| 29 | + @ApiModelProperty("发货数量") | |
| 30 | + private BigDecimal shipmentQuantity; | |
| 31 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.bo.statistics.shipmentQuantityIndustry; | |
| 2 | + | |
| 3 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsDto; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import java.math.BigDecimal; | |
| 8 | +import java.time.LocalDate; | |
| 9 | + | |
| 10 | +@Data | |
| 11 | +public class QueryShipmentQuantityIndustryStatisticsBo { | |
| 12 | + | |
| 13 | + public QueryShipmentQuantityIndustryStatisticsBo(ShipmentQuantityIndustryStatisticsDto dto) { | |
| 14 | + this.shipmentDate = dto.getShipmentDate(); | |
| 15 | + this.industry = dto.getIndustry(); | |
| 16 | + this.workshopName = dto.getWorkshopName(); | |
| 17 | + this.shipmentQuantity = dto.getShipmentQuantity(); | |
| 18 | + } | |
| 19 | + | |
| 20 | + @ApiModelProperty("发货日期") | |
| 21 | + private LocalDate shipmentDate; | |
| 22 | + | |
| 23 | + @ApiModelProperty("行业") | |
| 24 | + private String industry; | |
| 25 | + | |
| 26 | + @ApiModelProperty("分厂") | |
| 27 | + private String workshopName; | |
| 28 | + | |
| 29 | + @ApiModelProperty("发货数量") | |
| 30 | + private BigDecimal shipmentQuantity; | |
| 31 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.controller.statistics; | |
| 2 | + | |
| 3 | +import com.lframework.starter.mq.core.utils.ExportTaskUtil; | |
| 4 | +import com.lframework.starter.web.core.annotations.security.HasPermission; | |
| 5 | +import com.lframework.starter.web.core.components.resp.InvokeResult; | |
| 6 | +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | |
| 7 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 8 | +import com.lframework.starter.web.core.controller.DefaultBaseController; | |
| 9 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 10 | +import com.lframework.xingyun.sc.bo.statistics.shipmentQuantityIndustry.QueryShipmentQuantityIndustryStatisticsBo; | |
| 11 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsDto; | |
| 12 | +import com.lframework.xingyun.sc.enums.ExportType; | |
| 13 | +import com.lframework.xingyun.sc.excel.statistics.ShipmentQuantityIndustryStatisticsExportTaskWorker; | |
| 14 | +import com.lframework.xingyun.sc.service.statistics.ShipmentQuantityIndustryStatisticsService; | |
| 15 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantityIndustry.QueryShipmentQuantityIndustryStatisticsVo; | |
| 16 | +import io.swagger.annotations.Api; | |
| 17 | +import io.swagger.annotations.ApiOperation; | |
| 18 | +import org.springframework.http.MediaType; | |
| 19 | +import org.springframework.validation.annotation.Validated; | |
| 20 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 21 | +import org.springframework.web.bind.annotation.PostMapping; | |
| 22 | +import org.springframework.web.bind.annotation.RequestBody; | |
| 23 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 24 | +import org.springframework.web.bind.annotation.RestController; | |
| 25 | + | |
| 26 | +import javax.annotation.Resource; | |
| 27 | +import javax.validation.Valid; | |
| 28 | +import java.util.List; | |
| 29 | +import java.util.stream.Collectors; | |
| 30 | + | |
| 31 | +@Api(tags = "各行业月度统计梳理") | |
| 32 | +@Validated | |
| 33 | +@RestController | |
| 34 | +@RequestMapping("/statistics/shipmentQuantityIndustry") | |
| 35 | +public class ShipmentQuantityIndustryStatisticsController extends DefaultBaseController { | |
| 36 | + | |
| 37 | + @Resource | |
| 38 | + private ShipmentQuantityIndustryStatisticsService shipmentQuantityIndustryStatisticsService; | |
| 39 | + | |
| 40 | + @ApiOperation("查询列表") | |
| 41 | + @HasPermission({"statistical-report:industry-order-detail:query"}) | |
| 42 | + @GetMapping("/query") | |
| 43 | + public InvokeResult<PageResult<QueryShipmentQuantityIndustryStatisticsBo>> query(@Valid QueryShipmentQuantityIndustryStatisticsVo vo) { | |
| 44 | + | |
| 45 | + PageResult<ShipmentQuantityIndustryStatisticsDto> pageResult = | |
| 46 | + shipmentQuantityIndustryStatisticsService.query(getPageIndex(vo), getPageSize(vo), vo); | |
| 47 | + List<QueryShipmentQuantityIndustryStatisticsBo> results = null; | |
| 48 | + if (pageResult.getDatas() != null && !pageResult.getDatas().isEmpty()) { | |
| 49 | + results = pageResult.getDatas().stream().map(QueryShipmentQuantityIndustryStatisticsBo::new).collect(Collectors.toList()); | |
| 50 | + } | |
| 51 | + return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @ApiOperation("各行业月度统计梳理导出") | |
| 55 | + @HasPermission({"statistical-report:industry-order-detail:export"}) | |
| 56 | + @PostMapping(value = "/export", consumes = MediaType.APPLICATION_JSON_VALUE) | |
| 57 | + public InvokeResult<Void> exportJson(@Valid @RequestBody QueryShipmentQuantityIndustryStatisticsVo vo) { | |
| 58 | + vo.setExportType(ExportType.SHIPMENT_QUANTITY_INDUSTRY_REPORT.getCode()); | |
| 59 | + ExportTaskUtil.exportTask("各行业月度统计梳理", ShipmentQuantityIndustryStatisticsExportTaskWorker.class, vo); | |
| 60 | + return InvokeResultBuilder.success(); | |
| 61 | + } | |
| 62 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.controller.statistics; | |
| 2 | + | |
| 3 | +import com.lframework.starter.mq.core.utils.ExportTaskUtil; | |
| 4 | +import com.lframework.starter.web.core.annotations.security.HasPermission; | |
| 5 | +import com.lframework.starter.web.core.components.resp.InvokeResult; | |
| 6 | +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | |
| 7 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 8 | +import com.lframework.starter.web.core.controller.DefaultBaseController; | |
| 9 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 10 | +import com.lframework.xingyun.sc.bo.statistics.shipmentQuantity.QueryShipmentQuantityStatisticsBo; | |
| 11 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDto; | |
| 12 | +import com.lframework.xingyun.sc.enums.ExportType; | |
| 13 | +import com.lframework.xingyun.sc.excel.statistics.ShipmentQuantityStatisticsExportTaskWorker; | |
| 14 | +import com.lframework.xingyun.sc.service.statistics.ShipmentQuantityStatisticsService; | |
| 15 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantity.QueryShipmentQuantityStatisticsVo; | |
| 16 | +import io.swagger.annotations.Api; | |
| 17 | +import io.swagger.annotations.ApiOperation; | |
| 18 | +import org.springframework.http.MediaType; | |
| 19 | +import org.springframework.validation.annotation.Validated; | |
| 20 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 21 | +import org.springframework.web.bind.annotation.PostMapping; | |
| 22 | +import org.springframework.web.bind.annotation.RequestBody; | |
| 23 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 24 | +import org.springframework.web.bind.annotation.RestController; | |
| 25 | + | |
| 26 | +import javax.annotation.Resource; | |
| 27 | +import javax.validation.Valid; | |
| 28 | +import java.util.List; | |
| 29 | +import java.util.stream.Collectors; | |
| 30 | + | |
| 31 | +@Api(tags = "各办事处月度统计梳理") | |
| 32 | +@Validated | |
| 33 | +@RestController | |
| 34 | +@RequestMapping("/statistics/shipmentQuantity") | |
| 35 | +public class ShipmentQuantityStatisticsController extends DefaultBaseController { | |
| 36 | + | |
| 37 | + @Resource | |
| 38 | + private ShipmentQuantityStatisticsService shipmentQuantityStatisticsService; | |
| 39 | + | |
| 40 | + @ApiOperation("查询列表") | |
| 41 | + @HasPermission({"statistical-report:dept-order-detail:query"}) | |
| 42 | + @GetMapping("/query") | |
| 43 | + public InvokeResult<PageResult<QueryShipmentQuantityStatisticsBo>> query(@Valid QueryShipmentQuantityStatisticsVo vo) { | |
| 44 | + | |
| 45 | + PageResult<ShipmentQuantityStatisticsDto> pageResult = shipmentQuantityStatisticsService.query(getPageIndex(vo), getPageSize(vo), vo); | |
| 46 | + List<QueryShipmentQuantityStatisticsBo> results = null; | |
| 47 | + if (pageResult.getDatas() != null && !pageResult.getDatas().isEmpty()) { | |
| 48 | + results = pageResult.getDatas().stream().map(QueryShipmentQuantityStatisticsBo::new).collect(Collectors.toList()); | |
| 49 | + } | |
| 50 | + return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @ApiOperation("各办事处月度统计梳理导出") | |
| 54 | + @HasPermission({"statistical-report:dept-order-detail:export"}) | |
| 55 | + @PostMapping(value = "/export", consumes = MediaType.APPLICATION_JSON_VALUE) | |
| 56 | + public InvokeResult<Void> exportJson(@Valid @RequestBody QueryShipmentQuantityStatisticsVo vo) { | |
| 57 | + vo.setExportType(ExportType.SHIPMENT_QUANTITY_REPORT.getCode()); | |
| 58 | + ExportTaskUtil.exportTask("各办事处月度统计梳理", ShipmentQuantityStatisticsExportTaskWorker.class, vo); | |
| 59 | + return InvokeResultBuilder.success(); | |
| 60 | + } | |
| 61 | + | |
| 62 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.dto.statistics; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import java.math.BigDecimal; | |
| 6 | +import java.time.LocalDate; | |
| 7 | + | |
| 8 | +@Data | |
| 9 | +public class ShipmentQuantityIndustryStatisticsDto { | |
| 10 | + | |
| 11 | + private LocalDate shipmentDate; | |
| 12 | + | |
| 13 | + private String industry; | |
| 14 | + | |
| 15 | + private String workshopId; | |
| 16 | + | |
| 17 | + private String workshopCode; | |
| 18 | + | |
| 19 | + private String workshopName; | |
| 20 | + | |
| 21 | + private BigDecimal shipmentQuantity; | |
| 22 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.dto.statistics; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import java.math.BigDecimal; | |
| 6 | +import java.time.LocalDate; | |
| 7 | + | |
| 8 | +@Data | |
| 9 | +public class ShipmentQuantityIndustryStatisticsInvalidDto { | |
| 10 | + | |
| 11 | + private String orderId; | |
| 12 | + | |
| 13 | + private String orderNo; | |
| 14 | + | |
| 15 | + private String lineId; | |
| 16 | + | |
| 17 | + private LocalDate shipmentDate; | |
| 18 | + | |
| 19 | + private String industry; | |
| 20 | + | |
| 21 | + private String workshopId; | |
| 22 | + | |
| 23 | + private BigDecimal quantity; | |
| 24 | +} | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/dto/statistics/ShipmentQuantityStatisticsDto.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.dto.statistics; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import java.math.BigDecimal; | |
| 6 | +import java.time.LocalDate; | |
| 7 | + | |
| 8 | +@Data | |
| 9 | +public class ShipmentQuantityStatisticsDto { | |
| 10 | + | |
| 11 | + private LocalDate shipmentDate; | |
| 12 | + | |
| 13 | + private String deptId; | |
| 14 | + | |
| 15 | + private String deptCode; | |
| 16 | + | |
| 17 | + private String deptName; | |
| 18 | + | |
| 19 | + private String workshopId; | |
| 20 | + | |
| 21 | + private String workshopCode; | |
| 22 | + | |
| 23 | + private String workshopName; | |
| 24 | + | |
| 25 | + private BigDecimal shipmentQuantity; | |
| 26 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.dto.statistics; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import java.math.BigDecimal; | |
| 6 | +import java.time.LocalDate; | |
| 7 | + | |
| 8 | +@Data | |
| 9 | +public class ShipmentQuantityStatisticsInvalidDto { | |
| 10 | + | |
| 11 | + private String orderId; | |
| 12 | + | |
| 13 | + private String orderNo; | |
| 14 | + | |
| 15 | + private String lineId; | |
| 16 | + | |
| 17 | + private LocalDate shipmentDate; | |
| 18 | + | |
| 19 | + private String deptId; | |
| 20 | + | |
| 21 | + private String workshopId; | |
| 22 | + | |
| 23 | + private BigDecimal quantity; | |
| 24 | +} | ... | ... |
| ... | ... | @@ -314,6 +314,11 @@ public class ContractDistributorStandard extends BaseEntity implements BaseDto { |
| 314 | 314 | private Boolean priceSpecLocked; |
| 315 | 315 | |
| 316 | 316 | /** |
| 317 | + * 变更原因 | |
| 318 | + */ | |
| 319 | + private String changeReason; | |
| 320 | + | |
| 321 | + /** | |
| 317 | 322 | * 双方盖章合同ID |
| 318 | 323 | */ |
| 319 | 324 | private String signedContractFileId; |
| ... | ... | @@ -362,4 +367,10 @@ public class ContractDistributorStandard extends BaseEntity implements BaseDto { |
| 362 | 367 | */ |
| 363 | 368 | @TableField(exist = false) |
| 364 | 369 | private Boolean canSplit; |
| 370 | + | |
| 371 | + /** | |
| 372 | + * 剩余锁规数量 | |
| 373 | + */ | |
| 374 | + @TableField(exist = false) | |
| 375 | + private BigDecimal remainingQuantity; | |
| 365 | 376 | } | ... | ... |
| ... | ... | @@ -11,6 +11,8 @@ public enum ExportType implements BaseEnum<String> { |
| 11 | 11 | CONTRACT_FRAMEWORK("CONTRACT_FRAMEWORK", "合同框架"), |
| 12 | 12 | RECEIVABLE_LEDGER_REPORT("RECEIVABLE_LEDGER_REPORT", "应收款台账报表"), |
| 13 | 13 | SHIPMENT_DETAIL_REPORT("SHIPMENT_DETAIL_REPORT", "发货明细报表"), |
| 14 | + SHIPMENT_QUANTITY_REPORT("SHIPMENT_QUANTITY_REPORT", "各办事处月度统计梳理"), | |
| 15 | + SHIPMENT_QUANTITY_INDUSTRY_REPORT("SHIPMENT_QUANTITY_INDUSTRY_REPORT", "各行业月度统计梳理"), | |
| 14 | 16 | ORDER_DETAIL_REPORT("ORDER_DETAIL_REPORT", "订单明细报表"), |
| 15 | 17 | ORDER_EXPORT_ZIP("ORDER_EXPORT_ZIP", "订货单信息"), |
| 16 | 18 | QUALITY_ORDER_DETAIL_REPORT("QUALITY_ORDER_DETAIL_REPORT", "品质科订单明细报表"), | ... | ... |
| 1 | +package com.lframework.xingyun.sc.excel.statistics; | |
| 2 | + | |
| 3 | +import com.lframework.starter.common.utils.CollectionUtil; | |
| 4 | +import com.lframework.starter.mq.core.components.export.ExportTaskWorker; | |
| 5 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 6 | +import com.lframework.starter.web.core.utils.ApplicationUtil; | |
| 7 | +import com.lframework.starter.web.core.utils.JsonUtil; | |
| 8 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 9 | +import com.lframework.xingyun.sc.bo.statistics.shipmentQuantityIndustry.QueryShipmentQuantityIndustryStatisticsBo; | |
| 10 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsDto; | |
| 11 | +import com.lframework.xingyun.sc.service.statistics.ShipmentQuantityIndustryStatisticsService; | |
| 12 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantityIndustry.QueryShipmentQuantityIndustryStatisticsVo; | |
| 13 | + | |
| 14 | +import java.time.ZoneId; | |
| 15 | +import java.util.Date; | |
| 16 | +import java.util.List; | |
| 17 | +import java.util.stream.Collectors; | |
| 18 | + | |
| 19 | +public class ShipmentQuantityIndustryStatisticsExportTaskWorker implements | |
| 20 | + ExportTaskWorker<QueryShipmentQuantityIndustryStatisticsVo, QueryShipmentQuantityIndustryStatisticsBo, ShipmentQuantityIndustryStatisticsModel> { | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public QueryShipmentQuantityIndustryStatisticsVo parseParams(String json) { | |
| 24 | + return JsonUtil.parseObject(json, QueryShipmentQuantityIndustryStatisticsVo.class); | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public PageResult<QueryShipmentQuantityIndustryStatisticsBo> getDataList(int pageIndex, int pageSize, | |
| 29 | + QueryShipmentQuantityIndustryStatisticsVo params) { | |
| 30 | + ShipmentQuantityIndustryStatisticsService service = ApplicationUtil.getBean(ShipmentQuantityIndustryStatisticsService.class); | |
| 31 | + PageResult<ShipmentQuantityIndustryStatisticsDto> pageResult = service.query(pageIndex, pageSize, params); | |
| 32 | + List<QueryShipmentQuantityIndustryStatisticsBo> results = null; | |
| 33 | + if (!CollectionUtil.isEmpty(pageResult.getDatas())) { | |
| 34 | + results = pageResult.getDatas().stream().map(QueryShipmentQuantityIndustryStatisticsBo::new).collect(Collectors.toList()); | |
| 35 | + } | |
| 36 | + return PageResultUtil.rebuild(pageResult, results); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public ShipmentQuantityIndustryStatisticsModel exportData(QueryShipmentQuantityIndustryStatisticsBo data) { | |
| 41 | + ShipmentQuantityIndustryStatisticsModel model = new ShipmentQuantityIndustryStatisticsModel(); | |
| 42 | + if (data.getShipmentDate() != null) { | |
| 43 | + model.setShipmentDate(Date.from(data.getShipmentDate().atStartOfDay(ZoneId.systemDefault()).toInstant())); | |
| 44 | + } | |
| 45 | + model.setIndustry(data.getIndustry()); | |
| 46 | + model.setWorkshopName(data.getWorkshopName()); | |
| 47 | + model.setShipmentQuantity(data.getShipmentQuantity()); | |
| 48 | + return model; | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public Class<ShipmentQuantityIndustryStatisticsModel> getModelClass() { | |
| 53 | + return ShipmentQuantityIndustryStatisticsModel.class; | |
| 54 | + } | |
| 55 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.excel.statistics; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | +import com.alibaba.excel.annotation.format.DateTimeFormat; | |
| 5 | +import com.lframework.starter.web.core.components.excel.ExcelModel; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | +import java.util.Date; | |
| 10 | + | |
| 11 | +@Data | |
| 12 | +public class ShipmentQuantityIndustryStatisticsModel implements ExcelModel { | |
| 13 | + | |
| 14 | + @ExcelProperty(value = "日期", index = 0) | |
| 15 | + @DateTimeFormat("yyyy/MM/dd") | |
| 16 | + private Date shipmentDate; | |
| 17 | + | |
| 18 | + @ExcelProperty(value = "行业", index = 1) | |
| 19 | + private String industry; | |
| 20 | + | |
| 21 | + @ExcelProperty(value = "分厂", index = 2) | |
| 22 | + private String workshopName; | |
| 23 | + | |
| 24 | + @ExcelProperty(value = "发货数量", index = 3) | |
| 25 | + private BigDecimal shipmentQuantity; | |
| 26 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.excel.statistics; | |
| 2 | + | |
| 3 | +import com.lframework.starter.common.utils.CollectionUtil; | |
| 4 | +import com.lframework.starter.mq.core.components.export.ExportTaskWorker; | |
| 5 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 6 | +import com.lframework.starter.web.core.utils.ApplicationUtil; | |
| 7 | +import com.lframework.starter.web.core.utils.JsonUtil; | |
| 8 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 9 | +import com.lframework.xingyun.sc.bo.statistics.shipmentQuantity.QueryShipmentQuantityStatisticsBo; | |
| 10 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDto; | |
| 11 | +import com.lframework.xingyun.sc.service.statistics.ShipmentQuantityStatisticsService; | |
| 12 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantity.QueryShipmentQuantityStatisticsVo; | |
| 13 | + | |
| 14 | +import java.time.ZoneId; | |
| 15 | +import java.util.Date; | |
| 16 | +import java.util.List; | |
| 17 | +import java.util.stream.Collectors; | |
| 18 | + | |
| 19 | +public class ShipmentQuantityStatisticsExportTaskWorker implements | |
| 20 | + ExportTaskWorker<QueryShipmentQuantityStatisticsVo, QueryShipmentQuantityStatisticsBo, ShipmentQuantityStatisticsModel> { | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public QueryShipmentQuantityStatisticsVo parseParams(String json) { | |
| 24 | + return JsonUtil.parseObject(json, QueryShipmentQuantityStatisticsVo.class); | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public PageResult<QueryShipmentQuantityStatisticsBo> getDataList(int pageIndex, int pageSize, | |
| 29 | + QueryShipmentQuantityStatisticsVo params) { | |
| 30 | + ShipmentQuantityStatisticsService shipmentQuantityStatisticsService = ApplicationUtil.getBean(ShipmentQuantityStatisticsService.class); | |
| 31 | + PageResult<ShipmentQuantityStatisticsDto> pageResult = shipmentQuantityStatisticsService.query(pageIndex, pageSize, params); | |
| 32 | + List<QueryShipmentQuantityStatisticsBo> results = null; | |
| 33 | + if (!CollectionUtil.isEmpty(pageResult.getDatas())) { | |
| 34 | + results = pageResult.getDatas().stream().map(QueryShipmentQuantityStatisticsBo::new).collect(Collectors.toList()); | |
| 35 | + } | |
| 36 | + return PageResultUtil.rebuild(pageResult, results); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public ShipmentQuantityStatisticsModel exportData(QueryShipmentQuantityStatisticsBo data) { | |
| 41 | + ShipmentQuantityStatisticsModel model = new ShipmentQuantityStatisticsModel(); | |
| 42 | + if (data.getShipmentDate() != null) { | |
| 43 | + model.setShipmentDate(Date.from(data.getShipmentDate().atStartOfDay(ZoneId.systemDefault()).toInstant())); | |
| 44 | + } | |
| 45 | + model.setDeptName(data.getDeptName()); | |
| 46 | + model.setWorkshopName(data.getWorkshopName()); | |
| 47 | + model.setShipmentQuantity(data.getShipmentQuantity()); | |
| 48 | + return model; | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public Class<ShipmentQuantityStatisticsModel> getModelClass() { | |
| 53 | + return ShipmentQuantityStatisticsModel.class; | |
| 54 | + } | |
| 55 | +} | |
| 56 | + | ... | ... |
| 1 | +package com.lframework.xingyun.sc.excel.statistics; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | +import com.alibaba.excel.annotation.format.DateTimeFormat; | |
| 5 | +import com.alibaba.excel.annotation.format.NumberFormat; | |
| 6 | +import com.lframework.starter.web.core.components.excel.ExcelModel; | |
| 7 | +import lombok.Data; | |
| 8 | + | |
| 9 | +import java.math.BigDecimal; | |
| 10 | +import java.util.Date; | |
| 11 | + | |
| 12 | +@Data | |
| 13 | +public class ShipmentQuantityStatisticsModel implements ExcelModel { | |
| 14 | + | |
| 15 | + @ExcelProperty(value = "日期", index = 0) | |
| 16 | + @DateTimeFormat("yyyy-MM-dd") | |
| 17 | + private Date shipmentDate; | |
| 18 | + | |
| 19 | + @ExcelProperty(value = "办事处", index = 1) | |
| 20 | + private String deptName; | |
| 21 | + | |
| 22 | + @ExcelProperty(value = "分厂", index = 2) | |
| 23 | + private String workshopName; | |
| 24 | + | |
| 25 | + @ExcelProperty(value = "发货数量", index = 3) | |
| 26 | + private BigDecimal shipmentQuantity; | |
| 27 | +} | ... | ... |
| ... | ... | @@ -215,8 +215,7 @@ public class ContractDistributorStandardServiceImpl extends |
| 215 | 215 | public List<ContractDistributorStandard> query(QueryContractDistributorStandardVo vo) { |
| 216 | 216 | |
| 217 | 217 | List<ContractDistributorStandard> datas = getBaseMapper().query(vo); |
| 218 | - CollectionUtils.emptyIfNull(datas).forEach(data -> data.setCanSplit(isCanSplitByCode(data.getCode()) | |
| 219 | - && !Boolean.TRUE.equals(data.getPriceSpecLocked()))); | |
| 218 | + CollectionUtils.emptyIfNull(datas).forEach(data -> data.setCanSplit(isCanSplit(data))); | |
| 220 | 219 | return datas; |
| 221 | 220 | } |
| 222 | 221 | |
| ... | ... | @@ -227,7 +226,7 @@ public class ContractDistributorStandardServiceImpl extends |
| 227 | 226 | if (data == null) { |
| 228 | 227 | return null; |
| 229 | 228 | } |
| 230 | - data.setCanSplit(isCanSplitByCode(data.getCode()) && !Boolean.TRUE.equals(data.getPriceSpecLocked())); | |
| 229 | + data.setCanSplit(isCanSplit(data)); | |
| 231 | 230 | Wrapper<PurchaseOrderInfo> orderInfoWrapper = Wrappers.lambdaQuery(PurchaseOrderInfo.class) |
| 232 | 231 | .eq(PurchaseOrderInfo::getContractId, data.getId()); |
| 233 | 232 | List<PurchaseOrderInfo> purchaseOrderInfoList = purchaseOrderInfoService.list(orderInfoWrapper); |
| ... | ... | @@ -236,6 +235,7 @@ public class ContractDistributorStandardServiceImpl extends |
| 236 | 235 | canEdit = true; |
| 237 | 236 | } |
| 238 | 237 | data.setCanEdit(canEdit); |
| 238 | + fillRemainingQuantity(data); | |
| 239 | 239 | |
| 240 | 240 | // 获取当前人员的待办任务数据 |
| 241 | 241 | List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId()); |
| ... | ... | @@ -260,6 +260,31 @@ public class ContractDistributorStandardServiceImpl extends |
| 260 | 260 | return data; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | + private void fillRemainingQuantity(ContractDistributorStandard data) { | |
| 264 | + if (data == null || StringUtils.isBlank(data.getId())) { | |
| 265 | + return; | |
| 266 | + } | |
| 267 | + if (data.getTotalQuantity() == null) { | |
| 268 | + data.setRemainingQuantity(BigDecimal.ZERO); | |
| 269 | + return; | |
| 270 | + } | |
| 271 | + | |
| 272 | + Wrapper<ContractDistributorStandard> childWrapper = Wrappers.lambdaQuery(ContractDistributorStandard.class) | |
| 273 | + .eq(ContractDistributorStandard::getParentId, data.getId()); | |
| 274 | + List<ContractDistributorStandard> childContractList = getBaseMapper().selectList(childWrapper); | |
| 275 | + BigDecimal totalLockedQuantity = CollectionUtils.emptyIfNull(childContractList).stream() | |
| 276 | + .filter(Objects::nonNull) | |
| 277 | + .map(ContractDistributorStandard::getTotalQuantity) | |
| 278 | + .filter(Objects::nonNull) | |
| 279 | + .reduce(BigDecimal.ZERO, BigDecimal::add); | |
| 280 | + | |
| 281 | + BigDecimal remainingQuantity = data.getTotalQuantity().subtract(totalLockedQuantity); | |
| 282 | + if (remainingQuantity.compareTo(BigDecimal.ZERO) < 0) { | |
| 283 | + remainingQuantity = BigDecimal.ZERO; | |
| 284 | + } | |
| 285 | + data.setRemainingQuantity(remainingQuantity); | |
| 286 | + } | |
| 287 | + | |
| 263 | 288 | private boolean isCanSplitByCode(String code) { |
| 264 | 289 | if (StringUtils.isBlank(code)) { |
| 265 | 290 | return false; |
| ... | ... | @@ -267,6 +292,19 @@ public class ContractDistributorStandardServiceImpl extends |
| 267 | 292 | return !code.matches(".*_\\d{2}$"); |
| 268 | 293 | } |
| 269 | 294 | |
| 295 | + private boolean isCanSplit(ContractDistributorStandard data) { | |
| 296 | + if (data == null) { | |
| 297 | + return false; | |
| 298 | + } | |
| 299 | + if (!isCanSplitByCode(data.getCode()) || Boolean.TRUE.equals(data.getPriceSpecLocked())) { | |
| 300 | + return false; | |
| 301 | + } | |
| 302 | + if ("FORMAL".equals(data.getStatus())) { | |
| 303 | + return "PASS".equals(data.getFormalApproved()); | |
| 304 | + } | |
| 305 | + return true; | |
| 306 | + } | |
| 307 | + | |
| 270 | 308 | @OpLog(type = OtherOpLogType.class, name = "新增合同,ID:{}", params = {"#id"}) |
| 271 | 309 | @Transactional(rollbackFor = Exception.class) |
| 272 | 310 | @Override |
| ... | ... | @@ -1264,6 +1302,7 @@ public class ContractDistributorStandardServiceImpl extends |
| 1264 | 1302 | data.setOrderDate(LocalDate.now()); |
| 1265 | 1303 | data.setStatus("STANDARD"); |
| 1266 | 1304 | data.setParentId(vo.getId()); |
| 1305 | + data.setChangeReason(vo.getChangeReason()); | |
| 1267 | 1306 | // data.setStandardizedAt(LocalDateTime.now()); |
| 1268 | 1307 | getBaseMapper().insert(data); |
| 1269 | 1308 | |
| ... | ... | @@ -1287,11 +1326,20 @@ public class ContractDistributorStandardServiceImpl extends |
| 1287 | 1326 | contractDistributorLine.setAmountExcludingTax(lineVo.getAmountExcludingTax()); |
| 1288 | 1327 | contractDistributorLine.setTotalAmount(lineVo.getTotalAmount()); |
| 1289 | 1328 | contractDistributorLine.setDeliveryDate(lineVo.getDeliveryDate()); |
| 1329 | + contractDistributorLine.setMaterialCode(lineVo.getMaterialCode()); | |
| 1290 | 1330 | contractDistributorLineService.getBaseMapper().insert(contractDistributorLine); |
| 1331 | + | |
| 1332 | + //更新物料编码 | |
| 1333 | + Wrapper<ContractDistributorLine> contractDistributorLineWrapper = Wrappers.lambdaUpdate(ContractDistributorLine.class) | |
| 1334 | + .set(ContractDistributorLine::getMaterialCode, lineVo.getMaterialCode()) | |
| 1335 | + .eq(ContractDistributorLine::getId, lineVo.getId()); | |
| 1336 | + | |
| 1337 | + contractDistributorLineService.update(contractDistributorLineWrapper); | |
| 1291 | 1338 | } |
| 1292 | 1339 | |
| 1293 | 1340 | Wrapper<ContractDistributorStandard> changeLocked = Wrappers.lambdaUpdate(ContractDistributorStandard.class) |
| 1294 | 1341 | .set(ContractDistributorStandard::getPriceSpecLocked, true) |
| 1342 | + .set(StringUtils.isNotBlank(vo.getChangeReason()), ContractDistributorStandard::getChangeReason, vo.getChangeReason()) | |
| 1295 | 1343 | .eq(ContractDistributorStandard::getId, vo.getId()); |
| 1296 | 1344 | getBaseMapper().update(changeLocked); |
| 1297 | 1345 | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/shipments/ShipmentsOrderInfoServiceImpl.java
| ... | ... | @@ -836,14 +836,16 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr |
| 836 | 836 | paymentTypeSet.add(paymentType); |
| 837 | 837 | paymentTypeBuilder.append(paymentType).append(" | "); |
| 838 | 838 | } |
| 839 | - // 目的地 外贸标准合同、外贸库存合同、外贸未锁规格合同、加工标准合同用 | |
| 839 | + // 目的地 外贸标准合同、外贸库存合同、外贸未锁规格合同用 | |
| 840 | 840 | if (StringUtils.isNotEmpty(orderInfo.getContractType()) && ("INTL_STD_CONTRACT".equals(orderInfo.getContractType()) |
| 841 | 841 | || "INTL_INVENTORY_AGMT".equals(orderInfo.getContractType()) |
| 842 | - || "INTL_OPEN_SPEC_AGMT".equals(orderInfo.getContractType()) | |
| 843 | - || "PROCESS_STD_AGMT".equals(orderInfo.getContractType()))) { | |
| 842 | + || "INTL_OPEN_SPEC_AGMT".equals(orderInfo.getContractType()))) { | |
| 844 | 843 | String foreignDestination = orderInfo.getForeignDestination(); |
| 845 | - destinationBuilder.append(foreignDestination); | |
| 846 | - destinationBuilder.append(" | "); | |
| 844 | + if (StringUtils.isNotBlank(foreignDestination) && !destinationSet.contains(foreignDestination)) { | |
| 845 | + destinationSet.add(foreignDestination); | |
| 846 | + destinationBuilder.append(foreignDestination); | |
| 847 | + destinationBuilder.append(" | "); | |
| 848 | + } | |
| 847 | 849 | } else { |
| 848 | 850 | String destination = orderInfo.getDestination(); |
| 849 | 851 | if (StringUtils.isNotBlank(destination) && !destinationSet.contains(destination)) { | ... | ... |
| 1 | +package com.lframework.xingyun.sc.impl.statistics; | |
| 2 | + | |
| 3 | +import com.github.pagehelper.Page; | |
| 4 | +import com.github.pagehelper.PageInfo; | |
| 5 | +import com.lframework.starter.common.utils.Assert; | |
| 6 | +import com.lframework.starter.common.utils.CollectionUtil; | |
| 7 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 8 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 9 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsDto; | |
| 10 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsInvalidDto; | |
| 11 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDateRangeDto; | |
| 12 | +import com.lframework.xingyun.sc.mappers.ShipmentQuantityIndustryStatisticsMapper; | |
| 13 | +import com.lframework.xingyun.sc.service.statistics.ShipmentQuantityIndustryStatisticsService; | |
| 14 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantityIndustry.QueryShipmentQuantityIndustryStatisticsVo; | |
| 15 | +import lombok.extern.slf4j.Slf4j; | |
| 16 | +import org.apache.commons.lang3.StringUtils; | |
| 17 | +import org.springframework.stereotype.Service; | |
| 18 | + | |
| 19 | +import javax.annotation.Resource; | |
| 20 | +import java.math.BigDecimal; | |
| 21 | +import java.time.LocalDate; | |
| 22 | +import java.time.format.DateTimeFormatter; | |
| 23 | +import java.util.ArrayList; | |
| 24 | +import java.util.HashMap; | |
| 25 | +import java.util.List; | |
| 26 | +import java.util.Map; | |
| 27 | +import java.util.stream.Collectors; | |
| 28 | + | |
| 29 | +@Slf4j | |
| 30 | +@Service | |
| 31 | +public class ShipmentQuantityIndustryStatisticsServiceImpl implements ShipmentQuantityIndustryStatisticsService { | |
| 32 | + | |
| 33 | + private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | |
| 34 | + | |
| 35 | + @Resource | |
| 36 | + private ShipmentQuantityIndustryStatisticsMapper shipmentQuantityIndustryStatisticsMapper; | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public PageResult<ShipmentQuantityIndustryStatisticsDto> query(Integer pageIndex, Integer pageSize, | |
| 40 | + QueryShipmentQuantityIndustryStatisticsVo vo) { | |
| 41 | + | |
| 42 | + Assert.greaterThanZero(pageIndex); | |
| 43 | + Assert.greaterThanZero(pageSize); | |
| 44 | + | |
| 45 | + logInvalid(vo); | |
| 46 | + | |
| 47 | + List<ShipmentQuantityIndustryStatisticsDto> fullList = buildFilledList(vo); | |
| 48 | + long total = fullList.size(); | |
| 49 | + | |
| 50 | + int fromIndex = (pageIndex - 1) * pageSize; | |
| 51 | + List<ShipmentQuantityIndustryStatisticsDto> pageDatas; | |
| 52 | + if (fromIndex >= total) { | |
| 53 | + pageDatas = new ArrayList<>(); | |
| 54 | + } else { | |
| 55 | + int toIndex = (int) Math.min(fromIndex + pageSize, total); | |
| 56 | + pageDatas = fullList.subList(fromIndex, toIndex); | |
| 57 | + } | |
| 58 | + | |
| 59 | + Page<ShipmentQuantityIndustryStatisticsDto> page = new Page<>(pageIndex, pageSize); | |
| 60 | + page.setTotal(total); | |
| 61 | + page.addAll(pageDatas); | |
| 62 | + return PageResultUtil.convert(new PageInfo<>(page)); | |
| 63 | + } | |
| 64 | + | |
| 65 | + @Override | |
| 66 | + public List<ShipmentQuantityIndustryStatisticsDto> query(QueryShipmentQuantityIndustryStatisticsVo vo) { | |
| 67 | + logInvalid(vo); | |
| 68 | + return buildFilledList(vo); | |
| 69 | + } | |
| 70 | + | |
| 71 | + private void logInvalid(QueryShipmentQuantityIndustryStatisticsVo vo) { | |
| 72 | + List<ShipmentQuantityIndustryStatisticsInvalidDto> invalidList = shipmentQuantityIndustryStatisticsMapper.queryInvalid(vo); | |
| 73 | + if (CollectionUtil.isEmpty(invalidList)) { | |
| 74 | + return; | |
| 75 | + } | |
| 76 | + | |
| 77 | + String invalidMsg = invalidList.stream() | |
| 78 | + .map(this::formatInvalid) | |
| 79 | + .collect(Collectors.joining("; ")); | |
| 80 | + log.error("发货数量统计(行业):检测到核心字段缺失的异常记录,已拦截不参与统计。{}", invalidMsg); | |
| 81 | + } | |
| 82 | + | |
| 83 | + private String formatInvalid(ShipmentQuantityIndustryStatisticsInvalidDto dto) { | |
| 84 | + StringBuilder sb = new StringBuilder(); | |
| 85 | + sb.append("orderNo=").append(dto.getOrderNo()) | |
| 86 | + .append(", lineId=").append(dto.getLineId()); | |
| 87 | + sb.append(", missing="); | |
| 88 | + boolean has = false; | |
| 89 | + if (dto.getShipmentDate() == null) { | |
| 90 | + sb.append("shipmentDate"); | |
| 91 | + has = true; | |
| 92 | + } | |
| 93 | + if (dto.getIndustry() == null || dto.getIndustry().isEmpty()) { | |
| 94 | + if (has) sb.append("|"); | |
| 95 | + sb.append("industry"); | |
| 96 | + has = true; | |
| 97 | + } | |
| 98 | + if (dto.getWorkshopId() == null || dto.getWorkshopId().isEmpty()) { | |
| 99 | + if (has) sb.append("|"); | |
| 100 | + sb.append("workshop"); | |
| 101 | + has = true; | |
| 102 | + } | |
| 103 | + if (dto.getQuantity() == null) { | |
| 104 | + if (has) sb.append("|"); | |
| 105 | + sb.append("quantity"); | |
| 106 | + } | |
| 107 | + return sb.toString(); | |
| 108 | + } | |
| 109 | + | |
| 110 | + private List<ShipmentQuantityIndustryStatisticsDto> buildFilledList(QueryShipmentQuantityIndustryStatisticsVo vo) { | |
| 111 | + if (!hasAccessibleBaseData(vo)) { | |
| 112 | + return new ArrayList<>(); | |
| 113 | + } | |
| 114 | + | |
| 115 | + LocalDate startDate = parse(vo.getShipmentDateStart()); | |
| 116 | + LocalDate endDate = parse(vo.getShipmentDateEnd()); | |
| 117 | + LocalDate today = LocalDate.now(); | |
| 118 | + | |
| 119 | + if (startDate == null && endDate == null) { | |
| 120 | + ShipmentQuantityStatisticsDateRangeDto dateRange = queryDateRangeWithFallback(vo); | |
| 121 | + if (dateRange == null || dateRange.getStartDate() == null || dateRange.getEndDate() == null) { | |
| 122 | + startDate = today; | |
| 123 | + endDate = today; | |
| 124 | + } else { | |
| 125 | + startDate = dateRange.getStartDate(); | |
| 126 | + LocalDate endDateDefault = dateRange.getEndDate(); | |
| 127 | + if (endDateDefault.isBefore(today)) { | |
| 128 | + endDateDefault = today; | |
| 129 | + } | |
| 130 | + endDate = endDateDefault; | |
| 131 | + } | |
| 132 | + } else { | |
| 133 | + if (startDate == null) { | |
| 134 | + startDate = endDate; | |
| 135 | + } | |
| 136 | + if (endDate == null) { | |
| 137 | + endDate = startDate; | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 141 | + if (startDate == null || endDate == null || endDate.isBefore(startDate)) { | |
| 142 | + return new ArrayList<>(); | |
| 143 | + } | |
| 144 | + | |
| 145 | + QueryShipmentQuantityIndustryStatisticsVo queryVo = new QueryShipmentQuantityIndustryStatisticsVo(); | |
| 146 | + queryVo.setIndustry(vo.getIndustry()); | |
| 147 | + queryVo.setWorkshopId(vo.getWorkshopId()); | |
| 148 | + queryVo.setShipmentDateStart(startDate.format(DATE_FORMATTER)); | |
| 149 | + queryVo.setShipmentDateEnd(endDate.format(DATE_FORMATTER)); | |
| 150 | + | |
| 151 | + List<ShipmentQuantityIndustryStatisticsDto> aggList = shipmentQuantityIndustryStatisticsMapper.query(queryVo); | |
| 152 | + | |
| 153 | + List<String> industryList; | |
| 154 | + industryList = shipmentQuantityIndustryStatisticsMapper.queryIndustryDim(queryVo); | |
| 155 | + if (industryList == null) { | |
| 156 | + industryList = new ArrayList<>(); | |
| 157 | + } | |
| 158 | + | |
| 159 | + if (CollectionUtil.isEmpty(industryList)) { | |
| 160 | + return new ArrayList<>(); | |
| 161 | + } | |
| 162 | + | |
| 163 | + List<ShipmentQuantityIndustryStatisticsDto> workshopList; | |
| 164 | + if (StringUtils.isNotBlank(vo.getWorkshopId())) { | |
| 165 | + ShipmentQuantityIndustryStatisticsDto workshop = shipmentQuantityIndustryStatisticsMapper.queryWorkshopDimById(vo.getWorkshopId()); | |
| 166 | + workshopList = new ArrayList<>(); | |
| 167 | + if (workshop != null) { | |
| 168 | + workshopList.add(workshop); | |
| 169 | + } | |
| 170 | + } else { | |
| 171 | + List<String> workshopCodes = new ArrayList<>(); | |
| 172 | + workshopCodes.add("yfc"); | |
| 173 | + workshopCodes.add("efc"); | |
| 174 | + workshopCodes.add("sfc"); | |
| 175 | + workshopCodes.add("ztfc"); | |
| 176 | + workshopList = shipmentQuantityIndustryStatisticsMapper.queryWorkshopDimByCodes(workshopCodes); | |
| 177 | + if (workshopList == null) { | |
| 178 | + workshopList = new ArrayList<>(); | |
| 179 | + } | |
| 180 | + } | |
| 181 | + | |
| 182 | + if (CollectionUtil.isEmpty(workshopList)) { | |
| 183 | + return new ArrayList<>(); | |
| 184 | + } | |
| 185 | + | |
| 186 | + if (CollectionUtil.isEmpty(aggList)) { | |
| 187 | + aggList = new ArrayList<>(); | |
| 188 | + } | |
| 189 | + | |
| 190 | + Map<String, BigDecimal> quantityMap = new HashMap<>(); | |
| 191 | + for (ShipmentQuantityIndustryStatisticsDto d : aggList) { | |
| 192 | + if (d.getShipmentDate() == null) { | |
| 193 | + continue; | |
| 194 | + } | |
| 195 | + if (StringUtils.isBlank(d.getIndustry()) || StringUtils.isBlank(d.getWorkshopId())) { | |
| 196 | + continue; | |
| 197 | + } | |
| 198 | + BigDecimal qty = d.getShipmentQuantity() == null ? BigDecimal.ZERO : d.getShipmentQuantity(); | |
| 199 | + String key = buildKey(d.getShipmentDate(), d.getIndustry(), d.getWorkshopId()); | |
| 200 | + quantityMap.merge(key, qty, BigDecimal::add); | |
| 201 | + } | |
| 202 | + | |
| 203 | + List<ShipmentQuantityIndustryStatisticsDto> results = new ArrayList<>(); | |
| 204 | + for (LocalDate date = endDate; !date.isBefore(startDate); date = date.minusDays(1)) { | |
| 205 | + for (ShipmentQuantityIndustryStatisticsDto w : workshopList) { | |
| 206 | + for (String industry : industryList) { | |
| 207 | + ShipmentQuantityIndustryStatisticsDto row = new ShipmentQuantityIndustryStatisticsDto(); | |
| 208 | + row.setShipmentDate(date); | |
| 209 | + row.setIndustry(industry); | |
| 210 | + row.setWorkshopId(w.getWorkshopId()); | |
| 211 | + row.setWorkshopCode(w.getWorkshopCode()); | |
| 212 | + row.setWorkshopName(w.getWorkshopName()); | |
| 213 | + BigDecimal qty = quantityMap.get(buildKey(date, industry, w.getWorkshopId())); | |
| 214 | + row.setShipmentQuantity(qty == null ? BigDecimal.ZERO : qty); | |
| 215 | + results.add(row); | |
| 216 | + } | |
| 217 | + } | |
| 218 | + } | |
| 219 | + | |
| 220 | + return results; | |
| 221 | + } | |
| 222 | + | |
| 223 | + private static String buildKey(LocalDate date, String industry, String workshopId) { | |
| 224 | + return date + "|" + industry + "|" + workshopId; | |
| 225 | + } | |
| 226 | + | |
| 227 | + private boolean hasAccessibleBaseData(QueryShipmentQuantityIndustryStatisticsVo vo) { | |
| 228 | + QueryShipmentQuantityIndustryStatisticsVo permissionCheckVo = new QueryShipmentQuantityIndustryStatisticsVo(); | |
| 229 | + permissionCheckVo.setIndustry(vo.getIndustry()); | |
| 230 | + permissionCheckVo.setWorkshopId(vo.getWorkshopId()); | |
| 231 | + | |
| 232 | + ShipmentQuantityStatisticsDateRangeDto dateRange = shipmentQuantityIndustryStatisticsMapper.queryDateRange(permissionCheckVo); | |
| 233 | + return dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null; | |
| 234 | + } | |
| 235 | + | |
| 236 | + private ShipmentQuantityStatisticsDateRangeDto queryDateRangeWithFallback(QueryShipmentQuantityIndustryStatisticsVo vo) { | |
| 237 | + ShipmentQuantityStatisticsDateRangeDto dateRange = shipmentQuantityIndustryStatisticsMapper.queryDateRange(vo); | |
| 238 | + if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) { | |
| 239 | + return dateRange; | |
| 240 | + } | |
| 241 | + | |
| 242 | + String industry = vo.getIndustry(); | |
| 243 | + String workshopId = vo.getWorkshopId(); | |
| 244 | + | |
| 245 | + if (StringUtils.isNotBlank(industry)) { | |
| 246 | + QueryShipmentQuantityIndustryStatisticsVo v = new QueryShipmentQuantityIndustryStatisticsVo(); | |
| 247 | + v.setWorkshopId(workshopId); | |
| 248 | + dateRange = shipmentQuantityIndustryStatisticsMapper.queryDateRange(v); | |
| 249 | + if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) { | |
| 250 | + return dateRange; | |
| 251 | + } | |
| 252 | + } | |
| 253 | + | |
| 254 | + if (StringUtils.isNotBlank(workshopId)) { | |
| 255 | + QueryShipmentQuantityIndustryStatisticsVo v = new QueryShipmentQuantityIndustryStatisticsVo(); | |
| 256 | + v.setIndustry(industry); | |
| 257 | + dateRange = shipmentQuantityIndustryStatisticsMapper.queryDateRange(v); | |
| 258 | + if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) { | |
| 259 | + return dateRange; | |
| 260 | + } | |
| 261 | + } | |
| 262 | + | |
| 263 | + QueryShipmentQuantityIndustryStatisticsVo v = new QueryShipmentQuantityIndustryStatisticsVo(); | |
| 264 | + return shipmentQuantityIndustryStatisticsMapper.queryDateRange(v); | |
| 265 | + } | |
| 266 | + | |
| 267 | + private static LocalDate parse(String dateStr) { | |
| 268 | + if (StringUtils.isBlank(dateStr)) { | |
| 269 | + return null; | |
| 270 | + } | |
| 271 | + try { | |
| 272 | + return LocalDate.parse(dateStr, DATE_FORMATTER); | |
| 273 | + } catch (Exception e) { | |
| 274 | + return null; | |
| 275 | + } | |
| 276 | + } | |
| 277 | + | |
| 278 | + private static LocalDate parseOrDefault(String dateStr, LocalDate defaultValue) { | |
| 279 | + if (StringUtils.isBlank(dateStr)) { | |
| 280 | + return defaultValue; | |
| 281 | + } | |
| 282 | + try { | |
| 283 | + return LocalDate.parse(dateStr, DATE_FORMATTER); | |
| 284 | + } catch (Exception e) { | |
| 285 | + return defaultValue; | |
| 286 | + } | |
| 287 | + } | |
| 288 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.impl.statistics; | |
| 2 | + | |
| 3 | +import com.github.pagehelper.Page; | |
| 4 | +import com.github.pagehelper.PageInfo; | |
| 5 | +import com.lframework.starter.common.utils.Assert; | |
| 6 | +import com.lframework.starter.common.utils.CollectionUtil; | |
| 7 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 8 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 9 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDateRangeDto; | |
| 10 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDto; | |
| 11 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsInvalidDto; | |
| 12 | +import com.lframework.xingyun.sc.mappers.ShipmentQuantityStatisticsMapper; | |
| 13 | +import com.lframework.xingyun.sc.service.statistics.ShipmentQuantityStatisticsService; | |
| 14 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantity.QueryShipmentQuantityStatisticsVo; | |
| 15 | +import lombok.extern.slf4j.Slf4j; | |
| 16 | +import org.apache.commons.lang3.StringUtils; | |
| 17 | +import org.springframework.stereotype.Service; | |
| 18 | + | |
| 19 | +import javax.annotation.Resource; | |
| 20 | +import java.math.BigDecimal; | |
| 21 | +import java.time.LocalDate; | |
| 22 | +import java.time.format.DateTimeFormatter; | |
| 23 | +import java.util.ArrayList; | |
| 24 | +import java.util.Comparator; | |
| 25 | +import java.util.HashMap; | |
| 26 | +import java.util.List; | |
| 27 | +import java.util.Map; | |
| 28 | +import java.util.stream.Collectors; | |
| 29 | + | |
| 30 | +@Slf4j | |
| 31 | +@Service | |
| 32 | +public class ShipmentQuantityStatisticsServiceImpl implements ShipmentQuantityStatisticsService { | |
| 33 | + | |
| 34 | + private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private ShipmentQuantityStatisticsMapper shipmentQuantityStatisticsMapper; | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public PageResult<ShipmentQuantityStatisticsDto> query(Integer pageIndex, Integer pageSize, | |
| 41 | + QueryShipmentQuantityStatisticsVo vo) { | |
| 42 | + | |
| 43 | + Assert.greaterThanZero(pageIndex); | |
| 44 | + Assert.greaterThanZero(pageSize); | |
| 45 | + | |
| 46 | + logInvalid(vo); | |
| 47 | + | |
| 48 | + List<ShipmentQuantityStatisticsDto> fullList = buildFilledList(vo); | |
| 49 | + long total = fullList.size(); | |
| 50 | + | |
| 51 | + int fromIndex = (pageIndex - 1) * pageSize; | |
| 52 | + List<ShipmentQuantityStatisticsDto> pageDatas; | |
| 53 | + if (fromIndex >= total) { | |
| 54 | + pageDatas = new ArrayList<>(); | |
| 55 | + } else { | |
| 56 | + int toIndex = (int) Math.min(fromIndex + pageSize, total); | |
| 57 | + pageDatas = fullList.subList(fromIndex, toIndex); | |
| 58 | + } | |
| 59 | + | |
| 60 | + Page<ShipmentQuantityStatisticsDto> page = new Page<>(pageIndex, pageSize); | |
| 61 | + page.setTotal(total); | |
| 62 | + page.addAll(pageDatas); | |
| 63 | + return PageResultUtil.convert(new PageInfo<>(page)); | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public List<ShipmentQuantityStatisticsDto> query(QueryShipmentQuantityStatisticsVo vo) { | |
| 68 | + logInvalid(vo); | |
| 69 | + return buildFilledList(vo); | |
| 70 | + } | |
| 71 | + | |
| 72 | + private void logInvalid(QueryShipmentQuantityStatisticsVo vo) { | |
| 73 | + List<ShipmentQuantityStatisticsInvalidDto> invalidList = shipmentQuantityStatisticsMapper.queryInvalid(vo); | |
| 74 | + if (CollectionUtil.isEmpty(invalidList)) { | |
| 75 | + return; | |
| 76 | + } | |
| 77 | + | |
| 78 | + String invalidMsg = invalidList.stream() | |
| 79 | + .map(this::formatInvalid) | |
| 80 | + .collect(Collectors.joining("; ")); | |
| 81 | + log.error("发货数量统计:检测到核心字段缺失的异常记录,已拦截不参与统计。{}", invalidMsg); | |
| 82 | + } | |
| 83 | + | |
| 84 | + private String formatInvalid(ShipmentQuantityStatisticsInvalidDto dto) { | |
| 85 | + StringBuilder sb = new StringBuilder(); | |
| 86 | + sb.append("orderNo=").append(dto.getOrderNo()) | |
| 87 | + .append(", lineId=").append(dto.getLineId()); | |
| 88 | + sb.append(", missing="); | |
| 89 | + boolean has = false; | |
| 90 | + if (dto.getShipmentDate() == null) { | |
| 91 | + sb.append("shipmentDate"); | |
| 92 | + has = true; | |
| 93 | + } | |
| 94 | + if (dto.getDeptId() == null || dto.getDeptId().isEmpty()) { | |
| 95 | + if (has) sb.append("|"); | |
| 96 | + sb.append("dept"); | |
| 97 | + has = true; | |
| 98 | + } | |
| 99 | + if (dto.getWorkshopId() == null || dto.getWorkshopId().isEmpty()) { | |
| 100 | + if (has) sb.append("|"); | |
| 101 | + sb.append("workshop"); | |
| 102 | + has = true; | |
| 103 | + } | |
| 104 | + if (dto.getQuantity() == null) { | |
| 105 | + if (has) sb.append("|"); | |
| 106 | + sb.append("quantity"); | |
| 107 | + } | |
| 108 | + return sb.toString(); | |
| 109 | + } | |
| 110 | + | |
| 111 | + private List<ShipmentQuantityStatisticsDto> buildFilledList(QueryShipmentQuantityStatisticsVo vo) { | |
| 112 | + if (!hasAccessibleBaseData(vo)) { | |
| 113 | + return new ArrayList<>(); | |
| 114 | + } | |
| 115 | + | |
| 116 | + LocalDate startDate = parse(vo.getShipmentDateStart()); | |
| 117 | + LocalDate endDate = parse(vo.getShipmentDateEnd()); | |
| 118 | + LocalDate today = LocalDate.now(); | |
| 119 | + | |
| 120 | + if (startDate == null && endDate == null) { | |
| 121 | + ShipmentQuantityStatisticsDateRangeDto dateRange = queryDateRangeWithFallback(vo); | |
| 122 | + if (dateRange == null || dateRange.getStartDate() == null || dateRange.getEndDate() == null) { | |
| 123 | + startDate = today; | |
| 124 | + endDate = today; | |
| 125 | + } else { | |
| 126 | + startDate = dateRange.getStartDate(); | |
| 127 | + LocalDate endDateDefault = dateRange.getEndDate(); | |
| 128 | + if (endDateDefault.isBefore(today)) { | |
| 129 | + endDateDefault = today; | |
| 130 | + } | |
| 131 | + endDate = endDateDefault; | |
| 132 | + } | |
| 133 | + } else { | |
| 134 | + if (startDate == null) { | |
| 135 | + startDate = endDate; | |
| 136 | + } | |
| 137 | + if (endDate == null) { | |
| 138 | + endDate = startDate; | |
| 139 | + } | |
| 140 | + } | |
| 141 | + | |
| 142 | + if (startDate == null || endDate == null || endDate.isBefore(startDate)) { | |
| 143 | + return new ArrayList<>(); | |
| 144 | + } | |
| 145 | + | |
| 146 | + QueryShipmentQuantityStatisticsVo queryVo = new QueryShipmentQuantityStatisticsVo(); | |
| 147 | + queryVo.setDeptId(vo.getDeptId()); | |
| 148 | + queryVo.setWorkshopId(vo.getWorkshopId()); | |
| 149 | + queryVo.setShipmentDateStart(startDate.format(DATE_FORMATTER)); | |
| 150 | + queryVo.setShipmentDateEnd(endDate.format(DATE_FORMATTER)); | |
| 151 | + | |
| 152 | + List<ShipmentQuantityStatisticsDto> aggList = shipmentQuantityStatisticsMapper.query(queryVo); | |
| 153 | + List<ShipmentQuantityStatisticsDto> deptList; | |
| 154 | + if (StringUtils.isNotBlank(vo.getDeptId())) { | |
| 155 | + ShipmentQuantityStatisticsDto dept = shipmentQuantityStatisticsMapper.queryDeptDimById(vo.getDeptId()); | |
| 156 | + deptList = new ArrayList<>(); | |
| 157 | + if (dept != null) { | |
| 158 | + deptList.add(dept); | |
| 159 | + } | |
| 160 | + } else { | |
| 161 | + List<String> deptCodes = new ArrayList<>(); | |
| 162 | + deptCodes.add("BF"); | |
| 163 | + deptCodes.add("CZ"); | |
| 164 | + deptCodes.add("DG"); | |
| 165 | + deptCodes.add("FS"); | |
| 166 | + deptCodes.add("NB"); | |
| 167 | + deptCodes.add("SZ"); | |
| 168 | + deptCodes.add("WZ"); | |
| 169 | + deptCodes.add("ZT"); | |
| 170 | + deptCodes.add("WM"); | |
| 171 | + deptList = shipmentQuantityStatisticsMapper.queryDeptDimByCodes(deptCodes); | |
| 172 | + if (deptList == null) { | |
| 173 | + deptList = new ArrayList<>(); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + if (CollectionUtil.isEmpty(deptList)) { | |
| 178 | + return new ArrayList<>(); | |
| 179 | + } | |
| 180 | + | |
| 181 | + List<ShipmentQuantityStatisticsDto> workshopList; | |
| 182 | + if (StringUtils.isNotBlank(vo.getWorkshopId())) { | |
| 183 | + ShipmentQuantityStatisticsDto workshop = shipmentQuantityStatisticsMapper.queryWorkshopDimById(vo.getWorkshopId()); | |
| 184 | + workshopList = new ArrayList<>(); | |
| 185 | + if (workshop != null) { | |
| 186 | + workshopList.add(workshop); | |
| 187 | + } | |
| 188 | + } else { | |
| 189 | + List<String> workshopCodes = new ArrayList<>(); | |
| 190 | + workshopCodes.add("yfc"); | |
| 191 | + workshopCodes.add("efc"); | |
| 192 | + workshopCodes.add("sfc"); | |
| 193 | + workshopCodes.add("ztfc"); | |
| 194 | + workshopList = shipmentQuantityStatisticsMapper.queryWorkshopDimByCodes(workshopCodes); | |
| 195 | + if (workshopList == null) { | |
| 196 | + workshopList = new ArrayList<>(); | |
| 197 | + } | |
| 198 | + } | |
| 199 | + | |
| 200 | + if (CollectionUtil.isEmpty(workshopList)) { | |
| 201 | + return new ArrayList<>(); | |
| 202 | + } | |
| 203 | + | |
| 204 | + if (CollectionUtil.isEmpty(aggList)) { | |
| 205 | + aggList = new ArrayList<>(); | |
| 206 | + } | |
| 207 | + | |
| 208 | + Map<String, BigDecimal> quantityMap = aggList.stream() | |
| 209 | + .filter(d -> d.getShipmentDate() != null) | |
| 210 | + .filter(d -> StringUtils.isNotBlank(d.getDeptId())) | |
| 211 | + .filter(d -> StringUtils.isNotBlank(d.getWorkshopId())) | |
| 212 | + .collect(Collectors.toMap( | |
| 213 | + d -> buildKey(d.getShipmentDate(), d.getDeptId(), d.getWorkshopId()), | |
| 214 | + d -> d.getShipmentQuantity() == null ? BigDecimal.ZERO : d.getShipmentQuantity(), | |
| 215 | + BigDecimal::add | |
| 216 | + )); | |
| 217 | + | |
| 218 | + List<ShipmentQuantityStatisticsDto> results = new ArrayList<>(); | |
| 219 | + for (LocalDate date = endDate; !date.isBefore(startDate); date = date.minusDays(1)) { | |
| 220 | + for (ShipmentQuantityStatisticsDto w : workshopList) { | |
| 221 | + for (ShipmentQuantityStatisticsDto dept : deptList) { | |
| 222 | + ShipmentQuantityStatisticsDto row = new ShipmentQuantityStatisticsDto(); | |
| 223 | + row.setShipmentDate(date); | |
| 224 | + row.setDeptId(dept.getDeptId()); | |
| 225 | + row.setDeptName(dept.getDeptName()); | |
| 226 | + row.setWorkshopId(w.getWorkshopId()); | |
| 227 | + row.setWorkshopCode(w.getWorkshopCode()); | |
| 228 | + row.setWorkshopName(w.getWorkshopName()); | |
| 229 | + BigDecimal qty = quantityMap.get(buildKey(date, dept.getDeptId(), w.getWorkshopId())); | |
| 230 | + row.setShipmentQuantity(qty == null ? BigDecimal.ZERO : qty); | |
| 231 | + results.add(row); | |
| 232 | + } | |
| 233 | + } | |
| 234 | + } | |
| 235 | + | |
| 236 | + return results; | |
| 237 | + } | |
| 238 | + | |
| 239 | + private static String buildKey(LocalDate date, String deptId, String workshopId) { | |
| 240 | + return date + "|" + deptId + "|" + workshopId; | |
| 241 | + } | |
| 242 | + | |
| 243 | + private boolean hasAccessibleBaseData(QueryShipmentQuantityStatisticsVo vo) { | |
| 244 | + QueryShipmentQuantityStatisticsVo permissionCheckVo = new QueryShipmentQuantityStatisticsVo(); | |
| 245 | + permissionCheckVo.setDeptId(vo.getDeptId()); | |
| 246 | + permissionCheckVo.setWorkshopId(vo.getWorkshopId()); | |
| 247 | + | |
| 248 | + ShipmentQuantityStatisticsDateRangeDto dateRange = shipmentQuantityStatisticsMapper.queryDateRange(permissionCheckVo); | |
| 249 | + return dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null; | |
| 250 | + } | |
| 251 | + | |
| 252 | + private ShipmentQuantityStatisticsDateRangeDto queryDateRangeWithFallback(QueryShipmentQuantityStatisticsVo vo) { | |
| 253 | + ShipmentQuantityStatisticsDateRangeDto dateRange = shipmentQuantityStatisticsMapper.queryDateRange(vo); | |
| 254 | + if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) { | |
| 255 | + return dateRange; | |
| 256 | + } | |
| 257 | + | |
| 258 | + String deptId = vo.getDeptId(); | |
| 259 | + String workshopId = vo.getWorkshopId(); | |
| 260 | + | |
| 261 | + if (StringUtils.isNotBlank(deptId)) { | |
| 262 | + QueryShipmentQuantityStatisticsVo v = new QueryShipmentQuantityStatisticsVo(); | |
| 263 | + v.setWorkshopId(workshopId); | |
| 264 | + dateRange = shipmentQuantityStatisticsMapper.queryDateRange(v); | |
| 265 | + if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) { | |
| 266 | + return dateRange; | |
| 267 | + } | |
| 268 | + } | |
| 269 | + | |
| 270 | + if (StringUtils.isNotBlank(workshopId)) { | |
| 271 | + QueryShipmentQuantityStatisticsVo v = new QueryShipmentQuantityStatisticsVo(); | |
| 272 | + v.setDeptId(deptId); | |
| 273 | + dateRange = shipmentQuantityStatisticsMapper.queryDateRange(v); | |
| 274 | + if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) { | |
| 275 | + return dateRange; | |
| 276 | + } | |
| 277 | + } | |
| 278 | + | |
| 279 | + QueryShipmentQuantityStatisticsVo v = new QueryShipmentQuantityStatisticsVo(); | |
| 280 | + return shipmentQuantityStatisticsMapper.queryDateRange(v); | |
| 281 | + } | |
| 282 | + | |
| 283 | + private static LocalDate parse(String dateStr) { | |
| 284 | + if (StringUtils.isBlank(dateStr)) { | |
| 285 | + return null; | |
| 286 | + } | |
| 287 | + try { | |
| 288 | + return LocalDate.parse(dateStr, DATE_FORMATTER); | |
| 289 | + } catch (Exception e) { | |
| 290 | + return null; | |
| 291 | + } | |
| 292 | + } | |
| 293 | + | |
| 294 | + private static LocalDate parseOrDefault(String dateStr, LocalDate defaultValue) { | |
| 295 | + if (StringUtils.isBlank(dateStr)) { | |
| 296 | + return defaultValue; | |
| 297 | + } | |
| 298 | + try { | |
| 299 | + return LocalDate.parse(dateStr, DATE_FORMATTER); | |
| 300 | + } catch (Exception e) { | |
| 301 | + return defaultValue; | |
| 302 | + } | |
| 303 | + } | |
| 304 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.mappers; | |
| 2 | + | |
| 3 | +import com.lframework.starter.web.core.annotations.permission.DataPermission; | |
| 4 | +import com.lframework.starter.web.core.annotations.permission.DataPermissions; | |
| 5 | +import com.lframework.starter.web.inner.components.permission.OrderDataPermissionDataPermissionType; | |
| 6 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsDto; | |
| 7 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsInvalidDto; | |
| 8 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDateRangeDto; | |
| 9 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantityIndustry.QueryShipmentQuantityIndustryStatisticsVo; | |
| 10 | +import org.apache.ibatis.annotations.Param; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +public interface ShipmentQuantityIndustryStatisticsMapper { | |
| 15 | + | |
| 16 | + @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { | |
| 17 | + @DataPermission(template = "order", alias = "t") | |
| 18 | + }) | |
| 19 | + List<ShipmentQuantityIndustryStatisticsDto> query(@Param("vo") QueryShipmentQuantityIndustryStatisticsVo vo); | |
| 20 | + | |
| 21 | + @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { | |
| 22 | + @DataPermission(template = "order", alias = "t") | |
| 23 | + }) | |
| 24 | + ShipmentQuantityStatisticsDateRangeDto queryDateRange(@Param("vo") QueryShipmentQuantityIndustryStatisticsVo vo); | |
| 25 | + | |
| 26 | + List<String> queryIndustryDim(@Param("vo") QueryShipmentQuantityIndustryStatisticsVo vo); | |
| 27 | + | |
| 28 | + ShipmentQuantityIndustryStatisticsDto queryWorkshopDimById(@Param("workshopId") String workshopId); | |
| 29 | + | |
| 30 | + List<ShipmentQuantityIndustryStatisticsDto> queryWorkshopDimByCodes(@Param("codes") List<String> codes); | |
| 31 | + | |
| 32 | + List<ShipmentQuantityIndustryStatisticsInvalidDto> queryInvalid(@Param("vo") QueryShipmentQuantityIndustryStatisticsVo vo); | |
| 33 | +} | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/mappers/ShipmentQuantityStatisticsMapper.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.mappers; | |
| 2 | + | |
| 3 | +import com.lframework.starter.web.core.annotations.permission.DataPermission; | |
| 4 | +import com.lframework.starter.web.core.annotations.permission.DataPermissions; | |
| 5 | +import com.lframework.starter.web.inner.components.permission.OrderDataPermissionDataPermissionType; | |
| 6 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDateRangeDto; | |
| 7 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDto; | |
| 8 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsInvalidDto; | |
| 9 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantity.QueryShipmentQuantityStatisticsVo; | |
| 10 | +import org.apache.ibatis.annotations.Param; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +public interface ShipmentQuantityStatisticsMapper { | |
| 15 | + /** | |
| 16 | + * 查询列表 | |
| 17 | + * 开启权限控制 | |
| 18 | + * | |
| 19 | + * @param vo 查询条件 | |
| 20 | + * @return List<ShipmentQuantityStatisticsDto> | |
| 21 | + */ | |
| 22 | + @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { | |
| 23 | + @DataPermission(template = "order", alias = "t") | |
| 24 | + }) | |
| 25 | + List<ShipmentQuantityStatisticsDto> query(@Param("vo") QueryShipmentQuantityStatisticsVo vo); | |
| 26 | + | |
| 27 | + @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { | |
| 28 | + @DataPermission(template = "order", alias = "t") | |
| 29 | + }) | |
| 30 | + ShipmentQuantityStatisticsDateRangeDto queryDateRange(@Param("vo") QueryShipmentQuantityStatisticsVo vo); | |
| 31 | + | |
| 32 | + List<ShipmentQuantityStatisticsDto> queryDeptDimByCodes(@Param("codes") List<String> codes); | |
| 33 | + | |
| 34 | + ShipmentQuantityStatisticsDto queryDeptDimById(@Param("deptId") String deptId); | |
| 35 | + | |
| 36 | + List<ShipmentQuantityStatisticsDto> queryWorkshopDimByCodes(@Param("codes") List<String> codes); | |
| 37 | + | |
| 38 | + ShipmentQuantityStatisticsDto queryWorkshopDimById(@Param("workshopId") String workshopId); | |
| 39 | + | |
| 40 | + List<ShipmentQuantityStatisticsInvalidDto> queryInvalid(@Param("vo") QueryShipmentQuantityStatisticsVo vo); | |
| 41 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.service.statistics; | |
| 2 | + | |
| 3 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 4 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsDto; | |
| 5 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantityIndustry.QueryShipmentQuantityIndustryStatisticsVo; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +public interface ShipmentQuantityIndustryStatisticsService { | |
| 10 | + | |
| 11 | + PageResult<ShipmentQuantityIndustryStatisticsDto> query(Integer pageIndex, Integer pageSize, QueryShipmentQuantityIndustryStatisticsVo vo); | |
| 12 | + | |
| 13 | + List<ShipmentQuantityIndustryStatisticsDto> query(QueryShipmentQuantityIndustryStatisticsVo vo); | |
| 14 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.service.statistics; | |
| 2 | + | |
| 3 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 4 | +import com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDto; | |
| 5 | +import com.lframework.xingyun.sc.vo.statistics.shipmentQuantity.QueryShipmentQuantityStatisticsVo; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +public interface ShipmentQuantityStatisticsService { | |
| 10 | + | |
| 11 | + PageResult<ShipmentQuantityStatisticsDto> query(Integer pageIndex, Integer pageSize, QueryShipmentQuantityStatisticsVo vo); | |
| 12 | + | |
| 13 | + List<ShipmentQuantityStatisticsDto> query(QueryShipmentQuantityStatisticsVo vo); | |
| 14 | +} | ... | ... |
| ... | ... | @@ -233,6 +233,10 @@ public class UpdateContractDistributorStandardVo implements BaseVo, Serializable |
| 233 | 233 | @Length(message = "备注最多允许65,535个字符!") |
| 234 | 234 | private String remarks; |
| 235 | 235 | |
| 236 | + @ApiModelProperty(value = "变更原因") | |
| 237 | + @Length(message = "变更原因最多允许50个字符!") | |
| 238 | + private String changeReason; | |
| 239 | + | |
| 236 | 240 | /** |
| 237 | 241 | * 合计数量 |
| 238 | 242 | */ | ... | ... |
| ... | ... | @@ -61,6 +61,9 @@ public class QueryOrderDetailReportVo extends PageVo implements BaseVo, Serializ |
| 61 | 61 | @ApiModelProperty("导出类型") |
| 62 | 62 | private String exportType; |
| 63 | 63 | |
| 64 | + @ApiModelProperty("订单分类:有价订单明细、库存订单明细、未锁规格订单明细") | |
| 65 | + private String orderCategory; | |
| 66 | + | |
| 64 | 67 | /** |
| 65 | 68 | * 排序 |
| 66 | 69 | */ | ... | ... |
| 1 | +package com.lframework.xingyun.sc.vo.statistics.shipmentQuantity; | |
| 2 | + | |
| 3 | +import com.lframework.starter.web.core.vo.BaseVo; | |
| 4 | +import com.lframework.starter.web.core.vo.PageVo; | |
| 5 | +import io.swagger.annotations.ApiModelProperty; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.io.Serializable; | |
| 9 | + | |
| 10 | +@Data | |
| 11 | +public class QueryShipmentQuantityStatisticsVo extends PageVo implements BaseVo, Serializable { | |
| 12 | + | |
| 13 | + private static final long serialVersionUID = 1L; | |
| 14 | + | |
| 15 | + @ApiModelProperty("发货日期开始") | |
| 16 | + private String shipmentDateStart; | |
| 17 | + | |
| 18 | + @ApiModelProperty("发货日期结束") | |
| 19 | + private String shipmentDateEnd; | |
| 20 | + | |
| 21 | + @ApiModelProperty("办事处ID") | |
| 22 | + private String deptId; | |
| 23 | + | |
| 24 | + @ApiModelProperty("生产厂ID") | |
| 25 | + private String workshopId; | |
| 26 | + | |
| 27 | + @ApiModelProperty("导出类型") | |
| 28 | + private String exportType; | |
| 29 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.vo.statistics.shipmentQuantityIndustry; | |
| 2 | + | |
| 3 | +import com.lframework.starter.web.core.vo.BaseVo; | |
| 4 | +import com.lframework.starter.web.core.vo.PageVo; | |
| 5 | +import io.swagger.annotations.ApiModelProperty; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.io.Serializable; | |
| 9 | + | |
| 10 | +@Data | |
| 11 | +public class QueryShipmentQuantityIndustryStatisticsVo extends PageVo implements BaseVo, Serializable { | |
| 12 | + | |
| 13 | + private static final long serialVersionUID = 1L; | |
| 14 | + | |
| 15 | + @ApiModelProperty("发货日期开始") | |
| 16 | + private String shipmentDateStart; | |
| 17 | + | |
| 18 | + @ApiModelProperty("发货日期结束") | |
| 19 | + private String shipmentDateEnd; | |
| 20 | + | |
| 21 | + @ApiModelProperty("行业") | |
| 22 | + private String industry; | |
| 23 | + | |
| 24 | + @ApiModelProperty("生产厂ID") | |
| 25 | + private String workshopId; | |
| 26 | + | |
| 27 | + @ApiModelProperty("导出类型") | |
| 28 | + private String exportType; | |
| 29 | +} | ... | ... |
| ... | ... | @@ -64,6 +64,7 @@ |
| 64 | 64 | <result column="formalized_at" property="formalizedAt"/> |
| 65 | 65 | <result column="standardized_at" property="standardizedAt"/> |
| 66 | 66 | <result column="title" property="title"/> |
| 67 | + <result column="change_reason" property="changeReason"/> | |
| 67 | 68 | </resultMap> |
| 68 | 69 | |
| 69 | 70 | <sql id="ContractDistributorStandard_sql"> |
| ... | ... | @@ -127,7 +128,8 @@ |
| 127 | 128 | tb.signed_contract_file_name, |
| 128 | 129 | tb.formalized_at, |
| 129 | 130 | tb.standardized_at, |
| 130 | - tb.title | |
| 131 | + tb.title, | |
| 132 | + tb.change_reason | |
| 131 | 133 | FROM tbl_contract_distributor_standard AS tb |
| 132 | 134 | </sql> |
| 133 | 135 | ... | ... |
| ... | ... | @@ -301,6 +301,29 @@ |
| 301 | 301 | ) |
| 302 | 302 | ) |
| 303 | 303 | </if> |
| 304 | + <if test="vo.orderCategory != null and vo.orderCategory != ''"> | |
| 305 | + AND poi.examine_status = 'PASS' | |
| 306 | + <choose> | |
| 307 | + <when test="vo.orderCategory == 'PRICED'"> | |
| 308 | + AND ( | |
| 309 | + (c.type IN ('DIST_STOCK_CONTRACT', 'INTL_INVENTORY_AGMT') AND poi.type = 'NO_PRODUCTION') | |
| 310 | + OR (c.type IN ('DRAFT_DIST_AGMT', 'INTL_OPEN_SPEC_AGMT') AND poi.type IN ('PRODUCTION', 'NO_PRODUCTION')) | |
| 311 | + OR (c.type IN ('DISTRIB_STD', 'INTL_STD_CONTRACT', 'PROCESS_STD_AGMT') AND poi.type = 'PRODUCTION') | |
| 312 | + ) | |
| 313 | + </when> | |
| 314 | + <when test="vo.orderCategory == 'INVENTORY'"> | |
| 315 | + AND c.type IN ('DIST_STOCK_CONTRACT', 'INTL_INVENTORY_AGMT') | |
| 316 | + AND poi.type = 'PRODUCTION' | |
| 317 | + </when> | |
| 318 | + <when test="vo.orderCategory == 'OPEN_SPEC'"> | |
| 319 | + AND c.type IN ('DRAFT_DIST_AGMT', 'INTL_OPEN_SPEC_AGMT') | |
| 320 | + AND poi.type = 'NO_PRODUCTION' | |
| 321 | + </when> | |
| 322 | + <otherwise> | |
| 323 | + AND 1 = 0 | |
| 324 | + </otherwise> | |
| 325 | + </choose> | |
| 326 | + </if> | |
| 304 | 327 | </where> |
| 305 | 328 | ) t |
| 306 | 329 | ORDER BY | ... | ... |
xingyun-sc/src/main/resources/mappers/statistics/ShipmentQuantityIndustryStatisticsMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.lframework.xingyun.sc.mappers.ShipmentQuantityIndustryStatisticsMapper"> | |
| 4 | + | |
| 5 | + <resultMap id="ShipmentQuantityIndustryStatisticsDto" type="com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsDto"> | |
| 6 | + <result column="shipment_date" property="shipmentDate"/> | |
| 7 | + <result column="industry" property="industry"/> | |
| 8 | + <result column="workshop_id" property="workshopId"/> | |
| 9 | + <result column="workshop_code" property="workshopCode"/> | |
| 10 | + <result column="workshop_name" property="workshopName"/> | |
| 11 | + <result column="shipment_quantity" property="shipmentQuantity"/> | |
| 12 | + </resultMap> | |
| 13 | + | |
| 14 | + <resultMap id="ShipmentQuantityStatisticsDateRangeDto" type="com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDateRangeDto"> | |
| 15 | + <result column="start_date" property="startDate"/> | |
| 16 | + <result column="end_date" property="endDate"/> | |
| 17 | + </resultMap> | |
| 18 | + | |
| 19 | + <resultMap id="ShipmentQuantityIndustryStatisticsInvalidDto" type="com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityIndustryStatisticsInvalidDto"> | |
| 20 | + <result column="order_id" property="orderId"/> | |
| 21 | + <result column="order_no" property="orderNo"/> | |
| 22 | + <result column="line_id" property="lineId"/> | |
| 23 | + <result column="shipment_date" property="shipmentDate"/> | |
| 24 | + <result column="industry" property="industry"/> | |
| 25 | + <result column="workshop_id" property="workshopId"/> | |
| 26 | + <result column="quantity" property="quantity"/> | |
| 27 | + </resultMap> | |
| 28 | + | |
| 29 | + <sql id="ShipmentQuantityIndustryStatistics_base_where"> | |
| 30 | + o.type = 'PRODUCTION' | |
| 31 | + AND o.examine_status = 'PASS' | |
| 32 | + AND (o.status IS NULL OR o.status != 'CANCEL') | |
| 33 | + AND (ol.del_flag IS NULL OR ol.del_flag = 0) | |
| 34 | + </sql> | |
| 35 | + | |
| 36 | + <select id="query" resultMap="ShipmentQuantityIndustryStatisticsDto"> | |
| 37 | + SELECT | |
| 38 | + t.shipment_date, | |
| 39 | + t.industry, | |
| 40 | + t.workshop_id, | |
| 41 | + t.workshop_code, | |
| 42 | + t.shipment_quantity | |
| 43 | + FROM ( | |
| 44 | + SELECT | |
| 45 | + ol.delivery_date AS shipment_date, | |
| 46 | + ol.industry AS industry, | |
| 47 | + o.workshop_id AS workshop_id, | |
| 48 | + ws.code AS workshop_code, | |
| 49 | + ws.name AS workshop_name, | |
| 50 | + SUM(ol.quantity) AS shipment_quantity | |
| 51 | + FROM tbl_purchase_order_line ol | |
| 52 | + INNER JOIN purchase_order_info o ON o.id = ol.purchase_order_id | |
| 53 | + LEFT JOIN base_data_workshop ws ON ws.id = o.workshop_id | |
| 54 | + WHERE | |
| 55 | + <include refid="ShipmentQuantityIndustryStatistics_base_where"/> | |
| 56 | + AND ol.delivery_date IS NOT NULL | |
| 57 | + AND ol.industry IS NOT NULL AND ol.industry != '' | |
| 58 | + AND o.workshop_id IS NOT NULL AND o.workshop_id != '' | |
| 59 | + AND ol.quantity IS NOT NULL | |
| 60 | + <if test="vo.shipmentDateStart != null and vo.shipmentDateStart != ''"> | |
| 61 | + AND ol.delivery_date <![CDATA[>=]]> #{vo.shipmentDateStart} | |
| 62 | + </if> | |
| 63 | + <if test="vo.shipmentDateEnd != null and vo.shipmentDateEnd != ''"> | |
| 64 | + AND ol.delivery_date <![CDATA[<=]]> #{vo.shipmentDateEnd} | |
| 65 | + </if> | |
| 66 | + <if test="vo.industry != null and vo.industry != ''"> | |
| 67 | + AND ol.industry LIKE CONCAT('%', #{vo.industry}, '%') | |
| 68 | + </if> | |
| 69 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | |
| 70 | + AND o.workshop_id = #{vo.workshopId} | |
| 71 | + </if> | |
| 72 | + GROUP BY ol.delivery_date, ol.industry, o.workshop_id | |
| 73 | + ) t | |
| 74 | + ORDER BY | |
| 75 | + t.shipment_date DESC, | |
| 76 | + CASE t.workshop_code | |
| 77 | + WHEN 'yfc' THEN 1 | |
| 78 | + WHEN 'efc' THEN 2 | |
| 79 | + WHEN 'sfc' THEN 3 | |
| 80 | + WHEN 'ztfc' THEN 4 | |
| 81 | + ELSE 99 | |
| 82 | + END, | |
| 83 | + t.industry | |
| 84 | + </select> | |
| 85 | + | |
| 86 | + <select id="queryDateRange" resultMap="ShipmentQuantityStatisticsDateRangeDto"> | |
| 87 | + SELECT | |
| 88 | + MIN(t.shipment_date) AS start_date, | |
| 89 | + MAX(t.shipment_date) AS end_date | |
| 90 | + FROM ( | |
| 91 | + SELECT | |
| 92 | + ol.delivery_date AS shipment_date, | |
| 93 | + o.workshop_id AS workshop_id | |
| 94 | + FROM tbl_purchase_order_line ol | |
| 95 | + INNER JOIN purchase_order_info o ON o.id = ol.purchase_order_id | |
| 96 | + WHERE | |
| 97 | + <include refid="ShipmentQuantityIndustryStatistics_base_where"/> | |
| 98 | + AND ol.delivery_date IS NOT NULL | |
| 99 | + AND ol.industry IS NOT NULL AND ol.industry != '' | |
| 100 | + AND o.workshop_id IS NOT NULL AND o.workshop_id != '' | |
| 101 | + AND ol.quantity IS NOT NULL | |
| 102 | + <if test="vo.industry != null and vo.industry != ''"> | |
| 103 | + AND ol.industry LIKE CONCAT('%', #{vo.industry}, '%') | |
| 104 | + </if> | |
| 105 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | |
| 106 | + AND o.workshop_id = #{vo.workshopId} | |
| 107 | + </if> | |
| 108 | + ) t | |
| 109 | + </select> | |
| 110 | + | |
| 111 | + <select id="queryIndustryDim" resultType="java.lang.String"> | |
| 112 | + SELECT DISTINCT | |
| 113 | + ol.industry AS industry | |
| 114 | + FROM tbl_purchase_order_line ol | |
| 115 | + INNER JOIN purchase_order_info o ON o.id = ol.purchase_order_id | |
| 116 | + WHERE | |
| 117 | + <include refid="ShipmentQuantityIndustryStatistics_base_where"/> | |
| 118 | + AND ol.delivery_date IS NOT NULL | |
| 119 | + AND ol.industry IS NOT NULL AND ol.industry != '' | |
| 120 | + AND o.workshop_id IS NOT NULL AND o.workshop_id != '' | |
| 121 | + AND ol.quantity IS NOT NULL | |
| 122 | + <if test="vo.shipmentDateStart != null and vo.shipmentDateStart != ''"> | |
| 123 | + AND ol.delivery_date <![CDATA[>=]]> #{vo.shipmentDateStart} | |
| 124 | + </if> | |
| 125 | + <if test="vo.shipmentDateEnd != null and vo.shipmentDateEnd != ''"> | |
| 126 | + AND ol.delivery_date <![CDATA[<=]]> #{vo.shipmentDateEnd} | |
| 127 | + </if> | |
| 128 | + <if test="vo.industry != null and vo.industry != ''"> | |
| 129 | + AND ol.industry LIKE CONCAT('%', #{vo.industry}, '%') | |
| 130 | + </if> | |
| 131 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | |
| 132 | + AND o.workshop_id = #{vo.workshopId} | |
| 133 | + </if> | |
| 134 | + ORDER BY ol.industry | |
| 135 | + </select> | |
| 136 | + | |
| 137 | + <select id="queryWorkshopDimByCodes" resultMap="ShipmentQuantityIndustryStatisticsDto"> | |
| 138 | + SELECT | |
| 139 | + w.id AS workshop_id, | |
| 140 | + w.code AS workshop_code, | |
| 141 | + w.name AS workshop_name | |
| 142 | + FROM base_data_workshop w | |
| 143 | + WHERE w.code IN | |
| 144 | + <foreach collection="codes" item="code" open="(" close=")" separator=","> | |
| 145 | + #{code} | |
| 146 | + </foreach> | |
| 147 | + ORDER BY | |
| 148 | + CASE w.code | |
| 149 | + WHEN 'yfc' THEN 1 | |
| 150 | + WHEN 'efc' THEN 2 | |
| 151 | + WHEN 'sfc' THEN 3 | |
| 152 | + WHEN 'ztfc' THEN 4 | |
| 153 | + ELSE 99 | |
| 154 | + END, | |
| 155 | + w.name | |
| 156 | + </select> | |
| 157 | + | |
| 158 | + <select id="queryWorkshopDimById" resultMap="ShipmentQuantityIndustryStatisticsDto"> | |
| 159 | + SELECT | |
| 160 | + w.id AS workshop_id, | |
| 161 | + w.code AS workshop_code, | |
| 162 | + w.name AS workshop_name | |
| 163 | + FROM base_data_workshop w | |
| 164 | + WHERE w.id = #{workshopId} | |
| 165 | + </select> | |
| 166 | + | |
| 167 | + <select id="queryInvalid" resultMap="ShipmentQuantityIndustryStatisticsInvalidDto"> | |
| 168 | + SELECT | |
| 169 | + t.order_id, | |
| 170 | + t.order_no, | |
| 171 | + t.line_id, | |
| 172 | + t.shipment_date, | |
| 173 | + t.industry, | |
| 174 | + t.workshop_id, | |
| 175 | + t.quantity | |
| 176 | + FROM ( | |
| 177 | + SELECT | |
| 178 | + o.id AS order_id, | |
| 179 | + o.order_no AS order_no, | |
| 180 | + ol.id AS line_id, | |
| 181 | + ol.delivery_date AS shipment_date, | |
| 182 | + ol.industry AS industry, | |
| 183 | + o.workshop_id AS workshop_id, | |
| 184 | + ol.quantity AS quantity, | |
| 185 | + o.create_time AS create_time | |
| 186 | + FROM tbl_purchase_order_line ol | |
| 187 | + INNER JOIN purchase_order_info o ON o.id = ol.purchase_order_id | |
| 188 | + WHERE | |
| 189 | + <include refid="ShipmentQuantityIndustryStatistics_base_where"/> | |
| 190 | + AND ( | |
| 191 | + ol.delivery_date IS NULL | |
| 192 | + OR ol.industry IS NULL OR ol.industry = '' | |
| 193 | + OR o.workshop_id IS NULL OR o.workshop_id = '' | |
| 194 | + OR ol.quantity IS NULL | |
| 195 | + ) | |
| 196 | + <if test="vo.shipmentDateStart != null and vo.shipmentDateStart != ''"> | |
| 197 | + AND (ol.delivery_date IS NULL OR ol.delivery_date <![CDATA[>=]]> #{vo.shipmentDateStart}) | |
| 198 | + </if> | |
| 199 | + <if test="vo.shipmentDateEnd != null and vo.shipmentDateEnd != ''"> | |
| 200 | + AND (ol.delivery_date IS NULL OR ol.delivery_date <![CDATA[<=]]> #{vo.shipmentDateEnd}) | |
| 201 | + </if> | |
| 202 | + <if test="vo.industry != null and vo.industry != ''"> | |
| 203 | + AND ol.industry LIKE CONCAT('%', #{vo.industry}, '%') | |
| 204 | + </if> | |
| 205 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | |
| 206 | + AND o.workshop_id = #{vo.workshopId} | |
| 207 | + </if> | |
| 208 | + ) t | |
| 209 | + ORDER BY t.create_time DESC | |
| 210 | + LIMIT 200 | |
| 211 | + </select> | |
| 212 | +</mapper> | ... | ... |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.lframework.xingyun.sc.mappers.ShipmentQuantityStatisticsMapper"> | |
| 4 | + | |
| 5 | + <resultMap id="ShipmentQuantityStatisticsDto" type="com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDto"> | |
| 6 | + <result column="shipment_date" property="shipmentDate"/> | |
| 7 | + <result column="dept_id" property="deptId"/> | |
| 8 | + <result column="dept_code" property="deptCode"/> | |
| 9 | + <result column="dept_name" property="deptName"/> | |
| 10 | + <result column="workshop_id" property="workshopId"/> | |
| 11 | + <result column="workshop_code" property="workshopCode"/> | |
| 12 | + <result column="workshop_name" property="workshopName"/> | |
| 13 | + <result column="shipment_quantity" property="shipmentQuantity"/> | |
| 14 | + </resultMap> | |
| 15 | + | |
| 16 | + <resultMap id="ShipmentQuantityStatisticsDateRangeDto" type="com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsDateRangeDto"> | |
| 17 | + <result column="start_date" property="startDate"/> | |
| 18 | + <result column="end_date" property="endDate"/> | |
| 19 | + </resultMap> | |
| 20 | + | |
| 21 | + <resultMap id="ShipmentQuantityStatisticsInvalidDto" type="com.lframework.xingyun.sc.dto.statistics.ShipmentQuantityStatisticsInvalidDto"> | |
| 22 | + <result column="order_id" property="orderId"/> | |
| 23 | + <result column="order_no" property="orderNo"/> | |
| 24 | + <result column="line_id" property="lineId"/> | |
| 25 | + <result column="shipment_date" property="shipmentDate"/> | |
| 26 | + <result column="dept_id" property="deptId"/> | |
| 27 | + <result column="workshop_id" property="workshopId"/> | |
| 28 | + <result column="quantity" property="quantity"/> | |
| 29 | + </resultMap> | |
| 30 | + | |
| 31 | + <sql id="ShipmentQuantityStatistics_base_where"> | |
| 32 | + o.type = 'PRODUCTION' | |
| 33 | + AND o.examine_status = 'PASS' | |
| 34 | + AND (o.status IS NULL OR o.status != 'CANCEL') | |
| 35 | + AND (ol.del_flag IS NULL OR ol.del_flag = 0) | |
| 36 | + </sql> | |
| 37 | + | |
| 38 | + <select id="query" resultMap="ShipmentQuantityStatisticsDto"> | |
| 39 | + SELECT | |
| 40 | + t.shipment_date, | |
| 41 | + t.dept_id, | |
| 42 | + t.dept_code, | |
| 43 | + t.dept_code, | |
| 44 | + t.dept_name, | |
| 45 | + t.workshop_id, | |
| 46 | + t.workshop_code, | |
| 47 | + t.shipment_quantity | |
| 48 | + FROM ( | |
| 49 | + SELECT | |
| 50 | + ol.delivery_date AS shipment_date, | |
| 51 | + o.dept_id AS dept_id, | |
| 52 | + sd.code AS dept_code, | |
| 53 | + sd.name AS dept_name, | |
| 54 | + o.workshop_id AS workshop_id, | |
| 55 | + ws.code AS workshop_code, | |
| 56 | + ws.name AS workshop_name, | |
| 57 | + SUM(ol.quantity) AS shipment_quantity | |
| 58 | + FROM tbl_purchase_order_line ol | |
| 59 | + INNER JOIN purchase_order_info o ON o.id = ol.purchase_order_id | |
| 60 | + LEFT JOIN sys_dept sd ON sd.id = o.dept_id | |
| 61 | + LEFT JOIN base_data_workshop ws ON ws.id = o.workshop_id | |
| 62 | + WHERE | |
| 63 | + <include refid="ShipmentQuantityStatistics_base_where"/> | |
| 64 | + AND ol.delivery_date IS NOT NULL | |
| 65 | + AND o.dept_id IS NOT NULL AND o.dept_id != '' | |
| 66 | + AND o.workshop_id IS NOT NULL AND o.workshop_id != '' | |
| 67 | + AND ol.quantity IS NOT NULL | |
| 68 | + <if test="vo.shipmentDateStart != null and vo.shipmentDateStart != ''"> | |
| 69 | + AND ol.delivery_date <![CDATA[>=]]> #{vo.shipmentDateStart} | |
| 70 | + </if> | |
| 71 | + <if test="vo.shipmentDateEnd != null and vo.shipmentDateEnd != ''"> | |
| 72 | + AND ol.delivery_date <![CDATA[<=]]> #{vo.shipmentDateEnd} | |
| 73 | + </if> | |
| 74 | + <if test="vo.deptId != null and vo.deptId != ''"> | |
| 75 | + AND o.dept_id = #{vo.deptId} | |
| 76 | + </if> | |
| 77 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | |
| 78 | + AND o.workshop_id = #{vo.workshopId} | |
| 79 | + </if> | |
| 80 | + GROUP BY ol.delivery_date, o.dept_id, o.workshop_id | |
| 81 | + ) t | |
| 82 | + ORDER BY | |
| 83 | + t.shipment_date DESC, | |
| 84 | + CASE t.workshop_code | |
| 85 | + WHEN 'yfc' THEN 1 | |
| 86 | + WHEN 'efc' THEN 2 | |
| 87 | + WHEN 'sfc' THEN 3 | |
| 88 | + WHEN 'ztfc' THEN 4 | |
| 89 | + ELSE 99 | |
| 90 | + END, | |
| 91 | + t.dept_name | |
| 92 | + </select> | |
| 93 | + | |
| 94 | + <select id="queryDateRange" resultMap="ShipmentQuantityStatisticsDateRangeDto"> | |
| 95 | + SELECT | |
| 96 | + MIN(t.shipment_date) AS start_date, | |
| 97 | + MAX(t.shipment_date) AS end_date | |
| 98 | + FROM ( | |
| 99 | + SELECT | |
| 100 | + ol.delivery_date AS shipment_date, | |
| 101 | + o.dept_id AS dept_id, | |
| 102 | + o.workshop_id AS workshop_id | |
| 103 | + FROM tbl_purchase_order_line ol | |
| 104 | + INNER JOIN purchase_order_info o ON o.id = ol.purchase_order_id | |
| 105 | + WHERE | |
| 106 | + <include refid="ShipmentQuantityStatistics_base_where"/> | |
| 107 | + AND ol.delivery_date IS NOT NULL | |
| 108 | + AND o.dept_id IS NOT NULL AND o.dept_id != '' | |
| 109 | + AND o.workshop_id IS NOT NULL AND o.workshop_id != '' | |
| 110 | + AND ol.quantity IS NOT NULL | |
| 111 | + <if test="vo.deptId != null and vo.deptId != ''"> | |
| 112 | + AND o.dept_id = #{vo.deptId} | |
| 113 | + </if> | |
| 114 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | |
| 115 | + AND o.workshop_id = #{vo.workshopId} | |
| 116 | + </if> | |
| 117 | + ) t | |
| 118 | + </select> | |
| 119 | + | |
| 120 | + <select id="queryDeptDimByCodes" resultMap="ShipmentQuantityStatisticsDto"> | |
| 121 | + SELECT | |
| 122 | + d.id AS dept_id, | |
| 123 | + d.code AS dept_code, | |
| 124 | + d.name AS dept_name | |
| 125 | + FROM sys_dept d | |
| 126 | + WHERE d.code IN | |
| 127 | + <foreach collection="codes" item="code" open="(" close=")" separator=","> | |
| 128 | + #{code} | |
| 129 | + </foreach> | |
| 130 | + ORDER BY | |
| 131 | + CASE d.code | |
| 132 | + WHEN 'BF' THEN 1 | |
| 133 | + WHEN 'CZ' THEN 2 | |
| 134 | + WHEN 'DG' THEN 3 | |
| 135 | + WHEN 'FS' THEN 4 | |
| 136 | + WHEN 'NB' THEN 5 | |
| 137 | + WHEN 'SZ' THEN 6 | |
| 138 | + WHEN 'WZ' THEN 7 | |
| 139 | + WHEN 'ZT' THEN 8 | |
| 140 | + WHEN 'WM' THEN 9 | |
| 141 | + ELSE 99 | |
| 142 | + END, | |
| 143 | + d.name | |
| 144 | + </select> | |
| 145 | + | |
| 146 | + <select id="queryDeptDimById" resultMap="ShipmentQuantityStatisticsDto"> | |
| 147 | + SELECT | |
| 148 | + d.id AS dept_id, | |
| 149 | + d.code AS dept_code, | |
| 150 | + d.name AS dept_name | |
| 151 | + FROM sys_dept d | |
| 152 | + WHERE d.id = #{deptId} | |
| 153 | + </select> | |
| 154 | + | |
| 155 | + <select id="queryWorkshopDimByCodes" resultMap="ShipmentQuantityStatisticsDto"> | |
| 156 | + SELECT | |
| 157 | + w.id AS workshop_id, | |
| 158 | + w.code AS workshop_code, | |
| 159 | + w.name AS workshop_name | |
| 160 | + FROM base_data_workshop w | |
| 161 | + WHERE w.code IN | |
| 162 | + <foreach collection="codes" item="code" open="(" close=")" separator=","> | |
| 163 | + #{code} | |
| 164 | + </foreach> | |
| 165 | + ORDER BY | |
| 166 | + CASE w.code | |
| 167 | + WHEN 'yfc' THEN 1 | |
| 168 | + WHEN 'efc' THEN 2 | |
| 169 | + WHEN 'sfc' THEN 3 | |
| 170 | + WHEN 'ztfc' THEN 4 | |
| 171 | + ELSE 99 | |
| 172 | + END, | |
| 173 | + w.name | |
| 174 | + </select> | |
| 175 | + | |
| 176 | + <select id="queryWorkshopDimById" resultMap="ShipmentQuantityStatisticsDto"> | |
| 177 | + SELECT | |
| 178 | + w.id AS workshop_id, | |
| 179 | + w.code AS workshop_code, | |
| 180 | + w.name AS workshop_name | |
| 181 | + FROM base_data_workshop w | |
| 182 | + WHERE w.id = #{workshopId} | |
| 183 | + </select> | |
| 184 | + | |
| 185 | + <select id="queryInvalid" resultMap="ShipmentQuantityStatisticsInvalidDto"> | |
| 186 | + SELECT | |
| 187 | + t.order_id, | |
| 188 | + t.order_no, | |
| 189 | + t.line_id, | |
| 190 | + t.shipment_date, | |
| 191 | + t.dept_id, | |
| 192 | + t.workshop_id, | |
| 193 | + t.quantity | |
| 194 | + FROM ( | |
| 195 | + SELECT | |
| 196 | + o.id AS order_id, | |
| 197 | + o.order_no AS order_no, | |
| 198 | + ol.id AS line_id, | |
| 199 | + ol.delivery_date AS shipment_date, | |
| 200 | + o.dept_id AS dept_id, | |
| 201 | + o.workshop_id AS workshop_id, | |
| 202 | + ol.quantity AS quantity, | |
| 203 | + o.create_time AS create_time | |
| 204 | + FROM tbl_purchase_order_line ol | |
| 205 | + INNER JOIN purchase_order_info o ON o.id = ol.purchase_order_id | |
| 206 | + WHERE | |
| 207 | + <include refid="ShipmentQuantityStatistics_base_where"/> | |
| 208 | + AND ( | |
| 209 | + ol.delivery_date IS NULL | |
| 210 | + OR o.dept_id IS NULL OR o.dept_id = '' | |
| 211 | + OR o.workshop_id IS NULL OR o.workshop_id = '' | |
| 212 | + OR ol.quantity IS NULL | |
| 213 | + ) | |
| 214 | + <if test="vo.shipmentDateStart != null and vo.shipmentDateStart != ''"> | |
| 215 | + AND (ol.delivery_date IS NULL OR ol.delivery_date <![CDATA[>=]]> #{vo.shipmentDateStart}) | |
| 216 | + </if> | |
| 217 | + <if test="vo.shipmentDateEnd != null and vo.shipmentDateEnd != ''"> | |
| 218 | + AND (ol.delivery_date IS NULL OR ol.delivery_date <![CDATA[<=]]> #{vo.shipmentDateEnd}) | |
| 219 | + </if> | |
| 220 | + <if test="vo.deptId != null and vo.deptId != ''"> | |
| 221 | + AND o.dept_id = #{vo.deptId} | |
| 222 | + </if> | |
| 223 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | |
| 224 | + AND o.workshop_id = #{vo.workshopId} | |
| 225 | + </if> | |
| 226 | + ) t | |
| 227 | + ORDER BY t.create_time DESC | |
| 228 | + LIMIT 200 | |
| 229 | + </select> | |
| 230 | +</mapper> | ... | ... |