制造库存

main
FOAM 2025-09-30 12:07:47 +08:00
parent 5e55f21584
commit 1bfbcf123f
12 changed files with 197 additions and 78 deletions

View File

@ -48,7 +48,9 @@ public interface PointRepository extends JpaRepository<Point, Long>, JpaSpecific
@Query(value = "select p.code,area.`name` areaName from base_point p \n" + @Query(value = "select p.code,area.`name` areaName from base_point p \n" +
"left join base_area area on area.id=p.area_id " + "left join base_area area on area.id=p.area_id " +
" where (area.name=:areaName or :areaName is null) and p.description='自由货位标签'", nativeQuery = true) " where (area.name=:areaName or :areaName is null) " +
List<PointZyPrint> queryPrintAll(String areaName); " and (p.code like CONCAT('%',:pointCode,'%') or :pointCode is null) " +
"and p.bqlx='自由货位标签'", nativeQuery = true)
List<PointZyPrint> queryPrintAll(String areaName,String pointCode);
} }

View File

@ -202,7 +202,7 @@ public class PointController {
public ResponseEntity<Object> queryPointPrintList(PointQueryCriteria criteria){ public ResponseEntity<Object> queryPointPrintList(PointQueryCriteria criteria){
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
redisUtils.del(SecurityUtils.getCurrentUsername()+"_BiaoQian_ZY"); redisUtils.del(SecurityUtils.getCurrentUsername()+"_BiaoQian_ZY");
List<PointZyPrint> list=pointRepository.queryPrintAll(criteria.getAreaName()); List<PointZyPrint> list=pointRepository.queryPrintAll(criteria.getAreaName(),criteria.getCode());
redisUtils.set(SecurityUtils.getCurrentUsername()+"_BiaoQian_ZY", JsonUtil.toJson(list)); redisUtils.set(SecurityUtils.getCurrentUsername()+"_BiaoQian_ZY", JsonUtil.toJson(list));
return new ResponseEntity<>(list,HttpStatus.OK); return new ResponseEntity<>(list,HttpStatus.OK);
} }

View File

@ -94,12 +94,15 @@ public class ImportProductionPlanServiceImpl implements ImportProductionPlanServ
} }
maps.put(zcdx+machineNo,IDNO); maps.put(zcdx+machineNo,IDNO);
} }
int hyCount = productionPlanRepository.existsGwHyIdno(IDNO,zcdx,machineNo); //如果IDNO为自编码则不校验直接存储
if (hyCount > 0) { if(IDNO.indexOf("-")<0) {
throw new BadRequestException( "大于" + IDNO + "存在已耗用数据"); int hyCount = productionPlanRepository.existsGwHyIdno(IDNO, zcdx, machineNo);
} else { if (hyCount > 0) {
List<ProductionPlan> productionPlans = productionPlanRepository.findByGwIdnoList(IDNO ,zcdx,machineNo); throw new BadRequestException("大于" + IDNO + "存在已耗用数据");
productionPlanRepository.deleteAll(productionPlans); } else {
List<ProductionPlan> productionPlans = productionPlanRepository.findByGwIdnoList(IDNO, zcdx, machineNo);
productionPlanRepository.deleteAll(productionPlans);
}
} }
} }

View File

@ -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;
}

View File

@ -25,6 +25,7 @@ import com.youchain.basicdata.repository.BomAccountRepository;
import com.youchain.basicdata.repository.PointRepository; import com.youchain.basicdata.repository.PointRepository;
import com.youchain.businessdata.domain.*; import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.inputJson.XdMoveReq; import com.youchain.businessdata.inputJson.XdMoveReq;
import com.youchain.businessdata.inputJson.buttenJson.InvYW;
import com.youchain.businessdata.inputJson.buttenJson.InventoryButton; import com.youchain.businessdata.inputJson.buttenJson.InventoryButton;
import com.youchain.businessdata.repository.InventoryRepository; import com.youchain.businessdata.repository.InventoryRepository;
import com.youchain.businessdata.repository.TaskRepository; import com.youchain.businessdata.repository.TaskRepository;
@ -103,7 +104,8 @@ public class InventoryController {
@GetMapping(value = "/downloadZz") @GetMapping(value = "/downloadZz")
@AnonymousAccess @AnonymousAccess
public void downloadZz(HttpServletResponse response, InventoryQueryCriteria criteria) throws Exception { public void downloadZz(HttpServletResponse response, InventoryQueryCriteria criteria) throws Exception {
inventoryService.downloadZz(inventoryService.queryAll(criteria), response); List<InventoryQueryDto> all= inventoryService.queryInvAll(criteria);
inventoryService.downloadZz(all, response);
} }
@GetMapping @GetMapping
@ -123,7 +125,7 @@ public class InventoryController {
@ApiOperation("查询制造库存") @ApiOperation("查询制造库存")
@AnonymousAccess @AnonymousAccess
public ResponseEntity<Object> queryInventoryZz(InventoryQueryCriteria criteria, Pageable pageable) { public ResponseEntity<Object> queryInventoryZz(InventoryQueryCriteria criteria, Pageable pageable) {
return new ResponseEntity<>(inventoryService.queryAll(criteria, pageable), HttpStatus.OK); return new ResponseEntity<>(inventoryService.queryInvAll(criteria, pageable), HttpStatus.OK);
} }
@PostMapping @PostMapping
@ -140,15 +142,17 @@ public class InventoryController {
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> updateInventory(@Validated @RequestBody Inventory resources) { public ResponseEntity<Object> updateInventory(@Validated @RequestBody Inventory resources) {
//库存修改 //库存修改
Inventory byId = inventoryRepository.getById(resources.getId()); Inventory inventory = inventoryRepository.getById(resources.getId());
if (byId.getQuantity()>resources.getQuantity()){//以前的大于现在的 ItemKey itemKey=inventory.getItemKey();
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()), if (inventory.getQuantity()>resources.getQuantity()){//以前的大于现在的
null,null,BizStatus.INVENTORY_ADJUST, byId.getId(), byId.getId(), resources.getDescription()); 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 { }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()), 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()),
null,null,BizStatus.INVENTORY_ADJUST, byId.getId(), byId.getId(), resources.getDescription()); 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); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }
@ -197,8 +201,8 @@ public class InventoryController {
@Log("库内移位") @Log("库内移位")
@ApiOperation("库内移位") @ApiOperation("库内移位")
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> knywInventory(@RequestBody InventoryButton resources) { public ResponseEntity<Object> knywInventory(@RequestBody InvYW invYW) {
inventoryService.kuneMovePosition(resources); inventoryService.kuneMovePosition(invYW);
return new ResponseEntity<>("库内移位成功", HttpStatus.CREATED); return new ResponseEntity<>("库内移位成功", HttpStatus.CREATED);
} }
@ -313,6 +317,7 @@ public class InventoryController {
throw new BadRequestException("库位品番"+point.getItemCode()+"不一致,不能移位"); throw new BadRequestException("库位品番"+point.getItemCode()+"不一致,不能移位");
} }
} }
inventory.setArea(point.getArea());
inventory.setPoint(point); inventory.setPoint(point);
inventoryRepository.save(inventory); 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, InventoryLog inventoryLog = inventoryLogService.storeInventoryLog(BizStatus.XD_MOVE, BizStatus.REDUCE, "箱单移位", point.getArea(), inventory.getItemKey(), srcPoint, point, null, null, srcQty, inventory.getQuantity(), xdMoveReq.getStockCode(), null,

View File

@ -21,12 +21,14 @@ import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock; import com.youchain.basicdata.domain.Stock;
import com.youchain.businessdata.domain.Inventory; import com.youchain.businessdata.domain.Inventory;
import com.youchain.businessdata.domain.ItemKey; import com.youchain.businessdata.domain.ItemKey;
import com.youchain.businessdata.inputJson.buttenJson.InvYW;
import com.youchain.businessdata.inputJson.buttenJson.InventoryButton; import com.youchain.businessdata.inputJson.buttenJson.InventoryButton;
import com.youchain.businessdata.returnJson.RInvQuery; import com.youchain.businessdata.returnJson.RInvQuery;
import com.youchain.businessdata.returnJson.XdInventory; import com.youchain.businessdata.returnJson.XdInventory;
import com.youchain.businessdata.service.dto.InvQueryCriteria; import com.youchain.businessdata.service.dto.InvQueryCriteria;
import com.youchain.businessdata.service.dto.InventoryDto; import com.youchain.businessdata.service.dto.InventoryDto;
import com.youchain.businessdata.service.dto.InventoryQueryCriteria; import com.youchain.businessdata.service.dto.InventoryQueryCriteria;
import com.youchain.businessdata.service.dto.InventoryQueryDto;
import com.youchain.modules.system.domain.Dept; import com.youchain.modules.system.domain.Dept;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
@ -60,6 +62,7 @@ public interface InventoryService {
List<InventoryDto> queryAll(InvQueryCriteria criteria); List<InventoryDto> queryAll(InvQueryCriteria criteria);
Map<String,Object> queryInvAll(InventoryQueryCriteria criteria, Pageable pageable); Map<String,Object> queryInvAll(InventoryQueryCriteria criteria, Pageable pageable);
List<InventoryQueryDto> queryInvAll(InventoryQueryCriteria criteria);
/** /**
* ID * ID
@ -101,7 +104,7 @@ public interface InventoryService {
void downloadXt(List<InventoryDto> all, HttpServletResponse response) throws Exception, Exception; void downloadXt(List<InventoryDto> all, HttpServletResponse response) throws Exception, Exception;
void downloadZz(List<InventoryDto> all, HttpServletResponse response) throws Exception, Exception; void downloadZz(List<InventoryQueryDto> all, HttpServletResponse response) throws Exception, Exception;
List<Inventory> queryInventoryAllocate(long itemId,long areaId,Long zzkwId,Long pointId,String stockCode,String propC2,String type); List<Inventory> queryInventoryAllocate(long itemId,long areaId,Long zzkwId,Long pointId,String stockCode,String propC2,String type);
@ -132,11 +135,8 @@ public interface InventoryService {
List<Inventory> getInvForPlan(String type,Long areaId,Long itemId,Long deptId); List<Inventory> getInvForPlan(String type,Long areaId,Long itemId,Long deptId);
/**
* void kuneMovePosition(InvYW invYW);
* @param inventoryButton
*/
void kuneMovePosition(InventoryButton inventoryButton);
/** /**
* *

View File

@ -93,4 +93,7 @@ public class InventoryQueryCriteria{
/** 模糊 */ /** 模糊 */
@Query(type = Query.Type.INNER_LIKE) @Query(type = Query.Type.INNER_LIKE)
private String stockCode; private String stockCode;
@Query(type = Query.Type.EQUAL)
private Boolean kcyj;
} }

View File

@ -42,4 +42,5 @@ public class InventoryQueryDto implements Serializable {
private String queued_qty; private String queued_qty;
private String prop_c2; private String prop_c2;
private String inv_min; private String inv_min;
private String kcyj_qty;
} }

View File

@ -23,6 +23,7 @@ import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock; import com.youchain.basicdata.domain.Stock;
import com.youchain.basicdata.service.PointService; import com.youchain.basicdata.service.PointService;
import com.youchain.businessdata.domain.*; 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.InventoryButton;
import com.youchain.businessdata.inputJson.buttenJson.dataAll.InventoryYW; import com.youchain.businessdata.inputJson.buttenJson.dataAll.InventoryYW;
import com.youchain.businessdata.repository.PickDetailRepository; 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.returnJson.XdInventory;
import com.youchain.businessdata.service.InventoryLogService; import com.youchain.businessdata.service.InventoryLogService;
import com.youchain.businessdata.service.dto.*; import com.youchain.businessdata.service.dto.*;
import com.youchain.businessdata.service.mapstruct.InventoryQQMapper;
import com.youchain.exception.BadRequestException; import com.youchain.exception.BadRequestException;
import com.youchain.modules.system.domain.Dept; import com.youchain.modules.system.domain.Dept;
import com.youchain.utils.*; import com.youchain.utils.*;
@ -71,6 +73,8 @@ public class InventoryServiceImpl implements InventoryService {
private final InventoryRepository inventoryRepository; private final InventoryRepository inventoryRepository;
private final InventoryMapper inventoryMapper; private final InventoryMapper inventoryMapper;
private final InventoryQQMapper inventoryQQMapper;
private final EntityManager entityManager; private final EntityManager entityManager;
private final InventoryLogService invLogService; private final InventoryLogService invLogService;
private final PointService pointService; private final PointService pointService;
@ -124,6 +128,9 @@ public class InventoryServiceImpl implements InventoryService {
@Override @Override
public void download(List<InventoryDto> all, HttpServletResponse response) throws Exception { public void download(List<InventoryDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"Inventory"); List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"Inventory");
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@ -141,7 +148,7 @@ public class InventoryServiceImpl implements InventoryService {
} }
@Override @Override
public void downloadZz(List<InventoryDto> all, HttpServletResponse response) throws Exception { public void downloadZz(List<InventoryQueryDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"InvZz"); List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"InvZz");
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@ -181,6 +188,33 @@ public class InventoryServiceImpl implements InventoryService {
List<Inventory> inventoryList = query.getResultList(); List<Inventory> inventoryList = query.getResultList();
return inventoryList; return inventoryList;
} }
@Override
public List<InventoryQueryDto> 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<InventoryQueryDto> list = JSON.parseArray(JSON.toJSONString(queryResultList),InventoryQueryDto.class);
// List<InventoryQueryDto> 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 @Override
public Map<String,Object> queryInvAll(InventoryQueryCriteria criteria, Pageable pageable) { public Map<String,Object> queryInvAll(InventoryQueryCriteria criteria, Pageable pageable) {
@ -208,7 +242,7 @@ public class InventoryServiceImpl implements InventoryService {
public Query getQuery(InventoryQueryCriteria criteria,String type){ 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," + 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<p.inv_min,(p.inv_min-inv.quantity),'') kcyj_qty " ;
if(type.equals(BizStatus.QUERY_TOTAL)){ if(type.equals(BizStatus.QUERY_TOTAL)){
midSql="SELECT count(inv.id) "; midSql="SELECT count(inv.id) ";
} }
@ -225,22 +259,29 @@ public class InventoryServiceImpl implements InventoryService {
String point_code=criteria.getPointCode(); String point_code=criteria.getPointCode();
String prop_c2=criteria.getBonded(); String prop_c2=criteria.getBonded();
String point_type=criteria.getPointType(); String point_type=criteria.getPointType();
Boolean kcbz=true; String area_name=criteria.getAreaName();
if (item_code!=null &&item_code.equals("") ) { Boolean kcyj=criteria.getKcyj();
if (item_code!=null &&!item_code.equals("") ) {
sql += " and it.code like '%" + item_code + "%'"; sql += " and it.code like '%" + item_code + "%'";
} }
if (item_name!=null &&item_name.equals("") ) { if (item_name!=null &&!item_name.equals("") ) {
sql += " and it.name like '%" + item_code + "%'"; sql += " and it.name like '%" + item_code + "%'";
} }
if (point_code!=null &&point_code.equals("") ) { if (point_code!=null &&!point_code.equals("") ) {
sql += " and p.code like '%" + point_code + "%'"; sql += " and p.code like '%" + point_code + "%'";
} }
if (point_type!=null &&point_type.equals("") ) { if (point_type!=null &&!point_type.equals("") ) {
sql += " and p.type='" + point_type + "'"; sql += " and p.type='" + point_type + "'";
} }
if (prop_c2!=null &&prop_c2.equals("") ) { if (area_name!=null &&!area_name.equals("") ) {
sql += " and area.name='" + area_name + "'";
}
if (prop_c2!=null &&!prop_c2.equals("") ) {
sql += " and it.name like '%" + item_code + "%'"; sql += " and it.name like '%" + item_code + "%'";
} }
if(kcyj!=null&&kcyj){
sql += " and inv.quantity<p.inv_min ";
}
} }
sql+=" order by it.code "; sql+=" order by it.code ";
Query query = entityManager.createNativeQuery(sql); Query query = entityManager.createNativeQuery(sql);
@ -407,50 +448,36 @@ public class InventoryServiceImpl implements InventoryService {
} }
@Override @Override
public void kuneMovePosition(InventoryButton inventoryButton) { public void kuneMovePosition(InvYW invYW) {
//操作类型=移位,增加/减少=减少 Inventory srcInv = inventoryRepository.getById(invYW.getId());
//原点位=之前记录的库位,目标库位=选择的库位 库区、品番、暂存库位、制造库位都取inv上的。 原数量取原纪录,目标数量取移出后的数量, 发生数量=输入的移位数量 if(srcInv.getStockCode()!=null){
//操作类型=库存调整,增加/减少=根据实际数量判断,大于原数量为增加,小于原数量为减少,其他的类似上面数据 throw new BadRequestException( "箱单库存需使用箱单移位功能");
//移位时,加入目标库位之前没有这个记录,则自动生成 }
//库存唯一键areapointitemKeyzzkw,stockCode Point dstPoint=invYW.getDstPoint();
//位移所需要的数据
InventoryYW inventoryYW = inventoryButton.getInventoryYW();
//原数据
Inventory inventoryOld = inventoryRepository.getById(inventoryYW.getInventory().getId());
// 位移数量 // 位移数量
double rmNumber = inventoryYW.getRmNumber(); double rmNumber = invYW.getRmNumber();
//判断 库存-要移动的数量 //判断 库存-要移动的数量
double rmNum = inventoryOld.getQuantity() - rmNumber; double rmNum = srcInv.getQuantity() - rmNumber;
if (rmNum > 0) {//移除数量小于库存数量 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, invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, null, srcInv.getArea(), srcInv.getItemKey(), srcInv.getPoint(), invYW.getDstPoint(), srcInv.getStock(), srcInv.getStock(), srcInv.getQuantity(), rmNumber,
null,null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); 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, invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, null, dstPoint.getArea(), dstInv.getItemKey(), dstPoint, dstPoint, dstInv.getStock(), dstInv.getStock(), dstInv.getQuantity(), rmNumber,
null,null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); dstInv.getStockCode(),null, BizStatus.MOVE, dstInv.getId(), dstInv.getId(), dstInv.getDescription());
//减库存 //减库存
inventoryOld.setQuantity(rmNum); srcInv.setQuantity(rmNum);
this.update(inventoryOld); this.update(srcInv);
//加库存 //加库存
inventory.setQuantity(inventory.getQuantity() + rmNumber); dstInv.setQuantity(dstInv.getQuantity() + rmNumber);
this.update(inventory); this.update(dstInv);
} else if (rmNum < 0) {//移除数量大于库存数量 } else if (rmNum < 0) {//移除数量大于库存数量
throw new BadRequestException(HttpStatus.NOT_FOUND, "移除数量大于库存数量"); 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);
} }
} }

View File

@ -418,7 +418,7 @@ public class PickDetailServiceImpl implements PickDetailService {
} }
public List<ZzjlPickList> queryZzjlPickList(String itemCode,String areaName) { public List<ZzjlPickList> 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" + "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" + " from data_pick_detail d\n" +
" LEFT JOIN base_item it on it.id=d.item_id\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 "; " where 1=1 and d.type='ZZJL' and d.picked_qty=0 ";
if(areaName!=null&&!areaName.equals("")){ 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{ }else{
sql+= " and a.`name` is null"; sql+= " and a.`name` is null";
} }
@ -449,7 +453,7 @@ public class PickDetailServiceImpl implements PickDetailService {
} }
public List<ZzjlPickCountList> queryZzjlPickCountList() { public List<ZzjlPickCountList> 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" + "from data_pick_detail d\n" +
"left join base_area ck_area on ck_Area.id=d.area_id\n" + "left join base_area ck_area on ck_Area.id=d.area_id\n" +
"where d.picked_qty<d.order_qty and d.type='ZZJL' " + "where d.picked_qty<d.order_qty and d.type='ZZJL' " +

View File

@ -0,0 +1,33 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.youchain.businessdata.service.mapstruct;
import com.youchain.base.BaseMapper;
import com.youchain.businessdata.domain.Inventory;
import com.youchain.businessdata.service.dto.InventoryDto;
import com.youchain.businessdata.service.dto.InventoryQueryDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2023-08-22
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface InventoryQQMapper extends BaseMapper<InventoryQueryDto, Inventory> {
}

View File

@ -124,15 +124,40 @@ public class ExcelDownUtils {
} }
return list; 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 { public static Object getNestedFieldValue(Object obj, String nestedFieldName) throws Exception {
String[] fields = nestedFieldName.split("\\."); String[] fields = nestedFieldName.split("\\.");
Object result = obj; try {
for (String field : fields) { Object result = obj;
Field f = result.getClass().getDeclaredField(field); for (String field : fields) {
f.setAccessible(true); // 确保可以访问私有字段 if (result == null) {
result = f.get(result); 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;
} }
} }