no message

main
HUOJIN\92525 2024-09-24 16:11:30 +08:00
parent 00cfa17fe6
commit e84239bee7
21 changed files with 413 additions and 248 deletions

View File

@ -134,6 +134,10 @@ public class Item extends BaseEntity implements Serializable {
@ApiModelProperty(value = "是否SAP料号")
private Boolean isSapMaterial=false;
@Column(name = "`is_inspection`")
@ApiModelProperty(value = "是否质检")
private Boolean isInspection=false;
@Column(name = "`heat_value`")
@ApiModelProperty(value = "热度值")
private Integer heatValue=0;

View File

@ -118,6 +118,11 @@ public class Point extends BaseEntity implements Serializable {
@Column(name = "`sort_index`")
@ApiModelProperty(value = "排序")
private int sortIndex=0;
@OneToOne
@JoinColumn(name = "`stock_id`")
@ApiModelProperty(value = "容器")
private Stock stock;
public void copy(Point source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -16,6 +16,7 @@
package com.youchain.basicdata.service.dto;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock;
import com.youchain.modules.system.service.dto.DeptSmallDto;
import lombok.Data;
import java.sql.Timestamp;
@ -59,6 +60,9 @@ public class PointDto implements Serializable {
/** 仓库ID */
private DeptSmallDto dept;
/** 容器 */
private Stock stock;
/** 坐标X */
private Double posX;

View File

@ -325,7 +325,7 @@ public class BoxServiceImpl implements BoxService {
asnDetailService.create(asnDetail);
//生成Itemkey
ItemKey itemKey = itemKeyService.getItemKey(item, asnDetail.getPropC1(), asnDetail.getPropD1());
ItemKey itemKey = itemKeyService.getItemKey(item, asnDetail.getPropC1(), null, null, null, null, asnDetail.getPropD1());
//生成入库记录

View File

@ -118,19 +118,19 @@ public class AsnDetail extends BaseEntity implements Serializable {
private String propC2;
@Column(name = "`prop_c3`")
@ApiModelProperty(value = "家编号")
@ApiModelProperty(value = "厂")
private String propC3;
@Column(name = "`prop_c4`")
@ApiModelProperty(value = "属性4")
@ApiModelProperty(value = "loc")
private String propC4;
@Column(name = "`prop_c5`")
@ApiModelProperty(value = "属性5")
@ApiModelProperty(value = "特殊标记")
private String propC5;
@Column(name = "`prop_c6`")
@ApiModelProperty(value = "属性6")
@ApiModelProperty(value = "供应商")
private String propC6;
@Column(name = "`prop_d1`")

View File

@ -60,19 +60,19 @@ public class ItemKey extends BaseEntity implements Serializable {
private String propC2;
@Column(name = "`prop_c3`")
@ApiModelProperty(value = "属性4")
@ApiModelProperty(value = "工厂")
private String propC3;
@Column(name = "`prop_c4`")
@ApiModelProperty(value = "属性4")
@ApiModelProperty(value = "loc")
private String propC4;
@Column(name = "`prop_c5`")
@ApiModelProperty(value = "属性5")
@ApiModelProperty(value = "特殊标记")
private String propC5;
@Column(name = "`prop_c6`")
@ApiModelProperty(value = "属性6")
@ApiModelProperty(value = "供应商")
private String propC6;
@Column(name = "`prop_d1`")

View File

@ -0,0 +1,26 @@
package com.youchain.businessdata.inputJson;
import com.youchain.basicdata.domain.Area;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock;
import lombok.Data;
/**
* @author huojin
* @date 2024-09-24
*
*/
@Data
public class Zhengli {
Long id;
Area area;
Stock stock;
Point point;
double receivedQty;
}

View File

@ -43,4 +43,11 @@ public interface InventoryRepository extends JpaRepository<Inventory, Long>, Jpa
" order by inv.item_key_id in (select id from data_item_key where item_id = ?1 ORDER BY prop_d1 ) ", nativeQuery = true)
List<Inventory> queryInventory(long itemId, long areaId);
@Query("from Inventory inv where inv.quantity > 0 " +
"and (:itemKeyId is null or inv.itemKey.id = :itemKeyId) " +
"and (:pointId is null or inv.point.id = :pointId) " +
"and (:stockId is null or inv.stock.id = :stockId) " +
"and (:deptId is null or inv.dept.id = :deptId)")
List<Inventory> findByInventory(Long itemKeyId, Long pointId, Long stockId, Long deptId);
}

View File

@ -34,6 +34,7 @@ import com.youchain.businessdata.inputJson.IRkConfirm;
import com.youchain.businessdata.inputJson.IRkInv;
import com.youchain.businessdata.inputJson.IRkPut;
import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.inputJson.Zhengli;
import com.youchain.businessdata.inputJson.buttenJson.AsnDetailButton;
import com.youchain.businessdata.repository.AsnDetailRepository;
import com.youchain.businessdata.repository.InventoryRepository;
@ -166,7 +167,6 @@ public class AsnDetailController {
}
@PutMapping
@Log("修改asn_detail")
@ApiOperation("修改asn_detail")
@ -324,6 +324,7 @@ public class AsnDetailController {
}
return new ResponseEntity("取消成功", HttpStatus.OK);
}
@Log("取消收货的操作")
@ApiOperation("取消收货的操作")
@PostMapping("/rkAndQxButtonQX")
@ -383,6 +384,7 @@ public class AsnDetailController {
}
return ApiResult.result(200, "操作成功", HttpStatus.OK);
}
/**
*
*
@ -581,7 +583,7 @@ public class AsnDetailController {
ik = xppRecord.getItemKey();
}
if (ik == null) {
ik = itemKeyService.getItemKey(d.getItem(), pc1, null);
ik = itemKeyService.getItemKey(d.getItem(), pc1, null, null, null, null, null);
}
Task t = taskService.storeTask(d, null, area, ik, point, point, recQty);
if (xppRecord != null) {
@ -626,4 +628,17 @@ public class AsnDetailController {
}
@PostMapping("/zhengli")
@Log("明细整理")
@ApiOperation("明细整理")
@PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> zhengli(@RequestBody Zhengli zhengli) {
try {
asnDetailService.zhengli(zhengli);
return new ResponseEntity<>(ApiResult.success("整理成功", null), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(ApiResult.fail(HttpStatus.BAD_REQUEST.value(), "整理失败:" + e.getMessage(), null), HttpStatus.BAD_REQUEST);
}
}
}

View File

@ -520,7 +520,7 @@ public class PickOutController {
Point point=pointService.findEntityById(pickDetail.getShArea().getPointId());
Dept dept= UserUtils.getDept();
//线边接收不需要管理到批次重新生成itemKey
ItemKey itemKey=itemKeyService.getItemKey(log.getItemKey().getItem(),null,null);
ItemKey itemKey=itemKeyService.getItemKey(log.getItemKey().getItem(),null,null,null,null,null,null);
Inventory inventory=inventoryService.getInventory(itemKey,pickDetail.getShArea(),point,pickDetail.getPoint(),dept,BizStatus.SL_ALL);
double srcQty=inventory.getQuantity();
inventory.setQuantity(inventory.getQuantity()+log.getSlQty());

View File

@ -371,7 +371,7 @@ public class PickTicketController {
Point point=pointService.findEntityById(pt.getShArea().getPointId());
Dept dept= UserUtils.getDept();
//线边接收不需要管理到批次重新生成itemKey
ItemKey itemKey=itemKeyService.getItemKey(log.getItemKey().getItem(),null,null);
ItemKey itemKey=itemKeyService.getItemKey(log.getItemKey().getItem(),null,null,null,null,null,null);
Inventory inventory=inventoryService.getInventory(itemKey,pt.getShArea(),point,pickDetail.getPoint(),dept,BizStatus.SL_ALL);
double srcQty=inventory.getQuantity();
inventory.setQuantity(inventory.getQuantity()+log.getSlQty());

View File

@ -425,7 +425,7 @@ public class XppRecordController {
}
}
String pc1=DateUtil.dateYmd(new Date());
ItemKey ik = itemKeyService.getItemKey(xppRecord.getItem(), pc1, null);
ItemKey ik = itemKeyService.getItemKey(xppRecord.getItem(), pc1, null,null,null,null,null);
xppRecord.setItemKey(ik);
if(type==1) {
inventoryLogService.storeInventoryLog(BizStatus.RECEIVING, BizStatus.ADD, "现品票采集", area, ik, srcPoint, srcPoint, null, 0d, xppRecord.getNrs() + 0d, ewm,

View File

@ -21,6 +21,7 @@ import com.youchain.basicdata.domain.Stock;
import com.youchain.basicdata.service.dto.StockDto;
import com.youchain.businessdata.domain.AsnDetail;
import com.youchain.businessdata.domain.XppRecord;
import com.youchain.businessdata.inputJson.Zhengli;
import com.youchain.businessdata.service.dto.AsnDetailDto;
import com.youchain.businessdata.service.dto.AsnDetailQueryCriteria;
import org.springframework.data.domain.Pageable;
@ -128,4 +129,10 @@ public interface AsnDetailService {
* @return
*/
List<AsnDetail> findAsnDetails(Long asnId,String type);
/**
*
* @param zhengli
*/
void zhengli(Zhengli zhengli);
}

View File

@ -142,4 +142,6 @@ public interface InventoryService {
* @return
*/
List<RInvQuery> queryInvApp(String code);
Inventory getInventory(ItemKey itemKey, Point point, Stock stock, Dept dept, String type);
}

View File

@ -86,7 +86,7 @@ public interface ItemKeyService {
*/
void download(List<ItemKeyDto> all, HttpServletResponse response) throws Exception, Exception;
ItemKey getItemKey(Item item, String propC1, Date propD1);
ItemKey getItemKey(Item item, String propC1,String propC3,String propC4,String propC5,String propC6, Date propD1);
}

View File

@ -17,6 +17,7 @@ package com.youchain.businessdata.service.dto;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Stock;
import com.youchain.basicdata.service.dto.ItemDto;
import com.youchain.basicdata.service.dto.ItemSmallDto;
import com.youchain.basicdata.service.dto.PointDto;
import com.youchain.basicdata.service.dto.StockDto;
@ -42,7 +43,7 @@ public class AsnDetailDto implements Serializable {
private AsnDto asn;
/** 物料 */
private ItemSmallDto item;
private ItemDto item;
/** 容器 */
private StockDto stock;

View File

@ -15,22 +15,22 @@
*/
package com.youchain.businessdata.service.impl;
import com.youchain.basicdata.domain.Area;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock;
import com.youchain.basicdata.service.StockService;
import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.inputJson.Zhengli;
import com.youchain.businessdata.repository.TaskRepository;
import com.youchain.businessdata.service.AsnService;
import com.youchain.businessdata.service.InventoryLogService;
import com.youchain.businessdata.service.InventoryService;
import com.youchain.businessdata.repository.XppRecordRepository;
import com.youchain.businessdata.service.*;
import com.youchain.businessdata.service.dto.AsnDto;
import com.youchain.businessdata.service.mapstruct.AsnMapper;
import com.youchain.exception.BadRequestException;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.repository.AsnDetailRepository;
import com.youchain.businessdata.service.AsnDetailService;
import com.youchain.businessdata.service.dto.AsnDetailDto;
import com.youchain.businessdata.service.dto.AsnDetailQueryCriteria;
import com.youchain.businessdata.service.mapstruct.AsnDetailMapper;
@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import java.io.IOException;
@ -48,9 +49,9 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author hjl
* @website https://eladmin.vip
* @description
* @author hjl
* @date 2023-08-14
**/
@Service
@ -58,13 +59,16 @@ import java.util.LinkedHashMap;
public class AsnDetailServiceImpl implements AsnDetailService {
private final AsnDetailRepository asnDetailRepository;
private final TaskRepository taskRepository;
private final XppRecordRepository xppRecordRepository;
private final AsnDetailMapper asnDetailMapper;
private final EntityManager entityMapper;
private final TaskRepository taskRepository;
private final AsnService asnService;
private final AsnMapper asnMapper;
private final InventoryService inventoryService;
private final InventoryLogService inventoryLogService;
private final ItemKeyService itemKeyService;
private final TaskService taskService;
@Override
public Map<String, Object> queryAll(AsnDetailQueryCriteria criteria, Pageable pageable) {
@ -126,6 +130,7 @@ public class AsnDetailServiceImpl implements AsnDetailService {
asnDetailRepository.deleteById(id);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void cancelPut(Long taskId, XppRecord xppRecord) {
@ -178,6 +183,7 @@ public class AsnDetailServiceImpl implements AsnDetailService {
public AsnDetail toEntity(AsnDetailDto detailDto) {
return asnDetailMapper.toEntity(detailDto);
}
@Override
public AsnDetail findByStock(String code) {
String hql = "select d from AsnDetail d where d.stock.code='" + code + "' and d.status='" + BizStatus.OPEN + "'";
@ -215,4 +221,64 @@ public class AsnDetailServiceImpl implements AsnDetailService {
List<AsnDetail> ds = query.getResultList();
return ds;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void zhengli(Zhengli zhengli) {
AsnDetail asnDetail = asnDetailRepository.findById(zhengli.getId()).get();
Item item = asnDetail.getItem();
if (item.getIsInspection()) {
throw new BadRequestException("该商品需要质检,请先完成质检!");
}
//生成Itemkey
ItemKey itemKey = itemKeyService.getItemKey(item, asnDetail.getPropC1(), asnDetail.getPropC3(), asnDetail.getPropC4(), asnDetail.getPropC5(), asnDetail.getPropC6(), asnDetail.getPropD1());
//生成入库记录
Task task = taskService.storeTask(asnDetail, null, zhengli.getArea(), itemKey, null, zhengli.getPoint(), zhengli.getReceivedQty());
task.setSrcStockCode(zhengli.getStock().getCode());
task.setSrcStock(zhengli.getStock());
taskRepository.save(task);
//生成库存记录
Inventory inventory = inventoryService.getInventory(itemKey, asnDetail.getPoint(), zhengli.getStock(), item.getDept(), BizStatus.ASN);
inventory.setStatus("待入库");
inventoryService.update(inventory);
//是序列号的商品,生成序列号记录
if (item.getIsSerial()) {
XppRecord xppRecord = new XppRecord();
xppRecord.setRkTask(task);
xppRecord.setItemKey(itemKey);
xppRecord.setInvPoint(asnDetail.getPoint());
xppRecordRepository.save(xppRecord);
}
//回写收货数量
asnDetail.setStock(zhengli.getStock());
asnDetail.setPoint(zhengli.getPoint());
asnDetail.setReceivedQty(asnDetail.getReceivedQty()+zhengli.getReceivedQty());
asnDetailRepository.save(asnDetail);
//刷新单头状态
updateAsnStatus(asnDetail.getAsn());
}
private void updateAsnStatus(Asn asn) {
double orderQty = 0;
double receivedQty = 0;
List<AsnDetail> asnDetails = asnDetailRepository.queryByAsnId(asn.getId());
for (AsnDetail detail : asnDetails) {
orderQty += detail.getOrderQty();
receivedQty += detail.getReceivedQty();
}
if (orderQty == receivedQty) {
asn.setStatus(BizStatus.RECEIVED);
} else if (receivedQty > 0 && receivedQty < orderQty) {
asn.setStatus(BizStatus.RECEIVING);
} else if (receivedQty == 0) {
asn.setStatus(BizStatus.OPEN);
}
asnService.update(asn);
}
}

View File

@ -392,4 +392,27 @@ public class InventoryServiceImpl implements InventoryService {
List<RInvQuery> list = JSON.parseArray(JSON.toJSONString(ts),RInvQuery.class);
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Inventory getInventory(ItemKey itemKey, Point point, Stock stock, Dept dept, String type) {
List<Inventory> inventoryList = inventoryRepository.findByInventory(itemKey.getId(), point.getId(), stock.getId(), dept.getId());
Inventory inventory = null;
if (inventoryList.size() > 0) {
inventory = inventoryList.get(0);
} else {
//创建Inventory
if (type.equals(BizStatus.ASN)) {
inventory = new Inventory();
inventory.setItemKey(itemKey);
inventory.setPoint(point);
inventory.setPointCode(point.getCode());
inventory.setStock(stock);
inventory.setStockCode(stock.getCode());
inventory.setDept(dept);
inventoryRepository.save(inventory);
}
}
return inventory;
}
}

View File

@ -40,9 +40,9 @@ import javax.persistence.Query;
import javax.servlet.http.HttpServletResponse;
/**
* @author houjianlan
* @website https://eladmin.vip
* @description
* @author houjianlan
* @date 2023-08-21
**/
@Service
@ -121,37 +121,42 @@ public class ItemKeyServiceImpl implements ItemKeyService {
@Override
@Transactional(rollbackFor = Exception.class)
public ItemKey getItemKey(Item item, String propC1, Date propD1) {
public ItemKey getItemKey(Item item, String propC1, String propC3, String propC4, String propC5, String propC6, Date propD1) {
//生成itemKey
String hql = " from ItemKey ik where 1=1 ";
if (item != null) {
hql += " and ik.item.id=" + item.getId() + " ";
}
if (propC1 != null && propC1.length() > 0) {
hql += " and ik.propC1='" + propC1 + "' ";
}else{
hql += " and ik.propC1 is null";
}
// if (propD1 != null) {
// hql += " and DATE(ik.propD1) ='" + propD1 +"'";
// }else{
// hql += " and ik.propD1 is null";
// }
String hql = "from ItemKey " +
"where " +
"item = :item " +
"and propC1 = :propC1 " +
"and propC3 = :propC3 " +
"and propC4 = :propC4 " +
"and propC5 = :propC5 " +
"and propC6 = :propC6 " +
"and propD1 = :propD1";
Query query = entityManager.createQuery(hql);
query.setParameter("item", item);
query.setParameter("propC1", propC1);
query.setParameter("propC3", propC3);
query.setParameter("propC4", propC4);
query.setParameter("propC5", propC5);
query.setParameter("propC6", propC6);
query.setParameter("propD1", propD1);
List<ItemKey> itemKeyList = query.getResultList();
ItemKey itemKey = null;
if (itemKeyList.size() > 0) {
itemKey = itemKeyList.get(0);
} else {
if (itemKeyList.isEmpty()) {
//创建ItemKey
itemKey = new ItemKey();
ItemKey itemKey = new ItemKey();
itemKey.setItem(item);
itemKey.setDept(item.getDept());
itemKey.setPropC1(propC1);
itemKey.setPropC3(propC3);
itemKey.setPropC4(propC4);
itemKey.setPropC5(propC5);
itemKey.setPropC6(propC6);
itemKey.setPropD1(propD1);
this.create(itemKey);
}
itemKeyRepository.save(itemKey);
return itemKey;
} else {
return itemKeyList.get(0);
}
}

View File

@ -173,7 +173,7 @@ public class SparepartsServiceImpl implements SparepartsService {
if(point==null){
throw new BadRequestException(ba.getRArea().getCode()+"库区无对应待投料库位");
}
ItemKey itemKey=itemKeyService.getItemKey(ba.getItem(),null,null);
ItemKey itemKey=itemKeyService.getItemKey(ba.getItem(),null,null,null,null,null,null);
Inventory inventory = new Inventory();
inventory.setItemKey(itemKey);
inventory.setPoint(point);

View File

@ -189,7 +189,7 @@ public class TaskServiceImpl implements TaskService {
t.setDstPoint(dstPoint);
t.setDstPointCode(dstPoint.getCode());
}
this.create(t);
taskRepository.save(t);
return t;
}
@Override