yys  1.仓储物流增加分类管理
2.仓储物流分类管理导出接口
4.新疆生产管控定制化
已修改6个文件
146 ■■■■■ 文件已修改
src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/SalesLedgerSchedulingProcessDto.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/SalesLedgerSchedulingService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/SalesLedgerSchedulingMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java
@@ -23,6 +23,9 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
/**
@@ -47,7 +50,8 @@
    public AjaxResult list() {
        List<SpeculativeTradingInfo> result = speculativeTradingInfoMapper.selectList(null);
        result.forEach(item -> {
            item.setCurrentWorkLoad(salesLedgerSchedulingService.getSchedulingNumBySpeculativeTradingName(item.getName()));
            item.setCurrentWorkLoad(salesLedgerSchedulingService.getSchedulingNumBySpeculativeTradingName(item.getName()).divide(new BigDecimal(1000),2, RoundingMode.CEILING));
            item.setVacant(item.getWorkLoad().subtract(item.getCurrentWorkLoad()));
        });
        return AjaxResult.success(result);
@@ -110,7 +114,18 @@
    @ApiOperation("生产管理-生产订单-生产派工")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult productionDispatch(@RequestBody ProductionDispatchAddDto productionDispatchAddDto) {
        int result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDto);
        List<ProductionDispatchAddDto> productionDispatchAddDtoList = new ArrayList<>();
        productionDispatchAddDtoList.add(productionDispatchAddDto);
        String result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDtoList);
        return AjaxResult.success(result);
    }
    @PostMapping("/productionDispatchList")
    @Log(title = "生产管理-生产订单-自动派工", businessType = BusinessType.INSERT)
    @ApiOperation("生产管理-生产订单-自动派工")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult productionDispatchList(@RequestBody List<ProductionDispatchAddDto> productionDispatchAddDto) {
        String result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDto);
        return AjaxResult.success(result);
    }
src/main/java/com/ruoyi/production/dto/SalesLedgerSchedulingProcessDto.java
@@ -26,6 +26,12 @@
    @ApiModelProperty(value = "销售台账ID")
    private Long salesLedgerId;
    /**
     * 生产炒机
     */
    @Excel(name = "生产炒机")
    private String speculativeTradingName;
    @ApiModelProperty(value = "开始时间")
    private String entryDateStart;
src/main/java/com/ruoyi/production/service/SalesLedgerSchedulingService.java
@@ -22,7 +22,7 @@
    void export(HttpServletResponse response);
    int productionDispatch(ProductionDispatchAddDto productionDispatchAddDto);
    String productionDispatch(List<ProductionDispatchAddDto> productionDispatchAddDto);
    IPage<SalesLedgerSchedulingProcessDto> listPageProcess(Page page, SalesLedgerSchedulingProcessDto salesLedgerSchedulingDto);
src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
@@ -4,7 +4,10 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.production.dto.*;
import com.ruoyi.production.mapper.SalesLedgerSchedulingMapper;
import com.ruoyi.production.mapper.SalesLedgerWorkMapper;
@@ -67,10 +70,12 @@
                    .map(SalesLedgerWork::getFinishedNum)
                    .reduce(BigDecimal.ZERO, BigDecimal::add));
            // 状态 = 数量和完工数量比较
            if(i.getSchedulingNum().compareTo(i.getSuccessNum()) == 0){
            if(i.getSchedulingNum().compareTo(new BigDecimal(0)) == 0){
                i.setStatus("未完成");
            } else if(i.getSchedulingNum().compareTo(i.getSuccessNum()) == 0){
                i.setStatus("已完成");
            }else{
                i.setStatus("未完成");
                i.setStatus("生产中");
            }
        });
        return list;
@@ -104,50 +109,73 @@
    private final SpeculativeTradingInfoMapper speculativeTradingInfoMapper;
    @Override
    public int productionDispatch(ProductionDispatchAddDto productionDispatchAddDto) {
        SysUser sysUser = sysUserMapper.selectUserById(productionDispatchAddDto.getSchedulingUserId());
        if(sysUser == null) throw new RuntimeException("排产人不存在");
        // 获取空余炒机
        String[] split = productionDispatchAddDto.getSpeculativeTradingName().split(",");
        if(split != null && split.length == 0){
            throw new RuntimeException("生产炒机不能为空");
        }
        List<SpeculativeTradingInfo> speculativeTradingInfos = speculativeTradingInfoMapper.selectList(new LambdaQueryWrapper<SpeculativeTradingInfo>()
                .in(SpeculativeTradingInfo::getName, Arrays.asList(split))
                .orderByAsc(SpeculativeTradingInfo::getSort));
        if(CollectionUtils.isEmpty(speculativeTradingInfos)){
            throw new RuntimeException("无空余炒机,请检查炒机表");
        }
        AtomicReference<String> name = new AtomicReference<>("");  //需要绑定的炒机
        //通过规格型号和排产数量计算本次生产产量
        String[] split1 = productionDispatchAddDto.getSpecificationModel().split("\\*");
        if(split1.length != 2) throw new RuntimeException("规格型号格式错误");
        // 本次生产产量
        BigDecimal productionNum = new BigDecimal(split1[0])
                .multiply(new BigDecimal(split1[1]).multiply(productionDispatchAddDto.getSchedulingNum()));
        // 多个炒机情况
        if(speculativeTradingInfos.size() > 1){
            speculativeTradingInfos.forEach(item ->{
                // 获取该炒机正在排产量
                BigDecimal schedulingNumBySpeculativeTradingName = getSchedulingNumBySpeculativeTradingName(item.getName());
                // 如果该炒机总量 - 正在排产量 >=本次生产产量就分配此炒机
                if(item.getWorkLoad().subtract(schedulingNumBySpeculativeTradingName).compareTo(productionNum) >= 0){
                    name.set(item.getName());
    public String productionDispatch(List<ProductionDispatchAddDto> productionDispatchAddDtoList) {
        int i = 0;
        int successNum = 0;
        LoginUser loginUser = SecurityUtils.getLoginUser();
        for (ProductionDispatchAddDto productionDispatchAddDto : productionDispatchAddDtoList) {
            SysUser sysUser = sysUserMapper.selectUserById(productionDispatchAddDto.getSchedulingUserId() == null ? loginUser.getUser().getUserId() : productionDispatchAddDto.getSchedulingUserId());
            if(sysUser == null){
                i++;
                continue;
            }
            // 获取空余炒机
            String[] split = productionDispatchAddDto.getSpeculativeTradingName().split(",");
            if(split != null && split.length == 0){
                i++;
                continue;
            }
            List<SpeculativeTradingInfo> speculativeTradingInfos = speculativeTradingInfoMapper.selectList(new LambdaQueryWrapper<SpeculativeTradingInfo>()
                    .in(SpeculativeTradingInfo::getName, Arrays.asList(split))
                    .orderByAsc(SpeculativeTradingInfo::getSort));
            if(CollectionUtils.isEmpty(speculativeTradingInfos)){
                i++;
                continue;
            }
            AtomicReference<String> name = new AtomicReference<>("");  //需要绑定的炒机
            //通过规格型号和排产数量计算本次生产产量
            String[] split1 = productionDispatchAddDto.getSpecificationModel().split("\\*");
            if(split1.length != 2){
                i++;
                continue;
            }
            // 本次生产产量
            BigDecimal productionNum = new BigDecimal(split1[0])
                    .multiply(new BigDecimal(split1[1]).multiply(productionDispatchAddDto.getSchedulingNum()));
            // 多个炒机情况
            if(speculativeTradingInfos.size() > 1){
                for (SpeculativeTradingInfo speculativeTradingInfo : speculativeTradingInfos) {
                    // 获取该炒机正在排产量
                    BigDecimal schedulingNumBySpeculativeTradingName = getSchedulingNumBySpeculativeTradingName(speculativeTradingInfo.getName());
                    // 如果该炒机总量(单位kg需要乘1000) - 正在排产量 >=本次生产产量就分配此炒机
                    if(speculativeTradingInfo.getWorkLoad().multiply(new BigDecimal(1000)).subtract(schedulingNumBySpeculativeTradingName).compareTo(productionNum) >= 0){
                        name.set(speculativeTradingInfo.getName());
                        break;
                    }
                }
            });
            }else{
                // 单个炒机情况
                name.set(speculativeTradingInfos.get(0).getName());
            }
            if(name.get().isEmpty()){
                i++;
                continue;
            }
            SalesLedgerScheduling salesLedgerScheduling = SalesLedgerScheduling.builder()
                    .salesLedgerId(productionDispatchAddDto.getSalesLedgerId())
                    .salesLedgerProductId(productionDispatchAddDto.getSalesLedgerProductId())
                    .speculativeTradingName(name.get())
                    .schedulingUserId(sysUser.getUserId())
                    .schedulingUserName(sysUser.getNickName())
                    .schedulingNum(productionDispatchAddDto.getSchedulingNum())
                    .schedulingDate(productionDispatchAddDto.getSchedulingDate() == null ? LocalDate.now() : LocalDate.parse(productionDispatchAddDto.getSchedulingDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")))
                    .status(1)
                    .build();
            salesLedgerSchedulingMapper.insert(salesLedgerScheduling);
            successNum++;
        }
        if(name.get().isEmpty()) throw new RuntimeException("无空余炒机,请检查炒机表");
        SalesLedgerScheduling salesLedgerScheduling = SalesLedgerScheduling.builder()
                .salesLedgerId(productionDispatchAddDto.getSalesLedgerId())
                .salesLedgerProductId(productionDispatchAddDto.getSalesLedgerProductId())
                .speculativeTradingName(name.get())
                .schedulingUserId(productionDispatchAddDto.getSchedulingUserId())
                .schedulingUserName(sysUser.getNickName())
                .schedulingNum(productionDispatchAddDto.getSchedulingNum())
                .schedulingDate(LocalDate.parse(productionDispatchAddDto.getSchedulingDate(), DateTimeFormatter.ISO_LOCAL_DATE))
                .status(1)
                .build();
        return salesLedgerSchedulingMapper.insert(salesLedgerScheduling);
        return "派工成功数量" + successNum + ",失败数量" + i;
    }
    private final SalesLedgerProductMapper salesLedgerProductMapper;
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -264,7 +264,7 @@
                iPage.getRecords().removeIf(salesLedger -> Objects.equals(salesLedger.getNoInvoiceAmountTotal(), new BigDecimal("0.00")));
            }
        }
        iPage.setTotal(iPage.getRecords().size());
        iPage.setTotal(iPage.getTotal());
        return iPage;
    }
}
src/main/resources/mapper/production/SalesLedgerSchedulingMapper.xml
@@ -72,6 +72,7 @@
        T2.status,
        T2.scheduling_user_id,
        T2.scheduling_user_name,
        T2.speculative_trading_name,
        T2.scheduling_date,
        ifNull(T2.scheduling_num,0) AS schedulingNum,
        ifNull(T2.finished_num,0) AS successNum,