From 1bfbcf123f9600dce1994c256e36ce86c6d145f1 Mon Sep 17 00:00:00 2001 From: FOAM <491460741@qq.com> Date: Tue, 30 Sep 2025 12:07:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B6=E9=80=A0=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basicdata/repository/PointRepository.java | 6 +- .../basicdata/rest/PointController.java | 2 +- .../impl/ImportProductionPlanServiceImpl.java | 15 ++- .../inputJson/buttenJson/InvYW.java | 16 +++ .../rest/InventoryController.java | 27 +++-- .../service/InventoryService.java | 12 +- .../service/dto/InventoryQueryCriteria.java | 3 + .../service/dto/InventoryQueryDto.java | 1 + .../service/impl/InventoryServiceImpl.java | 113 +++++++++++------- .../service/impl/PickDetailServiceImpl.java | 10 +- .../service/mapstruct/InventoryQQMapper.java | 33 +++++ .../com/youchain/utils/ExcelDownUtils.java | 37 +++++- 12 files changed, 197 insertions(+), 78 deletions(-) create mode 100644 youchain-system/src/main/java/com/youchain/businessdata/inputJson/buttenJson/InvYW.java create mode 100644 youchain-system/src/main/java/com/youchain/businessdata/service/mapstruct/InventoryQQMapper.java diff --git a/youchain-system/src/main/java/com/youchain/basicdata/repository/PointRepository.java b/youchain-system/src/main/java/com/youchain/basicdata/repository/PointRepository.java index 0870cee..e108c78 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/repository/PointRepository.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/repository/PointRepository.java @@ -48,7 +48,9 @@ public interface PointRepository extends JpaRepository, JpaSpecific @Query(value = "select p.code,area.`name` areaName from base_point p \n" + "left join base_area area on area.id=p.area_id " + - " where (area.name=:areaName or :areaName is null) and p.description='自由货位标签'", nativeQuery = true) - List queryPrintAll(String areaName); + " where (area.name=:areaName or :areaName is null) " + + " and (p.code like CONCAT('%',:pointCode,'%') or :pointCode is null) " + + "and p.bqlx='自由货位标签'", nativeQuery = true) + List queryPrintAll(String areaName,String pointCode); } \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/rest/PointController.java b/youchain-system/src/main/java/com/youchain/basicdata/rest/PointController.java index bcdbd32..cfb1ca3 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/rest/PointController.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/rest/PointController.java @@ -202,7 +202,7 @@ public class PointController { public ResponseEntity queryPointPrintList(PointQueryCriteria criteria){ RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); redisUtils.del(SecurityUtils.getCurrentUsername()+"_BiaoQian_ZY"); - List list=pointRepository.queryPrintAll(criteria.getAreaName()); + List list=pointRepository.queryPrintAll(criteria.getAreaName(),criteria.getCode()); redisUtils.set(SecurityUtils.getCurrentUsername()+"_BiaoQian_ZY", JsonUtil.toJson(list)); return new ResponseEntity<>(list,HttpStatus.OK); } diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportProductionPlanServiceImpl.java b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportProductionPlanServiceImpl.java index f2409ac..e66f4c1 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportProductionPlanServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportProductionPlanServiceImpl.java @@ -94,12 +94,15 @@ public class ImportProductionPlanServiceImpl implements ImportProductionPlanServ } maps.put(zcdx+machineNo,IDNO); } - int hyCount = productionPlanRepository.existsGwHyIdno(IDNO,zcdx,machineNo); - if (hyCount > 0) { - throw new BadRequestException( "大于" + IDNO + "存在已耗用数据"); - } else { - List productionPlans = productionPlanRepository.findByGwIdnoList(IDNO ,zcdx,machineNo); - productionPlanRepository.deleteAll(productionPlans); + //如果IDNO为自编码,则不校验直接存储 + if(IDNO.indexOf("-")<0) { + int hyCount = productionPlanRepository.existsGwHyIdno(IDNO, zcdx, machineNo); + if (hyCount > 0) { + throw new BadRequestException("大于" + IDNO + "存在已耗用数据"); + } else { + List productionPlans = productionPlanRepository.findByGwIdnoList(IDNO, zcdx, machineNo); + productionPlanRepository.deleteAll(productionPlans); + } } } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/inputJson/buttenJson/InvYW.java b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/buttenJson/InvYW.java new file mode 100644 index 0000000..d51918a --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/buttenJson/InvYW.java @@ -0,0 +1,16 @@ +package com.youchain.businessdata.inputJson.buttenJson; + +import com.youchain.basicdata.domain.Point; +import com.youchain.businessdata.domain.Inventory; +import lombok.Data; + +@Data +public class InvYW { + //目标库位 + private Point dstPoint; + //目标库位 + private Long id; + //移动数量 + private double rmNumber; + +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/InventoryController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/InventoryController.java index 906c668..e7c5112 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/InventoryController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/InventoryController.java @@ -25,6 +25,7 @@ import com.youchain.basicdata.repository.BomAccountRepository; import com.youchain.basicdata.repository.PointRepository; import com.youchain.businessdata.domain.*; import com.youchain.businessdata.inputJson.XdMoveReq; +import com.youchain.businessdata.inputJson.buttenJson.InvYW; import com.youchain.businessdata.inputJson.buttenJson.InventoryButton; import com.youchain.businessdata.repository.InventoryRepository; import com.youchain.businessdata.repository.TaskRepository; @@ -103,7 +104,8 @@ public class InventoryController { @GetMapping(value = "/downloadZz") @AnonymousAccess public void downloadZz(HttpServletResponse response, InventoryQueryCriteria criteria) throws Exception { - inventoryService.downloadZz(inventoryService.queryAll(criteria), response); + List all= inventoryService.queryInvAll(criteria); + inventoryService.downloadZz(all, response); } @GetMapping @@ -123,7 +125,7 @@ public class InventoryController { @ApiOperation("查询制造库存") @AnonymousAccess public ResponseEntity queryInventoryZz(InventoryQueryCriteria criteria, Pageable pageable) { - return new ResponseEntity<>(inventoryService.queryAll(criteria, pageable), HttpStatus.OK); + return new ResponseEntity<>(inventoryService.queryInvAll(criteria, pageable), HttpStatus.OK); } @PostMapping @@ -140,15 +142,17 @@ public class InventoryController { @PreAuthorize("@el.check('super:man')") public ResponseEntity updateInventory(@Validated @RequestBody Inventory resources) { //库存修改 - Inventory byId = inventoryRepository.getById(resources.getId()); - if (byId.getQuantity()>resources.getQuantity()){//以前的大于现在的 - inventoryLogService.storeInventoryLog(BizStatus.INVENTORY_ADJUST, BizStatus.REDUCE, null, byId.getArea(), byId.getItemKey(), byId.getPoint(), byId.getPoint(), byId.getStock(), byId.getStock(), byId.getQuantity(), (byId.getQuantity() - resources.getQuantity()), - null,null,BizStatus.INVENTORY_ADJUST, byId.getId(), byId.getId(), resources.getDescription()); + Inventory inventory = inventoryRepository.getById(resources.getId()); + ItemKey itemKey=inventory.getItemKey(); + if (inventory.getQuantity()>resources.getQuantity()){//以前的大于现在的 + inventoryLogService.storeInventoryLog(BizStatus.INVENTORY_ADJUST, BizStatus.REDUCE, null, inventory.getArea(), itemKey, inventory.getPoint(), inventory.getPoint(), inventory.getStock(), inventory.getStock(), inventory.getQuantity(), (inventory.getQuantity() - resources.getQuantity()), + inventory.getStockCode(),null,BizStatus.INVENTORY_ADJUST, inventory.getId(), inventory.getId(), resources.getDescription()); }else { - inventoryLogService.storeInventoryLog(BizStatus.INVENTORY_ADJUST, BizStatus.ADD, null, byId.getArea(), byId.getItemKey(), byId.getPoint(), byId.getPoint(), byId.getStock(), byId.getStock(), byId.getQuantity(), (resources.getQuantity()-byId.getQuantity()), - null,null,BizStatus.INVENTORY_ADJUST, byId.getId(), byId.getId(), resources.getDescription()); + inventoryLogService.storeInventoryLog(BizStatus.INVENTORY_ADJUST, BizStatus.ADD, null, inventory.getArea(), itemKey, inventory.getPoint(), inventory.getPoint(), inventory.getStock(), inventory.getStock(), inventory.getQuantity(), (resources.getQuantity()-inventory.getQuantity()), + inventory.getStockCode(),null,BizStatus.INVENTORY_ADJUST, inventory.getId(), inventory.getId(), resources.getDescription()); } - inventoryService.update(resources); + inventory.setQuantity(resources.getQuantity()); + inventoryService.update(inventory); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @@ -197,8 +201,8 @@ public class InventoryController { @Log("库内移位") @ApiOperation("库内移位") @PreAuthorize("@el.check('super:man')") - public ResponseEntity knywInventory(@RequestBody InventoryButton resources) { - inventoryService.kuneMovePosition(resources); + public ResponseEntity knywInventory(@RequestBody InvYW invYW) { + inventoryService.kuneMovePosition(invYW); return new ResponseEntity<>("库内移位成功", HttpStatus.CREATED); } @@ -313,6 +317,7 @@ public class InventoryController { throw new BadRequestException("库位品番"+point.getItemCode()+"不一致,不能移位"); } } + inventory.setArea(point.getArea()); inventory.setPoint(point); inventoryRepository.save(inventory); InventoryLog inventoryLog = inventoryLogService.storeInventoryLog(BizStatus.XD_MOVE, BizStatus.REDUCE, "箱单移位", point.getArea(), inventory.getItemKey(), srcPoint, point, null, null, srcQty, inventory.getQuantity(), xdMoveReq.getStockCode(), null, diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java b/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java index a0b2aaf..14f65bd 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java @@ -21,12 +21,14 @@ import com.youchain.basicdata.domain.Point; import com.youchain.basicdata.domain.Stock; import com.youchain.businessdata.domain.Inventory; import com.youchain.businessdata.domain.ItemKey; +import com.youchain.businessdata.inputJson.buttenJson.InvYW; import com.youchain.businessdata.inputJson.buttenJson.InventoryButton; import com.youchain.businessdata.returnJson.RInvQuery; import com.youchain.businessdata.returnJson.XdInventory; import com.youchain.businessdata.service.dto.InvQueryCriteria; import com.youchain.businessdata.service.dto.InventoryDto; import com.youchain.businessdata.service.dto.InventoryQueryCriteria; +import com.youchain.businessdata.service.dto.InventoryQueryDto; import com.youchain.modules.system.domain.Dept; import org.springframework.data.domain.Pageable; import java.util.Map; @@ -60,6 +62,7 @@ public interface InventoryService { List queryAll(InvQueryCriteria criteria); Map queryInvAll(InventoryQueryCriteria criteria, Pageable pageable); + List queryInvAll(InventoryQueryCriteria criteria); /** * 根据ID查询 @@ -101,7 +104,7 @@ public interface InventoryService { void downloadXt(List all, HttpServletResponse response) throws Exception, Exception; - void downloadZz(List all, HttpServletResponse response) throws Exception, Exception; + void downloadZz(List all, HttpServletResponse response) throws Exception, Exception; List queryInventoryAllocate(long itemId,long areaId,Long zzkwId,Long pointId,String stockCode,String propC2,String type); @@ -132,11 +135,8 @@ public interface InventoryService { List getInvForPlan(String type,Long areaId,Long itemId,Long deptId); - /** - * 库内移位 - * @param inventoryButton 页面操作数据 - */ - void kuneMovePosition(InventoryButton inventoryButton); + + void kuneMovePosition(InvYW invYW); /** * 查询库存 diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryCriteria.java b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryCriteria.java index 8677a1c..589778a 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryCriteria.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryCriteria.java @@ -93,4 +93,7 @@ public class InventoryQueryCriteria{ /** 模糊 */ @Query(type = Query.Type.INNER_LIKE) private String stockCode; + + @Query(type = Query.Type.EQUAL) + private Boolean kcyj; } \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryDto.java b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryDto.java index 1cd5faa..976e7d3 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryDto.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryDto.java @@ -42,4 +42,5 @@ public class InventoryQueryDto implements Serializable { private String queued_qty; private String prop_c2; private String inv_min; + private String kcyj_qty; } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java index a2f3dc4..372d27f 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java @@ -23,6 +23,7 @@ import com.youchain.basicdata.domain.Point; import com.youchain.basicdata.domain.Stock; import com.youchain.basicdata.service.PointService; import com.youchain.businessdata.domain.*; +import com.youchain.businessdata.inputJson.buttenJson.InvYW; import com.youchain.businessdata.inputJson.buttenJson.InventoryButton; import com.youchain.businessdata.inputJson.buttenJson.dataAll.InventoryYW; import com.youchain.businessdata.repository.PickDetailRepository; @@ -31,6 +32,7 @@ import com.youchain.businessdata.returnJson.RPTaskList; import com.youchain.businessdata.returnJson.XdInventory; import com.youchain.businessdata.service.InventoryLogService; import com.youchain.businessdata.service.dto.*; +import com.youchain.businessdata.service.mapstruct.InventoryQQMapper; import com.youchain.exception.BadRequestException; import com.youchain.modules.system.domain.Dept; import com.youchain.utils.*; @@ -71,6 +73,8 @@ public class InventoryServiceImpl implements InventoryService { private final InventoryRepository inventoryRepository; private final InventoryMapper inventoryMapper; + private final InventoryQQMapper inventoryQQMapper; + private final EntityManager entityManager; private final InventoryLogService invLogService; private final PointService pointService; @@ -124,6 +128,9 @@ public class InventoryServiceImpl implements InventoryService { @Override public void download(List all, HttpServletResponse response) throws Exception { + + + List> list=ExcelDownUtils.CreateMap(all,"Inventory"); FileUtil.downloadExcel(list, response); } @@ -141,7 +148,7 @@ public class InventoryServiceImpl implements InventoryService { } @Override - public void downloadZz(List all, HttpServletResponse response) throws Exception { + public void downloadZz(List all, HttpServletResponse response) throws Exception { List> list=ExcelDownUtils.CreateMap(all,"InvZz"); FileUtil.downloadExcel(list, response); } @@ -181,6 +188,33 @@ public class InventoryServiceImpl implements InventoryService { List inventoryList = query.getResultList(); return inventoryList; } + @Override + public List queryInvAll(InventoryQueryCriteria criteria) { + //return inventoryQQMapper.toDto(inventoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder))); + Query query = getQuery(criteria,BizStatus.QUERY_PAGE); + List queryResultList = query.unwrap(SQLQuery.class) + .setResultTransformer( + AliasToEntityMapResultTransformer.INSTANCE + ) + .list(); + List list = JSON.parseArray(JSON.toJSONString(queryResultList),InventoryQueryDto.class); +// List list=new ArrayList<>(); +// for (InventoryQueryDto obj: queryResultList) { +// InventoryQueryDto dto=new InventoryQueryDto(); +// dto.setId(obj.getId()); +// dto.setItem_code(obj.getItem_code()); +// dto.setItem_name(obj.getItem_name()); +// dto.setArea_name(obj.getArea_name()); +// dto.setPoint_code(obj.getPoint_code()); +// dto.setProp_c2(obj.getProp_c2()); +// dto.setQuantity(obj.getQuantity()); +// dto.setInv_min(obj.getInv_min()); +// dto.setKcyj_qty(obj.getKcyj_qty()); +// dto.setQuantity(obj.getQuantity()); +// list.add(dto); +// } + return list; + } @Override public Map queryInvAll(InventoryQueryCriteria criteria, Pageable pageable) { @@ -208,7 +242,7 @@ public class InventoryServiceImpl implements InventoryService { public Query getQuery(InventoryQueryCriteria criteria,String type){ String midSql="SELECT inv.id,area.name area_name,p.code point_code,it.code item_code,it.name item_name," + - " inv.quantity ,inv.queued_qty,ik.prop_c2 ,p.inv_min " ; + " inv.quantity ,inv.queued_qty,ik.prop_c2 ,p.inv_min,IF(inv.quantity 0) {//移除数量小于库存数量 + double rmNum = srcInv.getQuantity() - rmNumber; + if(srcInv.getPoint().getCode().equals(invYW.getDstPoint().getCode())){ + throw new BadRequestException( "库位不能一致"); + } + if (rmNum >= 0) {//移除数量小于库存数量 //生成库存或生成记录 - Inventory inventory = this.getInventory(inventoryOld.getItemKey(), inventoryOld.getArea(), inventoryYW.getDstPoint(), inventoryOld.getZzkw(), inventoryOld.getDept(), BizStatus.MOVE,null); + Inventory dstInv = this.getInventory(srcInv.getItemKey(), dstPoint.getArea(), dstPoint, srcInv.getZzkw(), srcInv.getDept(), BizStatus.MOVE,srcInv.getStockCode()); //生成移除的日志 - invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, null, inventoryOld.getArea(), inventoryOld.getItemKey(), inventoryOld.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventoryOld.getStock(), inventoryOld.getQuantity(), rmNumber, - null,null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); + invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, null, srcInv.getArea(), srcInv.getItemKey(), srcInv.getPoint(), invYW.getDstPoint(), srcInv.getStock(), srcInv.getStock(), srcInv.getQuantity(), rmNumber, + srcInv.getStockCode(),null, BizStatus.MOVE, srcInv.getId(), srcInv.getId(), srcInv.getDescription()); //生成目标点位的日志 - invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, null, inventory.getArea(), inventory.getItemKey(), inventory.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventory.getStock(), inventory.getQuantity(), rmNumber, - null,null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); + invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, null, dstPoint.getArea(), dstInv.getItemKey(), dstPoint, dstPoint, dstInv.getStock(), dstInv.getStock(), dstInv.getQuantity(), rmNumber, + dstInv.getStockCode(),null, BizStatus.MOVE, dstInv.getId(), dstInv.getId(), dstInv.getDescription()); //减库存 - inventoryOld.setQuantity(rmNum); - this.update(inventoryOld); + srcInv.setQuantity(rmNum); + this.update(srcInv); //加库存 - inventory.setQuantity(inventory.getQuantity() + rmNumber); - this.update(inventory); + dstInv.setQuantity(dstInv.getQuantity() + rmNumber); + this.update(dstInv); } else if (rmNum < 0) {//移除数量大于库存数量 throw new BadRequestException(HttpStatus.NOT_FOUND, "移除数量大于库存数量"); - } else {//移除数量等于库存数量 - //生成库存或生成记录 - Inventory inventory = this.getInventory(inventoryOld.getItemKey(), inventoryOld.getArea(), inventoryYW.getDstPoint(), inventoryOld.getZzkw(), inventoryOld.getDept(), BizStatus.MOVE,null); - //生成移除的日志 - invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, null, inventoryOld.getArea(), inventoryOld.getItemKey(), inventoryOld.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventoryOld.getStock(), inventoryOld.getQuantity(), rmNumber, - null,null,BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); - //生成目标点位的日志 - invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, null, inventory.getArea(), inventory.getItemKey(), inventory.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventory.getStock(), inventory.getQuantity(), rmNumber, - null,null,BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); - inventoryRepository.delete(inventoryOld); - //加库存 - inventory.setQuantity(inventory.getQuantity() + rmNumber); - this.update(inventory); } } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/PickDetailServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/PickDetailServiceImpl.java index 38d71ec..fd44f6f 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/PickDetailServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/PickDetailServiceImpl.java @@ -418,7 +418,7 @@ public class PickDetailServiceImpl implements PickDetailService { } public List queryZzjlPickList(String itemCode,String areaName) { - String sql="SELECT d.id detail_id,IFNULL(a.name,\"\") area_name,IFNULL(ck_point.code,\"\") ck_point_code," + + String sql="SELECT d.id detail_id,IFNULL(a.name,\"材管库位无库存\") area_name,IFNULL(ck_point.code,\"\") ck_point_code," + "d.be_xd_pf,s.`name` s_area_name,it.code item_code,it.name item_name, p.code point_code,d.prop_c2 bonded,d.order_qty,d.allocated_qty,d.picked_qty,d.create_by,d.create_time\n" + " from data_pick_detail d\n" + " LEFT JOIN base_item it on it.id=d.item_id\n" + @@ -429,7 +429,11 @@ public class PickDetailServiceImpl implements PickDetailService { " where 1=1 and d.type='ZZJL' and d.picked_qty=0 "; if(areaName!=null&&!areaName.equals("")){ - sql+= " and a.`name`='"+areaName+"'"; + if(areaName.equals("材管库位无库存")){ + sql+= " and a.`name` is null"; + }else { + sql += " and a.`name`='" + areaName + "'"; + } }else{ sql+= " and a.`name` is null"; } @@ -449,7 +453,7 @@ public class PickDetailServiceImpl implements PickDetailService { } public List queryZzjlPickCountList() { - String sql="SELECT IFNULL(ck_area.name,\"\") area_name,sum(d.order_qty) order_qty,sum(d.allocated_qty) allocated_qty ,count(d.id) count_qty\n" + + String sql="SELECT IFNULL(ck_area.name,\"材管库位无库存\") area_name,sum(d.order_qty) order_qty,sum(d.allocated_qty) allocated_qty ,count(d.id) count_qty\n" + "from data_pick_detail d\n" + "left join base_area ck_area on ck_Area.id=d.area_id\n" + "where d.picked_qty { + +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/utils/ExcelDownUtils.java b/youchain-system/src/main/java/com/youchain/utils/ExcelDownUtils.java index 32f110f..c6b8bfd 100644 --- a/youchain-system/src/main/java/com/youchain/utils/ExcelDownUtils.java +++ b/youchain-system/src/main/java/com/youchain/utils/ExcelDownUtils.java @@ -124,15 +124,40 @@ public class ExcelDownUtils { } return list; } + private static Field getFieldRecursively(Class clazz, String fieldName) { + while (clazz != null) { + try { + return clazz.getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + clazz = clazz.getSuperclass(); + } + } + return null; + } public static Object getNestedFieldValue(Object obj, String nestedFieldName) throws Exception { String[] fields = nestedFieldName.split("\\."); - Object result = obj; - for (String field : fields) { - Field f = result.getClass().getDeclaredField(field); - f.setAccessible(true); // 确保可以访问私有字段 - result = f.get(result); + try { + Object result = obj; + for (String field : fields) { + if (result == null) { + throw new IllegalArgumentException("尝试在 null 对象上访问字段: " + field); + } + + Field f = getFieldRecursively(result.getClass(), field); + if (f == null) { + throw new NoSuchFieldException("字段 " + field + " 在类 " + + result.getClass().getName() + " 中不存在"); + } + + f.setAccessible(true); + result = f.get(result); + } + return result; + } catch (Exception e) { + log.error("获取字段值失败: " + e.getMessage()); + + return null; } - return result; } }