diff --git a/RuoYi-App-master/pages/login.vue b/RuoYi-App-master/pages/login.vue index 7872d2c..d76486a 100644 --- a/RuoYi-App-master/pages/login.vue +++ b/RuoYi-App-master/pages/login.vue @@ -1,412 +1,307 @@ - diff --git a/bin/start.bat b/bin/start.bat new file mode 100644 index 0000000..5118362 --- /dev/null +++ b/bin/start.bat @@ -0,0 +1,9 @@ +@echo off +echo ============================================= +echo WMS ÏîĿÆô¶¯ÖУ¬ÇëÉԺò... +echo ============================================= +echo. + +"C:\Program Files\Java\jdk-17\bin\java" -jar D:\FLRD\Project\FT541\FT541-WMS\ruoyi-admin\target\wms.jar + +pause diff --git a/pom.xml b/pom.xml index 796e05e..fff748e 100644 --- a/pom.xml +++ b/pom.xml @@ -191,6 +191,13 @@ ${ruoyi.version} + + + com.ruoyi + ruoyi-license + ${ruoyi.version} + + org.springframework.ai spring-ai-bom @@ -243,6 +250,7 @@ ruoyi-quartz ruoyi-generator ruoyi-common + ruoyi-license pom diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index c3d5860..bcc31f2 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -127,6 +127,12 @@ mssql-jdbc + + + com.ruoyi + ruoyi-license + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/MyStartupRunner.java b/ruoyi-admin/src/main/java/com/ruoyi/MyStartupRunner.java deleted file mode 100644 index ddff0fc..0000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/MyStartupRunner.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.ruoyi; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.stereotype.Component; - -@Component -public class MyStartupRunner implements CommandLineRunner { - - @Override - public void run(String... args) throws Exception { - // 这里编写项目启动后要执行的方法逻辑 - System.out.println("项目启动成功后自动执行此方法"); - } -} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToWcsApiController.java b/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToWcsApiController.java index 93feced..3bc0c56 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToWcsApiController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToWcsApiController.java @@ -83,5 +83,15 @@ public class ToWcsApiController { requestLogService.insertRequestLog(requestLog); return ajaxResult; } + /** + * 取货无货,重新分配物料 + */ + @PostMapping("/outJobStart") + public AjaxResult outJobStart(@RequestBody WmsJobRequest wmsJobRequest) { + AjaxResult ajaxResult = toWcsService.outJobStart(wmsJobRequest); + RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(wmsJobRequest), "出库任务开始",ajaxResult,"WCS"); + requestLogService.insertRequestLog(requestLog); + return ajaxResult; + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/service/IToWcsService.java b/ruoyi-admin/src/main/java/com/ruoyi/api/service/IToWcsService.java index 99e85e2..e6695f7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/api/service/IToWcsService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/service/IToWcsService.java @@ -41,4 +41,6 @@ public interface IToWcsService { * 取货无货,重新分配单据 */ AjaxResult reMaterial(ReMaterialParam reMaterialParam); + + AjaxResult outJobStart(WmsJobRequest wmsJobRequest); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/service/impl/ToWcsServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/api/service/impl/ToWcsServiceImpl.java index 5f53f63..ca577ff 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/api/service/impl/ToWcsServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/service/impl/ToWcsServiceImpl.java @@ -25,6 +25,7 @@ import com.ruoyi.job.mydojobdetail.service.IMydoJobDetailService; import com.ruoyi.log.domain.RequestLog; import com.ruoyi.log.service.IRequestLogService; import com.ruoyi.out.outStockout.service.IOutStockoutService; +import com.ruoyi.out.outStockoutDetail.service.IOutStockoutDetailService; import com.ruoyi.pda.domain.TrayCodeMsg; import com.ruoyi.pda.mapper.PdaMapper; import com.ruoyi.pda.service.PdaService; @@ -59,6 +60,8 @@ public class ToWcsServiceImpl implements IToWcsService { private PdaMapper pdaMapper; @Autowired private IBasStockService basStockService; + @Autowired + private IOutStockoutDetailService outStockoutDetailService; @Autowired private IBasCargoSpaceWeightRuleService basCargoSpaceWeightRuleService; @@ -70,7 +73,7 @@ public class ToWcsServiceImpl implements IToWcsService { @Override - //@Scheduled(fixedDelay = 3000) + @Scheduled(fixedDelay = 3000) public void pushOutMydoJob() { //查询所有未推送的料箱出库作业 List list = new ArrayList<>(); @@ -89,7 +92,7 @@ public class ToWcsServiceImpl implements IToWcsService { if (i <= 3) { for (int exitId = 1; exitId <= 2; exitId++) { mydoJobParam.setRoadwayId(String.valueOf(i)); - mydoJobParam.setStatus("3"); + mydoJobParam.setStatus("2"); mydoJobParam.setExitId(exitId + ""); List roadwayRunningMydoJobs = mydoJobService.selectMydoJobListApi(mydoJobParam); if (CollUtil.isEmpty(roadwayRunningMydoJobs) || roadwayRunningMydoJobs.size() < 2) { @@ -102,7 +105,7 @@ public class ToWcsServiceImpl implements IToWcsService { if ("01".equals(outMydoJob.getWarehouseId())) { RequestLog requestLog = requestLogService.getRequestLog(PUSH_OUT_MYDO_JOB_1, JSONUtil.toJsonStr(outMydoJob), "推送出库任务"); if ("1".equals(requestLog.getIsSuccessful())) { - outMydoJob.setStatus("3"); + outMydoJob.setStatus("2"); outMydoJob.setExecutionPhase("1"); outMydoJob.setStartTime(DateUtil.formatDateTime(new Date())); mydoJobService.updateMydoJob(outMydoJob); @@ -113,7 +116,7 @@ public class ToWcsServiceImpl implements IToWcsService { } } else { mydoJobParam.setRoadwayId(String.valueOf(i)); - mydoJobParam.setStatus("3"); + mydoJobParam.setStatus("2"); List roadwayRunningMydoJobs = mydoJobService.selectMydoJobListApi(mydoJobParam); if (CollUtil.isEmpty(roadwayRunningMydoJobs) || roadwayRunningMydoJobs.size() < 2) { mydoJobParam1.setStatus("1"); @@ -124,7 +127,7 @@ public class ToWcsServiceImpl implements IToWcsService { if ("02".equals(outMydoJob.getWarehouseId())) { RequestLog requestLog = requestLogService.getRequestLog(PUSH_OUT_MYDO_JOB_2, JSONUtil.toJsonStr(outMydoJob), "推送出库任务"); if ("1".equals(requestLog.getIsSuccessful())) { - outMydoJob.setStatus("3"); + outMydoJob.setStatus("2"); outMydoJob.setExecutionPhase("1"); outMydoJob.setStartTime(DateUtil.formatDateTime(new Date())); mydoJobService.updateMydoJob(outMydoJob); @@ -322,7 +325,7 @@ public class ToWcsServiceImpl implements IToWcsService { MydoJob outJob = outMydoJobs.get(0); outJob.setExecutionPhase("2"); mydoJobService.updateMydoJob(outJob); - if ("24".equals(outJob.getInOrOut()) || "25".equals(outJob.getInOut())) { + if ("24".equals(outJob.getInOrOut()) || "25".equals(outJob.getInOrOut())) { String[] jobIds = new String[]{outJob.getJobId()}; mydoJobService.OuthandFinish(jobIds); } @@ -364,18 +367,17 @@ public class ToWcsServiceImpl implements IToWcsService { @Override public AjaxResult reMaterial(ReMaterialParam reMaterialParam) { MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(reMaterialParam.getJobId()); - mydoJob.setStatus("4"); - mydoJob.setFinishTime(DateUtil.formatDateTime(new Date())); + mydoJob.setClassId("取货无货"); + mydoJobService.updateMydoJob(mydoJob); + return AjaxResult.success(); + } + + @Override + public AjaxResult outJobStart(WmsJobRequest wmsJobRequest) { + MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(wmsJobRequest.getJobId()); + mydoJob.setStatus("3"); + mydoJob.setStartTime(DateUtil.formatDateTime(new Date())); mydoJobService.updateMydoJob(mydoJob); - //标记异常货位 - String cargoSpaceId = mydoJob.getCargoSpaceId(); - BasCargoSpace basCargoSpace = basCargoSpaceService.selectBasCargoSpaceByCargoSpaceId(cargoSpaceId); - basCargoSpace.setStatus("6"); - basCargoSpaceService.updateBasCargoSpace(basCargoSpace); - //删除库存 - //basStockService.deleteKtpStockByTrayCodeAndWarehouseId(mydoJob.getTrayCode(),mydoJob.getWarehouseId()); - //删除作业 - mydoJobService.insertHistory(mydoJob.getJobId()); return AjaxResult.success(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/in/stockin/service/impl/InStockinServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/in/stockin/service/impl/InStockinServiceImpl.java index fb31c5d..281aa92 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/in/stockin/service/impl/InStockinServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/in/stockin/service/impl/InStockinServiceImpl.java @@ -2,9 +2,10 @@ package com.ruoyi.in.stockin.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjUtil; +import cn.hutool.core.util.StrUtil; import com.ruoyi.bas.BasProduct.domain.BasProduct; import com.ruoyi.bas.basJobId.service.IBasJobIdService; import com.ruoyi.common.core.domain.AjaxResult; @@ -172,6 +173,7 @@ public class InStockinServiceImpl implements IInStockinService inStockinDetail.setStockinGuid(inStockin.getStockinGuid()); inStockinDetail.setStockinDetailId(inStockin.getStockinId()+"-"+i); inStockinDetail.setStockinId(inStockin.getStockinId()); + inStockinDetail.setSpare8(basProduct.getProductName()); iInStockinDetailService.insertInStockinDetail(inStockinDetail); } @@ -232,7 +234,7 @@ public class InStockinServiceImpl implements IInStockinService } else { //根据托盘码 判断是平库入库还是立体库入库 //查询托盘入库货位 - List oldBasStockList = basStockService.selectBasStockByTrayCode(inStockTraycodeBindMsg.getTrayCode()); + List oldBasStockList = basStockService.selectBasStockByTrayCode(inStockTraycodeBindMsg.getTrayCode(),old.getWarehouseId()); //如果是4位数字 必须存在托盘对应库位 如果不是4位数字则证明是平库 货位就是托盘码 if (CollUtil.isEmpty(oldBasStockList) && is4DigitNumber(inStockTraycodeBindMsg.getTrayCode())) { throw new RuntimeException(inStockTraycodeBindMsg.getTrayCode() + "尚未入库,查询不到库存"); @@ -255,9 +257,14 @@ public class InStockinServiceImpl implements IInStockinService BasStock stock = new BasStock(); stock.setStockId(basJobIdService.getJobId("KC")); if (is4DigitNumber(inStockTraycodeBindMsg.getTrayCode())) { + //部门 stock.setCargoSpaceId(oldBasStockList.get(0).getCargoSpaceId()); + stock.setModel(oldBasStockList.get(0).getModel()); + stock.setVoltage("1"); } else { stock.setCargoSpaceId(inStockTraycodeBindMsg.getTrayCode()); + stock.setModel(SecurityUtils.getDeptId().toString()); + stock.setVoltage("2"); } stock.setStockStatus("1"); stock.setOutQuantity("0"); @@ -283,8 +290,7 @@ public class InStockinServiceImpl implements IInStockinService stock.setDistribution(inStockinDetail.getSpare9()); //台次 stock.setSpare5(inStockinDetail.getSpare5()); - //部门 - stock.setModel(SecurityUtils.getDeptId().toString()); + //存货名称 stock.setProductName(inStockinDetail.getSpare8()); //单重 @@ -293,7 +299,7 @@ public class InStockinServiceImpl implements IInStockinService stock.setGrossWeight(inStockinDetail.getSpare3()); //供应商 stock.setPhase(inStockinDetail.getSupplierId()); - stock.setRemark(inStockinDetail.getRemark()); + stock.setSpare8(inStockTraycodeBindMsg.getLocation()); basStockList.add(stock); } @@ -305,11 +311,14 @@ public class InStockinServiceImpl implements IInStockinService iInStockinDetailService.updateInStockinDetail(inStockinDetail); } if (CollUtil.isNotEmpty(basStockList)) { - //插入库存 - basStockService.insertBasStockList(basStockList); - //删除新生成库存的托盘的空托盘库存记录 - basStockService.deleteKtpStockByList(basStockList, inStockin.getWarehouseId()); + for (List basStocks : CollUtil.split(basStockList, 50)) { + //插入库存 + basStockService.insertBasStockList(basStocks); + + //删除新生成库存的托盘的空托盘库存记录 + basStockService.deleteKtpStockByList(basStocks, old.getWarehouseId()); + } } //插入回传信息 if ("3".equals(old.getStockSource())){ @@ -454,7 +463,8 @@ public class InStockinServiceImpl implements IInStockinService public String importMaterial(List materialList) { //未到货 List list1 = materialList.stream().filter(x -> ObjUtil.isNull(x.getActualArriveQuantity())).toList(); - //生成入库单据 + List list2 = materialList.stream().filter(x -> ObjUtil.isNotNull(x.getRemainQuantity()) && x.getRemainQuantity()>0).toList(); + List list3 = materialList.stream().filter(x -> ObjUtil.isNotNull(x.getActualReceiveQuantity()) && x.getActualReceiveQuantity()>0).toList(); String warehouseId = null; LoginUser loginUser = SecurityUtils.getLoginUser(); List roles = loginUser.getUser().getRoles(); @@ -473,12 +483,67 @@ public class InStockinServiceImpl implements IInStockinService //三联合普通人员 warehouseId= "01"; } + StringBuilder res = new StringBuilder(); + //生成入库单据 + String s = importInStock(list1, warehouseId); + //生成库存记录 + //String s1 = importStock(list2, warehouseId); + //生成出库记录 + //String s2 = importOutStock(list3, warehouseId); + return res.append(s).append("|").toString(); + } + + private String importOutStock(List list3, String warehouseId) { + + return null; + } + + private String importStock(List list2, String warehouseId) { + Map> locationMap = list2.stream().filter(x -> StrUtil.isNotEmpty(x.getStorageLocation())).collect(Collectors.groupingBy(Material::getStorageLocation)); + int i = 0; + for (String location : locationMap.keySet()) { + List list = new ArrayList<>(); + List basStocks = basStockService.selectBasStockByTrayCode(location,warehouseId); + for (Material material : locationMap.get(location)) { + BasStock basStock = new BasStock(); + basStock.setStockId(basJobIdService.getJobId("KC")); + basStock.setWarehouseId(warehouseId); + basStock.setDistribution(material.getCode()); + basStock.setProductName(material.getName()); + basStock.setNetWeight(Convert.toStr(material.getSingleWeight())); + basStock.setGrossWeight(material.getRoute()); + basStock.setPhase(material.getSupplier()); + basStock.setOutQuantity("0"); + basStock.setQuantity(Convert.toStr(material.getRemainQuantity())); + if (!CollUtil.isEmpty(basStocks)) { + String[] split = location.split("-"); + if (is4DigitNumber(split[0])){ + basStock.setCargoSpaceId(basStocks.get(0).getCargoSpaceId()); + } + }else { + basStock.setCargoSpaceId(location); + } + basStock.setTrayCode(location); + list.add(basStock); + } + for (List basStockList : ListUtil.split(list, 50)) { + basStockService.insertBasStockList(basStockList); + + } + + } + return null; + } + + private String importInStock(List list1, String warehouseId) { + StringBuilder res = new StringBuilder(); + int i = 0; + InstockInVo inStockinVo = new InstockInVo(); + inStockinVo.setStockSource("1"); + inStockinVo.setInType("1"); + inStockinVo.setWarehouseId(warehouseId); + List list = new ArrayList<>(); for (Material material : list1) { - InstockInVo inStockinVo = new InstockInVo(); - inStockinVo.setStockSource("1"); - inStockinVo.setInType("1"); - inStockinVo.setWarehouseId(warehouseId); - List list = new ArrayList<>(); BasProduct basProduct = new BasProduct(); basProduct.setProductId(material.getCode()); basProduct.setSpare9(material.getCode()); @@ -489,9 +554,11 @@ public class InStockinServiceImpl implements IInStockinService basProduct.setSpare5(material.getTableNumber()); basProduct.setSupplierId(material.getSupplier()); list.add(basProduct); - inStockinVo.setProductVoList(list); - insertInStockin(inStockinVo); + i++; } - return ""; + inStockinVo.setProductVoList(list); + AjaxResult ajaxResult = insertInStockin(inStockinVo); + res.append("共导入").append(i).append("入库单据"); + return res.toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/in/stockinfinish/service/impl/InStockinFinishServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/in/stockinfinish/service/impl/InStockinFinishServiceImpl.java index acbd8ed..9a8ef8d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/in/stockinfinish/service/impl/InStockinFinishServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/in/stockinfinish/service/impl/InStockinFinishServiceImpl.java @@ -1,7 +1,10 @@ package com.ruoyi.in.stockinfinish.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.in.stockin.domain.InStockin; import com.ruoyi.in.stockinfinish.domain.InStockinFinish; @@ -10,7 +13,9 @@ import com.ruoyi.in.stockinfinish.service.IInStockinFinishService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; /** * 历史入库单据主信息Service业务层处理 @@ -99,9 +104,26 @@ public class InStockinFinishServiceImpl implements IInStockinFinishService @Override //@DataScope(warehouseAlias = "is2") public List selectInStockinFinishListByInStockin(InStockin inStockin) { - /*if (!"admin".equals(SecurityUtils.getUsername())){ - inStockin.setDepartmentNo(Convert.toStr(SecurityUtils.getDeptId())); - }*/ + if (!"admin".equals(SecurityUtils.getUsername())) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + List roles = loginUser.getUser().getRoles(); + if (CollUtil.isEmpty(roles)) { + //如果未设置角色 ,直接返回空列表 + return new ArrayList<>(); + } + //入库需要查看本部门任务 + Optional first = roles.stream().filter(x -> "role1".equals(x.getRoleKey()) || "role3".equals(x.getRoleKey())).findFirst(); + if (first.isPresent()) { + //二联合普通人员 + inStockin.setWarehouseId("02"); + } + Optional first1 = roles.stream().filter(x -> "role2".equals(x.getRoleKey()) || "role4".equals(x.getRoleKey())).findFirst(); + if (first1.isPresent()) { + //三联合普通人员 + inStockin.setWarehouseId("01"); + } + + } return inStockinFinishMapper.selectInStockinFinishListByInStockin(inStockin); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/mapper/MydoJobMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/mapper/MydoJobMapper.java index 454158a..d6eb8ba 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/mapper/MydoJobMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/mapper/MydoJobMapper.java @@ -78,5 +78,4 @@ public interface MydoJobMapper void cargoSpaceOut(HashMap map); - List exportOutJob(String stockoutId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/service/IMydoJobService.java b/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/service/IMydoJobService.java index 24afef0..237acb6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/service/IMydoJobService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/service/IMydoJobService.java @@ -119,5 +119,4 @@ public interface IMydoJobService AjaxResult cargoSpaceOut(String warehouseId, String cargoSpaceId, String exitId); - List exportOutJob(String stockoutId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/service/impl/MydoJobServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/service/impl/MydoJobServiceImpl.java index 5ec1b5c..35b0497 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/service/impl/MydoJobServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/job/mydojob/service/impl/MydoJobServiceImpl.java @@ -27,6 +27,7 @@ import com.ruoyi.job.mydojob.mapper.MydoJobMapper; import com.ruoyi.job.mydojob.service.IMydoJobService; import com.ruoyi.job.mydojobdetail.domain.MydoJobDetail; import com.ruoyi.job.mydojobdetail.service.IMydoJobDetailService; +import com.ruoyi.out.export.service.IOutStockAllotInfoService; import com.ruoyi.out.outStockout.domain.OutJobExcel; import com.ruoyi.out.outStockoutDetail.domain.OutStockoutDetail; import com.ruoyi.out.outStockoutDetail.service.IOutStockoutDetailService; @@ -87,6 +88,9 @@ public class MydoJobServiceImpl implements IMydoJobService { @Autowired private ICheckDifferenceRecordService checkDifferenceRecordService; + @Autowired + private IOutStockAllotInfoService outStockAllotInfoService; + /** * 查询任务表 @@ -312,10 +316,6 @@ public class MydoJobServiceImpl implements IMydoJobService { return AjaxResult.success(map.get("v_resultmsg")); } - @Override - public List exportOutJob(String stockoutId) { - return mydoJobMapper.exportOutJob(stockoutId); - } /** * 手动完成任务表 @@ -513,6 +513,7 @@ public class MydoJobServiceImpl implements IMydoJobService { stock.setNetWeight(mydoJobDetail.getSpare2()); stock.setGrossWeight(mydoJobDetail.getSpare3()); stock.setPhase(mydoJobDetail.getSupplierId()); + stock.setVoltage("1"); return stock; } @@ -575,6 +576,8 @@ public class MydoJobServiceImpl implements IMydoJobService { outStockoutDetail.setAllotQuantity(substract); outStockoutDetailService.updateOutStockoutDetail(outStockoutDetail); } + + } } //修改货位状态 @@ -587,6 +590,9 @@ public class MydoJobServiceImpl implements IMydoJobService { job.setFinishTime(DateUtil.formatDateTime(DateUtil.date())); updateMydoJob(job); insertHistory(jobId); + + //删除分配详情 + outStockAllotInfoService.deleteInfoByJobId(jobId); }else { log.error("任务处理异常"); return AjaxResult.error(jobId+"任务处理异常"); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/impl/KpiServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/impl/KpiServiceImpl.java index 4bccbb0..b306fd8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/impl/KpiServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/impl/KpiServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace; import com.ruoyi.bas.cargoSpace.mapper.BasCargoSpaceMapper; import com.ruoyi.common.core.domain.AjaxResult; @@ -525,6 +526,7 @@ public class KpiServiceImpl implements KpiService @Override public AjaxResult getInAnalysisByData(String warehouseId, String startTime, String endTime,String inOut) { + List roadwayIds = new ArrayList<>(); Map res = new HashMap<>(); MydoJob mydoJobParam = new MydoJob(); mydoJobParam.setWarehouseId(warehouseId); @@ -539,32 +541,41 @@ public class KpiServiceImpl implements KpiService //如果未设置角色 ,直接返回空列表 return AjaxResult.error("没有权限!"); } - ArrayList warehouseIdList = new ArrayList<>(); Optional first = roles.stream().filter(x -> "role1".equals(x.getRoleKey())).findFirst(); if (first.isPresent()){ //二联合普通人员 - mydoJobParam.setDepartmentId(SecurityUtils.getDeptId().toString()); - warehouseIdList.add("02"); - warehouseIdList.add("03"); + warehouseId="02"; + roadwayIds = Arrays.asList("4", "5" ,"6"); + } Optional first1 = roles.stream().filter(x -> "role2".equals(x.getRoleKey())).findFirst(); if (first1.isPresent()){ //三联合普通人员 + warehouseId="01"; mydoJobParam.setDepartmentId(SecurityUtils.getDeptId().toString()); - warehouseIdList.add("01"); + roadwayIds = Arrays.asList("1", "2" ,"3"); } Optional first2 = roles.stream().filter(x -> "role3".equals(x.getRoleKey())).findFirst(); if (first2.isPresent()){ //二联合管理员 - warehouseIdList.add("02"); - warehouseIdList.add("03"); + warehouseId="02"; + roadwayIds = Arrays.asList("4", "5" ,"6"); } Optional first3 = roles.stream().filter(x -> "role4".equals(x.getRoleKey())).findFirst(); if (first3.isPresent()){ //三联合管理员 - warehouseIdList.add("01"); + warehouseId="01"; + roadwayIds = Arrays.asList("1", "2" ,"3"); + } + mydoJobParam.setWarehouseId(warehouseId); + }else { + if (StrUtil.isEmpty(warehouseId)){ + roadwayIds = Arrays.asList("1", "2" ,"3","4","5","6"); + }else if ("01".equals(warehouseId)){ + roadwayIds = Arrays.asList("1", "2" ,"3"); + }else { + roadwayIds = Arrays.asList("4", "5" ,"6"); } - mydoJobParam.setWarehouseIdList(warehouseIdList); } }catch (Exception e){ log.error(e.getMessage(),e); @@ -572,9 +583,6 @@ public class KpiServiceImpl implements KpiService List datesBetween = DateUtil.rangeToList(DateUtil.parseDate(startTime), DateUtil.parseDate(endTime), DateField.DAY_OF_MONTH); List list = mydoJobFinishMapper.selectMydoJobFinishListByMydoJob(mydoJobParam); - // 获取所有巷道ID(1和2) - List roadwayIds = Arrays.asList("1", "2" ,"3"); - List xAxis = new ArrayList<>(); List> series = new ArrayList<>(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/export/controller/OutStockAllotInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/out/export/controller/OutStockAllotInfoController.java new file mode 100644 index 0000000..189f355 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/export/controller/OutStockAllotInfoController.java @@ -0,0 +1,104 @@ +package com.ruoyi.out.export.controller; + +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.out.export.domain.OutStockAllotInfo; +import com.ruoyi.out.export.service.IOutStockAllotInfoService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 出库任务导出Controller + * + * @author ruoyi + * @date 2026-04-01 + */ +@RestController +@RequestMapping("/out/jobExport") +public class OutStockAllotInfoController extends BaseController +{ + @Autowired + private IOutStockAllotInfoService outStockAllotInfoService; + + /** + * 查询出库任务导出列表 + */ + @PreAuthorize("@ss.hasPermi('jobExport:jobExport:list')") + @GetMapping("/list") + public TableDataInfo list(OutStockAllotInfo outStockAllotInfo) + { + startPage(); + List list = outStockAllotInfoService.selectOutStockAllotInfoList(outStockAllotInfo); + return getDataTable(list); + } + + /** + * 导出出库任务导出列表 + */ + @PreAuthorize("@ss.hasPermi('jobExport:jobExport:export')") + @Log(title = "出库任务导出", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, OutStockAllotInfo outStockAllotInfo) + { + List list = outStockAllotInfoService.selectOutStockAllotInfoList(outStockAllotInfo); + ExcelUtil util = new ExcelUtil(OutStockAllotInfo.class); + util.exportExcel(response, list, "出库任务导出数据"); + } + + /** + * 获取出库任务导出详细信息 + */ + @PreAuthorize("@ss.hasPermi('jobExport:jobExport:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(outStockAllotInfoService.selectOutStockAllotInfoById(id)); + } + + /** + * 新增出库任务导出 + */ + @PreAuthorize("@ss.hasPermi('jobExport:jobExport:add')") + @Log(title = "出库任务导出", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OutStockAllotInfo outStockAllotInfo) + { + return toAjax(outStockAllotInfoService.insertOutStockAllotInfo(outStockAllotInfo)); + } + + /** + * 修改出库任务导出 + */ + @PreAuthorize("@ss.hasPermi('jobExport:jobExport:edit')") + @Log(title = "出库任务导出", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OutStockAllotInfo outStockAllotInfo) + { + return toAjax(outStockAllotInfoService.updateOutStockAllotInfo(outStockAllotInfo)); + } + + /** + * 删除出库任务导出 + */ + @PreAuthorize("@ss.hasPermi('jobExport:jobExport:remove')") + @Log(title = "出库任务导出", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(outStockAllotInfoService.deleteOutStockAllotInfoByIds(ids)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/export/domain/OutStockAllotInfo.java b/ruoyi-admin/src/main/java/com/ruoyi/out/export/domain/OutStockAllotInfo.java new file mode 100644 index 0000000..d92ff32 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/export/domain/OutStockAllotInfo.java @@ -0,0 +1,269 @@ +package com.ruoyi.out.export.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.IndexedColors; + +import static org.apache.poi.ss.usermodel.IndexedColors.BLACK; +import static org.apache.poi.ss.usermodel.IndexedColors.WHITE1; + +/** + * 出库任务导出对象 out_stock_allot_info + * + * @author ruoyi + * @date 2026-04-01 + */ +public class OutStockAllotInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 出库主单 */ +// @Excel(name = "出库主单") + private String outStockId; + + /** 出库子单 */ +// @Excel(name = "出库子单") + private String outStockDetailId; + + /** 合同号 */ +// @Excel(name = "合同号") + private String orderId; + + /** 产品号 */ +// @Excel(name = "产品号") + private String power; + + /** 代号 */ + @Excel(name = "代号",sort = 1,width = 22,headerBackgroundColor=WHITE1,headerColor=BLACK,align= HorizontalAlignment.LEFT) + private String distribution; + + /** 台次 */ + @Excel(name = "台次",sort = 7,headerBackgroundColor=WHITE1,headerColor=BLACK,align= HorizontalAlignment.LEFT) + private String spare5; + + /** 单重 */ + @Excel(name = "单重",sort = 3,headerBackgroundColor=WHITE1,headerColor=BLACK,align= HorizontalAlignment.LEFT) + private String netWeight; + + /** 路线 */ +// @Excel(name = "路线") + private String grossWeight; + + /** 供应商 */ +// @Excel(name = "供应商") + private String phase; + + /** 物料编码 */ +// @Excel(name = "物料编码") + private String productId; + + /** 物料名称 */ + @Excel(name = "物料名称",sort = 2,headerBackgroundColor=WHITE1,headerColor=BLACK,align= HorizontalAlignment.LEFT) + private String productName; + + /** 存储位置 */ + @Excel(name = "存储位置",sort = 6,headerBackgroundColor=WHITE1,headerColor=BLACK,align= HorizontalAlignment.LEFT) + private String spare8; + + /** 托盘 */ + @Excel(name = "托盘",sort = 5,headerBackgroundColor=WHITE1,headerColor=BLACK,align= HorizontalAlignment.LEFT) + private String trayCode; + + /** 物料类型 */ +// @Excel(name = "物料类型 ") + private String productType; + + /** + * 出库数量 + */ + @Excel(name = "出库数量", sort = 4, headerBackgroundColor = WHITE1, headerColor = BLACK, align = HorizontalAlignment.LEFT) + private Long outQuantity; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setOutStockId(String outStockId) + { + this.outStockId = outStockId; + } + + public String getOutStockId() + { + return outStockId; + } + + public void setOutStockDetailId(String outStockDetailId) + { + this.outStockDetailId = outStockDetailId; + } + + public String getOutStockDetailId() + { + return outStockDetailId; + } + + public void setOrderId(String orderId) + { + this.orderId = orderId; + } + + public String getOrderId() + { + return orderId; + } + + public void setPower(String power) + { + this.power = power; + } + + public String getPower() + { + return power; + } + + public void setDistribution(String distribution) + { + this.distribution = distribution; + } + + public String getDistribution() + { + return distribution; + } + + public void setSpare5(String spare5) + { + this.spare5 = spare5; + } + + public String getSpare5() + { + return spare5; + } + + public void setNetWeight(String netWeight) + { + this.netWeight = netWeight; + } + + public String getNetWeight() + { + return netWeight; + } + + public void setGrossWeight(String grossWeight) + { + this.grossWeight = grossWeight; + } + + public String getGrossWeight() + { + return grossWeight; + } + + public void setPhase(String phase) + { + this.phase = phase; + } + + public String getPhase() + { + return phase; + } + + public void setProductId(String productId) + { + this.productId = productId; + } + + public String getProductId() + { + return productId; + } + + public void setProductName(String productName) + { + this.productName = productName; + } + + public String getProductName() + { + return productName; + } + + public void setSpare8(String spare8) + { + this.spare8 = spare8; + } + + public String getSpare8() + { + return spare8; + } + + public void setTrayCode(String trayCode) + { + this.trayCode = trayCode; + } + + public String getTrayCode() + { + return trayCode; + } + + public void setProductType(String productType) + { + this.productType = productType; + } + + public String getProductType() + { + return productType; + } + + public void setOutQuantity(Long outQuantity) + { + this.outQuantity = outQuantity; + } + + public Long getOutQuantity() + { + return outQuantity; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("outStockId", getOutStockId()) + .append("outStockDetailId", getOutStockDetailId()) + .append("orderId", getOrderId()) + .append("power", getPower()) + .append("distribution", getDistribution()) + .append("spare5", getSpare5()) + .append("netWeight", getNetWeight()) + .append("grossWeight", getGrossWeight()) + .append("phase", getPhase()) + .append("productId", getProductId()) + .append("productName", getProductName()) + .append("spare8", getSpare8()) + .append("trayCode", getTrayCode()) + .append("productType", getProductType()) + .append("outQuantity", getOutQuantity()) + .toString(); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/export/mapper/OutStockAllotInfoMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/out/export/mapper/OutStockAllotInfoMapper.java new file mode 100644 index 0000000..c06b2a9 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/export/mapper/OutStockAllotInfoMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.out.export.mapper; + +import java.util.List; +import com.ruoyi.out.export.domain.OutStockAllotInfo; + +/** + * 出库任务导出Mapper接口 + * + * @author ruoyi + * @date 2026-04-01 + */ +public interface OutStockAllotInfoMapper +{ + /** + * 查询出库任务导出 + * + * @param id 出库任务导出主键 + * @return 出库任务导出 + */ + public OutStockAllotInfo selectOutStockAllotInfoById(Long id); + + /** + * 查询出库任务导出列表 + * + * @param outStockAllotInfo 出库任务导出 + * @return 出库任务导出集合 + */ + public List selectOutStockAllotInfoList(OutStockAllotInfo outStockAllotInfo); + + /** + * 新增出库任务导出 + * + * @param outStockAllotInfo 出库任务导出 + * @return 结果 + */ + public int insertOutStockAllotInfo(OutStockAllotInfo outStockAllotInfo); + + /** + * 修改出库任务导出 + * + * @param outStockAllotInfo 出库任务导出 + * @return 结果 + */ + public int updateOutStockAllotInfo(OutStockAllotInfo outStockAllotInfo); + + /** + * 删除出库任务导出 + * + * @param id 出库任务导出主键 + * @return 结果 + */ + public int deleteOutStockAllotInfoById(Long id); + + /** + * 批量删除出库任务导出 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteOutStockAllotInfoByIds(Long[] ids); + + int deleteInfoByJobId(String jobId); +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/export/service/IOutStockAllotInfoService.java b/ruoyi-admin/src/main/java/com/ruoyi/out/export/service/IOutStockAllotInfoService.java new file mode 100644 index 0000000..3190a34 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/export/service/IOutStockAllotInfoService.java @@ -0,0 +1,63 @@ +package com.ruoyi.out.export.service; + +import java.util.List; +import com.ruoyi.out.export.domain.OutStockAllotInfo; + +/** + * 出库任务导出Service接口 + * + * @author ruoyi + * @date 2026-04-01 + */ +public interface IOutStockAllotInfoService +{ + /** + * 查询出库任务导出 + * + * @param id 出库任务导出主键 + * @return 出库任务导出 + */ + public OutStockAllotInfo selectOutStockAllotInfoById(Long id); + + /** + * 查询出库任务导出列表 + * + * @param outStockAllotInfo 出库任务导出 + * @return 出库任务导出集合 + */ + public List selectOutStockAllotInfoList(OutStockAllotInfo outStockAllotInfo); + + /** + * 新增出库任务导出 + * + * @param outStockAllotInfo 出库任务导出 + * @return 结果 + */ + public int insertOutStockAllotInfo(OutStockAllotInfo outStockAllotInfo); + + /** + * 修改出库任务导出 + * + * @param outStockAllotInfo 出库任务导出 + * @return 结果 + */ + public int updateOutStockAllotInfo(OutStockAllotInfo outStockAllotInfo); + + /** + * 批量删除出库任务导出 + * + * @param ids 需要删除的出库任务导出主键集合 + * @return 结果 + */ + public int deleteOutStockAllotInfoByIds(Long[] ids); + + /** + * 删除出库任务导出信息 + * + * @param id 出库任务导出主键 + * @return 结果 + */ + public int deleteOutStockAllotInfoById(Long id); + + int deleteInfoByJobId(String jobId); +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/export/service/impl/OutStockAllotInfoServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/out/export/service/impl/OutStockAllotInfoServiceImpl.java new file mode 100644 index 0000000..31e2b62 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/export/service/impl/OutStockAllotInfoServiceImpl.java @@ -0,0 +1,98 @@ +package com.ruoyi.out.export.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.out.export.mapper.OutStockAllotInfoMapper; +import com.ruoyi.out.export.domain.OutStockAllotInfo; +import com.ruoyi.out.export.service.IOutStockAllotInfoService; + +/** + * 出库任务导出Service业务层处理 + * + * @author ruoyi + * @date 2026-04-01 + */ +@Service +public class OutStockAllotInfoServiceImpl implements IOutStockAllotInfoService +{ + @Autowired + private OutStockAllotInfoMapper outStockAllotInfoMapper; + + /** + * 查询出库任务导出 + * + * @param id 出库任务导出主键 + * @return 出库任务导出 + */ + @Override + public OutStockAllotInfo selectOutStockAllotInfoById(Long id) + { + return outStockAllotInfoMapper.selectOutStockAllotInfoById(id); + } + + /** + * 查询出库任务导出列表 + * + * @param outStockAllotInfo 出库任务导出 + * @return 出库任务导出 + */ + @Override + public List selectOutStockAllotInfoList(OutStockAllotInfo outStockAllotInfo) + { + return outStockAllotInfoMapper.selectOutStockAllotInfoList(outStockAllotInfo); + } + + /** + * 新增出库任务导出 + * + * @param outStockAllotInfo 出库任务导出 + * @return 结果 + */ + @Override + public int insertOutStockAllotInfo(OutStockAllotInfo outStockAllotInfo) + { + return outStockAllotInfoMapper.insertOutStockAllotInfo(outStockAllotInfo); + } + + /** + * 修改出库任务导出 + * + * @param outStockAllotInfo 出库任务导出 + * @return 结果 + */ + @Override + public int updateOutStockAllotInfo(OutStockAllotInfo outStockAllotInfo) + { + return outStockAllotInfoMapper.updateOutStockAllotInfo(outStockAllotInfo); + } + + /** + * 批量删除出库任务导出 + * + * @param ids 需要删除的出库任务导出主键 + * @return 结果 + */ + @Override + public int deleteOutStockAllotInfoByIds(Long[] ids) + { + return outStockAllotInfoMapper.deleteOutStockAllotInfoByIds(ids); + } + + /** + * 删除出库任务导出信息 + * + * @param id 出库任务导出主键 + * @return 结果 + */ + @Override + public int deleteOutStockAllotInfoById(Long id) + { + return outStockAllotInfoMapper.deleteOutStockAllotInfoById(id); + } + + @Override + public int deleteInfoByJobId(String jobId) { + return outStockAllotInfoMapper.deleteInfoByJobId(jobId); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/controller/OutStockoutController.java b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/controller/OutStockoutController.java index cdb7e45..8c9c15a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/controller/OutStockoutController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/controller/OutStockoutController.java @@ -1,6 +1,7 @@ package com.ruoyi.out.outStockout.controller; import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; @@ -9,6 +10,9 @@ import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.out.export.domain.OutStockAllotInfo; +import com.ruoyi.out.export.service.IOutStockAllotInfoService; +import com.ruoyi.out.export.service.impl.OutStockAllotInfoServiceImpl; import com.ruoyi.out.outStockout.domain.OutJobExcel; import com.ruoyi.out.outStockout.domain.OutStockout; import com.ruoyi.out.outStockout.domain.OutStockoutVo; @@ -20,6 +24,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -35,6 +40,8 @@ public class OutStockoutController extends BaseController { private IOutStockoutService outStockoutService; @Autowired private IOutStockoutFinishService outStockoutFinishService; + @Autowired + private IOutStockAllotInfoService outStockAllotInfoService; /** * 查询出库主单列表 @@ -71,9 +78,16 @@ public class OutStockoutController extends BaseController { @Log(title = "出库任务导出", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, OutStockout outStockout) { - List list = outStockoutService.exportOutJob(outStockout.getStockoutId()); - ExcelUtil util = new ExcelUtil(OutJobExcel.class); - util.exportExcel(response, list, "出库任务"); + OutStockAllotInfo outStockAllotInfo = new OutStockAllotInfo(); + outStockAllotInfo.setOutStockId(outStockout.getStockoutId()); + List list = outStockAllotInfoService.selectOutStockAllotInfoList(outStockAllotInfo); + OutStockout outStockout1 = outStockoutService.selectOutStockoutByStockoutId(outStockout.getStockoutId()); + StringBuilder title = new StringBuilder(); + title.append("出库人:").append(outStockout1.getCreateManName()).append(" "); + title.append("创建时间:").append(DateUtil.format(new Date(), "yyyy-MM-dd")).append(" "); + title.append("领料人:").append(outStockout1.getClassNowId()).append(" "); + ExcelUtil util = new ExcelUtil(OutStockAllotInfo.class); + util.exportExcel(response, list, "出库任务",title.toString()); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/domain/OutJobExcel.java b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/domain/OutJobExcel.java index 9236f16..922dbf9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/domain/OutJobExcel.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/domain/OutJobExcel.java @@ -9,30 +9,20 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class OutJobExcel { - - @Excel(name = "台次") - private String spare5; - @Excel(name = "合同号") - private String spare6; - @Excel(name = "产品号") - private String spare7; @Excel(name = "代号") private String spare9; - @Excel(name = "存货编码") - private String productId; - @Excel(name = "存货名称") - private String productName; - @Excel(name = "托盘条码") - private String trayCode; + @Excel(name = "物料名称") + private String spare1; + @Excel(name = "单重") + private String spare2; @Excel(name = "出库数量") private String outQuantity; - @Excel(name = "货位编码") + @Excel(name = "托盘条码") + private String trayCode; + @Excel(name = "存放位置") + private String spare8; private String cargoSpaceId; - @Excel(name = "货位名称") private String cargoSpaceName; - @Excel(name = "规格") - private String spec; - @Excel(name = "单位") - private String unit; - + @Excel(name = "台次") + private String spare5; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/mapper/OutStockoutMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/mapper/OutStockoutMapper.java index c5c4496..604f9b0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/mapper/OutStockoutMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/mapper/OutStockoutMapper.java @@ -68,4 +68,6 @@ public interface OutStockoutMapper OutStockout selectOutStockoutByStockoutId(String stockoutId); void manualAllot(HashMap map); + + void autoAllotPk(HashMap map); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/service/IOutStockoutService.java b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/service/IOutStockoutService.java index bf70c06..059fa9a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/service/IOutStockoutService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/service/IOutStockoutService.java @@ -75,5 +75,6 @@ public interface IOutStockoutService AjaxResult manualAllot(String[] stockList,String stockoutDetailId); - List exportOutJob(String stockoutId); + + OutStockout selectOutStockoutByStockoutId(String stockoutId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/service/impl/OutStockoutServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/service/impl/OutStockoutServiceImpl.java index 0a4fa9f..05bb4b3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/service/impl/OutStockoutServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockout/service/impl/OutStockoutServiceImpl.java @@ -1,9 +1,12 @@ package com.ruoyi.out.outStockout.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.ruoyi.api.service.IToWcsService; import com.ruoyi.bas.basJobId.service.IBasJobIdService; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.uuid.UUID; @@ -24,9 +27,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; +import java.util.*; /** * 出库主单Service业务层处理 @@ -73,6 +74,26 @@ public class OutStockoutServiceImpl implements IOutStockoutService { /*if (!"admin".equals(SecurityUtils.getUsername())){ outStockout.setDepartmentNo(Convert.toStr(SecurityUtils.getDeptId())); }*/ + if (!"admin".equals(SecurityUtils.getUsername())) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + List roles = loginUser.getUser().getRoles(); + if (CollUtil.isEmpty(roles)) { + //如果未设置角色 ,直接返回空列表 + return new ArrayList<>(); + } + //入库需要查看本部门任务 + Optional first = roles.stream().filter(x -> "role1".equals(x.getRoleKey()) || "role3".equals(x.getRoleKey())).findFirst(); + if (first.isPresent()) { + //二联合普通人员 + outStockout.setWarehouseId("02"); + } + Optional first1 = roles.stream().filter(x -> "role2".equals(x.getRoleKey()) || "role4".equals(x.getRoleKey())).findFirst(); + if (first1.isPresent()) { + //三联合普通人员 + outStockout.setWarehouseId("01"); + } + + } return outStockoutMapper.selectOutStockoutList(outStockout); } @@ -146,7 +167,7 @@ public class OutStockoutServiceImpl implements IOutStockoutService { } catch (Exception e) { log.error("入库单保存异常,无用户信息"); } -// outStockout.setWarehouseId("01"); + outStockout.setWarehouseId(detailList.get(0).getWarehouseId()); for (int i = 0; i < detailList.size(); i++) { OutStockoutDetail outStockoutDetail = detailList.get(i); outStockoutDetail.setStockoutDetailId(stockOutId + "-" + (i + 1)); @@ -195,14 +216,26 @@ public class OutStockoutServiceImpl implements IOutStockoutService { outStockoutDetail.setStockoutId(stockoutId); List outStockoutDetails = outStockoutDetailService.selectOutStockoutDetailList(outStockoutDetail); for (OutStockoutDetail detail : outStockoutDetails) { - if (detail.getAllotQuantity().compareTo(detail.getQuantity()) < 0) { - map.put("v_stockout_detail_id", detail.getStockoutDetailId()); - outStockoutMapper.autoAllot(map); - toWcsService.pushOutMydoJob(); - if (!"10".equals(map.get("v_result"))) { - stringBuilder.append(",").append(map.get("v_resultString")); + if ("1".equals(detail.getVoltage())){ + if (detail.getAllotQuantity().compareTo(detail.getQuantity()) < 0) { + map.put("v_stockout_detail_id", detail.getStockoutDetailId()); + outStockoutMapper.autoAllot(map); + //toWcsService.pushOutMydoJob(); + if (!"10".equals(map.get("v_result"))) { + stringBuilder.append(",").append(map.get("v_resultString")); + } + } + }else { + if (detail.getAllotQuantity().compareTo(detail.getQuantity()) < 0) { + map.put("v_stockout_detail_id", detail.getStockoutDetailId()); + outStockoutMapper.autoAllotPk(map); + //toWcsService.pushOutMydoJob(); + if (!"10".equals(map.get("v_result"))) { + stringBuilder.append(",").append(map.get("v_resultString")); + } } } + } if (!StrUtil.isEmpty(stringBuilder.toString())) { return AjaxResult.warn(stringBuilder.toString()); @@ -235,7 +268,8 @@ public class OutStockoutServiceImpl implements IOutStockoutService { } @Override - public List exportOutJob(String stockoutId) { - return mydoJobService.exportOutJob(stockoutId); + public OutStockout selectOutStockoutByStockoutId(String stockoutId) { + return outStockoutMapper.selectOutStockoutByStockoutId(stockoutId); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockoutFinish/service/impl/OutStockoutFinishServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockoutFinish/service/impl/OutStockoutFinishServiceImpl.java index d73ed10..be552a6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/out/outStockoutFinish/service/impl/OutStockoutFinishServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/outStockoutFinish/service/impl/OutStockoutFinishServiceImpl.java @@ -1,5 +1,9 @@ package com.ruoyi.out.outStockoutFinish.service.impl; +import cn.hutool.core.collection.CollUtil; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.out.outStockout.domain.OutStockout; import com.ruoyi.out.outStockoutFinish.domain.OutStockoutFinish; import com.ruoyi.out.outStockoutFinish.mapper.OutStockoutFinishMapper; @@ -7,7 +11,9 @@ import com.ruoyi.out.outStockoutFinish.service.IOutStockoutFinishService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; /** * 出库单据完成表Service业务层处理 @@ -95,6 +101,26 @@ public class OutStockoutFinishServiceImpl implements IOutStockoutFinishService @Override public List selectOutStockoutFinishListByOutStockout(OutStockout outStockout) { + if (!"admin".equals(SecurityUtils.getUsername())) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + List roles = loginUser.getUser().getRoles(); + if (CollUtil.isEmpty(roles)) { + //如果未设置角色 ,直接返回空列表 + return new ArrayList<>(); + } + //入库需要查看本部门任务 + Optional first = roles.stream().filter(x -> "role1".equals(x.getRoleKey()) || "role3".equals(x.getRoleKey())).findFirst(); + if (first.isPresent()) { + //二联合普通人员 + outStockout.setWarehouseId("02"); + } + Optional first1 = roles.stream().filter(x -> "role2".equals(x.getRoleKey()) || "role4".equals(x.getRoleKey())).findFirst(); + if (first1.isPresent()) { + //三联合普通人员 + outStockout.setWarehouseId("01"); + } + + } return outStockoutFinishMapper.selectOutStockoutFinishListByOutStockout(outStockout); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/productAndStock/domain/ViewProductAndStock.java b/ruoyi-admin/src/main/java/com/ruoyi/out/productAndStock/domain/ViewProductAndStock.java index 7f655c3..6540ed3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/out/productAndStock/domain/ViewProductAndStock.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/productAndStock/domain/ViewProductAndStock.java @@ -7,7 +7,7 @@ import com.ruoyi.common.core.domain.BaseEntity; /** * 库存物资对象 view_product_and_stock - * + * * @author ruoyi * @date 2026-03-25 */ @@ -67,132 +67,142 @@ public class ViewProductAndStock extends BaseEntity @Excel(name = "部门") private String model; - public void setOnlyIdentity(Long onlyIdentity) + private String voltage; + + public String getVoltage() { + return voltage; + } + + public void setVoltage(String voltage) { + this.voltage = voltage; + } + + public void setOnlyIdentity(Long onlyIdentity) { this.onlyIdentity = onlyIdentity; } - public Long getOnlyIdentity() + public Long getOnlyIdentity() { return onlyIdentity; } - public void setProductId(String productId) + public void setProductId(String productId) { this.productId = productId; } - public String getProductId() + public String getProductId() { return productId; } - public void setProductName(String productName) + public void setProductName(String productName) { this.productName = productName; } - public String getProductName() + public String getProductName() { return productName; } - public void setQuantity(String quantity) + public void setQuantity(String quantity) { this.quantity = quantity; } - public String getQuantity() + public String getQuantity() { return quantity; } - public void setWarehouseId(String warehouseId) + public void setWarehouseId(String warehouseId) { this.warehouseId = warehouseId; } - public String getWarehouseId() + public String getWarehouseId() { return warehouseId; } - public void setOrderId(String orderId) + public void setOrderId(String orderId) { this.orderId = orderId; } - public String getOrderId() + public String getOrderId() { return orderId; } - public void setPower(String power) + public void setPower(String power) { this.power = power; } - public String getPower() + public String getPower() { return power; } - public void setDistribution(String distribution) + public void setDistribution(String distribution) { this.distribution = distribution; } - public String getDistribution() + public String getDistribution() { return distribution; } - public void setSpare5(String spare5) + public void setSpare5(String spare5) { this.spare5 = spare5; } - public String getSpare5() + public String getSpare5() { return spare5; } - public void setNetWeight(String netWeight) + public void setNetWeight(String netWeight) { this.netWeight = netWeight; } - public String getNetWeight() + public String getNetWeight() { return netWeight; } - public void setGrossWeight(String grossWeight) + public void setGrossWeight(String grossWeight) { this.grossWeight = grossWeight; } - public String getGrossWeight() + public String getGrossWeight() { return grossWeight; } - public void setPhase(String phase) + public void setPhase(String phase) { this.phase = phase; } - public String getPhase() + public String getPhase() { return phase; } - public void setModel(String model) + public void setModel(String model) { this.model = model; } - public String getModel() + public String getModel() { return model; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/out/productAndStock/service/impl/ViewProductAndStockServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/out/productAndStock/service/impl/ViewProductAndStockServiceImpl.java index 031de49..6c10fae 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/out/productAndStock/service/impl/ViewProductAndStockServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/out/productAndStock/service/impl/ViewProductAndStockServiceImpl.java @@ -1,27 +1,35 @@ package com.ruoyi.out.productAndStock.service.impl; -import java.util.List; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.out.productAndStock.domain.ViewProductAndStock; +import com.ruoyi.out.productAndStock.mapper.ViewProductAndStockMapper; +import com.ruoyi.out.productAndStock.service.IViewProductAndStockService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.out.productAndStock.mapper.ViewProductAndStockMapper; -import com.ruoyi.out.productAndStock.domain.ViewProductAndStock; -import com.ruoyi.out.productAndStock.service.IViewProductAndStockService; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; /** * 库存物资Service业务层处理 - * + * * @author ruoyi * @date 2026-03-25 */ @Service -public class ViewProductAndStockServiceImpl implements IViewProductAndStockService +public class ViewProductAndStockServiceImpl implements IViewProductAndStockService { @Autowired private ViewProductAndStockMapper viewProductAndStockMapper; /** * 查询库存物资 - * + * * @param onlyIdentity 库存物资主键 * @return 库存物资 */ @@ -33,19 +41,51 @@ public class ViewProductAndStockServiceImpl implements IViewProductAndStockServi /** * 查询库存物资列表 - * + * * @param viewProductAndStock 库存物资 * @return 库存物资 */ @Override - public List selectViewProductAndStockList(ViewProductAndStock viewProductAndStock) - { + public List selectViewProductAndStockList(ViewProductAndStock viewProductAndStock) { + if (!"admin".equals(SecurityUtils.getUsername())) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + List roles = loginUser.getUser().getRoles(); + if (CollUtil.isEmpty(roles)) { + //如果未设置角色 ,直接返回空列表 + return new ArrayList<>(); + } + //入库需要查看本部门任务 + Optional first = roles.stream().filter(x -> "role1".equals(x.getRoleKey())).findFirst(); + if (first.isPresent()) { + //二联合普通人员 + viewProductAndStock.setWarehouseId("02"); + viewProductAndStock.setModel(SecurityUtils.getDeptId().toString()); + } + Optional first1 = roles.stream().filter(x -> "role2".equals(x.getRoleKey())).findFirst(); + if (first1.isPresent()) { + //三联合普通人员 + viewProductAndStock.setWarehouseId("01"); + viewProductAndStock.setModel(SecurityUtils.getDeptId().toString()); + + + } + Optional first2 = roles.stream().filter(x -> "role3".equals(x.getRoleKey())).findFirst(); + if (first2.isPresent()) { + //二联合管理员 + viewProductAndStock.setWarehouseId("02"); + } + Optional first3 = roles.stream().filter(x -> "role4".equals(x.getRoleKey())).findFirst(); + if (first3.isPresent()) { + //三联合管理员 + viewProductAndStock.setWarehouseId("01"); + } + } return viewProductAndStockMapper.selectViewProductAndStockList(viewProductAndStock); } /** * 新增库存物资 - * + * * @param viewProductAndStock 库存物资 * @return 结果 */ @@ -57,7 +97,7 @@ public class ViewProductAndStockServiceImpl implements IViewProductAndStockServi /** * 修改库存物资 - * + * * @param viewProductAndStock 库存物资 * @return 结果 */ @@ -69,7 +109,7 @@ public class ViewProductAndStockServiceImpl implements IViewProductAndStockServi /** * 批量删除库存物资 - * + * * @param onlyIdentitys 需要删除的库存物资主键 * @return 结果 */ @@ -81,7 +121,7 @@ public class ViewProductAndStockServiceImpl implements IViewProductAndStockServi /** * 删除库存物资信息 - * + * * @param onlyIdentity 库存物资主键 * @return 结果 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewInJobFlow/domain/ViewInJobFlow.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewInJobFlow/domain/ViewInJobFlow.java index 9c6b1f2..2d51407 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewInJobFlow/domain/ViewInJobFlow.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewInJobFlow/domain/ViewInJobFlow.java @@ -14,646 +14,295 @@ import com.ruoyi.common.core.domain.BaseEntity; public class ViewInJobFlow extends BaseEntity { private static final long serialVersionUID = 1L; + /** 仓库编码 */ - @Excel(name = "仓库编码") + @Excel(name = "仓库编码", sort = 1) private String warehouseId; /** 子任务编码 */ - @Excel(name = "子任务编码") + @Excel(name = "子任务编码", sort = 22) private String jobDetailId; /** 任务编码 */ - @Excel(name = "任务编码") + @Excel(name = "任务编码", sort = 9) private String jobId; + /** 主单 */ - @Excel(name = "主单") + @Excel(name = "主单据", sort = 20) private String inOrOutId; /** 子单 */ - @Excel(name = "子单") + @Excel(name = "子单据", sort = 21) private String inOrOutDId; /** 任务号 */ - @Excel(name = "任务号") + @Excel(name = "任务号", sort = 12) private String taskNo; /** 状态 */ - @Excel(name = "状态",dictType = "mydo_job_status") + @Excel(name = "状态", sort = 11, dictType = "mydo_job_status") private String status; /** 任务类型 */ - @Excel(name = "任务类型",dictType = "job_type") + @Excel(name = "任务类型", sort = 10, dictType = "job_type") private Long inOrOut; - - - - /** 入口 */ - //@Excel(name = "入口") private String entranceId; /** 合同号 */ - @Excel(name = "合同号") + @Excel(name = "合同号", sort = 13) private String contract; + /** 产品号 */ - @Excel(name = "产品号") + @Excel(name = "产品号", sort = 2) private String cases; + /** 代号 */ - @Excel(name = "代号") + @Excel(name = "代号", sort = 3) private String managementNo; + /** 台次 */ - @Excel(name = "台次") + @Excel(name = "台次", sort = 16) private String units; + /** 托盘条码 */ - @Excel(name = "托盘条码") + @Excel(name = "托盘条码", sort = 6) private String trayCode; - @Excel(name = "部门") + + @Excel(name = "部门", sort = 8) private String deptName; -// @Excel(name = "货位") + private String cargoSpaceId; - @Excel(name = "货位名称") + + @Excel(name = "货位名称", sort = 7) private String cargoSpaceName; /** 物料编码 */ - @Excel(name = "物料编码") private String productId; /** 物料名称 */ - @Excel(name = "物料名称") + @Excel(name = "物料名称", sort = 4) private String productName; + /** 规格 */ - @Excel(name = "规格") private String spec; + /** 入库数量 */ - @Excel(name = "数量") + @Excel(name = "数量", sort = 5) private String quantity; + /** 开始时间 */ - @Excel(name = "开始时间") + @Excel(name = "开始时间", sort = 18) private String startTime; /** 结束时间 */ - @Excel(name = "结束时间") + @Excel(name = "结束时间", sort = 19) private String finishTime; + /** 常用码 */ - //@Excel(name = "常用码") private String parentId; /** 单价 */ - //@Excel(name = "单价") private String price; /** 图号 */ - //@Excel(name = "图号") private String cargoNo; /** 单位 */ - //@Excel(name = "单位") private String unit; - - /** 物料类型 */ - //@Excel(name = "物料类型",dictType = "product_type") private String productType; /** 是否系统项 */ - //@Excel(name = "是否系统项",dictType = "sys_yes_no") private String systemItem; /** 创建时间 */ - // @Excel(name = "创建时间") + @Excel(name = "创建时间", sort = 17) private String productCtm; /** 创建人 */ - //@Excel(name = "创建人") private String productCtu; /** 库存上限 */ - //@Excel(name = "库存上限") private String upperNum; /** 库存下限 */ - //@Excel(name = "库存下限") private String limitNum; /** 是否启用 */ - //@Excel(name = "是否启用",dictType = "sys_yes_no") private String enableFlag; - - /** 批次号 */ - //@Excel(name = "批次号") private String lotNo; - - /** 入库金额 */ - //@Excel(name = "入库金额") private String priceTotal; /** 来源 */ - //@Excel(name = "来源",dictType = "origin_type") private String origin; /** 周转类型 */ - // @Excel(name = "周转类型",dictType = "turnover_type") + @Excel(name = "单重", sort = 15) private String turnovertype; /** 套账 */ - // @Excel(name = "套账",dictType = "account_type") + @Excel(name = "路线", sort = 14) private String account; /** 用途 */ - //@Excel(name = "用途",dictType = "purpose_type") private String purpose; - - - - - /** 质量 */ - //@Excel(name = "质量",dictType = "quality_type") private String quality; private String departmentId; - private String dateStart; private String dateEnd; - - - public String getDeptName() { - return deptName; - } - - public void setDeptName(String deptName) { - this.deptName = deptName; - } - - public String getCargoSpaceName() { - return cargoSpaceName; - } - - public void setCargoSpaceName(String cargoSpaceName) { - this.cargoSpaceName = cargoSpaceName; - } - - public String getCargoSpaceId() { - return cargoSpaceId; - } - - public void setCargoSpaceId(String cargoSpaceId) { - this.cargoSpaceId = cargoSpaceId; - } - - - public String getDateStart() { - return dateStart; - } - - public void setDateStart(String dateStart) { - this.dateStart = dateStart; - } - - public String getDateEnd() { - return dateEnd; - } - - public void setDateEnd(String dateEnd) { - this.dateEnd = dateEnd; - } - - public String getDepartmentId() { - return departmentId; - } - - public void setDepartmentId(String departmentId) { - this.departmentId = departmentId; - } - - public void setJobDetailId(String jobDetailId) - { - this.jobDetailId = jobDetailId; - } - - public String getJobDetailId() - { - return jobDetailId; - } - - public void setJobId(String jobId) - { - this.jobId = jobId; - } - - public String getJobId() - { - return jobId; - } - - public void setTaskNo(String taskNo) - { - this.taskNo = taskNo; - } - - public String getTaskNo() - { - return taskNo; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - - public void setInOrOut(Long inOrOut) - { - this.inOrOut = inOrOut; - } - - public Long getInOrOut() - { - return inOrOut; - } - - public void setTrayCode(String trayCode) - { - this.trayCode = trayCode; - } - - public String getTrayCode() - { - return trayCode; - } - - public void setStartTime(String startTime) - { - this.startTime = startTime; - } - - public String getStartTime() - { - return startTime; - } - - public void setFinishTime(String finishTime) - { - this.finishTime = finishTime; - } - - public String getFinishTime() - { - return finishTime; - } - - public void setEntranceId(String entranceId) - { - this.entranceId = entranceId; - } - - public String getEntranceId() - { - return entranceId; - } - - public void setWarehouseId(String warehouseId) - { - this.warehouseId = warehouseId; - } - - public String getWarehouseId() - { - return warehouseId; - } - - public void setProductId(String productId) - { - this.productId = productId; - } - - public String getProductId() - { - return productId; - } - - public void setProductName(String productName) - { - this.productName = productName; - } - - public String getProductName() - { - return productName; - } - - public void setParentId(String parentId) - { - this.parentId = parentId; - } - - public String getParentId() - { - return parentId; - } - - public void setPrice(String price) - { - this.price = price; - } - - public String getPrice() - { - return price; - } - - public void setCargoNo(String cargoNo) - { - this.cargoNo = cargoNo; - } - - public String getCargoNo() - { - return cargoNo; - } - - public void setUnit(String unit) - { - this.unit = unit; - } - - public String getUnit() - { - return unit; - } - - public void setSpec(String spec) - { - this.spec = spec; - } - - public String getSpec() - { - return spec; - } - - public void setProductType(String productType) - { - this.productType = productType; - } - - public String getProductType() - { - return productType; - } - - public void setSystemItem(String systemItem) - { - this.systemItem = systemItem; - } - - public String getSystemItem() - { - return systemItem; - } - - public void setProductCtm(String productCtm) - { - this.productCtm = productCtm; - } - - public String getProductCtm() - { - return productCtm; - } - - public void setProductCtu(String productCtu) - { - this.productCtu = productCtu; - } - - public String getProductCtu() - { - return productCtu; - } - - public void setUpperNum(String upperNum) - { - this.upperNum = upperNum; - } - - public String getUpperNum() - { - return upperNum; - } - - public void setLimitNum(String limitNum) - { - this.limitNum = limitNum; - } - - public String getLimitNum() - { - return limitNum; - } - - public void setEnableFlag(String enableFlag) - { - this.enableFlag = enableFlag; - } - - public String getEnableFlag() - { - return enableFlag; - } - - public String getQuantity() { - return quantity; - } - - public void setQuantity(String quantity) { - this.quantity = quantity; - } - - public void setLotNo(String lotNo) - { - this.lotNo = lotNo; - } - - public String getLotNo() - { - return lotNo; - } - - public void setInOrOutId(String inOrOutId) - { - this.inOrOutId = inOrOutId; - } - - public String getInOrOutId() - { - return inOrOutId; - } - - public void setInOrOutDId(String inOrOutDId) - { - this.inOrOutDId = inOrOutDId; - } - - public String getInOrOutDId() - { - return inOrOutDId; - } - - public void setPriceTotal(String priceTotal) - { - this.priceTotal = priceTotal; - } - - public String getPriceTotal() - { - return priceTotal; - } - - public void setOrigin(String origin) - { - this.origin = origin; - } - - public String getOrigin() - { - return origin; - } - - public void setTurnovertype(String turnovertype) - { - this.turnovertype = turnovertype; - } - - public String getTurnovertype() - { - return turnovertype; - } - - public void setAccount(String account) - { - this.account = account; - } - - public String getAccount() - { - return account; - } - - public void setPurpose(String purpose) - { - this.purpose = purpose; - } - - public String getPurpose() - { - return purpose; - } - - public void setUnits(String units) - { - this.units = units; - } - - public String getUnits() - { - return units; - } - - public void setContract(String contract) - { - this.contract = contract; - } - - public String getContract() - { - return contract; - } - - public void setCases(String cases) - { - this.cases = cases; - } - - public String getCases() - { - return cases; - } - - public void setQuality(String quality) - { - this.quality = quality; - } - - public String getQuality() - { - return quality; - } - - public void setManagementNo(String managementNo) - { - this.managementNo = managementNo; - } - - public String getManagementNo() - { - return managementNo; - } + private String classId; + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + // ==================== getter/setter/toString 保持不变 ==================== + public String getDeptName() { return deptName; } + public void setDeptName(String deptName) { this.deptName = deptName; } + public String getCargoSpaceName() { return cargoSpaceName; } + public void setCargoSpaceName(String cargoSpaceName) { this.cargoSpaceName = cargoSpaceName; } + public String getCargoSpaceId() { return cargoSpaceId; } + public void setCargoSpaceId(String cargoSpaceId) { this.cargoSpaceId = cargoSpaceId; } + public String getDateStart() { return dateStart; } + public void setDateStart(String dateStart) { this.dateStart = dateStart; } + public String getDateEnd() { return dateEnd; } + public void setDateEnd(String dateEnd) { this.dateEnd = dateEnd; } + public String getDepartmentId() { return departmentId; } + public void setDepartmentId(String departmentId) { this.departmentId = departmentId; } + public void setJobDetailId(String jobDetailId) { this.jobDetailId = jobDetailId; } + public String getJobDetailId() { return jobDetailId; } + public void setJobId(String jobId) { this.jobId = jobId; } + public String getJobId() { return jobId; } + public void setTaskNo(String taskNo) { this.taskNo = taskNo; } + public String getTaskNo() { return taskNo; } + public void setStatus(String status) { this.status = status; } + public String getStatus() { return status; } + public void setInOrOut(Long inOrOut) { this.inOrOut = inOrOut; } + public Long getInOrOut() { return inOrOut; } + public void setTrayCode(String trayCode) { this.trayCode = trayCode; } + public String getTrayCode() { return trayCode; } + public void setStartTime(String startTime) { this.startTime = startTime; } + public String getStartTime() { return startTime; } + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } + public String getFinishTime() { return finishTime; } + public void setEntranceId(String entranceId) { this.entranceId = entranceId; } + public String getEntranceId() { return entranceId; } + public void setWarehouseId(String warehouseId) { this.warehouseId = warehouseId; } + public String getWarehouseId() { return warehouseId; } + public void setProductId(String productId) { this.productId = productId; } + public String getProductId() { return productId; } + public void setProductName(String productName) { this.productName = productName; } + public String getProductName() { return productName; } + public void setParentId(String parentId) { this.parentId = parentId; } + public String getParentId() { return parentId; } + public void setPrice(String price) { this.price = price; } + public String getPrice() { return price; } + public void setCargoNo(String cargoNo) { this.cargoNo = cargoNo; } + public String getCargoNo() { return cargoNo; } + public void setUnit(String unit) { this.unit = unit; } + public String getUnit() { return unit; } + public void setSpec(String spec) { this.spec = spec; } + public String getSpec() { return spec; } + public void setProductType(String productType) { this.productType = productType; } + public String getProductType() { return productType; } + public void setSystemItem(String systemItem) { this.systemItem = systemItem; } + public String getSystemItem() { return systemItem; } + public void setProductCtm(String productCtm) { this.productCtm = productCtm; } + public String getProductCtm() { return productCtm; } + public void setProductCtu(String productCtu) { this.productCtu = productCtu; } + public String getProductCtu() { return productCtu; } + public void setUpperNum(String upperNum) { this.upperNum = upperNum; } + public String getUpperNum() { return upperNum; } + public void setLimitNum(String limitNum) { this.limitNum = limitNum; } + public String getLimitNum() { return limitNum; } + public void setEnableFlag(String enableFlag) { this.enableFlag = enableFlag; } + public String getEnableFlag() { return enableFlag; } + public String getQuantity() { return quantity; } + public void setQuantity(String quantity) { this.quantity = quantity; } + public void setLotNo(String lotNo) { this.lotNo = lotNo; } + public String getLotNo() { return lotNo; } + public void setInOrOutId(String inOrOutId) { this.inOrOutId = inOrOutId; } + public String getInOrOutId() { return inOrOutId; } + public void setInOrOutDId(String inOrOutDId) { this.inOrOutDId = inOrOutDId; } + public String getInOrOutDId() { return inOrOutDId; } + public void setPriceTotal(String priceTotal) { this.priceTotal = priceTotal; } + public String getPriceTotal() { return priceTotal; } + public void setOrigin(String origin) { this.origin = origin; } + public String getOrigin() { return origin; } + public void setTurnovertype(String turnovertype) { this.turnovertype = turnovertype; } + public String getTurnovertype() { return turnovertype; } + public void setAccount(String account) { this.account = account; } + public String getAccount() { return account; } + public void setPurpose(String purpose) { this.purpose = purpose; } + public String getPurpose() { return purpose; } + public void setUnits(String units) { this.units = units; } + public String getUnits() { return units; } + public void setContract(String contract) { this.contract = contract; } + public String getContract() { return contract; } + public void setCases(String cases) { this.cases = cases; } + public String getCases() { return cases; } + public void setQuality(String quality) { this.quality = quality; } + public String getQuality() { return quality; } + public void setManagementNo(String managementNo) { this.managementNo = managementNo; } + public String getManagementNo() { return managementNo; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobDetailId", getJobDetailId()) - .append("jobId", getJobId()) - .append("taskNo", getTaskNo()) - .append("status", getStatus()) - .append("inOrOut", getInOrOut()) - .append("trayCode", getTrayCode()) - .append("createTime", getCreateTime()) - .append("startTime", getStartTime()) - .append("finishTime", getFinishTime()) - .append("entranceId", getEntranceId()) - .append("warehouseId", getWarehouseId()) - .append("productId", getProductId()) - .append("productName", getProductName()) - .append("parentId", getParentId()) - .append("price", getPrice()) - .append("cargoNo", getCargoNo()) - .append("unit", getUnit()) - .append("spec", getSpec()) - .append("remark", getRemark()) - .append("productType", getProductType()) - .append("systemItem", getSystemItem()) - .append("productCtm", getProductCtm()) - .append("productCtu", getProductCtu()) - .append("upperNum", getUpperNum()) - .append("limitNum", getLimitNum()) - .append("enableFlag", getEnableFlag()) - .append("quantity", getQuantity()) - .append("lotNo", getLotNo()) - .append("inOrOutId", getInOrOutId()) - .append("inOrOutDId", getInOrOutDId()) - .append("priceTotal", getPriceTotal()) - .append("origin", getOrigin()) - .append("turnovertype", getTurnovertype()) - .append("account", getAccount()) - .append("purpose", getPurpose()) - .append("units", getUnits()) - .append("contract", getContract()) - .append("cases", getCases()) - .append("quality", getQuality()) - .append("managementNo", getManagementNo()) - .toString(); + .append("jobDetailId", getJobDetailId()) + .append("jobId", getJobId()) + .append("taskNo", getTaskNo()) + .append("status", getStatus()) + .append("inOrOut", getInOrOut()) + .append("trayCode", getTrayCode()) + .append("createTime", getCreateTime()) + .append("startTime", getStartTime()) + .append("finishTime", getFinishTime()) + .append("entranceId", getEntranceId()) + .append("warehouseId", getWarehouseId()) + .append("productId", getProductId()) + .append("productName", getProductName()) + .append("parentId", getParentId()) + .append("price", getPrice()) + .append("cargoNo", getCargoNo()) + .append("unit", getUnit()) + .append("spec", getSpec()) + .append("remark", getRemark()) + .append("productType", getProductType()) + .append("systemItem", getSystemItem()) + .append("productCtm", getProductCtm()) + .append("productCtu", getProductCtu()) + .append("upperNum", getUpperNum()) + .append("limitNum", getLimitNum()) + .append("enableFlag", getEnableFlag()) + .append("quantity", getQuantity()) + .append("lotNo", getLotNo()) + .append("inOrOutId", getInOrOutId()) + .append("inOrOutDId", getInOrOutDId()) + .append("priceTotal", getPriceTotal()) + .append("origin", getOrigin()) + .append("turnovertype", getTurnovertype()) + .append("account", getAccount()) + .append("purpose", getPurpose()) + .append("units", getUnits()) + .append("contract", getContract()) + .append("cases", getCases()) + .append("quality", getQuality()) + .append("managementNo", getManagementNo()) + .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockDetail/domain/ViewStockDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockDetail/domain/ViewStockDetail.java index db2eb2e..182ab17 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockDetail/domain/ViewStockDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockDetail/domain/ViewStockDetail.java @@ -25,117 +25,76 @@ import java.util.Date; public class ViewStockDetail extends BaseEntity { private static final long serialVersionUID = 1L; - @Excel(name = "仓库名称") - private String warehouseName; // 仓库名称 - @Excel(name = "库存编码") - private String stockId; // 库存编码 - @Excel(name = "库位编码") - private String cargoSpaceId; // 库位编码 - @Excel(name = "托盘") - private String trayCode; // 托盘 - @Excel(name = "库存状态") - private String stockStatus; // 库存状态 - @Excel(name = "合同号") - private String orderId; // 合同号 - @Excel(name = "产品号") - private String power; // 产品号 - @Excel(name = "代号") + + // 1 仓库名称 + @Excel(name = "仓库名称",sort = 1) + private String warehouseName; + + private String cargoSpaceId; + + // 2 产品号 + @Excel(name = "产品号",sort = 2) + private String power; + + // 3 代号 + @Excel(name = "代号",sort = 3) private String distribution; - @Excel(name = "台次") - private String spare5; // 台次 - @Excel(name = "物料编码") - private String productId; // 产品编码 - @Excel(name = "物料名称") - private String productName; // 产品名称 + private String productId; + // 4 物料名称 + @Excel(name = "物料名称",sort = 4) + private String productName; -// @Excel(name = "账套",dictType = "account_type") - private String spare3; // 账套 + private String spare3; + // 5 路线 + @Excel(name = "路线",sort = 5) + private String grossWeight; + // 6 单重 + @Excel(name = "单重",sort = 6) + private String netWeight; + private String phase; + private String spec; + // 7 数量 + @Excel(name = "数量",sort = 7) + private BigDecimal quantity; + private String spare6; + private BigDecimal price; + private String spare1; + private String unit; + private String cargoNo; + private String parentId; + private String stockinId; + private String supplierName; + private String supplierNo; + private String warehouseId; - - @Excel(name = "规格") - private String spec; // 规格 - - @Excel(name = "数量") - private BigDecimal quantity; // 数量 - -// @Excel(name = "金额") - private String spare6; // 金额 - -// @Excel(name = "单价") - private BigDecimal price; // 单价 - -// @Excel(name = "产品状态",dictType = "turnover_type") - private String spare1; // 产品状态 - -// @Excel(name = "单位") - private String unit; // 单位 - -// @Excel(name = "图号") - private String cargoNo; // 图号 - - - - - - - -// @Excel(name = "质量",dictType = "quality_type") - private String spare8; // 质量 - -// @Excel(name = "常用编码") - private String parentId; // 常用编码 - -// @Excel(name = "入库单号") - private String stockinId; // 入库单号 - -// @Excel(name = "供应商名称") - private String supplierName; // 供应商名称 - -// @Excel(name = "供应商编号") - private String supplierNo; // 供应商编号 - -// @Excel(name = "仓库编码") - private String warehouseId; // 仓库编码 - - - - @Excel(name = "首次入库时间") + // 14 首次入库时间 + @Excel(name = "首次入库时间", sort = 14) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date inDate; // 入库时间 + private Date inDate; - @Excel(name = "最后出库时间") + // 15 最后出库时间 + @Excel(name = "最后出库时间", sort = 15) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date backDate; // 出库时间 + private Date backDate; - - - @Excel(name = "出库时间") + // 废弃:原stackingId命名错误 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date stackingId; // 盘点时间 - - @Excel(name = "盘点标识",dictType = "check_flag") - private String spare7; // 盘点标识 - -// @Excel(name = "备注") - private String remark; // 备注 - - - -// @Excel(name = "批次号") - private String lotNo; // 批次号 - - private BigDecimal outQuantity; // 出库数量 + private Date stackingId; + private String spare7; + private String remark; + private String lotNo; + private BigDecimal outQuantity; private String roadwayId; private String theFloor; private String thePlatoon; @@ -148,8 +107,33 @@ public class ViewStockDetail extends BaseEntity private String outside; private String spare4; private String model; + + // 13 部门 + @Excel(name = "部门",sort = 13) private String deptName; + // ==================== 按前端顺序补充的缺失字段 ==================== + // 8 台次 + @Excel(name = "台次",sort = 8) + private String spare5; + // 9 合同号 + @Excel(name = "合同号",sort = 9) + private String orderId; + // 10 托盘 + @Excel(name = "托盘",sort = 10) + private String trayCode; + + // 11 位置 + @Excel(name = "位置",sort = 11) + private String spare8; + + // 12 库存编码 + @Excel(name = "库存编码",sort = 12) + private String stockId; + + // 库存状态 + @Excel(name = "库存状态",sort = 16) + private String stockStatus; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/controller/ViewStockinHistoryController.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/controller/ViewStockinHistoryController.java index 41771d5..0a70804 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/controller/ViewStockinHistoryController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/controller/ViewStockinHistoryController.java @@ -25,7 +25,7 @@ import com.ruoyi.common.core.page.TableDataInfo; * 入库单据流水Controller * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-27 */ @RestController @RequestMapping("/search/ViewStockinHistory") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/domain/ViewStockinHistory.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/domain/ViewStockinHistory.java index 8477bee..e34b82f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/domain/ViewStockinHistory.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/domain/ViewStockinHistory.java @@ -9,124 +9,107 @@ import com.ruoyi.common.core.domain.BaseEntity; * 入库单据流水对象 view_stockin_history * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-27 */ public class ViewStockinHistory extends BaseEntity { private static final long serialVersionUID = 1L; - - /** 入库单号 */ - @Excel(name = "入库单号") - private String stockinId; - - /** 入库子单号 */ - @Excel(name = "入库子单号") - private String stockinDetailId; - - /** 物料编码 */ - @Excel(name = "物料编码") - private String productId; - + /** 产品号 */ + @Excel(name = "产品号") + private String spare7; + /** 代号 */ + @Excel(name = "代号") + private String spare9; /** 物料名称 */ @Excel(name = "物料名称") private String productName; - /** 规格型号 */ - @Excel(name = "规格型号") - private String spec; - - /** 生产图号 */ - @Excel(name = "生产图号") - private String cargoNo; - - /** 产品状态 */ - @Excel(name = "产品状态",dictType = "product_type") - private String productType; - /** 计划数量 */ @Excel(name = "计划数量") private String quantity; - /** 扫码数量 */ - @Excel(name = "扫码数量") - private String scanNum; - - /** 实际数量 */ - @Excel(name = "实际数量") + /** 入库数量 */ + @Excel(name = "入库数量") private String assignNum; - - /** 单位 */ - @Excel(name = "单位") - private String unit; - - /** 单价 */ - @Excel(name = "单价") - private String price; - - /** 单据金额 */ - @Excel(name = "单据金额") - private String priceTotal; - - /** 供应商代号 */ - @Excel(name = "供应商代号") - private String supplierNo; - - /** 供应商名称 */ - @Excel(name = "供应商名称") - private String supplierName; - - /** 合同号 */ - @Excel(name = "合同号") - private String spare6; - + /** 路线 */ + @Excel(name = "路线") + private String spare3; /** 台次 */ @Excel(name = "台次") private String spare5; - /** 件次 */ - @Excel(name = "件次") - private String spare7; + /** 单重 */ + @Excel(name = "单重") + private String spare4; - /** 账套 */ - @Excel(name = "账套",dictType = "account_type") - private String spare3; - /** 创建用户 */ - @Excel(name = "创建用户") - private String createManId; + /** 仓库id */ + //@Excel(name = "仓库id") + private String warehouseId; + + /** 部门id */ + //@Excel(name = "部门id") + private String departmentNo; + + /** 入库类型 */ + @Excel(name = "入库类型") + private String inType; + /** 供应商 */ + @Excel(name = "供应商") + private String supplierId; + /** 合同号 */ + @Excel(name = "合同号") + private String spare6; + /** 入库单据 */ + @Excel(name = "入库单据") + private String stockinId; + /** 入库子单 */ + @Excel(name = "入库子单") + private String stockinDetailId; + + + + + + + + + + + + + /** 物料编码 */ + //@Excel(name = "物料编码") + private String productId; + /** 创建时间 */ @Excel(name = "创建时间") private String createDate; - /** 单据状态 */ - @Excel(name = "单据状态",dictType = "in_bill_status") - private String status; - /** 质量 */ - @Excel(name = "质量",dictType = "quality_type") - private String spare8; + private String startTime; - /** 来源 */ - @Excel(name = "来源",dictType = "origin_type") - private String spare1; + private String endTime; - /** 用途 */ - @Excel(name = "用途",dictType = "purpose_type") - private String spare4; + /** 结束时间 */ + @Excel(name = "结束时间") + private String finishDate; - /** 状态 */ - @Excel(name = "状态",dictType = "turnover_type") - private String spare2; - @Excel(name = "代号") - private String spare9; - - public String getSpare9() { - return spare9; + public String getStartTime() { + return startTime; } - public void setSpare9(String spare9) { - this.spare9 = spare9; + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; } public void setStockinId(String stockinId) @@ -139,6 +122,36 @@ public class ViewStockinHistory extends BaseEntity return stockinId; } + public void setWarehouseId(String warehouseId) + { + this.warehouseId = warehouseId; + } + + public String getWarehouseId() + { + return warehouseId; + } + + public void setDepartmentNo(String departmentNo) + { + this.departmentNo = departmentNo; + } + + public String getDepartmentNo() + { + return departmentNo; + } + + public void setInType(String inType) + { + this.inType = inType; + } + + public String getInType() + { + return inType; + } + public void setStockinDetailId(String stockinDetailId) { this.stockinDetailId = stockinDetailId; @@ -149,6 +162,76 @@ public class ViewStockinHistory extends BaseEntity return stockinDetailId; } + public void setSpare6(String spare6) + { + this.spare6 = spare6; + } + + public String getSpare6() + { + return spare6; + } + + public void setSpare7(String spare7) + { + this.spare7 = spare7; + } + + public String getSpare7() + { + return spare7; + } + + public void setSpare9(String spare9) + { + this.spare9 = spare9; + } + + public String getSpare9() + { + return spare9; + } + + public void setSpare5(String spare5) + { + this.spare5 = spare5; + } + + public String getSpare5() + { + return spare5; + } + + public void setSpare4(String spare4) + { + this.spare4 = spare4; + } + + public String getSpare4() + { + return spare4; + } + + public void setSpare3(String spare3) + { + this.spare3 = spare3; + } + + public String getSpare3() + { + return spare3; + } + + public void setSupplierId(String supplierId) + { + this.supplierId = supplierId; + } + + public String getSupplierId() + { + return supplierId; + } + public void setProductId(String productId) { this.productId = productId; @@ -169,36 +252,6 @@ public class ViewStockinHistory extends BaseEntity return productName; } - public void setSpec(String spec) - { - this.spec = spec; - } - - public String getSpec() - { - return spec; - } - - public void setCargoNo(String cargoNo) - { - this.cargoNo = cargoNo; - } - - public String getCargoNo() - { - return cargoNo; - } - - public void setProductType(String productType) - { - this.productType = productType; - } - - public String getProductType() - { - return productType; - } - public void setQuantity(String quantity) { this.quantity = quantity; @@ -209,16 +262,6 @@ public class ViewStockinHistory extends BaseEntity return quantity; } - public void setScanNum(String scanNum) - { - this.scanNum = scanNum; - } - - public String getScanNum() - { - return scanNum; - } - public void setAssignNum(String assignNum) { this.assignNum = assignNum; @@ -229,106 +272,6 @@ public class ViewStockinHistory extends BaseEntity return assignNum; } - public void setUnit(String unit) - { - this.unit = unit; - } - - public String getUnit() - { - return unit; - } - - public void setPrice(String price) - { - this.price = price; - } - - public String getPrice() - { - return price; - } - - public void setPriceTotal(String priceTotal) - { - this.priceTotal = priceTotal; - } - - public String getPriceTotal() - { - return priceTotal; - } - - public void setSupplierNo(String supplierNo) - { - this.supplierNo = supplierNo; - } - - public String getSupplierNo() - { - return supplierNo; - } - - public void setSupplierName(String supplierName) - { - this.supplierName = supplierName; - } - - public String getSupplierName() - { - return supplierName; - } - - public void setSpare6(String spare6) - { - this.spare6 = spare6; - } - - public String getSpare6() - { - return spare6; - } - - public void setSpare5(String spare5) - { - this.spare5 = spare5; - } - - public String getSpare5() - { - return spare5; - } - - public void setSpare7(String spare7) - { - this.spare7 = spare7; - } - - public String getSpare7() - { - return spare7; - } - - public void setSpare3(String spare3) - { - this.spare3 = spare3; - } - - public String getSpare3() - { - return spare3; - } - - public void setCreateManId(String createManId) - { - this.createManId = createManId; - } - - public String getCreateManId() - { - return createManId; - } - public void setCreateDate(String createDate) { this.createDate = createDate; @@ -339,86 +282,38 @@ public class ViewStockinHistory extends BaseEntity return createDate; } - public void setStatus(String status) + public void setFinishDate(String finishDate) { - this.status = status; + this.finishDate = finishDate; } - public String getStatus() + public String getFinishDate() { - return status; - } - - public void setSpare8(String spare8) - { - this.spare8 = spare8; - } - - public String getSpare8() - { - return spare8; - } - - public void setSpare1(String spare1) - { - this.spare1 = spare1; - } - - public String getSpare1() - { - return spare1; - } - - public void setSpare4(String spare4) - { - this.spare4 = spare4; - } - - public String getSpare4() - { - return spare4; - } - - public void setSpare2(String spare2) - { - this.spare2 = spare2; - } - - public String getSpare2() - { - return spare2; + return finishDate; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("stockinId", getStockinId()) + .append("warehouseId", getWarehouseId()) + .append("departmentNo", getDepartmentNo()) + .append("inType", getInType()) .append("stockinDetailId", getStockinDetailId()) + .append("spare6", getSpare6()) + .append("spare7", getSpare7()) + .append("spare9", getSpare9()) + .append("spare5", getSpare5()) + .append("spare4", getSpare4()) + .append("spare3", getSpare3()) + .append("supplierId", getSupplierId()) .append("productId", getProductId()) .append("productName", getProductName()) - .append("spec", getSpec()) - .append("cargoNo", getCargoNo()) - .append("productType", getProductType()) .append("quantity", getQuantity()) - .append("scanNum", getScanNum()) .append("assignNum", getAssignNum()) - .append("unit", getUnit()) - .append("price", getPrice()) - .append("priceTotal", getPriceTotal()) - .append("supplierNo", getSupplierNo()) - .append("supplierName", getSupplierName()) - .append("spare6", getSpare6()) - .append("spare5", getSpare5()) - .append("spare7", getSpare7()) - .append("spare3", getSpare3()) - .append("createManId", getCreateManId()) .append("createDate", getCreateDate()) - .append("status", getStatus()) - .append("spare8", getSpare8()) + .append("finishDate", getFinishDate()) .append("remark", getRemark()) - .append("spare1", getSpare1()) - .append("spare4", getSpare4()) - .append("spare2", getSpare2()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/mapper/ViewStockinHistoryMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/mapper/ViewStockinHistoryMapper.java index 3bcb7f1..16a3c24 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/mapper/ViewStockinHistoryMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/mapper/ViewStockinHistoryMapper.java @@ -7,7 +7,7 @@ import com.ruoyi.search.ViewStockinHistory.domain.ViewStockinHistory; * 入库单据流水Mapper接口 * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-27 */ public interface ViewStockinHistoryMapper { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/service/IViewStockinHistoryService.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/service/IViewStockinHistoryService.java index 884f20f..947381b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/service/IViewStockinHistoryService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/service/IViewStockinHistoryService.java @@ -7,7 +7,7 @@ import com.ruoyi.search.ViewStockinHistory.domain.ViewStockinHistory; * 入库单据流水Service接口 * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-27 */ public interface IViewStockinHistoryService { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/service/impl/ViewStockinHistoryServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/service/impl/ViewStockinHistoryServiceImpl.java index 37e63cb..3e3058d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/service/impl/ViewStockinHistoryServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockinHistory/service/impl/ViewStockinHistoryServiceImpl.java @@ -1,6 +1,13 @@ package com.ruoyi.search.ViewStockinHistory.service.impl; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; + +import cn.hutool.core.collection.CollUtil; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.search.ViewStockinHistory.mapper.ViewStockinHistoryMapper; @@ -9,19 +16,19 @@ import com.ruoyi.search.ViewStockinHistory.service.IViewStockinHistoryService; /** * 入库单据流水Service业务层处理 - * + * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-27 */ @Service -public class ViewStockinHistoryServiceImpl implements IViewStockinHistoryService +public class ViewStockinHistoryServiceImpl implements IViewStockinHistoryService { @Autowired private ViewStockinHistoryMapper viewStockinHistoryMapper; /** * 查询入库单据流水 - * + * * @param stockinId 入库单据流水主键 * @return 入库单据流水 */ @@ -33,19 +40,37 @@ public class ViewStockinHistoryServiceImpl implements IViewStockinHistoryService /** * 查询入库单据流水列表 - * + * * @param viewStockinHistory 入库单据流水 * @return 入库单据流水 */ @Override public List selectViewStockinHistoryList(ViewStockinHistory viewStockinHistory) { + if (!"admin".equals(SecurityUtils.getUsername())){ + LoginUser loginUser = SecurityUtils.getLoginUser(); + List roles = loginUser.getUser().getRoles(); + if (CollUtil.isEmpty(roles)) { + //如果未设置角色 ,直接返回空列表 + return new ArrayList<>(); + } + Optional role1 = roles.stream().filter(x -> "role1".equals(x.getRoleKey())).findFirst(); + Optional role2 = roles.stream().filter(x -> "role2".equals(x.getRoleKey())).findFirst(); + Optional role3 = roles.stream().filter(x -> "role3".equals(x.getRoleKey())).findFirst(); + Optional role4 = roles.stream().filter(x -> "role4".equals(x.getRoleKey())).findFirst(); + if (role1.isPresent()||role3.isPresent()){ + viewStockinHistory.setWarehouseId("02"); + } + if (role2.isPresent()||role4.isPresent()){ + viewStockinHistory.setWarehouseId("01"); + } + } return viewStockinHistoryMapper.selectViewStockinHistoryList(viewStockinHistory); } /** * 新增入库单据流水 - * + * * @param viewStockinHistory 入库单据流水 * @return 结果 */ @@ -57,7 +82,7 @@ public class ViewStockinHistoryServiceImpl implements IViewStockinHistoryService /** * 修改入库单据流水 - * + * * @param viewStockinHistory 入库单据流水 * @return 结果 */ @@ -69,7 +94,7 @@ public class ViewStockinHistoryServiceImpl implements IViewStockinHistoryService /** * 批量删除入库单据流水 - * + * * @param stockinIds 需要删除的入库单据流水主键 * @return 结果 */ @@ -81,7 +106,7 @@ public class ViewStockinHistoryServiceImpl implements IViewStockinHistoryService /** * 删除入库单据流水信息 - * + * * @param stockinId 入库单据流水主键 * @return 结果 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/controller/ViewStockoutHistoryController.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/controller/ViewStockoutHistoryController.java index 0548b22..b1b0193 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/controller/ViewStockoutHistoryController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/controller/ViewStockoutHistoryController.java @@ -25,7 +25,7 @@ import com.ruoyi.common.core.page.TableDataInfo; * 出库单据历史Controller * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-30 */ @RestController @RequestMapping("/search/ViewStockoutHistory") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/domain/ViewStockoutHistory.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/domain/ViewStockoutHistory.java index 4f5289a..4cddde3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/domain/ViewStockoutHistory.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/domain/ViewStockoutHistory.java @@ -8,44 +8,36 @@ import com.ruoyi.common.core.domain.BaseEntity; /** * 出库单据历史对象 view_stockout_history - * + * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-30 */ public class ViewStockoutHistory extends BaseEntity { private static final long serialVersionUID = 1L; - /** 出库单号 */ - @Excel(name = "出库单号") + /** 出库主单 */ + @Excel(name = "出库主单") private String stockoutId; - /** 出库子单号 */ - @Excel(name = "出库子单号") + /** 出库子单 */ + @Excel(name = "出库子单") private String stockoutDetailId; - /** 物料编码 */ - @Excel(name = "物料编码") - private String productId; + /** 产品号 */ + @Excel(name = "产品号") + private String power; + + /** 代号 */ + @Excel(name = "代号") + private String distribution; /** 物料名称 */ @Excel(name = "物料名称") private String productName; - /** 规格 */ - @Excel(name = "规格") - private String spec; - - /** 图号 */ - @Excel(name = "图号") - private String cargoNo; - - /** 物料状态 */ - @Excel(name = "物料状态",dictType = "product_type") - private String productType; - - /** 出库数量 */ - @Excel(name = "出库数量") + /** 计划数量 */ + @Excel(name = "计划数量") private BigDecimal quantity; /** 分配数量 */ @@ -56,384 +48,252 @@ public class ViewStockoutHistory extends BaseEntity @Excel(name = "实际数量") private BigDecimal assignNum; + /** 领料人 */ + @Excel(name = "领料人") + private String classNowId; + /** 合同号 */ @Excel(name = "合同号") - private String contract; + private String orderId; + + /** 出口 */ + @Excel(name = "出口") + private String exitId; /** 台次 */ @Excel(name = "台次") - private String power; + private String spec; - /** 件次 */ - @Excel(name = "件次") + /** 单重 */ + @Excel(name = "单重") + private String netWeight; + + /** 路线 */ + @Excel(name = "路线") + private String grossWeight; + + /** 供应商 */ + @Excel(name = "供应商") private String phase; - /** 单价 */ - @Excel(name = "单价") - private String price; + /** 物料编码 */ + @Excel(name = "物料编码") + private String productId; - /** 出库金额 */ - @Excel(name = "出库金额") - private String priceTotal; - - /** 客户编码 */ - @Excel(name = "客户编码") - private String customerNo; - - /** 客户名称 */ - @Excel(name = "客户名称") - private String customerName; - - /** 单据状态 */ - @Excel(name = "单据状态",dictType = "out_bill_status") - private String status; - - /** 创建人 */ - @Excel(name = "创建人") - private String createManId; + /** 仓库id */ + @Excel(name = "仓库id") + private String warehouseId; /** 创建时间 */ @Excel(name = "创建时间") private String createDate; - /** 单位 */ - @Excel(name = "单位") - private String unit; + /** 开始时间 */ + @Excel(name = "开始时间") + private String startDate; - /** 套账 */ - @Excel(name = "套账",dictType = "account_type") - private String account; + /** 结束时间 */ + @Excel(name = "结束时间") + private String finishDate; - /** 管理号 */ - @Excel(name = "管理号") - private String managementNo; - - /** 供应商编码 */ - @Excel(name = "供应商编码") - private String supplierId; - - /** 供应商 */ - @Excel(name = "供应商") - private String supplierName; - - /** 用途 */ - @Excel(name = "用途",dictType = "purpose_type") - private String purpose; - - /** 质量 */ - @Excel(name = "质量",dictType = "quality_type") - private String quality; - - /** 来源 */ - @Excel(name = "来源",dictType = "origin_type") - private String source; - - /** 状态 */ - @Excel(name = "状态",dictType = "turnover_type") - private String turnoverStatus; - - /** 用途2 */ - @Excel(name = "用途2") - private String purpose2; - - public void setStockoutId(String stockoutId) + public void setStockoutId(String stockoutId) { this.stockoutId = stockoutId; } - public String getStockoutId() + public String getStockoutId() { return stockoutId; } - public void setStockoutDetailId(String stockoutDetailId) + public void setStockoutDetailId(String stockoutDetailId) { this.stockoutDetailId = stockoutDetailId; } - public String getStockoutDetailId() + public String getStockoutDetailId() { return stockoutDetailId; } - public void setProductId(String productId) - { - this.productId = productId; - } - - public String getProductId() - { - return productId; - } - - public void setProductName(String productName) - { - this.productName = productName; - } - - public String getProductName() - { - return productName; - } - - public void setSpec(String spec) - { - this.spec = spec; - } - - public String getSpec() - { - return spec; - } - - public void setCargoNo(String cargoNo) - { - this.cargoNo = cargoNo; - } - - public String getCargoNo() - { - return cargoNo; - } - - public void setProductType(String productType) - { - this.productType = productType; - } - - public String getProductType() - { - return productType; - } - - public void setQuantity(BigDecimal quantity) - { - this.quantity = quantity; - } - - public BigDecimal getQuantity() - { - return quantity; - } - - public void setAllotQuantity(BigDecimal allotQuantity) - { - this.allotQuantity = allotQuantity; - } - - public BigDecimal getAllotQuantity() - { - return allotQuantity; - } - - public void setAssignNum(BigDecimal assignNum) - { - this.assignNum = assignNum; - } - - public BigDecimal getAssignNum() - { - return assignNum; - } - - public void setContract(String contract) - { - this.contract = contract; - } - - public String getContract() - { - return contract; - } - - public void setPower(String power) + public void setPower(String power) { this.power = power; } - public String getPower() + public String getPower() { return power; } - public void setPhase(String phase) + public void setDistribution(String distribution) + { + this.distribution = distribution; + } + + public String getDistribution() + { + return distribution; + } + + public void setProductName(String productName) + { + this.productName = productName; + } + + public String getProductName() + { + return productName; + } + + public void setQuantity(BigDecimal quantity) + { + this.quantity = quantity; + } + + public BigDecimal getQuantity() + { + return quantity; + } + + public void setAllotQuantity(BigDecimal allotQuantity) + { + this.allotQuantity = allotQuantity; + } + + public BigDecimal getAllotQuantity() + { + return allotQuantity; + } + + public void setAssignNum(BigDecimal assignNum) + { + this.assignNum = assignNum; + } + + public BigDecimal getAssignNum() + { + return assignNum; + } + + public void setClassNowId(String classNowId) + { + this.classNowId = classNowId; + } + + public String getClassNowId() + { + return classNowId; + } + + public void setOrderId(String orderId) + { + this.orderId = orderId; + } + + public String getOrderId() + { + return orderId; + } + + public void setExitId(String exitId) + { + this.exitId = exitId; + } + + public String getExitId() + { + return exitId; + } + + public void setSpec(String spec) + { + this.spec = spec; + } + + public String getSpec() + { + return spec; + } + + public void setNetWeight(String netWeight) + { + this.netWeight = netWeight; + } + + public String getNetWeight() + { + return netWeight; + } + + public void setGrossWeight(String grossWeight) + { + this.grossWeight = grossWeight; + } + + public String getGrossWeight() + { + return grossWeight; + } + + public void setPhase(String phase) { this.phase = phase; } - public String getPhase() + public String getPhase() { return phase; } - public void setPrice(String price) + public void setProductId(String productId) { - this.price = price; + this.productId = productId; } - public String getPrice() + public String getProductId() { - return price; + return productId; } - public void setPriceTotal(String priceTotal) + public void setWarehouseId(String warehouseId) { - this.priceTotal = priceTotal; + this.warehouseId = warehouseId; } - public String getPriceTotal() + public String getWarehouseId() { - return priceTotal; + return warehouseId; } - public void setCustomerNo(String customerNo) - { - this.customerNo = customerNo; - } - - public String getCustomerNo() - { - return customerNo; - } - - public void setCustomerName(String customerName) - { - this.customerName = customerName; - } - - public String getCustomerName() - { - return customerName; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - - public void setCreateManId(String createManId) - { - this.createManId = createManId; - } - - public String getCreateManId() - { - return createManId; - } - - public void setCreateDate(String createDate) + public void setCreateDate(String createDate) { this.createDate = createDate; } - public String getCreateDate() + public String getCreateDate() { return createDate; } - public void setUnit(String unit) + public void setStartDate(String startDate) { - this.unit = unit; + this.startDate = startDate; } - public String getUnit() + public String getStartDate() { - return unit; + return startDate; } - public void setAccount(String account) + public void setFinishDate(String finishDate) { - this.account = account; + this.finishDate = finishDate; } - public String getAccount() + public String getFinishDate() { - return account; - } - - public void setManagementNo(String managementNo) - { - this.managementNo = managementNo; - } - - public String getManagementNo() - { - return managementNo; - } - - public void setSupplierId(String supplierId) - { - this.supplierId = supplierId; - } - - public String getSupplierId() - { - return supplierId; - } - - public void setSupplierName(String supplierName) - { - this.supplierName = supplierName; - } - - public String getSupplierName() - { - return supplierName; - } - - public void setPurpose(String purpose) - { - this.purpose = purpose; - } - - public String getPurpose() - { - return purpose; - } - - public void setQuality(String quality) - { - this.quality = quality; - } - - public String getQuality() - { - return quality; - } - - public void setSource(String source) - { - this.source = source; - } - - public String getSource() - { - return source; - } - - public void setTurnoverStatus(String turnoverStatus) - { - this.turnoverStatus = turnoverStatus; - } - - public String getTurnoverStatus() - { - return turnoverStatus; - } - - public void setPurpose2(String purpose2) - { - this.purpose2 = purpose2; - } - - public String getPurpose2() - { - return purpose2; + return finishDate; } @Override @@ -441,35 +301,24 @@ public class ViewStockoutHistory extends BaseEntity return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("stockoutId", getStockoutId()) .append("stockoutDetailId", getStockoutDetailId()) - .append("productId", getProductId()) + .append("power", getPower()) + .append("distribution", getDistribution()) .append("productName", getProductName()) - .append("spec", getSpec()) - .append("cargoNo", getCargoNo()) - .append("productType", getProductType()) .append("quantity", getQuantity()) .append("allotQuantity", getAllotQuantity()) .append("assignNum", getAssignNum()) - .append("contract", getContract()) - .append("power", getPower()) + .append("classNowId", getClassNowId()) + .append("orderId", getOrderId()) + .append("exitId", getExitId()) + .append("spec", getSpec()) + .append("netWeight", getNetWeight()) + .append("grossWeight", getGrossWeight()) .append("phase", getPhase()) - .append("price", getPrice()) - .append("priceTotal", getPriceTotal()) - .append("customerNo", getCustomerNo()) - .append("customerName", getCustomerName()) - .append("status", getStatus()) - .append("createManId", getCreateManId()) + .append("productId", getProductId()) + .append("warehouseId", getWarehouseId()) .append("createDate", getCreateDate()) - .append("unit", getUnit()) - .append("account", getAccount()) - .append("managementNo", getManagementNo()) - .append("supplierId", getSupplierId()) - .append("supplierName", getSupplierName()) - .append("remark", getRemark()) - .append("purpose", getPurpose()) - .append("quality", getQuality()) - .append("source", getSource()) - .append("turnoverStatus", getTurnoverStatus()) - .append("purpose2", getPurpose2()) + .append("startDate", getStartDate()) + .append("finishDate", getFinishDate()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/mapper/ViewStockoutHistoryMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/mapper/ViewStockoutHistoryMapper.java index 7bfc061..7d49d77 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/mapper/ViewStockoutHistoryMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/mapper/ViewStockoutHistoryMapper.java @@ -7,7 +7,7 @@ import com.ruoyi.search.ViewStockoutHistory.domain.ViewStockoutHistory; * 出库单据历史Mapper接口 * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-30 */ public interface ViewStockoutHistoryMapper { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/service/IViewStockoutHistoryService.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/service/IViewStockoutHistoryService.java index 6cd553c..8c73ab5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/service/IViewStockoutHistoryService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/service/IViewStockoutHistoryService.java @@ -7,7 +7,7 @@ import com.ruoyi.search.ViewStockoutHistory.domain.ViewStockoutHistory; * 出库单据历史Service接口 * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-30 */ public interface IViewStockoutHistoryService { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/service/impl/ViewStockoutHistoryServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/service/impl/ViewStockoutHistoryServiceImpl.java index bb73de4..ec2ee9c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/service/impl/ViewStockoutHistoryServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/search/ViewStockoutHistory/service/impl/ViewStockoutHistoryServiceImpl.java @@ -11,7 +11,7 @@ import com.ruoyi.search.ViewStockoutHistory.service.IViewStockoutHistoryService; * 出库单据历史Service业务层处理 * * @author ruoyi - * @date 2025-10-27 + * @date 2026-03-30 */ @Service public class ViewStockoutHistoryServiceImpl implements IViewStockoutHistoryService diff --git a/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/mapper/BasStockMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/mapper/BasStockMapper.java index 634524b..a1c1637 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/mapper/BasStockMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/mapper/BasStockMapper.java @@ -76,7 +76,7 @@ public interface BasStockMapper int selectCountByTrayCodeAndWarehouseId(String trayCode, String warehouseId); - List selectBasStockByTrayCode(String trayCode); + List selectBasStockByTrayCode(String trayCode,String warehouseId); void deleteKtpStockByList(@Param("list") List basStockList,@Param("warehouseId")String warehouseId); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/service/IBasStockService.java b/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/service/IBasStockService.java index 48dc123..03946b4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/service/IBasStockService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/service/IBasStockService.java @@ -87,7 +87,7 @@ public interface IBasStockService AjaxResult updateBasStockDept(BasStock basStock); - List selectBasStockByTrayCode(String trayCode); + List selectBasStockByTrayCode(String trayCode,String warehouseId); void deleteKtpStockByList(List basStockList,String warehouseId); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/service/impl/BasStockServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/service/impl/BasStockServiceImpl.java index ff14514..f4d14fa 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/service/impl/BasStockServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/stock/stock/service/impl/BasStockServiceImpl.java @@ -471,8 +471,8 @@ public class BasStockServiceImpl implements IBasStockService } @Override - public List selectBasStockByTrayCode(String trayCode) { - return basStockMapper.selectBasStockByTrayCode(trayCode); + public List selectBasStockByTrayCode(String trayCode,String warehouseId) { + return basStockMapper.selectBasStockByTrayCode(trayCode,warehouseId); } @Override diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/SysLicenseController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/SysLicenseController.java new file mode 100644 index 0000000..1e5ec36 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/SysLicenseController.java @@ -0,0 +1,127 @@ +package com.ruoyi.web.controller.system.license; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.license.domain.SysLicense; +import com.ruoyi.license.service.ISysLicenseService; +import com.ruoyi.license.util.LicenseUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 授权码Controller + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/license") +public class SysLicenseController extends BaseController +{ + @Autowired + private ISysLicenseService sysLicenseService; + + /** + * 查询授权码列表 + */ + @PreAuthorize("@ss.hasPermi('system:license:list')") + @GetMapping("/list") + public TableDataInfo list(SysLicense sysLicense) + { + startPage(); + List list = sysLicenseService.selectSysLicenseList(sysLicense); + return getDataTable(list); + } + + /** + * 新增授权码 + */ + @PreAuthorize("@ss.hasPermi('system:license:add')") + @Log(title = "授权码", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(SysLicense sysLicense) + { + return toAjax(sysLicenseService.insertSysLicense(sysLicense)); + } + + /** + * 修改授权码 + */ + @PreAuthorize("@ss.hasPermi('system:license:edit')") + @Log(title = "授权码", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + public AjaxResult edit(SysLicense sysLicense) + { + return toAjax(sysLicenseService.updateSysLicense(sysLicense)); + } + + /** + * 删除授权码 + */ + @PreAuthorize("@ss.hasPermi('system:license:remove')") + @Log(title = "授权码", businessType = BusinessType.DELETE) + @PostMapping("/remove") + public AjaxResult remove(String ids) + { + return toAjax(sysLicenseService.deleteSysLicenseByIds(ids)); + } + + /** + * 激活授权码(无需登录) + */ +// @Log(title = "激活授权码", businessType = BusinessType.UPDATE) + @PostMapping("/active") + public AjaxResult active(String licenseCode) + { + if (!LicenseUtils.validateFormat(licenseCode)) + { + return error("授权码格式不正确"); + } + int result = sysLicenseService.activeLicense(licenseCode); + if (result > 0) + { + return success("授权码激活成功"); + } + return error("授权码激活失败,请检查授权码是否正确或已过期"); + } + + /** + * 获取当前授权信息 + * license 未开启或无有效授权时返回 code=200 data=null,前端静默处理 + */ +// @PreAuthorize("@ss.hasPermi('system:license:list')") + @GetMapping("/info") + public AjaxResult info() + { + SysLicense license = sysLicenseService.getActiveLicense(); + return AjaxResult.success(license); + } + + /** + * 生成授权码 + */ + @PreAuthorize("@ss.hasPermi('system:license:add')") + @GetMapping("/generate") + public AjaxResult generate(String type, String projectNo) + { + if (StringUtils.isEmpty(type) || StringUtils.isEmpty(projectNo)) + { + return error("授权类型和项目编号不能为空"); + } + String licenseCode = LicenseUtils.generateLicense(type, projectNo); + if (licenseCode == null) + { + return error("授权码生成失败"); + } + return AjaxResult.success("授权码生成成功", licenseCode); + } +} diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index fc97c91..4a4e893 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -34,7 +34,7 @@ server: # 日志配置 logging: level: - com.ruoyi: error + com.ruoyi: info org.springframework: warn # 用户配置 @@ -176,3 +176,5 @@ xss: urlPatterns: /system/*,/monitor/*,/tool/* +license: + enabled: true diff --git a/ruoyi-admin/src/main/resources/mapper/job/MydoJobFinishMapper.xml b/ruoyi-admin/src/main/resources/mapper/job/MydoJobFinishMapper.xml index a387df3..ac6e9b7 100644 --- a/ruoyi-admin/src/main/resources/mapper/job/MydoJobFinishMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/job/MydoJobFinishMapper.xml @@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mj.entrance_id = #{entranceId} and mj.exit_id = #{exitId} and mj.class_id = #{classId} - and mj.warehouse_id = #{warehouseId} + and mj.fault_flag = #{faultFlag} and mj.in_or_out >=20 and mj.in_or_out < 20 @@ -95,7 +95,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - ${params.warehouseDataScope} diff --git a/ruoyi-admin/src/main/resources/mapper/job/MydoJobMapper.xml b/ruoyi-admin/src/main/resources/mapper/job/MydoJobMapper.xml index 29c9e70..22333c1 100644 --- a/ruoyi-admin/src/main/resources/mapper/job/MydoJobMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/job/MydoJobMapper.xml @@ -247,13 +247,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{v_resultmsg,mode=OUT,jdbcType=VARCHAR} )} - diff --git a/ruoyi-admin/src/main/resources/mapper/jobExport/OutStockAllotInfoMapper.xml b/ruoyi-admin/src/main/resources/mapper/jobExport/OutStockAllotInfoMapper.xml new file mode 100644 index 0000000..95977cb --- /dev/null +++ b/ruoyi-admin/src/main/resources/mapper/jobExport/OutStockAllotInfoMapper.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select id, out_stock_id, out_stock_detail_id, order_id, power, distribution, spare5, net_weight, gross_weight, phase, product_id, product_name, spare8, tray_code, product_type, out_quantity from out_stock_allot_info + + + + + + + + insert into out_stock_allot_info + + out_stock_id, + out_stock_detail_id, + order_id, + power, + distribution, + spare5, + net_weight, + gross_weight, + phase, + product_id, + product_name, + spare8, + tray_code, + product_type, + out_quantity, + + + #{outStockId}, + #{outStockDetailId}, + #{orderId}, + #{power}, + #{distribution}, + #{spare5}, + #{netWeight}, + #{grossWeight}, + #{phase}, + #{productId}, + #{productName}, + #{spare8}, + #{trayCode}, + #{productType}, + #{outQuantity}, + + + + + update out_stock_allot_info + + out_stock_id = #{outStockId}, + out_stock_detail_id = #{outStockDetailId}, + order_id = #{orderId}, + power = #{power}, + distribution = #{distribution}, + spare5 = #{spare5}, + net_weight = #{netWeight}, + gross_weight = #{grossWeight}, + phase = #{phase}, + product_id = #{productId}, + product_name = #{productName}, + spare8 = #{spare8}, + tray_code = #{trayCode}, + product_type = #{productType}, + out_quantity = #{outQuantity}, + + where id = #{id} + + + + delete from out_stock_allot_info where id = #{id} + + + + delete from out_stock_allot_info where id in + + #{id} + + + + delete from out_stock_allot_info where out_job_id = #{jobId} + + diff --git a/ruoyi-admin/src/main/resources/mapper/out/OutStockoutDetailMapper.xml b/ruoyi-admin/src/main/resources/mapper/out/OutStockoutDetailMapper.xml index 1b102e2..2f15863 100644 --- a/ruoyi-admin/src/main/resources/mapper/out/OutStockoutDetailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/out/OutStockoutDetailMapper.xml @@ -128,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" lot_no, product_guid, product_id, - + product_name, quantity, quantity_x, quantity_j, @@ -170,6 +170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{lotNo}, #{productGuid}, #{productId}, + #{productName}, #{quantity}, #{quantityX}, @@ -269,7 +270,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" d.price, d.remark, d.warehouse_id, d.out_id, d.bukechai_quantity, d.kechai_quantity, d.entryid, d.flat_quantity, d.fid, d.erp_stockout_id, d.unit, d.spec, d.supplier_id, d.cargo_no, d.print_date, d.voltage, d.power, d.phase, d.net_weight, d.gross_weight, d.distribution, d.model, d.order_id, - p.product_name,p.parent_id,p.price as product_price,p.cargo_no as product_draw_no,p.unit as product_unit,p.spec as product_spec, + d.product_name,p.parent_id,p.price as product_price,p.cargo_no as product_draw_no,p.unit as product_unit,p.spec as product_spec, p.spare1 as product_status,p.spare3 as create_time,p.spare4 as create_sys,p.spare7 as is_used, s.supplier_name, c.customer_name,mbc.status as sw_status diff --git a/ruoyi-admin/src/main/resources/mapper/out/OutStockoutMapper.xml b/ruoyi-admin/src/main/resources/mapper/out/OutStockoutMapper.xml index 22e4914..a6fffe5 100644 --- a/ruoyi-admin/src/main/resources/mapper/out/OutStockoutMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/out/OutStockoutMapper.xml @@ -183,7 +183,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" } + diff --git a/ruoyi-admin/src/main/resources/mapper/out/ViewProductAndStockMapper.xml b/ruoyi-admin/src/main/resources/mapper/out/ViewProductAndStockMapper.xml index 77cba62..530479b 100644 --- a/ruoyi-admin/src/main/resources/mapper/out/ViewProductAndStockMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/out/ViewProductAndStockMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -18,15 +18,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select only_identity, product_id, product_name, quantity, warehouse_id, order_id, power, distribution, spare5, net_weight, gross_weight, phase, model from view_product_and_stock + select only_identity, product_id, product_name, quantity, warehouse_id, order_id, power, distribution, spare5, net_weight, gross_weight, phase, model,voltage from view_product_and_stock - + diff --git a/ruoyi-admin/src/main/resources/mapper/search/ViewStockDetailMapper.xml b/ruoyi-admin/src/main/resources/mapper/search/ViewStockDetailMapper.xml index c05bb9f..8ef3491 100644 --- a/ruoyi-admin/src/main/resources/mapper/search/ViewStockDetailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/search/ViewStockDetailMapper.xml @@ -41,6 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -75,10 +77,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bs.stock_status, --库存状态 bs.lot_no, --批次号 bs.out_quantity, - bs.distribution, --来源 - bs.spare4, --来源 - bs.model, --来源 - sd.dept_name, --来源 + bs.distribution, + bs.spare4, + bs.model, --部门 + sd.dept_name, --部门名称 + bs.gross_weight, --路线 + bs.net_weight, --单重 bs.spare1 --用途 from bas_stock bs left join bas_product bp on bs.product_id = bp.product_id @@ -94,42 +98,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bs.stock_id = #{stockId} and (bs.model = #{model} or bs.model is null or bs.model = '') and sd.dept_name =#{deptName} - and bs.cargo_space_id = #{cargoSpaceId} - and bs.stock_status = #{stockStatus} - and bs.lot_no = #{lotNo} - and bs.in_date like concat('%', #{inDate}, '%') - and bs.back_date = #{backDate} - and bs.product_name like concat('%', #{productName}, '%') - and bs.quantity = #{quantity} - and bs.tray_code like concat('%', #{trayCode},'%') - and bs.out_quantity = #{outQuantity} - and bs.stockin_id = #{stockinId} + and bs.order_id like concat('%',#{orderId},'%') + and bs.power like concat('%',#{power},'%') + and bs.distribution like concat('%',#{distribution},'%') + and bs.spare5 like concat('%',#{spare5},'%') + and bs.net_weight like concat('%',#{netWeight},'%') + and bs.gross_weight like concat('%',#{grossWeight},'%') + and bs.phase like concat('%',#{v},'%') + and bs.product_id like concat('%',#{productId},'%') + and bs.product_name like concat('%',#{productName},'%') and bs.warehouse_id = #{warehouseId} - and bs.stacking_id = #{stackingId} - and bs.spare1 = #{spare1} - and bs.spare3 = #{spare3} - and bs.spare4 = #{spare4} - and bs.spare5 = #{spare5} - and bs.spare6 = #{spare6} - and bs.voltage = #{voltage} - and bs.power = #{power} - and bs.order_id = #{orderId} - and bs.product_id = #{productId} - and bcs.roadway_id = #{roadwayId} - and bcs.the_floor = #{theFloor} - and bcs.the_platoon = #{thePlatoon} - and bcs.the_column = #{theColumn} - and bp.spec = #{spec} - and bp.parent_id = #{parentId} - and bs2.supplier_no = #{supplierId} - and bs2.supplier_name = #{supplierName} - and bp.price = #{price} - and bs.in_date >= #{inDateStart} - and bs.in_date <= #{inDateEnd} - and bp.spare1 = #{productType} - - ${params.warehouseDataScope} - + and bs.tray_code = #{trayCode} + and bs.in_date between #{inDateStart} and #{inDateEnd} diff --git a/ruoyi-admin/src/main/resources/mapper/search/ViewStockinHistoryMapper.xml b/ruoyi-admin/src/main/resources/mapper/search/ViewStockinHistoryMapper.xml index 7cf6a6f..33d7502 100644 --- a/ruoyi-admin/src/main/resources/mapper/search/ViewStockinHistoryMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/search/ViewStockinHistoryMapper.xml @@ -6,69 +6,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + - - - - - - - - - - - - - - - - + - - - - - select stockin_id, stockin_detail_id, product_id, product_name, spec, cargo_no, productType, quantity, scan_num, assign_num, unit, price, priceTotal, supplier_no, supplier_name, spare6, spare5, spare7, spare3, create_man_id, create_date, status, spare8, remark, spare1, spare4, spare2,spare9 from view_stockin_history + select stockin_id, warehouse_id, department_no, in_type, stockin_detail_id, spare6, spare7, spare9, spare5, spare4, spare3, supplier_id, product_id, product_name, quantity, assign_num, create_date, finish_date, remark from view_stockin_history @@ -81,93 +63,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into view_stockin_history stockin_id, + warehouse_id, + department_no, + in_type, stockin_detail_id, + spare6, + spare7, + spare9, + spare5, + spare4, + spare3, + supplier_id, product_id, product_name, - spec, - cargo_no, - productType, quantity, - scan_num, assign_num, - unit, - price, - priceTotal, - supplier_no, - supplier_name, - spare6, - spare5, - spare7, - spare3, - create_man_id, create_date, - status, - spare8, + finish_date, remark, - spare1, - spare4, - spare2, #{stockinId}, + #{warehouseId}, + #{departmentNo}, + #{inType}, #{stockinDetailId}, + #{spare6}, + #{spare7}, + #{spare9}, + #{spare5}, + #{spare4}, + #{spare3}, + #{supplierId}, #{productId}, #{productName}, - #{spec}, - #{cargoNo}, - #{productType}, #{quantity}, - #{scanNum}, #{assignNum}, - #{unit}, - #{price}, - #{priceTotal}, - #{supplierNo}, - #{supplierName}, - #{spare6}, - #{spare5}, - #{spare7}, - #{spare3}, - #{createManId}, #{createDate}, - #{status}, - #{spare8}, + #{finishDate}, #{remark}, - #{spare1}, - #{spare4}, - #{spare2}, update view_stockin_history + warehouse_id = #{warehouseId}, + department_no = #{departmentNo}, + in_type = #{inType}, stockin_detail_id = #{stockinDetailId}, + spare6 = #{spare6}, + spare7 = #{spare7}, + spare9 = #{spare9}, + spare5 = #{spare5}, + spare4 = #{spare4}, + spare3 = #{spare3}, + supplier_id = #{supplierId}, product_id = #{productId}, product_name = #{productName}, - spec = #{spec}, - cargo_no = #{cargoNo}, - productType = #{productType}, quantity = #{quantity}, - scan_num = #{scanNum}, assign_num = #{assignNum}, - unit = #{unit}, - price = #{price}, - priceTotal = #{priceTotal}, - supplier_no = #{supplierNo}, - supplier_name = #{supplierName}, - spare6 = #{spare6}, - spare5 = #{spare5}, - spare7 = #{spare7}, - spare3 = #{spare3}, - create_man_id = #{createManId}, create_date = #{createDate}, - status = #{status}, - spare8 = #{spare8}, + finish_date = #{finishDate}, remark = #{remark}, - spare1 = #{spare1}, - spare4 = #{spare4}, - spare2 = #{spare2}, where stockin_id = #{stockinId} diff --git a/ruoyi-admin/src/main/resources/mapper/search/ViewStockoutHistoryMapper.xml b/ruoyi-admin/src/main/resources/mapper/search/ViewStockoutHistoryMapper.xml index 5b5448e..3d38def 100644 --- a/ruoyi-admin/src/main/resources/mapper/search/ViewStockoutHistoryMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/search/ViewStockoutHistoryMapper.xml @@ -7,39 +7,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + - - - - - + + + + + + - - - - - - + + - - - - - - - - - - - + + - select stockout_id, stockout_detail_id, product_id, product_name, spec, cargo_no, productType, quantity, allot_quantity, assign_num, contract, power, phase, price, priceTotal, customer_no, customer_name, status, create_man_id, create_date, unit, account, managementNo, supplier_id, supplier_name, remark, purpose, quality, source, turnoverStatus, purpose2 from view_stockout_history + select stockout_id, stockout_detail_id, power, distribution, product_name, quantity, allot_quantity, assign_num, class_now_id, order_id, exit_id, spec, net_weight, gross_weight, phase, product_id, warehouse_id, create_date, start_date, finish_date from view_stockout_history @@ -88,68 +67,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" stockout_id, stockout_detail_id, - product_id, + power, + distribution, product_name, - spec, - cargo_no, - productType, quantity, allot_quantity, assign_num, - contract, - power, + class_now_id, + order_id, + exit_id, + spec, + net_weight, + gross_weight, phase, - price, - priceTotal, - customer_no, - customer_name, - status, - create_man_id, + product_id, + warehouse_id, create_date, - unit, - account, - managementNo, - supplier_id, - supplier_name, - remark, - purpose, - quality, - source, - turnoverStatus, - purpose2, + start_date, + finish_date, #{stockoutId}, #{stockoutDetailId}, - #{productId}, + #{power}, + #{distribution}, #{productName}, - #{spec}, - #{cargoNo}, - #{productType}, #{quantity}, #{allotQuantity}, #{assignNum}, - #{contract}, - #{power}, + #{classNowId}, + #{orderId}, + #{exitId}, + #{spec}, + #{netWeight}, + #{grossWeight}, #{phase}, - #{price}, - #{priceTotal}, - #{customerNo}, - #{customerName}, - #{status}, - #{createManId}, + #{productId}, + #{warehouseId}, #{createDate}, - #{unit}, - #{account}, - #{managementNo}, - #{supplierId}, - #{supplierName}, - #{remark}, - #{purpose}, - #{quality}, - #{source}, - #{turnoverStatus}, - #{purpose2}, + #{startDate}, + #{finishDate}, @@ -157,35 +114,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update view_stockout_history stockout_detail_id = #{stockoutDetailId}, - product_id = #{productId}, + power = #{power}, + distribution = #{distribution}, product_name = #{productName}, - spec = #{spec}, - cargo_no = #{cargoNo}, - productType = #{productType}, quantity = #{quantity}, allot_quantity = #{allotQuantity}, assign_num = #{assignNum}, - contract = #{contract}, - power = #{power}, + class_now_id = #{classNowId}, + order_id = #{orderId}, + exit_id = #{exitId}, + spec = #{spec}, + net_weight = #{netWeight}, + gross_weight = #{grossWeight}, phase = #{phase}, - price = #{price}, - priceTotal = #{priceTotal}, - customer_no = #{customerNo}, - customer_name = #{customerName}, - status = #{status}, - create_man_id = #{createManId}, + product_id = #{productId}, + warehouse_id = #{warehouseId}, create_date = #{createDate}, - unit = #{unit}, - account = #{account}, - managementNo = #{managementNo}, - supplier_id = #{supplierId}, - supplier_name = #{supplierName}, - remark = #{remark}, - purpose = #{purpose}, - quality = #{quality}, - source = #{source}, - turnoverStatus = #{turnoverStatus}, - purpose2 = #{purpose2}, + start_date = #{startDate}, + finish_date = #{finishDate}, where stockout_id = #{stockoutId} diff --git a/ruoyi-admin/src/main/resources/mapper/stock/BasStockMapper.xml b/ruoyi-admin/src/main/resources/mapper/stock/BasStockMapper.xml index 58093b0..1c4a9b2 100644 --- a/ruoyi-admin/src/main/resources/mapper/stock/BasStockMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/stock/BasStockMapper.xml @@ -409,6 +409,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/domain/ExtraField.java b/ruoyi-common/src/main/java/com/ruoyi/common/domain/ExtraField.java index 1b2c57f..a350fc2 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/domain/ExtraField.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/domain/ExtraField.java @@ -10,7 +10,68 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class ExtraField { + @Excel(name = "序号") + private String seqNo; + + @Excel(name = "子件") + private String subItem; + + @Excel(name = "品号") + @NotEmpty(message = "物料GUID不能为空") private String productId; - private String spec; - private String parentId; + + @Excel(name = "品名") + private String materialDesc; + + @Excel(name = "英文描述") + private String englishDesc; + + @Excel(name = "数量") + @NotEmpty(message = "物料数量不能为空") + private String quantity; + + @Excel(name = "单位") + private String unit; + + @Excel(name = "单件净重Unit Net Weight") + private String unitNetWeight; + + @Excel(name = "总净重Total Net Weight") + private String totalNetWeight; + + @Excel(name = "箱号Carton NO.") + private String cartonNo; + + @Excel(name = "包装方式") + private String packingMethod; + + @Excel(name = "长(MM)") + private String length; + + @Excel(name = "宽(MM)") + private String width; + + @Excel(name = "高(MM)") + private String height; + + @Excel(name = "体积m³") + private String volume; + + @Excel(name = "净重(KG)NET WEIGHT") + private String netWeight; + + @Excel(name = "毛重(KG)GROSS WEIGHT") + private String grossWeight; + + @Excel(name = "单价") + private String unitPrice; + + @Excel(name = "总价") + private String totalPrice; + + @Excel(name = "备注") + private String remark; + + @Excel(name = "批次号") + private String lotNo; } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index 2d19205..db0889a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -19,6 +19,7 @@ import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.security.context.PermissionContextHolder; +import org.springframework.security.core.Authentication; /** * 数据过滤处理 @@ -69,17 +70,21 @@ public class DataScopeAspect protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope) { - // 获取当前的用户 - LoginUser loginUser = SecurityUtils.getLoginUser(); - if (StringUtils.isNotNull(loginUser)) + Authentication authentication = SecurityUtils.getAuthentication(); + if (authentication == null) { + return; + } + Object principal = authentication.getPrincipal(); + if (!(principal instanceof LoginUser)) { + return; + } + LoginUser loginUser = (LoginUser) principal; + SysUser currentUser = loginUser.getUser(); + // 如果是超级管理员,则不过滤数据 + if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) { - SysUser currentUser = loginUser.getUser(); - // 如果是超级管理员,则不过滤数据 - if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) - { - String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), PermissionContextHolder.getContext()); - dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), controllerDataScope.userAlias(),controllerDataScope.warehouseAlias(), permission); - } + String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), PermissionContextHolder.getContext()); + dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), controllerDataScope.userAlias(),controllerDataScope.warehouseAlias(), permission); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 70014cf..3ec35b9 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -100,7 +100,7 @@ public class SecurityConfig .authorizeHttpRequests((requests) -> { permitAllUrl.getUrls().forEach(url -> requests.requestMatchers(url).permitAll()); // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - requests.requestMatchers("/login", "/register", "/captchaImage").permitAll() + requests.requestMatchers("/login", "/register", "/captchaImage", "/system/license/active").permitAll() // 静态资源,可匿名访问 .requestMatchers(HttpMethod.GET, "/", "/*.html", "/**.html", "/**.css", "/**.js", "/profile/**").permitAll() .requestMatchers("/swagger-ui.html", "/v3/api-docs/**", "/swagger-ui/**", "/druid/**").permitAll() diff --git a/ruoyi-license/CHANGES.md b/ruoyi-license/CHANGES.md new file mode 100644 index 0000000..d6c8609 --- /dev/null +++ b/ruoyi-license/CHANGES.md @@ -0,0 +1,270 @@ +# 授权码模块集成改动说明 + +> 本文档记录引入 `ruoyi-license` 授权码模块时,对原有项目文件的所有改动(不含 `ruoyi-license` 模块本身及 `SysLicenseController`)。 + +--- + +## 1. 根模块 `pom.xml` + +**文件路径:** `wms/pom.xml` + +**改动内容:** + +1. `` 中注册 `ruoyi-license` 子模块: + +```xml + + ruoyi-admin + ruoyi-framework + ruoyi-system + ruoyi-quartz + ruoyi-generator + ruoyi-common + ruoyi-license + +``` + +2. `` 中声明 `ruoyi-license` 依赖版本: + +```xml + + + com.ruoyi + ruoyi-license + ${ruoyi.version} + +``` + +--- + +## 2. `ruoyi-admin/pom.xml` + +**文件路径:** `wms/ruoyi-admin/pom.xml` + +**改动内容:** + +引入 `ruoyi-license` 依赖,使授权拦截器和配置能被 Spring Boot 扫描加载: + +```xml + + + com.ruoyi + ruoyi-license + +``` + +--- + +## 3. `SecurityConfig.java` + +**文件路径:** `wms/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java` + +**改动内容:** + +在 Spring Security 匿名白名单中加入 `/system/license/active`,允许未登录用户调用激活授权码接口: + +```java +// 改动前 +requests.antMatchers("/login", "/register", "/captchaImage").permitAll() + +// 改动后 +requests.antMatchers("/login", "/register", "/captchaImage", "/system/license/active").permitAll() +``` + +--- + +## 4. 前端 `api/license.js`(新建) + +**文件路径:** `wms/ui/src/api/license.js` + +**改动内容:** + +新建文件,封装授权码相关接口: + +```js +import request from '@/utils/request' + +// 激活授权码(无需登录) +export function activeLicense(licenseCode) { + return request({ + url: '/system/license/active', + method: 'post', + params: { licenseCode } + }) +} + +// 查询当前授权信息(需登录) +export function getLicenseInfo() { + return request({ + url: '/system/license/info', + method: 'get' + }) +} +``` + +--- + +## 5. 登录页 `login.vue` + +**文件路径:** `wms/ui/src/views/login.vue` + +**改动内容:** + +### 5.1 模板部分 + +在登录按钮下方新增"激活授权码"按钮,以及激活弹窗: + +```html + + + 激活授权码 + + + + + + + 取 消 + 激 活 + + +``` + +### 5.2 Script 部分 + +新增 import、data 字段和方法: + +```js +// 新增 import +import { activeLicense } from "@/api/license" + +// 新增 data 字段 +licenseDialogVisible: false, +licenseCode: '', +licenseLoading: false + +// 新增方法 +openLicenseDialog() { + this.licenseCode = '' + this.licenseDialogVisible = true +}, +handleActiveLicense() { + if (!this.licenseCode.trim()) { + this.$message.warning('请输入授权码') + return + } + this.licenseLoading = true + activeLicense(this.licenseCode.trim()).then(res => { + if (res.code === 200) { + this.$message.success(res.msg || '授权码激活成功') + this.licenseDialogVisible = false + } else { + this.$message.error(res.msg || '授权码激活失败') + } + }).catch(() => { + this.$message.error('授权码激活失败') + }).finally(() => { + this.licenseLoading = false + }) +} +``` + +--- + +## 6. 顶部导航栏 `Navbar.vue` + +**文件路径:** `wms/ui/src/layout/components/Navbar.vue` + +**改动内容:** + +### 6.1 模板部分 + +在 navbar 中间插入授权到期警告条(剩余不足 30 天时显示): + +```html +
+ + 系统授权将于 {{ licenseExpireText }} 后过期,请及时联系管理员续期 +
+``` + +### 6.2 Script 部分 + +```js +// 新增 import +import { getLicenseInfo } from '@/api/license' + +// 新增 data 字段 +licenseWarning: false, +licenseExpireText: '', +licenseTimer: null + +// 新增生命周期钩子 +mounted() { + this.checkLicenseExpire() + this.licenseTimer = setInterval(() => this.checkLicenseExpire(), 60 * 1000) +}, +beforeDestroy() { + if (this.licenseTimer) clearInterval(this.licenseTimer) +}, + +// 新增方法 +checkLicenseExpire() { + getLicenseInfo().then(res => { + if (res.code === 200 && res.data && res.data.expireTime) { + const expireTime = new Date(res.data.expireTime).getTime() + const now = Date.now() + const diffMs = expireTime - now + const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24)) + if (diffMs > 0 && diffDays <= 30) { + this.licenseWarning = true + if (diffMs < 1000 * 60 * 60 * 24) { + const hours = Math.floor(diffMs / (1000 * 60 * 60)) + const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60)) + this.licenseExpireText = hours > 0 ? `${hours} 小时 ${minutes} 分钟` : `${minutes} 分钟` + } else if (diffDays < 7) { + this.licenseExpireText = diffDays + ' 天' + } else { + this.licenseExpireText = Math.ceil(diffDays / 7) + ' 周' + } + } + } + }).catch(() => {}) +} +``` + +### 6.3 样式部分 + +```scss +.license-warning { + position: absolute; + left: 50%; + transform: translateX(-50%); + top: 0; + height: 50px; + line-height: 50px; + font-size: 13px; + color: #e6a23c; + font-weight: 500; + pointer-events: none; + i { margin-right: 4px; } +} +``` + +--- + +## 改动文件汇总 + +| 文件 | 类型 | 说明 | +|---|---|---| +| `wms/pom.xml` | 修改 | 注册模块 + 声明依赖版本 | +| `wms/ruoyi-admin/pom.xml` | 修改 | 引入 ruoyi-license 依赖 | +| `ruoyi-framework/.../SecurityConfig.java` | 修改 | 白名单加入激活授权码接口 | +| `ui/src/api/license.js` | 新建 | 封装激活和查询授权信息接口 | +| `ui/src/views/login.vue` | 修改 | 新增激活授权码按钮和弹窗 | +| `ui/src/layout/components/Navbar.vue` | 修改 | 新增授权到期倒计时警告条 | diff --git a/ruoyi-license/DEPLOYMENT_CHECKLIST.md b/ruoyi-license/DEPLOYMENT_CHECKLIST.md new file mode 100644 index 0000000..cac7b0e --- /dev/null +++ b/ruoyi-license/DEPLOYMENT_CHECKLIST.md @@ -0,0 +1,250 @@ +# 授权码模块部署检查清单 + +## 📋 部署前检查 + +### 1. 文件完整性检查 +- [ ] ruoyi-license 模块目录存在 +- [ ] pom.xml 已添加 license 模块 +- [ ] ruoyi-admin/pom.xml 已添加 license 依赖 +- [ ] SysLicenseController.java 已创建 +- [ ] license.html 和 active.html 已创建 +- [ ] login.html 和 login.js 已修改 +- [ ] sys_license.sql 脚本已准备 + +### 2. 数据库准备 +- [ ] 创建 sys_license 表 +- [ ] 插入授权管理菜单数据 +- [ ] 验证表结构正确 +- [ ] 检查菜单权限配置 + +### 3. 代码配置 +- [ ] 修改 LicenseUtils.java 中的密钥(生产环境必须) +- [ ] 确认拦截器路径配置正确 +- [ ] 确认定时任务cron表达式 +- [ ] 启动类添加 @EnableScheduling 注解 + +## 🔧 部署步骤 + +### 步骤1: 执行数据库脚本 +```bash +mysql -u root -p your_database < sql/sys_license.sql +``` +- [ ] 执行成功 +- [ ] 表创建成功 +- [ ] 菜单数据插入成功 + +### 步骤2: 修改启动类 +```java +@SpringBootApplication +@EnableScheduling // 添加此注解 +public class RuoYiApplication { + // ... +} +``` +- [ ] 注解已添加 + +### 步骤3: 编译项目 +```bash +mvn clean install +``` +- [ ] 编译成功 +- [ ] 无错误信息 +- [ ] JAR包生成 + +### 步骤4: 启动应用 +```bash +java -jar ruoyi-admin.jar +``` +- [ ] 启动成功 +- [ ] 无异常日志 +- [ ] 端口正常监听 + +### 步骤5: 生成授权码 +**方式A: 使用独立工具** +```bash +java com.ruoyi.license.util.LicenseGenerator +``` +- [ ] 工具运行成功 +- [ ] 授权码生成成功 +- [ ] 授权码已保存 + +**方式B: 使用系统界面** +- [ ] 登录系统 +- [ ] 访问授权管理 +- [ ] 点击生成授权码 +- [ ] 输入天数并生成 + +### 步骤6: 激活授权码 +- [ ] 访问登录页 +- [ ] 点击"激活授权码" +- [ ] 输入授权码 +- [ ] 激活成功 + +## ✅ 功能测试 + +### 测试1: 授权码生成 +- [ ] 系统界面生成授权码成功 +- [ ] 独立工具生成授权码成功 +- [ ] 授权码格式正确 + +### 测试2: 授权码激活 +- [ ] 登录页激活成功 +- [ ] 系统内激活成功 +- [ ] 数据库记录正确 + +### 测试3: 授权验证 +- [ ] 有效授权可正常登录 +- [ ] 无授权无法登录 +- [ ] 过期授权无法登录 + +### 测试4: 授权拦截 +- [ ] 未授权访问被拦截 +- [ ] 有效授权可正常访问 +- [ ] 静态资源不被拦截 + +### 测试5: 定时检查 +- [ ] 定时任务正常执行 +- [ ] 授权过期自动更新状态 +- [ ] 在线用户被踢出 + +### 测试6: 授权管理 +- [ ] 授权列表查询正常 +- [ ] 授权信息显示正确 +- [ ] 授权删除功能正常 + +## 🔍 问题排查 + +### 问题1: 编译失败 +**检查项:** +- [ ] Maven依赖是否正确 +- [ ] JDK版本是否匹配 +- [ ] pom.xml配置是否正确 + +**解决方案:** +```bash +mvn clean +mvn dependency:resolve +mvn install +``` + +### 问题2: 启动失败 +**检查项:** +- [ ] 数据库连接是否正常 +- [ ] 端口是否被占用 +- [ ] 配置文件是否正确 + +**解决方案:** +- 检查 application.yml 配置 +- 查看启动日志错误信息 +- 确认数据库表已创建 + +### 问题3: 无法激活授权码 +**检查项:** +- [ ] 授权码格式是否正确 +- [ ] 授权码是否已过期 +- [ ] 密钥是否一致 + +**解决方案:** +- 重新生成授权码 +- 检查 LicenseUtils 密钥配置 +- 查看后台错误日志 + +### 问题4: 授权验证不生效 +**检查项:** +- [ ] 拦截器是否注册 +- [ ] 数据库授权记录是否正确 +- [ ] 定时任务是否执行 + +**解决方案:** +- 检查 LicenseConfig 配置 +- 验证数据库 status 字段 +- 确认 @EnableScheduling 已添加 + +### 问题5: 在线用户未被踢出 +**检查项:** +- [ ] SessionDAO 是否注入 +- [ ] 定时任务是否执行 +- [ ] Shiro配置是否正确 + +**解决方案:** +- 检查 LicenseCheckTask 日志 +- 验证 SessionDAO bean +- 重启应用服务器 + +## 📊 监控指标 + +### 运行时监控 +- [ ] 授权状态正常 +- [ ] 定时任务执行正常 +- [ ] 无异常日志 +- [ ] 内存使用正常 +- [ ] CPU使用正常 + +### 业务监控 +- [ ] 授权激活次数 +- [ ] 授权过期提醒 +- [ ] 用户登录成功率 +- [ ] 授权拦截次数 + +## 🔐 安全检查 + +### 配置安全 +- [ ] 生产环境已修改默认密钥 +- [ ] 数据库密码已加密 +- [ ] 授权码传输使用HTTPS +- [ ] 敏感日志已脱敏 + +### 权限安全 +- [ ] 授权管理菜单仅管理员可见 +- [ ] 授权激活操作有日志记录 +- [ ] 授权码生成有权限控制 +- [ ] 数据库访问有权限限制 + +### 数据安全 +- [ ] 授权码加密存储 +- [ ] 定期备份授权数据 +- [ ] 授权日志完整保存 +- [ ] 敏感信息不输出到日志 + +## 📝 上线清单 + +### 上线前 +- [ ] 所有测试通过 +- [ ] 代码已提交版本库 +- [ ] 数据库脚本已准备 +- [ ] 部署文档已编写 +- [ ] 回滚方案已准备 + +### 上线中 +- [ ] 备份现有数据 +- [ ] 执行数据库脚本 +- [ ] 部署新版本代码 +- [ ] 生成初始授权码 +- [ ] 激活授权码 + +### 上线后 +- [ ] 验证功能正常 +- [ ] 检查日志无异常 +- [ ] 监控系统运行状态 +- [ ] 通知相关人员 +- [ ] 更新运维文档 + +## 📞 应急联系 + +### 技术支持 +- 开发负责人: ___________ +- 运维负责人: ___________ +- 数据库管理员: ___________ + +### 应急预案 +1. 授权失效 -> 立即激活新授权码 +2. 系统无法登录 -> 检查授权状态 +3. 数据丢失 -> 从备份恢复 +4. 性能问题 -> 调整定时任务频率 + +--- + +**检查人**: ___________ +**检查日期**: ___________ +**部署环境**: [ ] 开发 [ ] 测试 [ ] 生产 +**部署状态**: [ ] 成功 [ ] 失败 [ ] 部分成功 diff --git a/ruoyi-license/INTEGRATION.md b/ruoyi-license/INTEGRATION.md new file mode 100644 index 0000000..1b8199b --- /dev/null +++ b/ruoyi-license/INTEGRATION.md @@ -0,0 +1,231 @@ +# RuoYi 授权码模块集成指南 + +## 一、模块说明 + +本授权码模块已完成开发,包含以下文件: + +``` +ruoyi-license/ # 授权模块(独立模块) +├── src/main/java/com/ruoyi/license/ +│ ├── config/ +│ │ └── LicenseConfig.java # 拦截器配置 +│ ├── domain/ +│ │ └── SysLicense.java # 授权实体 +│ ├── interceptor/ +│ │ └── LicenseInterceptor.java # 授权拦截器 +│ ├── mapper/ +│ │ └── SysLicenseMapper.java # 数据访问接口 +│ ├── service/ +│ │ ├── ISysLicenseService.java # 服务接口 +│ │ └── impl/ +│ │ └── SysLicenseServiceImpl.java # 服务实现 +│ ├── task/ +│ │ └── LicenseCheckTask.java # 定时检查任务 +│ └── util/ +│ ├── LicenseUtils.java # 授权工具类 +│ └── LicenseGenerator.java # 授权码生成器 +├── src/main/resources/mapper/license/ +│ └── SysLicenseMapper.xml # MyBatis映射 +├── pom.xml # 模块依赖 +└── README.md # 使用说明 + +sql/ +└── sys_license.sql # 数据库脚本 + +ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/ +└── SysLicenseController.java # 授权控制器 + +ruoyi-admin/src/main/resources/templates/system/license/ +├── license.html # 授权列表页 +└── active.html # 激活页面 + +修改的文件: +- pom.xml # 添加license模块 +- ruoyi-admin/pom.xml # 添加license依赖 +- login.html # 添加激活入口 +- login.js # 添加激活功能 +``` + +## 二、部署步骤 + +### 1. 执行数据库脚本 + +```bash +# 在MySQL中执行 +mysql -u root -p your_database < sql/sys_license.sql +``` + +或手动执行 `sql/sys_license.sql` 中的SQL语句。 + +### 2. 启用定时任务 + +在启动类上添加 `@EnableScheduling` 注解: + +```java +@SpringBootApplication +@EnableScheduling // 添加此注解 +public class RuoYiApplication { + public static void main(String[] args) { + SpringApplication.run(RuoYiApplication.class, args); + } +} +``` + +### 3. 编译项目 + +```bash +cd d:\fortucky\project\RuoYi-master +mvn clean install +``` + +### 4. 生成授权码 + +**方式一:使用独立工具生成** +```bash +cd ruoyi-license/src/main/java +javac com/ruoyi/license/util/LicenseUtils.java +javac com/ruoyi/license/util/LicenseGenerator.java +java com.ruoyi.license.util.LicenseGenerator +``` + +**方式二:启动系统后在界面生成** +- 登录系统 +- 进入"系统管理 -> 授权管理" +- 点击"生成授权码"按钮 + +### 5. 激活授权码 + +**首次激活(登录页):** +1. 访问登录页 +2. 点击"激活授权码"链接 +3. 输入生成的授权码 +4. 提交激活 + +**系统内激活:** +1. 登录系统(需要先有有效授权) +2. 进入"系统管理 -> 授权管理" +3. 点击"激活授权码" +4. 输入新的授权码 + +## 三、功能验证 + +### 1. 验证授权拦截 + +- 未激活授权码时,访问任何页面应跳转到登录页并提示"授权已过期" +- 激活授权码后,可正常访问系统 + +### 2. 验证定时检查 + +- 修改数据库中授权码的 `expire_time` 为过去时间 +- 等待5分钟(或重启系统) +- 在线用户应被强制退出 +- 尝试登录应提示授权过期 + +### 3. 验证授权管理 + +- 访问"系统管理 -> 授权管理" +- 查看授权列表 +- 生成新授权码 +- 激活授权码 +- 删除过期授权 + +## 四、复用到其他项目 + +### 方式一:Maven依赖(推荐) + +1. 将 `ruoyi-license` 模块复制到目标项目 +2. 在父pom.xml添加模块声明 +3. 在需要的模块添加依赖 +4. 执行数据库脚本 +5. 复制Controller和前端页面 + +### 方式二:JAR包依赖 + +1. 打包license模块: +```bash +cd ruoyi-license +mvn clean package +``` + +2. 安装到本地仓库: +```bash +mvn install:install-file -Dfile=target/ruoyi-license-4.8.2.jar \ + -DgroupId=com.ruoyi -DartifactId=ruoyi-license \ + -Dversion=4.8.2 -Dpackaging=jar +``` + +3. 在目标项目添加依赖: +```xml + + com.ruoyi + ruoyi-license + 4.8.2 + +``` + +## 五、配置说明 + +### 1. 修改密钥(重要) + +生产环境必须修改默认密钥: + +```java +// LicenseUtils.java +private static final String SECRET_KEY = "YourCustomKey123"; // 改为16位自定义密钥 +``` + +### 2. 调整检查频率 + +```java +// LicenseCheckTask.java +@Scheduled(cron = "0 */5 * * * ?") // 每5分钟,可根据需要调整 +``` + +### 3. 自定义拦截路径 + +```java +// LicenseConfig.java +.excludePathPatterns( + "/login", + "/your-path/**" // 添加需要排除的路径 +) +``` + +## 六、注意事项 + +1. **首次部署**:必须先生成并激活授权码,否则无法登录 +2. **时间同步**:确保服务器时间准确,避免授权判断错误 +3. **密钥安全**:生产环境务必修改默认密钥 +4. **数据备份**:定期备份 `sys_license` 表数据 +5. **权限控制**:授权管理菜单仅授予超级管理员 + +## 七、故障排查 + +### 问题1:无法激活授权码 +- 检查授权码格式是否正确 +- 检查授权码是否已过期 +- 查看后台日志错误信息 + +### 问题2:授权有效但仍被拦截 +- 检查数据库中授权状态是否为"1" +- 检查 `expire_time` 是否大于当前时间 +- 重启应用服务器 + +### 问题3:定时任务不执行 +- 确认启动类添加了 `@EnableScheduling` +- 检查日志是否有定时任务执行记录 + +### 问题4:在线用户未被踢出 +- 检查 `SessionDAO` 是否正确注入 +- 查看定时任务是否正常执行 +- 检查Shiro配置是否正确 + +## 八、技术支持 + +如遇到问题,请提供以下信息: +1. 错误日志 +2. 数据库授权记录 +3. 系统环境信息 +4. 操作步骤 + +联系方式:参考RuoYi官方文档 diff --git a/ruoyi-license/LICENSE_FILTER_CONFIG.md b/ruoyi-license/LICENSE_FILTER_CONFIG.md new file mode 100644 index 0000000..7a3ba06 --- /dev/null +++ b/ruoyi-license/LICENSE_FILTER_CONFIG.md @@ -0,0 +1,168 @@ +# 授权码全局拦截配置说明 + +## 功能说明 + +通过自定义 Shiro Filter,实现授权码失效时,**所有接口**(包括 `anon` 匿名访问的接口)都无法访问。 + +## 实现原理 + +1. 创建 `LicenseValidateFilter` 继承 `AccessControlFilter` +2. 在 Shiro 过滤链的**最前面**添加此过滤器 +3. 所有请求都会先经过授权码验证,验证失败则拒绝访问 + +## 已完成的修改 + +### 1. 新增文件 +- `ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/license/LicenseValidateFilter.java` + +### 2. 修改文件 +- `ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java` + - 导入 `LicenseValidateFilter` + - 注册过滤器:`filters.put("licenseValidate", licenseValidateFilter())` + - 添加到过滤链:`filterChainDefinitionMap.put("/**", "licenseValidate,user,kickout,onlineSession,syncOnlineSession")` + +## 白名单配置 + +以下路径即使授权失效也可以访问(必要的登录和静态资源): + +```java +private static final String[] WHITE_LIST = { + "/login", // 登录页 + "/captcha/captchaImage", // 验证码 + "/css/", // 样式文件 + "/js/", // 脚本文件 + "/img/", // 图片资源 + "/fonts/", // 字体文件 + "/ajax/", // Ajax资源 + "/ruoyi/", // 若依资源 + "/favicon.ico", // 网站图标 + "/system/license/active" // 授权激活页面(必须放行) +}; +``` + +## 自定义白名单 + +如果需要添加其他路径到白名单,修改 `LicenseValidateFilter.java`: + +```java +private static final String[] WHITE_LIST = { + // ... 原有配置 + "/your-custom-path/**", // 添加你的自定义路径 +}; +``` + +## 拦截效果 + +### 授权有效时 +- 所有接口正常访问(包括 `/board/**`、`/agv/api/**` 等 anon 接口) + +### 授权失效时 +- **普通请求**:重定向到 `/login?license=expired` +- **Ajax请求**:返回 JSON `{"code":401,"msg":"授权已过期,请联系管理员激活授权码"}` +- **白名单路径**:仍可访问(用于激活授权码) + +## 测试步骤 + +### 1. 启用授权功能 +在 `application.yml` 中配置: +```yaml +license: + enabled: true +``` + +### 2. 配置项目编号 +在数据库 `sys_config` 表中添加: +```sql +INSERT INTO sys_config (config_name, config_key, config_value, config_type, create_by, create_time, remark) +VALUES ('项目编号', 'fortucky.project.no', 'FT507', 'Y', 'admin', NOW(), '用于授权码验证'); +``` + +### 3. 测试授权失效场景 + +**方式一:不激活授权码** +- 启动系统 +- 访问 `/board/**` 接口 +- 预期:被拦截,重定向到登录页 + +**方式二:授权码过期** +- 生成5分钟测试授权码并激活 +- 等待5分钟后访问 `/board/**` 接口 +- 预期:被拦截 + +### 4. 测试授权有效场景 +- 生成并激活有效授权码 +- 访问 `/board/**` 接口 +- 预期:正常访问 + +## 注意事项 + +1. **白名单必须包含授权激活页面** + - `/system/license/active` 必须在白名单中 + - 否则授权失效后无法激活新授权码 + +2. **静态资源必须放行** + - CSS、JS、图片等资源必须在白名单 + - 否则登录页面无法正常显示 + +3. **过滤器顺序很重要** + - `licenseValidate` 必须在最前面 + - 确保所有请求都先经过授权验证 + +4. **开发环境可关闭授权** + ```yaml + license: + enabled: false # 开发时可关闭 + ``` + +## 与原有拦截器的区别 + +### 原有 LicenseInterceptor(Spring MVC 拦截器) +- 在 Spring MVC 层拦截 +- 只拦截进入 Controller 的请求 +- 无法拦截 Shiro 已放行的 `anon` 接口 + +### 新增 LicenseValidateFilter(Shiro 过滤器) +- 在 Shiro 层拦截 +- 拦截所有请求(包括 `anon` 接口) +- 优先级高于 Shiro 的其他过滤器 + +## 建议 + +1. **保留两个拦截器** + - `LicenseValidateFilter`:全局拦截(包括 anon 接口) + - `LicenseInterceptor`:作为二次验证(可选) + +2. **生产环境必须启用** + ```yaml + license: + enabled: true + ``` + +3. **定期检查白名单** + - 确保白名单路径最小化 + - 避免过度放行 + +## 故障排查 + +### 问题1:所有请求都被拦截 +- 检查 `license.enabled` 是否为 `true` +- 检查是否有有效授权码 +- 查看后台日志 `[授权验证]` 相关信息 + +### 问题2:anon 接口仍可访问 +- 检查过滤器是否注册:`filters.put("licenseValidate", ...)` +- 检查过滤链配置:`"licenseValidate,user,..."` +- 确认 `licenseValidate` 在最前面 + +### 问题3:无法激活授权码 +- 检查 `/system/license/active` 是否在白名单 +- 检查白名单匹配逻辑是否正确 + +## 完成标志 + +✅ 授权失效时,`/board/**` 接口无法访问 +✅ 授权失效时,`/agv/api/**` 接口无法访问 +✅ 授权失效时,仍可访问登录页和激活页 +✅ 授权有效时,所有接口正常访问 +✅ Ajax 请求返回 JSON 错误信息 +✅ 普通请求重定向到登录页 diff --git a/ruoyi-license/README.md b/ruoyi-license/README.md new file mode 100644 index 0000000..5cfa495 --- /dev/null +++ b/ruoyi-license/README.md @@ -0,0 +1,193 @@ +# RuoYi 授权码模块 + +## 模块简介 + +ruoyi-license 是一个独立的授权码管理模块,用于控制系统的使用期限。当授权码过期后,系统将无法登录,已登录用户会被强制退出。 + +## 功能特性 + +- ✅ 授权码加密存储 +- ✅ 登录时验证授权有效性 +- ✅ 定时检查授权状态(每5分钟) +- ✅ 授权过期自动踢出在线用户 +- ✅ 系统管理界面查看/激活授权 +- ✅ 登录页面激活授权码 +- ✅ 授权码生成工具 +- ✅ 独立模块,方便其他项目复用 + +## 快速开始 + +### 1. 执行数据库脚本 + +```sql +-- 执行 sql/sys_license.sql 创建授权表和菜单 +``` + +### 2. 添加模块依赖 + +在需要使用授权功能的项目中,添加依赖: + +```xml + + com.ruoyi + ruoyi-license + 4.8.2 + +``` + +### 3. 配置包扫描 + +确保Spring能扫描到授权模块的包: + +```java +@SpringBootApplication +@ComponentScan(basePackages = {"com.ruoyi"}) +public class RuoYiApplication { + // ... +} +``` + +### 4. 生成授权码 + +访问系统管理 -> 授权管理,点击"生成授权码"按钮,输入授权天数(如365天),系统会生成加密的授权码。 + +### 5. 激活授权码 + +**方式一:登录页激活** +- 在登录页面点击"激活授权码"链接 +- 输入授权码并提交 + +**方式二:系统内激活** +- 登录系统后,进入"系统管理 -> 授权管理" +- 点击"激活授权码"按钮 +- 输入授权码并提交 + +## 核心类说明 + +### 1. 实体类 +- `SysLicense`: 授权码实体,包含授权码、开始时间、结束时间、状态等信息 + +### 2. 工具类 +- `LicenseUtils`: 授权码工具类 + - `generateLicense()`: 生成授权码 + - `encrypt()`: 加密数据 + - `decrypt()`: 解密数据 + - `validateFormat()`: 验证授权码格式 + +### 3. 服务类 +- `ISysLicenseService`: 授权服务接口 + - `activeLicense()`: 激活授权码 + - `checkLicenseValid()`: 检查授权是否有效 + - `getActiveLicense()`: 获取当前有效授权 + +### 4. 拦截器 +- `LicenseInterceptor`: 授权拦截器,在每次请求时验证授权有效性 + +### 5. 定时任务 +- `LicenseCheckTask`: 每5分钟检查授权状态,过期自动踢出在线用户 + +## 授权码格式 + +授权码采用AES加密,格式为: +``` +加密(开始时间戳|结束时间戳) +``` + +示例: +``` +原始数据: 1704067200000|1735689600000 +加密后: Xj8K9mN2pQ5rT7vW1yZ3aB4cD6eF8gH0iJ2kL4mN6oP8qR0sT2uV4wX6yZ8 +``` + +## 集成到其他项目 + +### 步骤1:复制模块 +将 `ruoyi-license` 文件夹复制到目标项目根目录 + +### 步骤2:修改pom.xml +在父pom.xml中添加: +```xml + + ruoyi-license + + + + + + com.ruoyi + ruoyi-license + ${project.version} + + + +``` + +### 步骤3:添加依赖 +在启动模块的pom.xml中添加: +```xml + + com.ruoyi + ruoyi-license + +``` + +### 步骤4:执行SQL脚本 +执行 `sql/sys_license.sql` 创建数据库表 + +### 步骤5:配置Controller +将 `SysLicenseController.java` 复制到项目的controller包中 + +### 步骤6:配置前端页面 +将 `templates/system/license/` 目录复制到项目的templates目录 + +### 步骤7:修改登录页面 +参考 `login.html` 和 `login.js` 的修改,添加授权码激活入口 + +## 自定义配置 + +### 修改密钥 +编辑 `LicenseUtils.java`: +```java +private static final String SECRET_KEY = "YourSecretKey123"; // 16位密钥 +``` + +### 修改检查频率 +编辑 `LicenseCheckTask.java`: +```java +@Scheduled(cron = "0 */10 * * * ?") // 改为每10分钟检查 +``` + +### 自定义拦截规则 +编辑 `LicenseConfig.java`,添加或排除拦截路径: +```java +.excludePathPatterns( + "/login", + "/your-custom-path/**" +) +``` + +## 注意事项 + +1. **密钥安全**:生产环境务必修改默认密钥 +2. **时间同步**:确保服务器时间准确 +3. **数据备份**:定期备份授权表数据 +4. **权限控制**:授权管理菜单仅授予管理员 +5. **测试环境**:建议先在测试环境验证功能 + +## 常见问题 + +**Q: 授权码激活失败?** +A: 检查授权码格式是否正确,是否已过期 + +**Q: 如何延长授权期限?** +A: 生成新的授权码并激活即可 + +**Q: 授权过期后如何恢复?** +A: 在登录页点击"激活授权码",输入新的授权码 + +**Q: 可以同时激活多个授权码吗?** +A: 系统只使用最新激活且未过期的授权码 + +## 技术支持 + +如有问题,请联系技术支持或查看RuoYi官方文档。 diff --git a/ruoyi-license/SUMMARY.md b/ruoyi-license/SUMMARY.md new file mode 100644 index 0000000..dc7e368 --- /dev/null +++ b/ruoyi-license/SUMMARY.md @@ -0,0 +1,239 @@ +# RuoYi 授权码模块 - 项目总结 + +## 📦 已完成的工作 + +### 1. 核心模块开发 ✅ + +**ruoyi-license 独立模块** +- ✅ Maven模块配置 (pom.xml) +- ✅ 授权实体类 (SysLicense.java) +- ✅ 数据访问层 (SysLicenseMapper.java + XML) +- ✅ 业务逻辑层 (ISysLicenseService.java + Impl) +- ✅ 授权工具类 (LicenseUtils.java) +- ✅ 授权拦截器 (LicenseInterceptor.java) +- ✅ 拦截器配置 (LicenseConfig.java) +- ✅ 定时检查任务 (LicenseCheckTask.java) +- ✅ 授权码生成器 (LicenseGenerator.java) +- ✅ 测试工具 (LicenseTest.java) + +### 2. 控制器和前端 ✅ + +**后端控制器** +- ✅ SysLicenseController.java (授权管理控制器) + - 授权列表查询 + - 授权码激活 + - 授权码生成 + - 授权信息查看 + - 授权删除 + +**前端页面** +- ✅ license.html (授权列表页) +- ✅ active.html (激活页面) +- ✅ login.html (添加激活入口) +- ✅ login.js (添加激活功能) + +### 3. 数据库脚本 ✅ + +- ✅ sys_license.sql + - 授权表结构 + - 菜单权限配置 + +### 4. 项目集成 ✅ + +- ✅ 主pom.xml (添加license模块) +- ✅ ruoyi-admin/pom.xml (添加license依赖) + +### 5. 文档编写 ✅ + +- ✅ README.md (使用说明) +- ✅ INTEGRATION.md (集成指南) + +## 🎯 功能特性 + +### 核心功能 +1. **授权码加密存储** - AES加密,安全可靠 +2. **登录验证** - 登录时自动验证授权有效性 +3. **拦截器保护** - 所有请求都经过授权验证 +4. **定时检查** - 每5分钟自动检查授权状态 +5. **自动踢出** - 授权过期自动踢出所有在线用户 +6. **管理界面** - 完整的授权管理功能 +7. **登录页激活** - 无需登录即可激活授权码 +8. **授权码生成** - 内置生成工具,支持自定义天数 + +### 技术亮点 +- 🔒 AES加密算法保护授权码 +- 🔄 Spring拦截器实现全局授权验证 +- ⏰ Spring定时任务自动检查授权 +- 🎨 完整的前后端交互界面 +- 📦 独立模块设计,方便复用 +- 🛠️ 提供测试工具和生成工具 + +## 📂 文件清单 + +``` +ruoyi-license/ +├── src/main/java/com/ruoyi/license/ +│ ├── config/ +│ │ └── LicenseConfig.java (拦截器配置) +│ ├── domain/ +│ │ └── SysLicense.java (授权实体) +│ ├── interceptor/ +│ │ └── LicenseInterceptor.java (授权拦截器) +│ ├── mapper/ +│ │ └── SysLicenseMapper.java (Mapper接口) +│ ├── service/ +│ │ ├── ISysLicenseService.java (服务接口) +│ │ └── impl/ +│ │ └── SysLicenseServiceImpl.java (服务实现) +│ ├── task/ +│ │ └── LicenseCheckTask.java (定时任务) +│ └── util/ +│ ├── LicenseUtils.java (工具类) +│ ├── LicenseGenerator.java (生成器) +│ └── LicenseTest.java (测试工具) +├── src/main/resources/mapper/license/ +│ └── SysLicenseMapper.xml (MyBatis映射) +├── pom.xml (模块配置) +├── README.md (使用说明) +└── INTEGRATION.md (集成指南) + +sql/ +└── sys_license.sql (数据库脚本) + +ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/ +└── SysLicenseController.java (控制器) + +ruoyi-admin/src/main/resources/templates/system/license/ +├── license.html (列表页) +└── active.html (激活页) + +修改的文件: +├── pom.xml (添加模块) +├── ruoyi-admin/pom.xml (添加依赖) +├── ruoyi-admin/src/main/resources/templates/login.html +└── ruoyi-admin/src/main/resources/static/ruoyi/login.js +``` + +## 🚀 快速开始 + +### 1. 执行数据库脚本 +```sql +source sql/sys_license.sql; +``` + +### 2. 启用定时任务 +在 RuoYiApplication.java 添加 @EnableScheduling + +### 3. 编译项目 +```bash +mvn clean install +``` + +### 4. 生成授权码 +运行 LicenseGenerator.java 或在系统界面生成 + +### 5. 激活授权码 +登录页点击"激活授权码"输入授权码 + +## 🔧 使用场景 + +### 场景1:软件交付 +- 开发完成后生成授权码 +- 交付给客户时提供授权码 +- 客户激活后可使用指定期限 + +### 场景2:试用版本 +- 生成30天试用授权码 +- 客户试用满意后购买正式授权 +- 激活正式授权码延长使用期限 + +### 场景3:订阅服务 +- 按年生成授权码 +- 到期前提醒客户续费 +- 续费后激活新授权码 + +### 场景4:多项目复用 +- 将license模块复制到其他项目 +- 修改密钥和配置 +- 快速实现授权功能 + +## ⚙️ 自定义配置 + +### 修改密钥(必须) +```java +// LicenseUtils.java +private static final String SECRET_KEY = "YourKey16Chars!!"; +``` + +### 调整检查频率 +```java +// LicenseCheckTask.java +@Scheduled(cron = "0 */10 * * * ?") // 改为10分钟 +``` + +### 自定义拦截路径 +```java +// LicenseConfig.java +.excludePathPatterns("/api/**", "/public/**") +``` + +## 📊 数据库表结构 + +```sql +sys_license (授权表) +├── license_id (授权ID - 主键) +├── license_code (授权码 - 加密存储) +├── start_time (开始时间) +├── expire_time (结束时间) +├── status (状态: 0未激活 1已激活 2已过期) +├── active_time (激活时间) +├── active_by (激活人) +├── create_by (创建者) +├── create_time (创建时间) +├── update_by (更新者) +├── update_time (更新时间) +└── remark (备注) +``` + +## 🔐 安全建议 + +1. **生产环境必须修改默认密钥** +2. **授权码通过安全渠道传递** +3. **定期备份授权表数据** +4. **限制授权管理菜单权限** +5. **监控授权激活日志** + +## 📝 后续优化建议 + +1. **硬件绑定** - 绑定服务器MAC地址或CPU序列号 +2. **在线验证** - 连接授权服务器在线验证 +3. **授权分级** - 不同授权码对应不同功能权限 +4. **自动续费** - 集成支付接口自动续费 +5. **授权统计** - 统计授权使用情况和到期提醒 + +## ✅ 测试清单 + +- [ ] 数据库表创建成功 +- [ ] 菜单权限配置正确 +- [ ] 授权码生成功能正常 +- [ ] 授权码加密解密正确 +- [ ] 登录页激活功能正常 +- [ ] 系统内激活功能正常 +- [ ] 授权拦截器生效 +- [ ] 定时任务执行正常 +- [ ] 授权过期自动踢出 +- [ ] 授权列表查询正常 + +## 📞 技术支持 + +如有问题,请查看: +1. README.md - 使用说明 +2. INTEGRATION.md - 集成指南 +3. RuoYi官方文档 + +--- + +**开发完成时间**: 2024 +**模块版本**: 1.0.0 +**适用框架**: RuoYi v4.8.2 +**技术栈**: SpringBoot + MyBatis + Shiro + Thymeleaf diff --git a/ruoyi-license/pom.xml b/ruoyi-license/pom.xml new file mode 100644 index 0000000..7ef9d44 --- /dev/null +++ b/ruoyi-license/pom.xml @@ -0,0 +1,43 @@ + + + + ruoyi + com.ruoyi + 3.9.0 + + 4.0.0 + + ruoyi-license + + + 授权码管理模块 + + + + + + + com.ruoyi + ruoyi-common + + + + + com.ruoyi + ruoyi-system + + + + + org.springframework.boot + spring-boot-starter-web + + + com.ruoyi + ruoyi-framework + + + + diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/config/LicenseConfig.java b/ruoyi-license/src/main/java/com/ruoyi/license/config/LicenseConfig.java new file mode 100644 index 0000000..2c4a18a --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/config/LicenseConfig.java @@ -0,0 +1,61 @@ +package com.ruoyi.license.config; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import com.ruoyi.framework.config.properties.PermitAllUrlProperties; +import com.ruoyi.license.interceptor.LicenseInterceptor; + +/** + * 授权模块配置 + * + * @author ruoyi + */ +@Configuration +public class LicenseConfig implements WebMvcConfigurer +{ + @Autowired + private LicenseInterceptor licenseInterceptor; + + @Autowired + private PermitAllUrlProperties permitAllUrl; + + @Value("${license.enabled:false}") + private boolean licenseEnabled; + + private static final List BASE_EXCLUDE = Arrays.asList( + "/login", + "/logout", + "/register", + "/captchaImage", + "/system/license/active", + "/swagger-ui.html", + "/swagger-resources/**", + "/webjars/**", + "/*/api-docs", + "/druid/**", + "/*.html", + "/**/*.html", + "/**/*.css", + "/**/*.js", + "/profile/**" + ); + + @Override + public void addInterceptors(InterceptorRegistry registry) + { + if (licenseEnabled) + { + List excludeList = new ArrayList<>(BASE_EXCLUDE); + excludeList.addAll(permitAllUrl.getUrls()); + registry.addInterceptor(licenseInterceptor) + .addPathPatterns("/**") + .excludePathPatterns(excludeList); + } + } +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/domain/SysLicense.java b/ruoyi-license/src/main/java/com/ruoyi/license/domain/SysLicense.java new file mode 100644 index 0000000..90dfc8d --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/domain/SysLicense.java @@ -0,0 +1,105 @@ +package com.ruoyi.license.domain; + +import com.ruoyi.common.core.domain.BaseEntity; +import java.util.Date; + +/** + * 系统授权码对象 sys_license + * + * @author ruoyi + */ +public class SysLicense extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 授权ID */ + private Long licenseId; + + /** 授权码 */ + private String licenseCode; + + /** 授权开始时间 */ + private Date startTime; + + /** 授权结束时间 */ + private Date expireTime; + + /** 授权状态(0未激活 1已激活 2已过期) */ + private String status; + + /** 激活时间 */ + private Date activeTime; + + /** 激活人 */ + private String activeBy; + + public Long getLicenseId() + { + return licenseId; + } + + public void setLicenseId(Long licenseId) + { + this.licenseId = licenseId; + } + + public String getLicenseCode() + { + return licenseCode; + } + + public void setLicenseCode(String licenseCode) + { + this.licenseCode = licenseCode; + } + + public Date getStartTime() + { + return startTime; + } + + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getExpireTime() + { + return expireTime; + } + + public void setExpireTime(Date expireTime) + { + this.expireTime = expireTime; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public Date getActiveTime() + { + return activeTime; + } + + public void setActiveTime(Date activeTime) + { + this.activeTime = activeTime; + } + + public String getActiveBy() + { + return activeBy; + } + + public void setActiveBy(String activeBy) + { + this.activeBy = activeBy; + } +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/interceptor/LicenseInterceptor.java b/ruoyi-license/src/main/java/com/ruoyi/license/interceptor/LicenseInterceptor.java new file mode 100644 index 0000000..0fe44d4 --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/interceptor/LicenseInterceptor.java @@ -0,0 +1,48 @@ +package com.ruoyi.license.interceptor; + +import java.io.PrintWriter; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; +import com.ruoyi.license.service.ISysLicenseService; + +/** + * 授权拦截器 + * + * @author ruoyi + */ +@Component +public class LicenseInterceptor implements HandlerInterceptor +{ + @Autowired + private ISysLicenseService licenseService; + + @Value("${license.enabled:false}") + private boolean licenseEnabled; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception + { + if (!licenseEnabled) + { + return true; + } + + if (!licenseService.checkLicenseValid()) + { + + response.setStatus(HttpServletResponse.SC_OK); + response.setContentType("application/json;charset=UTF-8"); + PrintWriter writer = response.getWriter(); + writer.write("{\"code\":500,\"msg\":\"\u7cfb\u7edf\u6388\u6743\u5df2\u8fc7\u671f\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u6fc0\u6d3b\u6388\u6743\u7801\"}"); + writer.flush(); + return false; + } + + return true; + } +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/mapper/SysLicenseMapper.java b/ruoyi-license/src/main/java/com/ruoyi/license/mapper/SysLicenseMapper.java new file mode 100644 index 0000000..bd29eb6 --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/mapper/SysLicenseMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.license.mapper; + +import com.ruoyi.license.domain.SysLicense; +import java.util.List; + +/** + * 授权码Mapper接口 + * + * @author ruoyi + */ +public interface SysLicenseMapper +{ + /** + * 查询授权码 + * + * @param licenseId 授权码ID + * @return 授权码 + */ + public SysLicense selectSysLicenseById(Long licenseId); + + /** + * 查询授权码列表 + * + * @param sysLicense 授权码 + * @return 授权码集合 + */ + public List selectSysLicenseList(SysLicense sysLicense); + + /** + * 查询当前有效的授权码 + * + * @return 授权码 + */ + public SysLicense selectActiveLicense(); + + /** + * 新增授权码 + * + * @param sysLicense 授权码 + * @return 结果 + */ + public int insertSysLicense(SysLicense sysLicense); + + /** + * 修改授权码 + * + * @param sysLicense 授权码 + * @return 结果 + */ + public int updateSysLicense(SysLicense sysLicense); + + /** + * 删除授权码 + * + * @param licenseId 授权码ID + * @return 结果 + */ + public int deleteSysLicenseById(Long licenseId); + + /** + * 批量删除授权码 + * + * @param licenseIds 需要删除的数据ID + * @return 结果 + */ + public int deleteSysLicenseByIds(String[] licenseIds); +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/service/ISysLicenseService.java b/ruoyi-license/src/main/java/com/ruoyi/license/service/ISysLicenseService.java new file mode 100644 index 0000000..1a9a225 --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/service/ISysLicenseService.java @@ -0,0 +1,87 @@ +package com.ruoyi.license.service; + +import com.ruoyi.license.domain.SysLicense; +import java.util.List; + +/** + * 授权码Service接口 + * + * @author ruoyi + */ +public interface ISysLicenseService +{ + /** + * 查询授权码 + * + * @param licenseId 授权码ID + * @return 授权码 + */ + public SysLicense selectSysLicenseById(Long licenseId); + + /** + * 查询授权码列表 + * + * @param sysLicense 授权码 + * @return 授权码集合 + */ + public List selectSysLicenseList(SysLicense sysLicense); + + /** + * 新增授权码 + * + * @param sysLicense 授权码 + * @return 结果 + */ + public int insertSysLicense(SysLicense sysLicense); + + /** + * 修改授权码 + * + * @param sysLicense 授权码 + * @return 结果 + */ + public int updateSysLicense(SysLicense sysLicense); + + /** + * 批量删除授权码 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysLicenseByIds(String ids); + + /** + * 删除授权码信息 + * + * @param licenseId 授权码ID + * @return 结果 + */ + public int deleteSysLicenseById(Long licenseId); + + /** + * 激活授权码 + * + * @param licenseCode 授权码 + * @return 结果 + */ + public int activeLicense(String licenseCode); + + /** + * 检查授权是否有效 + * + * @return true有效 false无效 + */ + public boolean checkLicenseValid(); + + /** + * 获取当前有效授权信息 + * + * @return 授权信息 + */ + public SysLicense getActiveLicense(); + + /** + * 更新过期授权码状态 + */ + public void updateExpiredLicenses(); +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/service/impl/SysLicenseServiceImpl.java b/ruoyi-license/src/main/java/com/ruoyi/license/service/impl/SysLicenseServiceImpl.java new file mode 100644 index 0000000..79f070c --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/service/impl/SysLicenseServiceImpl.java @@ -0,0 +1,266 @@ +package com.ruoyi.license.service.impl; + +import java.util.Date; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.license.domain.SysLicense; +import com.ruoyi.license.mapper.SysLicenseMapper; +import com.ruoyi.license.service.ISysLicenseService; +import com.ruoyi.license.util.LicenseUtils; + +/** + * 授权码Service业务层处理 + * + * @author ruoyi + */ +@Service +public class SysLicenseServiceImpl implements ISysLicenseService +{ + @Autowired + private SysLicenseMapper sysLicenseMapper; + + @Autowired + private com.ruoyi.system.mapper.SysConfigMapper sysConfigMapper; + + @org.springframework.beans.factory.annotation.Value("${license.enabled:false}") + private boolean licenseEnabled; + + /** + * 查询授权码 + * + * @param licenseId 授权码ID + * @return 授权码 + */ + @Override + public SysLicense selectSysLicenseById(Long licenseId) + { + return sysLicenseMapper.selectSysLicenseById(licenseId); + } + + /** + * 查询授权码列表 + * + * @param sysLicense 授权码 + * @return 授权码 + */ + @Override + public List selectSysLicenseList(SysLicense sysLicense) + { + return sysLicenseMapper.selectSysLicenseList(sysLicense); + } + + /** + * 新增授权码 + * + * @param sysLicense 授权码 + * @return 结果 + */ + @Override + public int insertSysLicense(SysLicense sysLicense) + { + sysLicense.setCreateTime(new Date()); + return sysLicenseMapper.insertSysLicense(sysLicense); + } + + /** + * 修改授权码 + * + * @param sysLicense 授权码 + * @return 结果 + */ + @Override + public int updateSysLicense(SysLicense sysLicense) + { + sysLicense.setUpdateTime(new Date()); + return sysLicenseMapper.updateSysLicense(sysLicense); + } + + /** + * 删除授权码对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteSysLicenseByIds(String ids) + { + return sysLicenseMapper.deleteSysLicenseByIds(Convert.toStrArray(ids)); + } + + /** + * 删除授权码信息 + * + * @param licenseId 授权码ID + * @return 结果 + */ + @Override + public int deleteSysLicenseById(Long licenseId) + { + return sysLicenseMapper.deleteSysLicenseById(licenseId); + } + + /** + * 激活授权码 + * + * @param licenseCode 授权码 + * @return 结果 + */ + @Override + public int activeLicense(String licenseCode) + { + if (StringUtils.isEmpty(licenseCode)) + { + return 0; + } + + // 验证授权码格式 + if (!LicenseUtils.validateFormat(licenseCode)) + { + return 0; + } + + try + { + // 从配置表获取项目编号 + String projectNo = sysConfigMapper.selectConfigByKey("fortucky.project.no"); + if (StringUtils.isEmpty(projectNo)) + { + return 0; + } + + // 解析授权码 + long expireTime = LicenseUtils.parseLicense(licenseCode, projectNo); + if (expireTime == 0) + { + return 0; + } + + Date now = new Date(); + Date startTime = now; + Date expireDate = new Date(expireTime); + + // 验证是否已过期 + if (expireDate.before(now)) + { + return 0; + } + + // 创建授权记录 + SysLicense license = new SysLicense(); + license.setLicenseCode(licenseCode); + license.setStartTime(startTime); + license.setExpireTime(expireDate); + license.setStatus("1"); + license.setActiveTime(now); + license.setCreateTime(now); + + return sysLicenseMapper.insertSysLicense(license); + } + catch (Exception e) + { + return 0; + } + } + + /** + * 检查授权是否有效 + * + * @return true有效 false无效 + */ + @Override + public boolean checkLicenseValid() + { + // 如果授权码功能未启用,直接返回true + if (!licenseEnabled) + { + return true; + } + + SysLicense license = sysLicenseMapper.selectActiveLicense(); + if (license == null) + { + System.out.println("[授权检查] 没有找到激活的授权码"); + return false; + } + + // 从配置表获取项目编号 + String projectNo = sysConfigMapper.selectConfigByKey("fortucky.project.no"); + if (StringUtils.isEmpty(projectNo)) + { + System.out.println("[授权检查] 项目编号未配置"); + return false; + } + + System.out.println("[授权检查] 授权码: " + license.getLicenseCode()); + System.out.println("[授权检查] 项目编号: " + projectNo); + + // 从授权码解析过期时间 + long expireTime = LicenseUtils.parseLicense(license.getLicenseCode(), projectNo); + if (expireTime == 0) + { + System.out.println("[授权检查] 授权码解析失败"); + return false; + } + + Date now = new Date(); + System.out.println("[授权检查] 当前时间: " + now.getTime()); + System.out.println("[授权检查] 过期时间: " + expireTime); + + if (expireTime < now.getTime()) + { + System.out.println("[授权检查] 授权已过期"); + // 更新为过期状态 + license.setStatus("2"); + sysLicenseMapper.updateSysLicense(license); + return false; + } + + + return true; + } + + /** + * 获取当前有效授权信息 + * + * @return 授权信息 + */ + @Override + public SysLicense getActiveLicense() + { + return sysLicenseMapper.selectActiveLicense(); + } + + /** + * 更新过期授权码状态 + */ + @Override + public void updateExpiredLicenses() + { + SysLicense query = new SysLicense(); + query.setStatus("1"); + List licenses = sysLicenseMapper.selectSysLicenseList(query); + + // 从配置表获取项目编号 + String projectNo = sysConfigMapper.selectConfigByKey("fortucky.project.no"); + if (StringUtils.isEmpty(projectNo)) + { + return; + } + + Date now = new Date(); + for (SysLicense license : licenses) + { + // 从授权码解析过期时间 + long expireTime = LicenseUtils.parseLicense(license.getLicenseCode(), projectNo); + if (expireTime > 0 && expireTime < now.getTime()) + { + license.setStatus("2"); + license.setUpdateTime(now); + sysLicenseMapper.updateSysLicense(license); + } + } + } +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/task/LicenseCheckTask.java b/ruoyi-license/src/main/java/com/ruoyi/license/task/LicenseCheckTask.java new file mode 100644 index 0000000..9963c61 --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/task/LicenseCheckTask.java @@ -0,0 +1,47 @@ +package com.ruoyi.license.task; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import com.ruoyi.common.constant.CacheConstants; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.license.service.ISysLicenseService; + +/** + * 授权检查定时任务 + * + * @author ruoyi + */ +@Component +public class LicenseCheckTask +{ + @Autowired + private ISysLicenseService licenseService; + + @Autowired + private RedisCache redisCache; + + @Value("${license.enabled:false}") + private boolean licenseEnabled; + + /** + * 每5分钟检查一次授权状态 + */ + @Scheduled(cron = "0 */5 * * * ?") + public void checkLicense() + { + if (!licenseEnabled) + { + return; + } + + if (!licenseService.checkLicenseValid()) + { + // 授权无效,删除 Redis 中所有登录 token,强制踢出所有在线用户 + redisCache.deleteObject(redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*")); + } + + licenseService.updateExpiredLicenses(); + } +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseGenerator.java b/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseGenerator.java new file mode 100644 index 0000000..16ce407 --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseGenerator.java @@ -0,0 +1,127 @@ +package com.ruoyi.license.util; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Scanner; + +/** + * 授权码生成工具(独立运行) + * + * @author ruoyi + */ +public class LicenseGenerator +{ + public static void main(String[] args) + { + Scanner scanner = new Scanner(System.in); + + System.out.println("========================================"); + System.out.println(" RuoYi 授权码生成工具"); + System.out.println("========================================"); + System.out.println(); + + try + { + // 选择授权类型 + System.out.println("请选择授权类型:"); + System.out.println("1. 5分钟测试"); + System.out.println("2. 1个月授权"); + System.out.println("3. 3个月授权"); + System.out.println("4. 1年授权"); + System.out.println("5. 5年授权"); + System.out.println("6. 长期授权"); + System.out.print("请输入选项(1-6): "); + String typeChoice = scanner.nextLine().trim(); + + String type; + String typeDesc; + long expireTime; + + switch (typeChoice) + { + case "1": + type = LicenseUtils.TYPE_TEST; + typeDesc = "5分钟测试"; + expireTime = System.currentTimeMillis() + 5 * 60 * 1000L; + break; + case "2": + type = LicenseUtils.TYPE_MONTH; + typeDesc = "1个月授权"; + expireTime = System.currentTimeMillis() + 30L * 24 * 60 * 60 * 1000; + break; + case "3": + type = LicenseUtils.TYPE_THREE; + typeDesc = "3个月授权"; + expireTime = System.currentTimeMillis() + 90L * 24 * 60 * 60 * 1000; + break; + case "4": + type = LicenseUtils.TYPE_YEAR; + typeDesc = "1年授权"; + expireTime = System.currentTimeMillis() + 365L * 24 * 60 * 60 * 1000; + break; + case "5": + type = LicenseUtils.TYPE_FIVE; + typeDesc = "5年授权"; + expireTime = System.currentTimeMillis() + 5 * 365L * 24 * 60 * 60 * 1000; + break; + case "6": + type = LicenseUtils.TYPE_FOREVER; + typeDesc = "长期授权"; + expireTime = System.currentTimeMillis() + 100 * 365L * 24 * 60 * 60 * 1000; + break; + default: + System.out.println("错误:无效的选项"); + return; + } + + // 输入项目编号 + System.out.print("请输入项目编号: "); + String projectNo = scanner.nextLine().trim(); + + if (projectNo.isEmpty()) + { + System.out.println("错误:项目编号不能为空"); + return; + } + + // 生成授权码 + String licenseCode = LicenseUtils.generateLicense(type, projectNo); + + if (licenseCode == null) + { + System.out.println("错误:授权码生成失败"); + return; + } + + // 格式化日期 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + Date expire = new Date(expireTime); + + System.out.println(); + System.out.println("========================================"); + System.out.println("授权码生成成功!"); + System.out.println("========================================"); + System.out.println("授权类型: " + typeDesc); + System.out.println("项目编号: " + projectNo); + System.out.println("当前时间: " + sdf.format(now)); + System.out.println("过期时间: " + sdf.format(expire)); + System.out.println("----------------------------------------"); + System.out.println("授权码:"); + System.out.println(licenseCode); + System.out.println("========================================"); + System.out.println(); + System.out.println("请妥善保管授权码,在系统中激活后即可使用。"); + System.out.println("注意:系统配置中的项目编号必须与此处一致才能激活。"); + } + catch (Exception e) + { + System.out.println("错误:" + e.getMessage()); + e.printStackTrace(); + } + finally + { + scanner.close(); + } + } +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseTest.java b/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseTest.java new file mode 100644 index 0000000..beff323 --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseTest.java @@ -0,0 +1,90 @@ +package com.ruoyi.license.util; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 授权码测试工具 + * + * @author ruoyi + */ +public class LicenseTest +{ + public static void main(String[] args) + { + System.out.println("========================================"); + System.out.println(" 授权码功能测试"); + System.out.println("========================================"); + System.out.println(); + + String projectNo = "FT541"; + + + // 测试1:生成各类型授权码 + System.out.println("【测试1】生成各类型授权码"); + String testCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_TEST, projectNo); + String yearCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_YEAR, projectNo); + String fiveCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_FIVE, projectNo); + String foreverCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_FOREVER, projectNo); + + System.out.println("5分钟测试: " + testCode); + System.out.println("1年授权: " + yearCode); + System.out.println("5年授权: " + fiveCode); + System.out.println("长期授权: " + foreverCode); + System.out.println("结果: ✓ 通过"); + System.out.println(); + + // 测试2:验证授权码格式 + System.out.println("【测试2】验证授权码格式"); + boolean isValid = LicenseUtils.validateFormat(yearCode); + System.out.println("格式验证: " + (isValid ? "✓ 通过" : "✗ 失败")); + System.out.println(); + + // 测试3:解析授权码 + System.out.println("【测试3】解析授权码"); + long expireTime = LicenseUtils.parseLicense(yearCode, projectNo); + if (expireTime > 0) + { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date expire = new Date(expireTime); + System.out.println("过期时间: " + sdf.format(expire)); + System.out.println("结果: ✓ 通过"); + } + else + { + System.out.println("结果: ✗ 失败"); + } + System.out.println(); + + // 测试4:项目编号验证 + System.out.println("【测试4】项目编号验证"); + long validResult = LicenseUtils.parseLicense(yearCode, projectNo); + long invalidResult = LicenseUtils.parseLicense(yearCode, "WRONG001"); + System.out.println("正确项目编号: " + (validResult > 0 ? "✓ 通过" : "✗ 失败")); + System.out.println("错误项目编号: " + (invalidResult == 0 ? "✓ 通过(正确拒绝)" : "✗ 失败")); + System.out.println(); + + // 测试5:授权码格式展示 + System.out.println("【测试5】授权码格式展示"); + System.out.println("授权码: " + yearCode); + String[] parts = yearCode.split("_"); + if (parts.length == 5) + { + System.out.println("前缀: " + parts[0]); + System.out.println("类型: " + parts[1] + " (" + LicenseUtils.getTypeDesc(parts[1]) + ")"); + System.out.println("项目编号: " + parts[2]); + System.out.println("加密时间: " + parts[3]); + System.out.println("校验码: " + parts[4]); + System.out.println("结果: ✓ 通过"); + } + else + { + System.out.println("结果: ✗ 失败"); + } + System.out.println(); + + System.out.println("========================================"); + System.out.println("测试完成!"); + System.out.println("========================================"); + } +} diff --git a/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseUtils.java b/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseUtils.java new file mode 100644 index 0000000..ef456ae --- /dev/null +++ b/ruoyi-license/src/main/java/com/ruoyi/license/util/LicenseUtils.java @@ -0,0 +1,275 @@ +package com.ruoyi.license.util; + +import java.util.Base64; +import java.util.Date; +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +/** + * 授权码工具类 + * 格式: FORTUCKY_授权类型_项目编号_加密时间_校验码 + * + * @author ruoyi + */ +public class LicenseUtils +{ + // 密钥(16位) + private static final String SECRET_KEY = "RuoYiLicense2024"; + + // 授权类型 + public static final String TYPE_TEST = "TEST"; // 5分钟测试 + public static final String TYPE_MONTH = "MONTH"; // 1个月 + public static final String TYPE_THREE = "THREE"; // 3个月 + public static final String TYPE_YEAR = "YEAR"; // 1年 + public static final String TYPE_FIVE = "FIVE"; // 5年 + public static final String TYPE_FOREVER = "FOREVER"; // 长期 + + /** + * 生成授权码 + * + * @param type 授权类型 + * @param projectNo 项目编号 + * @return 授权码 + */ + public static String generateLicense(String type, String projectNo) + { + try + { + long expireTime = calculateExpireTime(type); + if (expireTime == 0) + { + return null; + } + + // 加密过期时间 + String encryptedTime = encrypt(String.valueOf(expireTime)); + if (encryptedTime == null) + { + return null; + } + + // 生成校验码(取加密时间的前8位MD5) + String checkCode = generateCheckCode(type, projectNo, encryptedTime); + + // 拼接授权码: FORTUCKY_类型_项目编号_加密时间_校验码 + return "FORTUCKY_" + type + "_" + projectNo + "_" + encryptedTime + "_" + checkCode; + } + catch (Exception e) + { + return null; + } + } + + /** + * 验证授权码格式 + * + * @param licenseCode 授权码 + * @return true有效 false无效 + */ + public static boolean validateFormat(String licenseCode) + { + if (licenseCode == null || licenseCode.trim().isEmpty()) + { + return false; + } + + String[] parts = licenseCode.split("_"); + if (parts.length != 5) + { + return false; + } + + if (!"FORTUCKY".equals(parts[0])) + { + return false; + } + + // 验证授权类型 + String type = parts[1]; + if (!TYPE_TEST.equals(type) && !TYPE_MONTH.equals(type) && !TYPE_THREE.equals(type) && + !TYPE_YEAR.equals(type) && !TYPE_FIVE.equals(type) && !TYPE_FOREVER.equals(type)) + { + return false; + } + + return true; + } + + /** + * 解析授权码 + * + * @param licenseCode 授权码 + * @param projectNo 系统项目编号 + * @return 过期时间戳,0表示解析失败 + */ + public static long parseLicense(String licenseCode, String projectNo) + { + try + { + if (!validateFormat(licenseCode)) + { + return 0; + } + + String[] parts = licenseCode.split("_"); + String type = parts[1]; + String codeProjectNo = parts[2]; + String encryptedTime = parts[3]; + String checkCode = parts[4]; + + // 验证项目编号 + if (!codeProjectNo.equals(projectNo)) + { + return 0; + } + + // 验证校验码 + String expectedCheckCode = generateCheckCode(type, codeProjectNo, encryptedTime); + if (!checkCode.equals(expectedCheckCode)) + { + return 0; + } + + // 解密时间 + String decrypted = decrypt(encryptedTime); + if (decrypted == null) + { + return 0; + } + + return Long.parseLong(decrypted); + } + catch (Exception e) + { + return 0; + } + } + + /** + * 获取授权类型描述 + * + * @param type 授权类型 + * @return 描述 + */ + public static String getTypeDesc(String type) + { + switch (type) + { + case TYPE_TEST: return "5分钟测试"; + case TYPE_MONTH: return "1个月授权"; + case TYPE_THREE: return "3个月授权"; + case TYPE_YEAR: return "1年授权"; + case TYPE_FIVE: return "5年授权"; + case TYPE_FOREVER: return "长期授权"; + default: return "未知"; + } + } + + /** + * 计算过期时间 + * + * @param type 授权类型 + * @return 过期时间戳 + */ + private static long calculateExpireTime(String type) + { + long now = System.currentTimeMillis(); + + switch (type) + { + case TYPE_TEST: + return now + 5 * 60 * 1000L; // 5分钟 + case TYPE_MONTH: + return now + 30L * 24 * 60 * 60 * 1000; // 1个月 + case TYPE_THREE: + return now + 90L * 24 * 60 * 60 * 1000; // 3个月 + case TYPE_YEAR: + return now + 365L * 24 * 60 * 60 * 1000; // 1年 + case TYPE_FIVE: + return now + 5 * 365L * 24 * 60 * 60 * 1000; // 5年 + case TYPE_FOREVER: + return now + 100 * 365L * 24 * 60 * 60 * 1000; // 100年(视为长期) + default: + return 0; + } + } + + /** + * 生成校验码 + * + * @param type 授权类型 + * @param projectNo 项目编号 + * @param encryptedTime 加密时间 + * @return 校验码 + */ + private static String generateCheckCode(String type, String projectNo, String encryptedTime) + { + try + { + String data = type + projectNo + encryptedTime; + java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); + byte[] hash = md.digest(data.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < Math.min(4, hash.length); i++) + { + sb.append(String.format("%02x", hash[i])); + } + return sb.toString().toUpperCase(); + } + catch (Exception e) + { + return "00000000"; + } + } + + /** + * 加密 + * + * @param data 原始数据 + * @return 加密后的数据 + */ + private static String encrypt(String data) + { + try + { + SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes("UTF-8"), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, key); + byte[] encrypted = cipher.doFinal(data.getBytes("UTF-8")); + return Base64.getEncoder().encodeToString(encrypted).replace("+", "-").replace("/", ".").replace("=", ""); + } + catch (Exception e) + { + return null; + } + } + + /** + * 解密 + * + * @param encryptedData 加密数据 + * @return 解密后的数据 + */ + private static String decrypt(String encryptedData) + { + try + { + String base64Data = encryptedData.replace("-", "+").replace(".", "/"); + int padding = (4 - base64Data.length() % 4) % 4; + for (int i = 0; i < padding; i++) + { + base64Data += "="; + } + + SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes("UTF-8"), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, key); + byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(base64Data)); + return new String(decrypted, "UTF-8"); + } + catch (Exception e) + { + return null; + } + } +} diff --git a/ruoyi-license/src/main/resources/mapper/license/SysLicenseMapper.xml b/ruoyi-license/src/main/resources/mapper/license/SysLicenseMapper.xml new file mode 100644 index 0000000..e6603f0 --- /dev/null +++ b/ruoyi-license/src/main/resources/mapper/license/SysLicenseMapper.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + select license_id, license_code, start_time, expire_time, status, active_time, active_by, create_by, create_time, update_by, update_time, remark from sys_license + + + + + + + + + + insert into sys_license + + license_code, + start_time, + expire_time, + status, + active_time, + active_by, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{licenseCode}, + #{startTime}, + #{expireTime}, + #{status}, + #{activeTime}, + #{activeBy}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update sys_license + + license_code = #{licenseCode}, + start_time = #{startTime}, + expire_time = #{expireTime}, + status = #{status}, + active_time = #{activeTime}, + active_by = #{activeBy}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where license_id = #{licenseId} + + + + delete from sys_license where license_id = #{licenseId} + + + + delete from sys_license where license_id in + + #{licenseId} + + + + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java index 5342a06..6380931 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java @@ -74,4 +74,6 @@ public interface SysConfigMapper * @return 结果 */ public int deleteConfigByIds(Long[] configIds); + + String selectConfigByKey(String configKey); } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml index 6891002..c5a9345 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml @@ -117,4 +117,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + diff --git a/ruoyi-ui/README.md b/ruoyi-ui/README.md index 9630425..3b31977 100644 --- a/ruoyi-ui/README.md +++ b/ruoyi-ui/README.md @@ -1,4 +1,5 @@ - ## 开发 + +## 开发 ```bash # 克隆项目 diff --git a/ruoyi-ui/src/api/license.js b/ruoyi-ui/src/api/license.js new file mode 100644 index 0000000..e8ead05 --- /dev/null +++ b/ruoyi-ui/src/api/license.js @@ -0,0 +1,16 @@ +import request from '@/utils/request' + +export function activeLicense(licenseCode) { + return request({ + url: '/system/license/active', + method: 'post', + params: { licenseCode } + }) +} + +export function getLicenseInfo() { + return request({ + url: '/system/license/info', + method: 'get' + }) +} diff --git a/ruoyi-ui/src/assets/styles/element-ui.scss b/ruoyi-ui/src/assets/styles/element-ui.scss index 363092a..49201a0 100644 --- a/ruoyi-ui/src/assets/styles/element-ui.scss +++ b/ruoyi-ui/src/assets/styles/element-ui.scss @@ -89,4 +89,58 @@ > .el-submenu__title .el-submenu__icon-arrow { display: none; -} \ No newline at end of file +} + +// global button styles +.el-button { + font-weight: 700 !important; + color: #303133 !important; +} + +.el-button--primary, +.el-button--success, +.el-button--danger, +.el-button--info, +.el-button--warning { + background-color: #f5f7fa !important; + border-color: #dcdfe6 !important; + color: #303133 !important; + font-weight: 700 !important; +} + +.el-button--primary:hover, +.el-button--success:hover, +.el-button--danger:hover, +.el-button--info:hover, +.el-button--warning:hover { + background-color: #e4e7ed !important; + border-color: #c0c4cc !important; +} + +// global checkbox styles +.el-checkbox__inner, +.el-table th .el-checkbox__inner, +.el-table td .el-checkbox__inner { + border: 2px solid #606266 !important; + width: 16px; + height: 16px; +} + +.el-checkbox.is-checked .el-checkbox__inner, +.el-checkbox.is-indeterminate .el-checkbox__inner, +.el-table .is-checked .el-checkbox__inner, +.el-table .is-indeterminate .el-checkbox__inner { + background-color: #606266 !important; + border-color: #606266 !important; +} + +.el-checkbox__inner::after, +.el-table .el-checkbox__inner::after { + border: 2px solid #fff !important; +} + +.el-checkbox.is-indeterminate .el-checkbox__inner::before, +.el-table .is-indeterminate .el-checkbox__inner::before { + background-color: #fff !important; + height: 2px !important; +} diff --git a/ruoyi-ui/src/components/Pagination/index.vue b/ruoyi-ui/src/components/Pagination/index.vue index 7c45781..3de78e8 100644 --- a/ruoyi-ui/src/components/Pagination/index.vue +++ b/ruoyi-ui/src/components/Pagination/index.vue @@ -36,7 +36,7 @@ export default { pageSizes: { type: Array, default() { - return [10, 50, 100, 500] + return [10, 100, 200, 500] } }, // 移动端页码按钮的数量端默认值5 diff --git a/ruoyi-ui/src/layout/components/Navbar.vue b/ruoyi-ui/src/layout/components/Navbar.vue index 8b51fc4..5cc61d1 100644 --- a/ruoyi-ui/src/layout/components/Navbar.vue +++ b/ruoyi-ui/src/layout/components/Navbar.vue @@ -1,41 +1,49 @@ @@ -48,11 +56,11 @@ import Hamburger from '@/components/Hamburger' import Screenfull from '@/components/Screenfull' import SizeSelect from '@/components/SizeSelect' import Search from '@/components/HeaderSearch' -// import RuoYiGit from '@/components/RuoYi/Git' -// import RuoYiDoc from '@/components/RuoYi/Doc' +import RuoYiGit from '@/components/RuoYi/Git' +import RuoYiDoc from '@/components/RuoYi/Doc' +import { getLicenseInfo } from '@/api/license' export default { - emits: ['setLayout'], components: { Breadcrumb, TopNav, @@ -60,19 +68,31 @@ export default { Screenfull, SizeSelect, Search, - // RuoYiGit, - // RuoYiDoc + RuoYiGit, + RuoYiDoc + }, + data() { + return { + licenseWarning: false, + licenseExpireText: '', + licenseTimer: null + } }, computed: { ...mapGetters([ 'sidebar', 'avatar', - 'device', - 'nickName' + 'device' ]), setting: { get() { return this.$store.state.settings.showSettings + }, + set(val) { + this.$store.dispatch('settings/changeSetting', { + key: 'showSettings', + value: val + }) } }, topNav: { @@ -81,17 +101,49 @@ export default { } } }, + mounted() { + this.checkLicenseExpire() + this.licenseTimer = setInterval(() => this.checkLicenseExpire(), 60 * 1000) + }, + beforeDestroy() { + if (this.licenseTimer) { + clearInterval(this.licenseTimer) + } + }, methods: { + checkLicenseExpire() { + getLicenseInfo().then(res => { + if (res.code === 200 && res.data && res.data.expireTime) { + const expireTime = new Date(res.data.expireTime).getTime() + const now = Date.now() + const diffMs = expireTime - now + const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24)) + if (diffMs > 0 && diffDays <= 30) { + this.licenseWarning = true + if (diffMs < 1000 * 60 * 60 * 24) { + const hours = Math.floor(diffMs / (1000 * 60 * 60)) + const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60)) + if (hours > 0) { + this.licenseExpireText = hours + ' 小时 ' + minutes + ' 分钟' + } else { + this.licenseExpireText = minutes + ' 分钟' + } + } else if (diffDays < 7) { + this.licenseExpireText = diffDays + ' 天' + } else { + this.licenseExpireText = Math.ceil(diffDays / 7) + ' 周' + } + } + } + }).catch(() => {}) + }, toggleSideBar() { this.$store.dispatch('app/toggleSideBar') }, - setLayout(event) { - this.$emit('setLayout') - }, logout() { - this.$confirm(this.$t('top.logoutTip'), this.$t('top.logoutTitle'), { - confirmButtonText: this.$t('top.confirm') , - cancelButtonText: this.$t('top.cancel') , + this.$confirm('确定注销并退出系统吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', type: 'warning' }).then(() => { this.$store.dispatch('LogOut').then(() => { @@ -104,15 +156,25 @@ export default { + diff --git a/ruoyi-ui/src/views/in/job/index.vue b/ruoyi-ui/src/views/in/job/index.vue index 7d195a6..44967f8 100644 --- a/ruoyi-ui/src/views/in/job/index.vue +++ b/ruoyi-ui/src/views/in/job/index.vue @@ -131,20 +131,20 @@ - + - - + + + - - - - - - + + + + + 入库物料 - + 添加物料 - - +
+ + + @@ -18,7 +18,7 @@ - + @@ -27,19 +27,15 @@ 重置 - - - - -
- 主单列表 -
+
+ 主单列表 +
单据作废 单据审核 单据确认 - 打印条码 - 导入 - + + 导入 +
@@ -70,27 +66,33 @@ :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" - style="padding: 10px 0 0 0;" + style="padding: 8px 0;" /> - - - -
- +
+ 子单明细 (当前主单: {{ queryDetailParams.stockinId }}) + -
+
+ + + + + 保存子单明细
- + 批量填充 +
+ {{ detailFilters.assignedStatus === 'assigned' ? '已分配' : '未分配' }}
- - - - - - - - + + + + + + - + + + + + + + + + +