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;
@ -95,4 +99,4 @@ public class PointDto implements Serializable {
/** 修改时间 */
private Timestamp updateTime;
}
}

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")
@ -195,24 +195,24 @@ public class AsnDetailController {
@ApiOperation("APP现品票上架-单个")
@AnonymousAccess
public ResponseEntity<Object> putawayInvApp(@RequestBody IRkPut s) {
log.info("s:"+s);
log.info("s:" + s);
String pointCode = s.getPointCode();
String ewm = s.getEwm();
int seq=s.getSeq();
XppRecord xppRecord =null;
Point point =null;
int seq = s.getSeq();
XppRecord xppRecord = null;
Point point = null;
RRkXpp map = new RRkXpp();
AsnDetail d=null;
AsnDetail d = null;
xppRecord = xppRecordRepository.findByCode(ewm);
if(xppRecord==null){
if (xppRecord == null) {
return new ResponseEntity<>(ewm + "未收货", BAD_REQUEST);
}
d=xppRecord.getAsnDetailId();
if(d.getReceivedQty()>0){
d = xppRecord.getAsnDetailId();
if (d.getReceivedQty() > 0) {
return new ResponseEntity<>(ewm + "已上架,不能重复上架", BAD_REQUEST);
}
if(seq==1){
Item it=d.getItem();
if (seq == 1) {
Item it = d.getItem();
map.setItemCode(it.getCode());
map.setItemName(it.getName());
map.setAc(xppRecord.getAc());
@ -220,26 +220,26 @@ public class AsnDetailController {
map.setNrs(xppRecord.getNrs());
map.setNrzsr(DateUtil.dateYmd(xppRecord.getNrDate()));
map.setFzh(xppRecord.getFzh());
map.setTjkw(it.getPoint()==null?null:it.getPoint().getCode());
map.setTjkw(it.getPoint() == null ? null : it.getPoint().getCode());
return new ResponseEntity<>(map, HttpStatus.OK);
}
if (seq==2) {
if(pointCode==null||!pointCode.equals("")){
Point dstPoint=d.getItem().getPoint();
if(dstPoint==null){
if (seq == 2) {
if (pointCode == null || !pointCode.equals("")) {
Point dstPoint = d.getItem().getPoint();
if (dstPoint == null) {
return new ResponseEntity<>(d.getItem().getCode() + "品番未维护库位", BAD_REQUEST);
}
point=dstPoint;
pointCode=dstPoint.getCode();
}else {
point = dstPoint;
pointCode = dstPoint.getCode();
} else {
point = pointService.getPoint(pointCode, null, null, null);
if (point == null) {
return new ResponseEntity<>(pointCode + "库位不存在", BAD_REQUEST);
}
}
Area area=point.getArea();
putawayInv(d.getId(),area.getId(),point.getId(),s.getQty(),ewm);
//直接上架确认
Area area = point.getArea();
putawayInv(d.getId(), area.getId(), point.getId(), s.getQty(), ewm);
//直接上架确认
}
return new ResponseEntity<>("操作成功", HttpStatus.OK);
}
@ -249,37 +249,37 @@ public class AsnDetailController {
@ApiOperation("扫描现品票上架APP")
@PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> putawayXppApp(@RequestBody IRkPut s) {
int seq=s.getSeq();
if(seq==1){
XppRecord xppRecord =null;
int seq = s.getSeq();
if (seq == 1) {
XppRecord xppRecord = null;
String ewm = s.getEwm();
xppRecord = xppRecordRepository.findByCode(ewm);
if(xppRecord==null){
if (xppRecord == null) {
return new ResponseEntity<>(ewm + "二维码未采集", BAD_REQUEST);
}
if(!xppRecord.getStatus().equals(BizStatus.RECEIVED)&&!xppRecord.getStatus().equals(BizStatus.RETENTION_IN)){
throw new BadRequestException(xppRecord.getItem().getCode()+"现品票状态不正确");
if (!xppRecord.getStatus().equals(BizStatus.RECEIVED) && !xppRecord.getStatus().equals(BizStatus.RETENTION_IN)) {
throw new BadRequestException(xppRecord.getItem().getCode() + "现品票状态不正确");
}
if(!xppRecord.getStatus().equals(BizStatus.RECEIVED)&&!xppRecord.getStatus().equals(BizStatus.RETENTION_IN)){
if (!xppRecord.getStatus().equals(BizStatus.RECEIVED) && !xppRecord.getStatus().equals(BizStatus.RETENTION_IN)) {
return new ResponseEntity<>("现品票状态不正确", BAD_REQUEST);
}
RRkXpp map = xppRecordService.xppAnalysis(xppRecord);
return new ResponseEntity<>(map, HttpStatus.OK);
}
if (seq==2) {
if (seq == 2) {
String pointCode = s.getPointCode();
if (pointCode == null||pointCode.equals("")) {
return new ResponseEntity<>( "库位不能为空", BAD_REQUEST);
if (pointCode == null || pointCode.equals("")) {
return new ResponseEntity<>("库位不能为空", BAD_REQUEST);
}
Point point = pointService.getPoint(pointCode,null, null, null);
Point point = pointService.getPoint(pointCode, null, null, null);
if (point == null) {
return new ResponseEntity<>(pointCode + "库位不存在", BAD_REQUEST);
}
Area area=point.getArea();
for(String ewm:s.getEwms()){
XppRecord xppRecord=xppRecordRepository.findByCode(ewm);
Area area = point.getArea();
for (String ewm : s.getEwms()) {
XppRecord xppRecord = xppRecordRepository.findByCode(ewm);
AsnDetail d = xppRecordService.addAsnDetail(xppRecord);
putawayInv(d.getId(), area.getId(), point.getId(), d.getOrderQty(),ewm);
putawayInv(d.getId(), area.getId(), point.getId(), d.getOrderQty(), ewm);
}
}
return new ResponseEntity<>("操作成功", HttpStatus.OK);
@ -292,11 +292,11 @@ public class AsnDetailController {
@PreAuthorize("@el.check('super:man')")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<Object> putawayConfirmXpp(@RequestBody HashMap rk) {
Long asnDetailId=Long.parseLong(rk.get("detailId").toString());
AsnDetailDto dto= asnDetailService.findById(asnDetailId);
Double recQty=dto.getOrderQty()-dto.getReceivedQty();
Long asnDetailId = Long.parseLong(rk.get("detailId").toString());
AsnDetailDto dto = asnDetailService.findById(asnDetailId);
Double recQty = dto.getOrderQty() - dto.getReceivedQty();
putawayInv(asnDetailId, Long.parseLong(rk.get("areaId").toString())
, Long.parseLong(rk.get("pointId").toString()),recQty,null);
, Long.parseLong(rk.get("pointId").toString()), recQty, null);
return new ResponseEntity<>("操作成功", HttpStatus.OK);
}
@ -306,24 +306,25 @@ public class AsnDetailController {
@PreAuthorize("@el.check('super:man')")
@Transactional
public ResponseEntity<Object> cancelPut(@RequestBody Long[] ids) {
for (Long id:ids){
XppRecord xppRecord = xppRecordService.getEntity(id);
AsnDetail ad=xppRecord.getAsnDetailId();
if(ad==null){
return new ResponseEntity("找不到上架记录", BAD_REQUEST);
}
if (!xppRecord.getStatus().equals(BizStatus.PUTAWAY)) {
throw new BadRequestException("上架状态才能取消上架");
}
Task t=xppRecord.getRkTask();
for (Long id : ids) {
XppRecord xppRecord = xppRecordService.getEntity(id);
AsnDetail ad = xppRecord.getAsnDetailId();
if (ad == null) {
return new ResponseEntity("找不到上架记录", BAD_REQUEST);
}
if (!xppRecord.getStatus().equals(BizStatus.PUTAWAY)) {
throw new BadRequestException("上架状态才能取消上架");
}
Task t = xppRecord.getRkTask();
// List<Task> ts=taskService.queryTask(ad.getId(),null,null,null);
// for(Task t:ts) {
asnDetailService.cancelPut(t.getId(), xppRecord);
asnDetailService.cancelPut(t.getId(), xppRecord);
// }
xppRecordRepository.delete(xppRecord);
}
xppRecordRepository.delete(xppRecord);
}
return new ResponseEntity("取消成功", HttpStatus.OK);
}
@Log("取消收货的操作")
@ApiOperation("取消收货的操作")
@PostMapping("/rkAndQxButtonQX")
@ -332,7 +333,7 @@ public class AsnDetailController {
if (!asnDetailButton.getAsnDetailDataS().isEmpty()) {
for (AsnDetail ad : asnDetailButton.getAsnDetailDataS()) {
Asn asn = ad.getAsn();
if (Objects.isNull(asn)){
if (Objects.isNull(asn)) {
throw new BadRequestException(HttpStatus.NOT_FOUND, ad.getItem().getCode() + "没有主单(订单序号)");
}
AsnDto byId = asnMapper.toDto(asn);
@ -360,22 +361,22 @@ public class AsnDetailController {
List<InventoryDto> inventoryDtos = invService.queryAll(inventoryQueryCriteria);
if (!inventoryDtos.isEmpty()) {
InventoryDto inventoryDto = inventoryDtos.get(0);
double pd = inventoryDto.getQuantity()-ad.getReceivedQty();
if (pd>0){
inventoryDto.setQuantity((int)pd);
double pd = inventoryDto.getQuantity() - ad.getReceivedQty();
if (pd > 0) {
inventoryDto.setQuantity((int) pd);
invService.update(inventoryMapper.toEntity(inventoryDto));
}else if (pd==0d){
} else if (pd == 0d) {
inventoryRepository.deleteById(inventoryDto.getId());
}else {
throw new BadRequestException(HttpStatus.NOT_FOUND, ad.getItem().getCode()+"库存数量不满,无法取消");
} else {
throw new BadRequestException(HttpStatus.NOT_FOUND, ad.getItem().getCode() + "库存数量不满,无法取消");
}
//生成库存日志
InventoryLog inventoryLog = invLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL, BizStatus.REDUCE, null, ad.getPoint().getArea(), inventoryDto.getItemKey(),
pointMapper.toEntity(inventoryDto.getPoint()) , dstPoint, ad.getStock(), ad.getStock(), ad.getReceivedQty(), ad.getReceivedQty(), null,null,BizStatus.ASN, ad.getId(), inventoryDto.getId(), ad.getRemark());
pointMapper.toEntity(inventoryDto.getPoint()), dstPoint, ad.getStock(), ad.getStock(), ad.getReceivedQty(), ad.getReceivedQty(), null, null, BizStatus.ASN, ad.getId(), inventoryDto.getId(), ad.getRemark());
}
// }
byId.setReceivedQuantity(byId.getReceivedQuantity()-ad.getReceivedQty());
byId.setReceivedQuantity(byId.getReceivedQuantity() - ad.getReceivedQty());
ad.setReceivedQty(0d);
asnDetailService.update(ad);
asnService.update(asnMapper.toEntity(byId));
@ -383,6 +384,7 @@ public class AsnDetailController {
}
return ApiResult.result(200, "操作成功", HttpStatus.OK);
}
/**
*
*
@ -410,10 +412,10 @@ public class AsnDetailController {
throw new BadRequestException(HttpStatus.NOT_FOUND, asnId + "库区未填写");
}
//查询 那个明细需要确认
List<AsnDetail> asnDetails =asnDetailService.findAsnDetails(asnId,"1");
List<AsnDetail> asnDetails = asnDetailService.findAsnDetails(asnId, "1");
if (!asnDetails.isEmpty()) {
for (AsnDetail d : asnDetails) {
this.putawayInv(d.getId(), byId.getArea().getId(), d.getPoint()==null?null:d.getPoint().getId(),(d.getOrderQty()-d.getReceivedQty()),null);
this.putawayInv(d.getId(), byId.getArea().getId(), d.getPoint() == null ? null : d.getPoint().getId(), (d.getOrderQty() - d.getReceivedQty()), null);
byId.setReceivedDate(new Timestamp(System.currentTimeMillis()));
byId.setReceivedQuantity(byId.getReceivedQuantity() + d.getOrderQty());
@ -428,7 +430,7 @@ public class AsnDetailController {
}
return ApiResult.result(200, "入库确认成功", HttpStatus.OK);
} else if (asnDetailButton.getButton() == 2) {
double qty=asnDetailButton.getOneRNumber();
double qty = asnDetailButton.getOneRNumber();
long id = asnDetailButton.getId();
AsnDto byId = asnService.findById(id);
if (Objects.isNull(byId)) {
@ -441,15 +443,15 @@ public class AsnDetailController {
// 通用异常,使用自定义状态码
throw new BadRequestException(HttpStatus.NOT_FOUND, id + "库区未填写");
}
putawayInv(id,area.getId(),asnDetailButton.getOneRPoint().getId(),qty,null);
putawayInv(id, area.getId(), asnDetailButton.getOneRPoint().getId(), qty, null);
} else if (asnDetailButton.getButton() == 3) {
long id = asnDetailButton.getId();
AsnDto byId = asnService.findById(id);
if (!asnDetailButton.getAsnDetailDataS().isEmpty()) {
for (AsnDetail ad : asnDetailButton.getAsnDetailDataS()) {
List<Task> ts=taskService.queryTask(ad.getId(),null,null,null,null);
for(Task t:ts) {
asnDetailService.cancelPut(t.getId(),null);
List<Task> ts = taskService.queryTask(ad.getId(), null, null, null, null);
for (Task t : ts) {
asnDetailService.cancelPut(t.getId(), null);
}
}
}
@ -467,7 +469,7 @@ public class AsnDetailController {
@Transactional(rollbackFor = Exception.class)
public ApiResult invVerify(@RequestBody Long[] ids) {
for (Long id : ids) {
Asn asn=asnService.getEntity(id);
Asn asn = asnService.getEntity(id);
//AsnDto asnDto = asnService.findById(id);
if (Objects.isNull(asn)) {
// 通用异常,使用自定义状态码
@ -479,14 +481,14 @@ public class AsnDetailController {
// 通用异常,使用自定义状态码
throw new BadRequestException(HttpStatus.NOT_FOUND, id + "库区未填写");
}
BillType bt=asn.getBillType();
BillType bt = asn.getBillType();
if (bt.getBezl() && asn.getZlBy() == null) {
throw new BadRequestException(asn.getCode() + "该单子还未整理,请先整理");
}
if (bt.getBecy() && asn.getCyBy() == null) {
throw new BadRequestException(asn.getCode() + "该单子还未抽样,请先抽样");
}
if(bt.getBezj()&& asn.getZjBy() == null) {
if (bt.getBezj() && asn.getZjBy() == null) {
throw new BadRequestException(asn.getCode() + "该单子还未质检,请先质检");
}
// if (!area.getBesh()){
@ -515,15 +517,15 @@ public class AsnDetailController {
}
ApiResult apiResult = null;
if (asnDetailData.getReceivedQty()>0){
if (asnDetailData.getReceivedQty() > 0) {
// 通用异常,使用自定义状态码
throw new BadRequestException(HttpStatus.NOT_FOUND, id + "的副表" + asnDetailData.getId() + "的物料已经单一入库无法使用整单入库");
}
Point p=asnDetailData.getPoint();
if(p==null){
p=pointRepository.findByCode("MR-CH");
Point p = asnDetailData.getPoint();
if (p == null) {
p = pointRepository.findByCode("MR-CH");
}
apiResult=this.putawayInv(asnDetailData.getId(), asn.getArea().getId(), p.getId(),(asnDetailData.getOrderQty()-asnDetailData.getReceivedQty()),null);
apiResult = this.putawayInv(asnDetailData.getId(), asn.getArea().getId(), p.getId(), (asnDetailData.getOrderQty() - asnDetailData.getReceivedQty()), null);
if (apiResult.getStatus() == 200) {
//收货日期改成当前日期 数量累计
asn.setReceivedDate(new Timestamp(System.currentTimeMillis()));
@ -546,56 +548,56 @@ public class AsnDetailController {
}
public ApiResult putawayInv(@RequestBody Long asnDetailId, Long areaId, Long pointId,double recQty,String ewm) {
public ApiResult putawayInv(@RequestBody Long asnDetailId, Long areaId, Long pointId, double recQty, String ewm) {
AsnDetail d = asnDetailService.getEntity(asnDetailId);
Area area = areaService.findEntityById(areaId);
Point point = null;
if(pointId!=null){
if (pointId != null) {
point = pointService.findEntityById(pointId);
}else{
point =pointRepository.findByCode("MR-CH");
} else {
point = pointRepository.findByCode("MR-CH");
}
Point zzkw=null;
if(area.getBexb()){
point= pointService.getPoint(area.getPointCode(), null, BaseStatus.HCKW, null);//取默认线边库位
zzkw=d.getPoint();
if(zzkw==null){
Point zzkw = null;
if (area.getBexb()) {
point = pointService.getPoint(area.getPointCode(), null, BaseStatus.HCKW, null);//取默认线边库位
zzkw = d.getPoint();
if (zzkw == null) {
//取默认制造库位
zzkw= pointService.getPoint("ZZKW", null, null, null);
zzkw = pointService.getPoint("ZZKW", null, null, null);
}
}
if(point==null){
if (point == null) {
throw new BadRequestException("请选择入库库位");
}
double unRecQty=d.getOrderQty() - d.getReceivedQty();
if ( recQty<=unRecQty ) {
String pc1=null;
double unRecQty = d.getOrderQty() - d.getReceivedQty();
if (recQty <= unRecQty) {
String pc1 = null;
//现品票确认将任务id回写到现品票表中
XppRecord xppRecord = xppRecordRepository.findByCode(ewm);
ItemKey ik=null;
if(xppRecord!=null){
if(!xppRecord.getStatus().equals(BizStatus.RECEIVED)&&!xppRecord.getStatus().equals(BizStatus.RETENTION_IN)){
throw new BadRequestException(d.getItem().getCode()+"现品票状态不正确");
ItemKey ik = null;
if (xppRecord != null) {
if (!xppRecord.getStatus().equals(BizStatus.RECEIVED) && !xppRecord.getStatus().equals(BizStatus.RETENTION_IN)) {
throw new BadRequestException(d.getItem().getCode() + "现品票状态不正确");
}
pc1=DateUtil.dateYmd(new Date());
ik=xppRecord.getItemKey();
pc1 = DateUtil.dateYmd(new Date());
ik = xppRecord.getItemKey();
}
if(ik==null){
ik = itemKeyService.getItemKey(d.getItem(), pc1, null);
if (ik == 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) {
Task t = taskService.storeTask(d, null, area, ik, point, point, recQty);
if (xppRecord != null) {
xppRecord.setRkTask(t);
xppRecord.setInvPoint(point);
xppRecord.setStatus(BizStatus.PUTAWAY);
xppRecord.setItemKey(ik);
ewm=xppRecord.getEwm();
ewm = xppRecord.getEwm();
xppRecordService.update(xppRecord);
}
d.setReceivedQty(d.getReceivedQty()+recQty);
if(d.getReceivedQty().intValue()>=d.getOrderQty().intValue()){
d.setReceivedQty(d.getReceivedQty() + recQty);
if (d.getReceivedQty().intValue() >= d.getOrderQty().intValue()) {
d.setStatus(BizStatus.PUTAWAY);
}else if(d.getReceivedQty().intValue()>0){
} else if (d.getReceivedQty().intValue() > 0) {
d.setStatus(BizStatus.PUTAWAY);
}
asnDetailService.update(d);
@ -607,23 +609,36 @@ public class AsnDetailController {
double srcQty = inv.getQuantity();
inv.addQty(recQty);
invService.update(inv);
String billCode=null;
if(d.getAsn()!=null){
Asn asn=d.getAsn();
billCode=asn.getCode();
asn.setReceivedQuantity(asn.getReceivedQuantity()+recQty);
if(asn.getReceivedQuantity().intValue()>=asn.getOrderQuantity().intValue()) {
String billCode = null;
if (d.getAsn() != null) {
Asn asn = d.getAsn();
billCode = asn.getCode();
asn.setReceivedQuantity(asn.getReceivedQuantity() + recQty);
if (asn.getReceivedQuantity().intValue() >= asn.getOrderQuantity().intValue()) {
asnService.update(asn);
}
}
Point srcPoint = pointService.getPoint(null, null, BaseStatus.SHZC, null);
InventoryLog log=invLogService.storeInventoryLog(BizStatus.RECEIVING_UP, BizStatus.ADD, billCode, area, ik, srcPoint, point, zzkw, srcQty, recQty,ewm,
InventoryLog log = invLogService.storeInventoryLog(BizStatus.RECEIVING_UP, BizStatus.ADD, billCode, area, ik, srcPoint, point, zzkw, srcQty, recQty, ewm,
BizStatus.ASN, d.getId(), inv.getId(), d.getRemark());
} else {
throw new BadRequestException(d.getItem().getCode() + "收货数量不能大于未收数量");
}
return ApiResult.result(200,"" , HttpStatus.OK);
return ApiResult.result(200, "", HttpStatus.OK);
}
@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());
@ -638,4 +638,4 @@ public class PickOutController {
return new ResponseEntity<>(map,HttpStatus.OK);
}
}
}

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());
@ -414,4 +414,4 @@ public class PickTicketController {
return new ResponseEntity<>(map,HttpStatus.OK);
}
}
}

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,
@ -707,4 +707,4 @@ public class XppRecordController {
xppRecordService.update(xpp);
return new ResponseEntity<>("操作成功", HttpStatus.OK);
}
}
}

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;
@ -126,4 +127,4 @@ public class AsnDetailDto implements Serializable {
/** 修改时间 */
private Timestamp updateTime;
}
}

View File

@ -1,36 +1,36 @@
/*
* 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.
*/
* 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.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,40 +49,43 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description
* @author hjl
* @date 2023-08-14
**/
* @author hjl
* @website https://eladmin.vip
* @description
* @date 2023-08-14
**/
@Service
@RequiredArgsConstructor
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){
Page<AsnDetail> page = asnDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
public Map<String, Object> queryAll(AsnDetailQueryCriteria criteria, Pageable pageable) {
Page<AsnDetail> page = asnDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(asnDetailMapper::toDto));
}
@Override
public List<AsnDetailDto> queryAll(AsnDetailQueryCriteria criteria){
return asnDetailMapper.toDto(asnDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
public List<AsnDetailDto> queryAll(AsnDetailQueryCriteria criteria) {
return asnDetailMapper.toDto(asnDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
@Transactional
public AsnDetailDto findById(Long id) {
AsnDetail asnDetail = asnDetailRepository.findById(id).orElseGet(AsnDetail::new);
ValidationUtil.isNull(asnDetail.getId(),"AsnDetail","id",id);
ValidationUtil.isNull(asnDetail.getId(), "AsnDetail", "id", id);
return asnDetailMapper.toDto(asnDetail);
}
@ -102,7 +106,7 @@ public class AsnDetailServiceImpl implements AsnDetailService {
@Transactional(rollbackFor = Exception.class)
public void update(AsnDetail resources) {
AsnDetail asnDetail = asnDetailRepository.findById(resources.getId()).orElseGet(AsnDetail::new);
ValidationUtil.isNull( asnDetail.getId(),"AsnDetail","id",resources.getId());
ValidationUtil.isNull(asnDetail.getId(), "AsnDetail", "id", resources.getId());
asnDetail.copy(resources);
asnDetailRepository.save(asnDetail);
}
@ -111,53 +115,54 @@ public class AsnDetailServiceImpl implements AsnDetailService {
public void deleteAll(Long[] ids) {
for (Long id : ids) {
AsnDetail asnDetail = asnDetailRepository.getById(id);
if (asnDetail.getStatus().equals("OPEN")){
if (asnDetail.getStatus().equals("OPEN")) {
//修改容器状态
//删除关联表的数据 入库单明细(data_asn_detail)
if (taskRepository.getAsnDetailIdToId(id)!=null){
if (taskRepository.getAsnDetailIdToId(id) != null) {
taskRepository.deleteById(taskRepository.getAsnDetailIdToId(id));
}
//扣入库表的订单数量
Double orderQty = asnDetail.getOrderQty();
AsnDto byId = asnService.findById(asnDetail.getAsn().getId());
byId.setOrderQuantity(byId.getOrderQuantity()-orderQty);
byId.setOrderQuantity(byId.getOrderQuantity() - orderQty);
asnService.update(asnMapper.toEntity(byId));
}
asnDetailRepository.deleteById(id);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void cancelPut(Long taskId, XppRecord xppRecord) {
Task t=taskRepository.getById(taskId);
AsnDetail d=t.getAsnDetail();
Asn asn=d.getAsn();
String ewm=null;
if(t.getPlanQty()>0){
Point srcPoint=t.getDstPoint();
if(xppRecord!=null){
ewm=xppRecord.getEwm();
srcPoint=xppRecord.getInvPoint();
Task t = taskRepository.getById(taskId);
AsnDetail d = t.getAsnDetail();
Asn asn = d.getAsn();
String ewm = null;
if (t.getPlanQty() > 0) {
Point srcPoint = t.getDstPoint();
if (xppRecord != null) {
ewm = xppRecord.getEwm();
srcPoint = xppRecord.getInvPoint();
}
Inventory inventory=inventoryService.getInventory(t.getItemKey(),t.getArea(),srcPoint,t.getAsnDetail().getPoint(),t.getArea().getDept(),BizStatus.RECEIVING_CANCEL);
if(inventory==null){
Inventory inventory = inventoryService.getInventory(t.getItemKey(), t.getArea(), srcPoint, t.getAsnDetail().getPoint(), t.getArea().getDept(), BizStatus.RECEIVING_CANCEL);
if (inventory == null) {
throw new BadRequestException("找不到对应库存");
}
if((inventory.getQuantity().intValue()- inventory.getQueuedQty().intValue())<t.getPlanQty().intValue()){
if ((inventory.getQuantity().intValue() - inventory.getQueuedQty().intValue()) < t.getPlanQty().intValue()) {
throw new BadRequestException("库存不足");
}
double srcQty= inventory.getQuantity();
inventory.setQuantity(inventory.getQuantity()-t.getPlanQty());
double srcQty = inventory.getQuantity();
inventory.setQuantity(inventory.getQuantity() - t.getPlanQty());
inventoryService.update(inventory);
d.setReceivedQty(d.getReceivedQty()-t.getPlanQty());
if(asn!=null){
asn.setReceivedQuantity(asn.getReceivedQuantity()-t.getPlanQty());
d.setReceivedQty(d.getReceivedQty() - t.getPlanQty());
if (asn != null) {
asn.setReceivedQuantity(asn.getReceivedQuantity() - t.getPlanQty());
}
InventoryLog log=inventoryLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL,BizStatus.REDUCE,null,t.getArea(),t.getItemKey(),t.getDstPoint(),t.getSrcPoint(),null,null,srcQty,t.getPlanQty(),
null,ewm, BizStatus.ASN,inventory.getId(),inventory.getId(),"取消上架");
InventoryLog log = inventoryLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL, BizStatus.REDUCE, null, t.getArea(), t.getItemKey(), t.getDstPoint(), t.getSrcPoint(), null, null, srcQty, t.getPlanQty(),
null, ewm, BizStatus.ASN, inventory.getId(), inventory.getId(), "取消上架");
taskRepository.delete(t);
if(d!=null){
if (d != null) {
this.delete(d.getId());
}
}
@ -170,28 +175,29 @@ public class AsnDetailServiceImpl implements AsnDetailService {
@Override
public void download(List<AsnDetailDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"AsnDetail");
List<Map<String, Object>> list = ExcelDownUtils.CreateMap(all, "AsnDetail");
FileUtil.downloadExcel(list, response);
}
@Override
public AsnDetail toEntity(AsnDetailDto detailDto) {
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+"'";
Query query=entityMapper.createQuery(hql);
List<AsnDetail> ts=query.getResultList();
if(ts.size()>0){
public AsnDetail findByStock(String code) {
String hql = "select d from AsnDetail d where d.stock.code='" + code + "' and d.status='" + BizStatus.OPEN + "'";
Query query = entityMapper.createQuery(hql);
List<AsnDetail> ts = query.getResultList();
if (ts.size() > 0) {
return ts.get(0);
}
return null;
return null;
}
@Override
public AsnDetail createAsnDetail(Item item, Stock stock, Point srcPoint,String propC1,String gdh){
public AsnDetail createAsnDetail(Item item, Stock stock, Point srcPoint, String propC1, String gdh) {
AsnDetail asnDetail = new AsnDetail();
asnDetail.setItem(item);
asnDetail.setLineNo(1L);
@ -202,17 +208,77 @@ public class AsnDetailServiceImpl implements AsnDetailService {
asnDetail.setPoint(srcPoint);
asnDetail.setPropC1(propC1);
asnDetail.setOrderNumber(gdh);
return asnDetail;
return asnDetail;
}
@Override
public List<AsnDetail> findAsnDetails(Long asnId,String type) {
String hql =" from AsnDetail ad where ad.asn.id="+asnId;
if(type.equals("1")){//整单收货,查询未收货数据
hql+=" and ad.receivedQty<orderQty";
public List<AsnDetail> findAsnDetails(Long asnId, String type) {
String hql = " from AsnDetail ad where ad.asn.id=" + asnId;
if (type.equals("1")) {//整单收货,查询未收货数据
hql += " and ad.receivedQty<orderQty";
}
Query query=entityMapper.createQuery(hql);
List<AsnDetail> ds=query.getResultList();
Query query = entityMapper.createQuery(hql);
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

@ -1,18 +1,18 @@
/*
* 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.
*/
* 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.impl;
import com.youchain.basicdata.domain.Item;
@ -40,11 +40,11 @@ import javax.persistence.Query;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description
* @author houjianlan
* @date 2023-08-21
**/
* @author houjianlan
* @website https://eladmin.vip
* @description
* @date 2023-08-21
**/
@Service
@RequiredArgsConstructor
@Slf4j
@ -121,38 +121,43 @@ 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);
}
return itemKey;
}
}
}

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);
@ -195,4 +195,4 @@ public class SparepartsServiceImpl implements SparepartsService {
s.setHyTime(new Timestamp(new Date().getTime()));
this.update(s);
}
}
}

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