| | |
| | | ROW_FORMAT = Dynamic; |
| | | |
| | | SET FOREIGN_KEY_CHECKS = 1; |
| | | |
| | | |
| | | alter table production_plan |
| | | add status tinyint default 0 not null comment 'ç¶æ 0æªä¸å 1å·²ä¸å'; |
| | | |
| | | |
| | | ALTER TABLE `product-inventory-management-zsjc`.`production_plan` |
| | | DROP COLUMN `data_sync_type`, |
| | | MODIFY COLUMN `data_source_type` tinyint NULL DEFAULT 1 COMMENT 'æ°æ®æ¥æºç±»åï¼1=éé忥 2=æå¨æ°å¢' AFTER `form_modified_time`; |
| | |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation("ç©ææ°æ®") |
| | | @Log(title = "ç©ææ°æ®", businessType = BusinessType.OTHER) |
| | | public AjaxResult productMaterialList(String materialName) { |
| | | List<ProductMaterialGroupDto> productMaterialMap = productMaterialService.ProductMaterialList(materialName); |
| | | @ApiOperation("ç©ææ°æ®ç±»å«æ°æ®éå") |
| | | @Log(title = "ç©ææ°æ®ç±»å«æ°æ®éå", businessType = BusinessType.OTHER) |
| | | public AjaxResult productMaterialList(@RequestParam("type") Integer type) { |
| | | List<ProductMaterialGroupDto> productMaterialMap = productMaterialService.ProductMaterialList(type); |
| | | return AjaxResult.success(productMaterialMap); |
| | | } |
| | | |
| | | @GetMapping("/listQuery") |
| | | @ApiOperation("ç©ææ°æ®ç±»å«åç±»æ°æ®éå") |
| | | @Log(title = "ç©ææ°æ®ç±»å«åç±»æ°æ®éå", businessType = BusinessType.OTHER) |
| | | public AjaxResult productMaterialListByQuery(@RequestParam(value = "materialName", required = false) String materialName, @RequestParam(value = "materialTypeId", required = false) Integer materialTypeId) { |
| | | List<ProductMaterialGroupDto> productMaterialMap = productMaterialService.productMaterialListByQuery(materialName, materialTypeId); |
| | | return AjaxResult.success(productMaterialMap); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.production.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | |
| | | @GetMapping("/list") |
| | | @ApiOperation("ç©æè§æ ¼æ°æ®éå") |
| | | @Log(title = "ç©æè§æ ¼æ°æ®éå", businessType = BusinessType.OTHER) |
| | | public AjaxResult productMaterialSkuList(@RequestParam("materialId") Long materialId) { |
| | | List<ProductMaterialSkuDto> list = productMaterialSkuService.productMaterialSkuList(materialId); |
| | | public AjaxResult productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto) { |
| | | Page<ProductMaterialSkuDto> list = productMaterialSkuService.productMaterialSkuList(page, dto); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <br> |
| | | * 产åç©æä¿¡æ¯ Dto |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/13 10:50 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ProductMaterialDto", description = "ç©æä¸»è¡¨Dto") |
| | | public class ProductMaterialDto { |
| | | |
| | | @ApiModelProperty("主é®ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("ç©æç±»åID") |
| | | private Integer materialTypeId; |
| | | |
| | | @ApiModelProperty("åè´§ç±»å«ID") |
| | | private Integer inventoryCategoryId; |
| | | |
| | | @ApiModelProperty("ç©æåç§°") |
| | | private String materialName; |
| | | |
| | | |
| | | } |
| | |
| | | private String configName; |
| | | |
| | | @ApiModelProperty("ç©æå表") |
| | | private List<ProductMaterial> materialList; |
| | | private List<ProductMaterialDto> materialList; |
| | | } |
| | |
| | | @ApiModelProperty("ç©æåç§°") |
| | | private String materialName; |
| | | |
| | | @ApiModelProperty("ç©æç¼ç ") |
| | | private String materialCode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String baseUnit; |
| | | |
| | |
| | | |
| | | void syncProductMaterialJob(); |
| | | |
| | | List<ProductMaterialGroupDto> ProductMaterialList(String materialName); |
| | | List<ProductMaterialGroupDto> ProductMaterialList(Integer type); |
| | | |
| | | void addProductMaterial(ProductMaterial productMaterial); |
| | | |
| | | void updateProductMaterial(ProductMaterial productMaterial); |
| | | |
| | | void deleteProductMaterial(List<Long> ids); |
| | | |
| | | List<ProductMaterialGroupDto> productMaterialListByQuery(String materialName, Integer materialTypeId); |
| | | } |
| | |
| | | package com.ruoyi.production.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.production.dto.ProductMaterialSkuDto; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | |
| | | * @since 2026/03/12 10:04 |
| | | */ |
| | | public interface ProductMaterialSkuService extends IService<ProductMaterialSku> { |
| | | List<ProductMaterialSkuDto> productMaterialSkuList(Long materialId); |
| | | Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto); |
| | | |
| | | void addProductMaterialSku(ProductMaterialSku productMaterialSku); |
| | | |
| | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.production.dto.ProductMaterialDto; |
| | | import com.ruoyi.production.dto.ProductMaterialGroupDto; |
| | | import com.ruoyi.production.enums.MaterialConfigTypeEnum; |
| | | import com.ruoyi.production.mapper.ProductMaterialMapper; |
| | |
| | | import java.time.format.DateTimeParseException; |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductMaterialGroupDto> ProductMaterialList(String materialName) { |
| | | public List<ProductMaterialGroupDto> ProductMaterialList(Integer type) { |
| | | List<ProductMaterialConfig> configList = productMaterialConfigService.list(new LambdaQueryWrapper<ProductMaterialConfig>() |
| | | .eq(ProductMaterialConfig::getConfigType, MaterialConfigTypeEnum.MATERIAL_TYPE.name()) |
| | | ); |
| | | if (CollectionUtils.isEmpty(configList)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<ProductMaterialGroupDto> result = new ArrayList<>(); |
| | | Map<Integer, List<ProductMaterialDto>> materialMap = new HashMap<>(); |
| | | if (type != null && type == 2) { |
| | | List<ProductMaterial> materialList = this.list(new LambdaQueryWrapper<ProductMaterial>() |
| | | .select( |
| | | ProductMaterial::getId, |
| | | ProductMaterial::getMaterialTypeId, |
| | | ProductMaterial::getInventoryCategoryId, |
| | | ProductMaterial::getMaterialName |
| | | ) |
| | | ); |
| | | materialMap = materialList.stream() |
| | | .map(this::convert) |
| | | .collect(Collectors.groupingBy(ProductMaterialDto::getMaterialTypeId)); |
| | | } |
| | | |
| | | List<ProductMaterialConfig> materialConfigList = productMaterialConfigService.list(new LambdaQueryWrapper<ProductMaterialConfig>() |
| | | for (ProductMaterialConfig config : configList) { |
| | | ProductMaterialGroupDto dto = new ProductMaterialGroupDto(); |
| | | dto.setConfigId(config.getId()); |
| | | dto.setConfigName(config.getConfigName()); |
| | | if (type != null && type == 2) { |
| | | dto.setMaterialList(materialMap.getOrDefault(config.getId(), new ArrayList<>())); |
| | | } |
| | | result.add(dto); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<ProductMaterialGroupDto> productMaterialListByQuery(String materialName, Integer materialTypeId) { |
| | | |
| | | if (StringUtils.isEmpty(materialName) && materialTypeId == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductMaterial> wrapper = new LambdaQueryWrapper<>(); |
| | | // åªæ¥è¯¢éè¦çåæ®µæ°æ® |
| | | wrapper.select( |
| | | ProductMaterial::getId, |
| | | ProductMaterial::getMaterialTypeId, |
| | | ProductMaterial::getInventoryCategoryId, |
| | | ProductMaterial::getMaterialName |
| | | ); |
| | | if (StringUtils.isNotEmpty(materialName)) { |
| | | wrapper.like(ProductMaterial::getMaterialName, materialName); |
| | | } |
| | | if (materialTypeId != null) { |
| | | wrapper.eq(ProductMaterial::getMaterialTypeId, materialTypeId); |
| | | } |
| | | List<ProductMaterial> materials = this.list(wrapper); |
| | | if (CollectionUtils.isEmpty(materials)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | Map<Integer, List<ProductMaterialDto>> map = materials.stream() |
| | | .map(this::convert) |
| | | .collect(Collectors.groupingBy(ProductMaterialDto::getMaterialTypeId)); |
| | | |
| | | List<ProductMaterialConfig> configList = productMaterialConfigService.list(new LambdaQueryWrapper<ProductMaterialConfig>() |
| | | .eq(ProductMaterialConfig::getConfigType, MaterialConfigTypeEnum.MATERIAL_TYPE.name())); |
| | | |
| | | List<ProductMaterialGroupDto> productMaterialMap = new ArrayList<>(); |
| | | if (materialConfigList == null || materialConfigList.isEmpty()) { |
| | | return productMaterialMap; |
| | | } |
| | | for (ProductMaterialConfig materialConfig : materialConfigList) { |
| | | LambdaQueryWrapper<ProductMaterial> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ProductMaterial::getMaterialTypeId, materialConfig.getId()) |
| | | .like(materialName != null && !materialName.isEmpty(), ProductMaterial::getMaterialName, materialName); |
| | | List<ProductMaterial> productMaterialList = list(wrapper); |
| | | List<ProductMaterialGroupDto> result = new ArrayList<>(); |
| | | for (ProductMaterialConfig config : configList) { |
| | | List<ProductMaterialDto> dtoList = map.get(config.getId()); |
| | | if (CollectionUtils.isEmpty(dtoList)) { |
| | | continue; |
| | | } |
| | | ProductMaterialGroupDto dto = new ProductMaterialGroupDto(); |
| | | dto.setConfigId(materialConfig.getId()); |
| | | dto.setConfigName(materialConfig.getConfigName()); |
| | | dto.setMaterialList(productMaterialList); |
| | | productMaterialMap.add(dto); |
| | | dto.setConfigId(config.getId()); |
| | | dto.setConfigName(config.getConfigName()); |
| | | dto.setMaterialList(dtoList); |
| | | result.add(dto); |
| | | } |
| | | return productMaterialMap; |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private ProductMaterialDto convert(ProductMaterial m) { |
| | | ProductMaterialDto dto = new ProductMaterialDto(); |
| | | dto.setId(m.getId()); |
| | | dto.setMaterialName(m.getMaterialName()); |
| | | dto.setMaterialTypeId(m.getMaterialTypeId()); |
| | | dto.setInventoryCategoryId(m.getInventoryCategoryId()); |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | * æ¥è¯¢ç©æè§æ ¼å表 |
| | | */ |
| | | @Override |
| | | public List<ProductMaterialSkuDto> productMaterialSkuList(Long materialId) { |
| | | |
| | | if (materialId == null) { |
| | | return Collections.emptyList(); |
| | | public Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto) { |
| | | if (dto == null || dto.getMaterialId() == null) { |
| | | return new Page<>(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterialSku::getMaterialId, materialId) |
| | | queryWrapper.eq(ProductMaterialSku::getMaterialId, dto.getMaterialId()) |
| | | .like(StringUtils.isNotBlank(dto.getSpecification()), |
| | | ProductMaterialSku::getSpecification, dto.getSpecification()) |
| | | .like(StringUtils.isNotBlank(dto.getMaterialCode()), |
| | | ProductMaterialSku::getMaterialCode, dto.getMaterialCode()) |
| | | .orderByAsc(ProductMaterialSku::getId); |
| | | List<ProductMaterialSku> skuList = this.list(queryWrapper); |
| | | if (skuList == null || skuList.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // æ¥è¯¢ç©æä¿¡æ¯ |
| | | ProductMaterial material = productMaterialMapper.selectById(materialId); |
| | | |
| | | Page<ProductMaterialSku> skuPage = this.page(page, queryWrapper); |
| | | List<ProductMaterialSku> skuList = skuPage.getRecords(); |
| | | if (skuList == null || skuList.isEmpty()) { |
| | | return new Page<>(); |
| | | } |
| | | |
| | | ProductMaterial material = productMaterialMapper.selectById(dto.getMaterialId()); |
| | | String materialName = material != null ? material.getMaterialName() : null; |
| | | String baseUnit = material != null ? material.getBaseUnit() : null; |
| | | List<ProductMaterialSkuDto> result = new ArrayList<>(skuList.size()); |
| | | for (ProductMaterialSku sku : skuList) { |
| | | ProductMaterialSkuDto dto = new ProductMaterialSkuDto(); |
| | | dto.setMaterialId(materialId); |
| | | dto.setMaterialName(materialName); |
| | | dto.setBaseUnit(baseUnit); |
| | | dto.setSkuId(sku.getId()); |
| | | dto.setSpecification(sku.getSpecification()); |
| | | dto.setSupplyType(sku.getSupplyType()); |
| | | result.add(dto); |
| | | ProductMaterialSkuDto productMaterialSkuDto = new ProductMaterialSkuDto(); |
| | | productMaterialSkuDto.setMaterialId(dto.getMaterialId()); |
| | | productMaterialSkuDto.setMaterialName(materialName); |
| | | productMaterialSkuDto.setMaterialCode(sku.getMaterialCode()); |
| | | productMaterialSkuDto.setBaseUnit(baseUnit); |
| | | productMaterialSkuDto.setSkuId(sku.getId()); |
| | | productMaterialSkuDto.setSpecification(sku.getSpecification()); |
| | | productMaterialSkuDto.setSupplyType(sku.getSupplyType()); |
| | | result.add(productMaterialSkuDto); |
| | | } |
| | | |
| | | return result; |
| | | Page<ProductMaterialSkuDto> dtoPage = new Page<>(); |
| | | dtoPage.setCurrent(skuPage.getCurrent()); |
| | | dtoPage.setSize(skuPage.getSize()); |
| | | dtoPage.setTotal(skuPage.getTotal()); |
| | | dtoPage.setRecords(result); |
| | | return dtoPage; |
| | | } |
| | | |
| | | /** |
| | |
| | | * 产åè§æ ¼ |
| | | */ |
| | | @ApiModelProperty("产åè§æ ¼") |
| | | private String productSpec; |
| | | private String specification; |
| | | |
| | | /** |
| | | * 产åé¿åº¦ |
| | |
| | | @ApiModelProperty("æ±æ»æ¹æ°") |
| | | private BigDecimal volume; |
| | | |
| | | /** |
| | | * åºæ¬åä½ |
| | | */ |
| | | @ApiModelProperty("åºæ¬åä½") |
| | | private String baseUnit; |
| | | |
| | | } |
| | |
| | | @Getter |
| | | public enum DataSourceTypeEnum { |
| | | |
| | | SALES_ORDER(1, "忥"), |
| | | PRODUCTION_FORECAST(2, "æ°å¢"); |
| | | DING_TALK(1, "éé忥"), |
| | | MANUAL(2, "æå¨æ°å¢"); |
| | | |
| | | private final Integer code; |
| | | private final String desc; |
| | |
| | | @Excel(name = "强度") |
| | | private String strength; |
| | | |
| | | @ApiModelProperty("ç¶æ 0æªä¸å 1é¨åä¸å 2å·²ä¸å") |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æªä¸å,1=é¨åä¸å,2=å·²ä¸å") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * å¼å§æ¥æ |
| | | */ |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime formModifiedTime; |
| | | |
| | | /** |
| | | * æ°æ®åæ¥ç±»åï¼1=æå¨ 2=宿¶ä»»å¡ |
| | | */ |
| | | @ApiModelProperty("æ°æ®åæ¥ç±»åï¼1=æå¨ 2=宿¶ä»»å¡") |
| | | private Integer dataSyncType; |
| | | |
| | | /** |
| | | * æ°æ®æ¥æºç±»åï¼1=忥 2=æ°å¢ |
| | | * æ°æ®æ¥æºç±»åï¼1=éé忥 2=æå¨æ°å¢ |
| | | */ |
| | | @ApiModelProperty("æ°æ®æ¥æºç±»åï¼1=忥 2=æ°å¢") |
| | | @ApiModelProperty("æ°æ®æ¥æºç±»åï¼1=éé忥 2=æå¨æ°å¢") |
| | | private Integer dataSourceType; |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanDto; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanImportDto; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanSummaryDto; |
| | | import com.ruoyi.productionPlan.enums.DataSourceTypeEnum; |
| | | import com.ruoyi.productionPlan.mapper.ProductOrderPlanMapper; |
| | | import com.ruoyi.productionPlan.mapper.ProductionPlanMapper; |
| | | import com.ruoyi.productionPlan.pojo.ProductOrderPlan; |
| | |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.productionPlan.enums.DataSourceTypeEnum.PRODUCTION_FORECAST; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | |
| | | // æ ¡éªæ¯å¦åå¨ä¸åç产ååç§° |
| | | String firstProductName = plans.get(0).getProductName(); |
| | | if (plans.stream().anyMatch(p -> !p.getProductName().equals(firstProductName))) { |
| | | if (plans.stream().anyMatch(p -> p.getProductName() == null || !p.getProductName().equals(firstProductName))) { |
| | | throw new BaseException("å并失败ï¼åå¨ä¸åç产ååç§°"); |
| | | } |
| | | |
| | | // æ ¡éªæ¯å¦åå¨ä¸åç产åè§æ ¼ |
| | | String firstProductSpec = plans.get(0).getSpecification(); |
| | | if (plans.stream().anyMatch(p -> !p.getSpecification().equals(firstProductSpec))) { |
| | | if (plans.stream().anyMatch(p -> p.getSpecification() == null || !p.getSpecification().equals(firstProductSpec))) { |
| | | throw new BaseException("å并失败ï¼åå¨ä¸åç产åè§æ ¼"); |
| | | } |
| | | |
| | | // å å å©ä½æ¹æ° |
| | | BigDecimal totalRemainingVolume = plans.stream() |
| | | .map(ProductionPlan::getRemainingVolume) |
| | | .filter(v -> v != null) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 夿ä¸åæ°éæ¯å¦å¤§äºçäºå©ä½æ¹æ° |
| | | if (productionPlanDto.getTotalAssignedQuantity().compareTo(totalRemainingVolume) > 0) { |
| | |
| | | if (assignedVolume.add(remainingVolume).compareTo(productionPlanDto.getTotalAssignedQuantity()) >= 0) { |
| | | // æåä¸ä¸ªè®¡åï¼åé
å©ä½æ¹æ° |
| | | BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume); |
| | | plan.setStatus(1); |
| | | if (lastRemainingVolume.compareTo(BigDecimal.ZERO) <= 0) { |
| | | plan.setStatus(2); |
| | | } |
| | | plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume)); |
| | | productOrderPlan.setAssignedQuantity(lastRemainingVolume); |
| | | productionPlanMapper.updateById(plan); |
| | |
| | | } |
| | | |
| | | // åé
å½åè®¡åæ¹æ° |
| | | plan.setStatus(1); |
| | | if (remainingVolume.compareTo(BigDecimal.ZERO) <= 0) { |
| | | plan.setStatus(2); |
| | | } |
| | | plan.setAssignedQuantity(plan.getAssignedQuantity().add(remainingVolume)); |
| | | productOrderPlan.setAssignedQuantity(remainingVolume); |
| | | // æ´æ°ç产计å |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean add(ProductionPlanDto productionPlanDto) { |
| | | productionPlanDto.setDataSourceType(PRODUCTION_FORECAST.getCode()); |
| | | productionPlanDto.setDataSourceType(DataSourceTypeEnum.MANUAL.getCode()); |
| | | productionPlanDto.setStatus(0); |
| | | productionPlanMapper.insert(productionPlanDto); |
| | | return true; |
| | | } |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean update(ProductionPlanDto productionPlanDto) { |
| | | // å·²ä¸åç¶æï¼ä¸è½ç¼è¾ |
| | | if (productionPlanDto.getStatus() != 0) { |
| | | throw new BaseException("å·²ä¸åæé¨åä¸åç¶æï¼ä¸è½ç¼è¾"); |
| | | } |
| | | // æ¥è¯¢æ¯å¦æå
³è订å |
| | | boolean hasProductOrderPlan = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().eq(ProductOrderPlan::getProductionPlanId, productionPlanDto.getId())).stream().anyMatch(p -> p.getProductOrderId() != null); |
| | | if (hasProductOrderPlan) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean delete(List<Long> ids) { |
| | | // 妿åå¨å·²ä¸åç计åï¼åä¸è½å é¤ |
| | | if (productionPlanMapper.selectList(Wrappers.<ProductionPlan>lambdaQuery().in(ProductionPlan::getId, ids)).stream().anyMatch(p -> p.getStatus() == 1 || p.getStatus() == 2)) { |
| | | throw new BaseException("å é¤å¤±è´¥ï¼åå¨å·²ä¸åæé¨åä¸åç计å"); |
| | | } |
| | | // 妿æå
³è订åï¼åä¸è½å é¤ |
| | | if (productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductionPlanId, ids)).stream().anyMatch(p -> p.getProductOrderId() != null)) { |
| | | throw new BaseException("å é¤å¤±è´¥ï¼åå¨å
³è订å"); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void syncProdData(Integer dataSyncType) { |
| | | if (!syncLock.tryLock()) { |
| | | log.warn("忥æ£å¨è¿è¡ä¸ï¼æ¬æ¬¡ {} åæ¥è¯·æ±è¢«è·³è¿", dataSyncType == 1 ? "æå¨" : "宿¶ä»»å¡"); |
| | | log.warn("忥æ£å¨è¿è¡ä¸ï¼æ¬æ¬¡ {} åæ¥è¯·æ±è¢«è·³è¿", dataSyncType == 1 ? "æå¨åæ¥" : "宿¶ä»»å¡åæ¥"); |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | plan.setFormCreatedTime(parseUtcTime(item.getString("createdTimeGMT"))); |
| | | plan.setFormModifiedTime(parseUtcTime(item.getString("modifiedTimeGMT"))); |
| | | plan.setDataSyncType(dataSyncType); |
| | | plan.setDataSourceType(1); |
| | | plan.setDataSourceType(DataSourceTypeEnum.DING_TALK.getCode()); |
| | | plan.setCreateTime(now); |
| | | plan.setUpdateTime(now); |
| | | plan.setTotalCount(totalCount); |
| | |
| | | entity.setAssignedQuantity(BigDecimal.ZERO); |
| | | entity.setCreateTime(LocalDateTime.now()); |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | entity.setDataSourceType(2); |
| | | entity.setDataSyncType(1); |
| | | entity.setDataSourceType(DataSourceTypeEnum.DING_TALK.getCode()); |
| | | |
| | | // æ ¹æ®ç©æç¼ç å¡«å
å
³èID |
| | | if (StringUtils.isNotEmpty(dto.getMaterialCode())) { |
| | |
| | | # å¼åç¯å¢é
ç½® |
| | | server: |
| | | # æå¡å¨çHTTP端å£ï¼é»è®¤ä¸º8080 |
| | | port: 9003 |
| | | port: 9019 |
| | | servlet: |
| | | # åºç¨ç访é®è·¯å¾ |
| | | context-path: / |
| | |
| | | <select id="energyConsumptionTypeProportion" |
| | | resultType="com.ruoyi.energy.dto.EnergyConsumptionTypeDto"> |
| | | select e.energy_tyep, |
| | | SUM(ecd.dosage) energyConsumption, |
| | | SUM(ecd.dosage * e.unit_price) energyCost |
| | | SUM(COALESCE(ecd.dosage, 0)) energyConsumption, |
| | | SUM(COALESCE(ecd.dosage, 0) * e.unit_price) energyCost |
| | | from energy_consumption_detail ecd |
| | | left join energy e on ecd.energy_id = e.id |
| | | where ecd.meter_reading_date between #{c.startDate} and #{c.endDate} |
| | |
| | | group by e.energy_tyep |
| | | </select> |
| | | <select id="energyCostDtos" resultType="com.ruoyi.energy.dto.EnergyCostDto"> |
| | | select A.meter_reading_date, |
| | | A.waterConsumption, |
| | | A.waterCost, |
| | | B.electricityConsumption, |
| | | B.electricityCost, |
| | | C.gasConsumption, |
| | | C.gasCost, |
| | | sum(A.waterConsumption+B.electricityConsumption+C.gasConsumption) totalConsumption, |
| | | sum(A.waterCost+B.electricityCost+C.gasCost) totalCost |
| | | from |
| | | select z.meter_reading_date, |
| | | COALESCE(A.waterConsumption, 0) waterConsumption, |
| | | COALESCE(A.waterCost, 0) waterCost, |
| | | COALESCE(B.electricityConsumption, 0) electricityConsumption, |
| | | COALESCE(B.electricityCost, 0) electricityCost, |
| | | COALESCE(C.gasConsumption, 0) gasConsumption, |
| | | COALESCE(C.gasCost, 0) gasCost, |
| | | COALESCE(A.waterConsumption, 0)+ COALESCE(B.electricityConsumption, 0)+ COALESCE(C.gasConsumption, 0) totalConsumption, |
| | | COALESCE(A.waterCost, 0)+ COALESCE(B.electricityCost, 0)+ COALESCE(C.gasCost, 0) totalCost |
| | | from energy_consumption_detail z |
| | | left join |
| | | (select ecd.meter_reading_date, |
| | | sum(ecd.dosage) waterConsumption, |
| | | sum(ecd.dosage * e1.unit_price) waterCost |
| | |
| | | and ecd.type =#{c.type} |
| | | </if> |
| | | group by ecd.meter_reading_date)A |
| | | join |
| | | on z.meter_reading_date=A.meter_reading_date |
| | | left join |
| | | (select ecd.meter_reading_date, |
| | | sum(ecd.dosage) electricityConsumption, |
| | | sum(ecd.dosage * e2.unit_price) electricityCost |
| | |
| | | and ecd.type =#{c.type} |
| | | </if> |
| | | group by ecd.meter_reading_date)B |
| | | on A.meter_reading_date=B.meter_reading_date |
| | | join |
| | | on z.meter_reading_date=B.meter_reading_date |
| | | left join |
| | | (select ecd.meter_reading_date, |
| | | sum(ecd.dosage) gasConsumption, |
| | | sum(ecd.dosage * e3.unit_price) gasCost |
| | |
| | | and ecd.type =#{c.type} |
| | | </if> |
| | | group by ecd.meter_reading_date)C |
| | | on A.meter_reading_date=C.meter_reading_date |
| | | |
| | | on z.meter_reading_date=C.meter_reading_date |
| | | order by z.meter_reading_date |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <result property="modifierName" column="modifier_name"/> |
| | | <result property="formCreatedTime" column="form_created_time"/> |
| | | <result property="formModifiedTime" column="form_modified_time"/> |
| | | <result property="dataSyncType" column="data_sync_type"/> |
| | | <result property="dataSourceType" column="data_source_type"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| | |
| | | <if test="c.endDate != null"> |
| | | AND pp.end_date <= DATE_FORMAT(#{c.endDate},'%Y-%m-%d') |
| | | </if> |
| | | ORDER BY COALESCE(pp.form_modified_time, pp.id) DESC |
| | | </select> |
| | | |
| | | <select id="selectSummaryByProductType" resultType="com.ruoyi.productionPlan.dto.ProductionPlanSummaryDto"> |
| | | SELECT |
| | | sku.material_code, |
| | | pm.material_name AS product_name, |
| | | sku.specification AS product_spec, |
| | | sku.material_code AS materialCode, |
| | | pm.material_name AS productName, |
| | | sku.specification AS specification, |
| | | pp.length, |
| | | pp.width, |
| | | pp.height, |
| | | pm.base_unit AS baseUnit, |
| | | COALESCE(SUM(pp.quantity),0) AS quantity, |
| | | COALESCE(SUM(pp.volume),0) AS volume |
| | | FROM production_plan pp |
| | |
| | | <if test="productName != null and productName != ''"> |
| | | AND pm.material_name LIKE CONCAT('%', #{productName}, '%') |
| | | </if> |
| | | |
| | | <if test="specification != null and specification != ''"> |
| | | AND sku.specification LIKE CONCAT('%', #{specification}, '%') |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | sku.material_code, |
| | |
| | | sku.specification, |
| | | pp.length, |
| | | pp.width, |
| | | pp.height |
| | | pp.height, |
| | | pm.base_unit |
| | | </select> |
| | | |
| | | <select id="selectWithMaterialByIds" resultType="com.ruoyi.productionPlan.dto.ProductionPlanDto"> |