no message

main
HUOJIN\92525 2024-11-08 13:30:25 +08:00
parent 28286abf32
commit 62921aa99c
4 changed files with 147 additions and 164 deletions

View File

@ -189,7 +189,7 @@ public class PickDetailController {
} else {
return new ResponseEntity(ApiResult.fail(BAD_REQUEST.value(), "参数错误或者为null", ""), HttpStatus.BAD_REQUEST);
}
return new ResponseEntity<>(HttpStatus.OK);
return new ResponseEntity<>(ApiResult.success(),HttpStatus.OK);
}
@PostMapping("/sbPickdetail")

View File

@ -152,12 +152,11 @@ public class InventoryServiceImpl implements InventoryService {
String hql = " from Inventory inv where 1=1 " +
" and inv.itemKey.item.id=" + itemId + " " +
" and inv.area.id=" + areaId + " " +
" and inv.quantity-inv.queuedQty>0 ";
" and inv.quantity-inv.queuedQty>0" +
" and inv.status='已入库' ";
if (zzkwId != null) {
hql += " and inv.zzkw.id=" + zzkwId;
hql += "and inv.point.type in ('" + BaseStatus.HCKW + "','" + BaseStatus.ZZKW + "')";
} else {
hql += "and inv.point.type='" + BaseStatus.CH + "'";
}
hql += " order by inv.itemKey.propC1 asc ";
Query query = entityManager.createQuery(hql);

View File

@ -126,7 +126,7 @@ public class PickDetailServiceImpl implements PickDetailService {
PickTicket pickTicket = resources.getPickTicket();
PickDetailDto byId = this.findById(resources.getId());
pickTicket.setOrderQuantity(pickTicket.getOrderQuantity() - byId.getOrderQty() + resources.getOrderQty());
pickTicketRepository.updataOrderQuantity(pickTicket.getOrderQuantity(),pickTicket.getId());
pickTicketRepository.updataOrderQuantity(pickTicket.getOrderQuantity(), pickTicket.getId());
pickDetail.copy(resources);
pickDetailRepository.save(pickDetail);
}
@ -138,122 +138,107 @@ public class PickDetailServiceImpl implements PickDetailService {
}
}
public void deletePickDetail(Long id){
public void deletePickDetail(Long id) {
//扣主表的订单数量
PickDetail detail = pickDetailRepository.getById(id);
PickTicket pt=detail.getPickTicket();
Boolean bcbl=Boolean.FALSE;
if(pt.getBillType().getName().equals(BaseStatus.BT_BCBL)){
bcbl=Boolean.TRUE;
PickTicket pt = detail.getPickTicket();
Boolean bcbl = Boolean.FALSE;
if (pt.getBillType().getName().equals(BaseStatus.BT_BCBL)) {
bcbl = Boolean.TRUE;
}
if(detail.getAllocatedQty()+detail.getBcQty()>0){
if (detail.getAllocatedQty() + detail.getBcQty() > 0) {
throw new BadRequestException("已出单,不能删除");
}
if(bcbl){
PickDetail oldDetail=pickDetailRepository.getById(detail.getSourceId());
if(oldDetail!=null){
oldDetail.setBcQty(oldDetail.getBcQty()- detail.getOrderQty());
if (bcbl) {
PickDetail oldDetail = pickDetailRepository.getById(detail.getSourceId());
if (oldDetail != null) {
oldDetail.setBcQty(oldDetail.getBcQty() - detail.getOrderQty());
this.update(oldDetail);
}
}
pt.setOrderQuantity(pt.getOrderQuantity()-detail.getOrderQty());
// pickTicketService.update(pt);
pt.setOrderQuantity(pt.getOrderQuantity() - detail.getOrderQty());
// pickTicketService.update(pt);
pickTicketRepository.save(pt);
pickDetailRepository.deleteById(id);
}
@Override
public void download(List<PickDetailZscDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list= ExcelDownUtils.CreateMap(all,"ViewPickDetailZsc");
List<Map<String, Object>> list = ExcelDownUtils.CreateMap(all, "ViewPickDetailZsc");
FileUtil.downloadExcel(list, response);
}
@Override
@Transactional(rollbackFor = Exception.class)
public synchronized void allocate(long id, double quantity){
public synchronized void allocate(long id, double quantity) {
PickDetailDto pickDetailDto = findById(id);
PickDetail pd = toEntity(pickDetailDto);//Dto转实体
PickTicket pickTicket = pd.getPickTicket();
ItemDto itemDto = pickDetailDto.getItem();
Item item = itemService.toEntity(itemDto);
if (pd.getOrderQty() > pd.getAllocatedQty()) {
Long zzkwId=null;
if(pd.getPoint()!=null&&pickTicket.getArea().getBexb()){
zzkwId=pd.getPoint().getId();
}
List<Inventory> invs = inventoryService.queryInventoryAllocate(item.getId(), pickTicket.getArea().getId(),zzkwId);
if (invs.size() > 0) {
double allocateQty = 0;
double unQty = quantity;//未分配数量
double srs=0;
for (Inventory inv : invs) {
Point startPoint = inv.getPoint();//原库位
String areaCode="S仓";
if(startPoint.getArea().equals("A仓")){
areaCode="A仓";
}
Point endPoint = pointService.getPoint(null, null, BaseStatus.BHZC, areaCode);//目标库位
if(endPoint==null){
throw new BadRequestException(HttpStatus.NOT_FOUND, "请维护备货暂存区");
}
if (unQty <= 0) {
break;
}
allocateQty = inv.getQuantity() - inv.getQueuedQty();//库存可用数量
if (allocateQty <= 0) {
continue;
}
//本次拣货数小于收容数则按照收容数进行分配,只有正常备货单才走该逻辑
if(pickTicket.getCode().indexOf("BH")>=0||pickTicket.getCode().indexOf("BC")>=0) {
if (unQty < srs) {
if (allocateQty >= srs) {
unQty = srs;
} else {
//unQty = allocateQty;
}
}
}
if (unQty < allocateQty) {
allocateQty = unQty;
}
inv.setQueuedQty(inv.getQueuedQty() + allocateQty);
inventoryRepository.save(inv);
unQty -= allocateQty;
pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty);
pickDetailRepository.save(pd);
pickTicket.setAllocatedQuantity(pickTicket.getAllocatedQuantity() + allocateQty);
if (pickTicket.getAllocatedQuantity()>0) {
pickTicket.setStatus(BizStatus.ALLOCATE);
}
//备货表上出单日期(审核写)
pickTicket.setOutOrderDate(new Timestamp(new Date().getTime()));
pickTicketRepository.save(pickTicket);
Task task = taskService.storeTask(null,pd,pickTicket.getArea(),inv.getItemKey(),startPoint,endPoint,allocateQty);
}
}
} else {
throw new BadRequestException(HttpStatus.NOT_FOUND,"已分配,请勿重复操作!");
if (pd.getOrderQty() - pd.getAllocatedQty() == 0) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "已分配,请勿重复操作!");
}
Long zzkwId = null;
if (pd.getPoint() != null && pickTicket.getArea().getBexb()) {
zzkwId = pd.getPoint().getId();
}
Point endPoint = pointService.getPoint("FHQ", null, null, null);//目标库位
if (endPoint == null) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "请维护发货暂存区");
}
List<Inventory> invs = inventoryService.queryInventoryAllocate(item.getId(), pickTicket.getArea().getId(), zzkwId);
if (invs.size() > 0) {
double allocateQty = 0;
double unQty = quantity;//未分配数量
for (Inventory inv : invs) {
Point startPoint = inv.getPoint();//原库位
if (unQty <= 0) {
break;
}
allocateQty = inv.getQuantity() - inv.getQueuedQty();//库存可用数量
if (allocateQty <= 0) {
continue;
}
if (unQty < allocateQty) {
allocateQty = unQty;
}
inv.setQueuedQty(inv.getQueuedQty() + allocateQty);
inventoryRepository.save(inv);
unQty -= allocateQty;
pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty);
pickDetailRepository.save(pd);
pickTicket.setAllocatedQuantity(pickTicket.getAllocatedQuantity() + allocateQty);
if (pickTicket.getAllocatedQuantity() > 0) {
pickTicket.setStatus(BizStatus.ALLOCATE);
}
//备货表上出单日期(审核写)
pickTicket.setOutOrderDate(new Timestamp(new Date().getTime()));
pickTicketRepository.save(pickTicket);
taskService.storeTask(null, pd, pickTicket.getArea(), inv.getItemKey(), startPoint, endPoint, allocateQty);
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public synchronized void cancelAllocate(long id){
public synchronized void cancelAllocate(long id) {
PickDetailDto pickDetailDto = findById(id);
PickDetail pd = toEntity(pickDetailDto);
List<Task> Tasks = taskRepository.getPickNotAllTask(id);
for (Task task : Tasks) {
//根据Taskz找到对应的库存
double quantity=task.getPlanQty();
double quantity = task.getPlanQty();
Inventory inv = inventoryRepository.findById(task.getInvId()).get();
inv.setQueuedQty(inv.getQueuedQty() - quantity);
inventoryRepository.save(inv);
//删除Task
taskRepository.delete(task);
pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
pd.setPureXqBz(pd.getPropC4()-pd.getAllocatedQty());
pd.setPureXqBz(pd.getPropC4() - pd.getAllocatedQty());
if (pd.getAllocatedQty() <= 0) {
pd.setAllocatedQty(0d);
pd.setStatus(BizStatus.OPEN);
@ -294,7 +279,7 @@ public class PickDetailServiceImpl implements PickDetailService {
}
@Override
public PickDetail createPickDetail(PickTicket pt,Item item, String po,double qty,String supplier) {
public PickDetail createPickDetail(PickTicket pt, Item item, String po, double qty, String supplier) {
PickDetail d = new PickDetail();
d.setItem(item);
d.setLineNo(1l);
@ -315,37 +300,39 @@ public class PickDetailServiceImpl implements PickDetailService {
List<PickDetail> queryResultList = query.getResultList();
return queryResultList;
}
public List<PickDetailZscDto> queryZscAll(PickDetailQueryCriteria criteria) {
public List<PickDetailZscDto> queryZscAll(PickDetailQueryCriteria criteria) {
Query query = getQuery(criteria);
List ts= query
List ts = query
.unwrap(SQLQuery.class)
.setResultTransformer(
AliasToEntityMapResultTransformer.INSTANCE
)
.list();
List<PickDetailZscDto> list = JSON.parseArray(JSON.toJSONString(ts),PickDetailZscDto.class);
List<PickDetailZscDto> list = JSON.parseArray(JSON.toJSONString(ts), PickDetailZscDto.class);
return list;
}
public Map<String,Object> queryPickDetailAll(PickDetailQueryCriteria criteria, Pageable pageable) {
int pageNum=pageable.getPageNumber();//当前页
int pageSize=pageable.getPageSize();//条数
public Map<String, Object> queryPickDetailAll(PickDetailQueryCriteria criteria, Pageable pageable) {
int pageNum = pageable.getPageNumber();//当前页
int pageSize = pageable.getPageSize();//条数
Query query = getQuery(criteria);
int pageCount=query.getResultList().size();
query.setFirstResult((pageNum)*pageSize);
query.setMaxResults((pageNum+1)*pageSize);
int pageCount = query.getResultList().size();
query.setFirstResult((pageNum) * pageSize);
query.setMaxResults((pageNum + 1) * pageSize);
List<PickDetailZscDto> queryResultList = query.unwrap(SQLQuery.class)
.setResultTransformer(
AliasToEntityMapResultTransformer.INSTANCE
)
.list();
Map<String,Object> map=new HashMap<>();
map.put("content",queryResultList);
map.put("totalElements",pageCount);
Map<String, Object> map = new HashMap<>();
map.put("content", queryResultList);
map.put("totalElements", pageCount);
return map;
}
public Query getQuery(PickDetailQueryCriteria criteria){
public Query getQuery(PickDetailQueryCriteria criteria) {
String sql = "SELECT * from (select pd.id,pt.id pt_id,pt.`code`,rk.gc_code,rk.name rk_name,rk.code rk_code,ck.code ck_code,ck.name ck_name,pt.`status`,pt.order_date,it.code item_code,it.name item_name,it.unit,\n" +
"pd.xq_qty,it.extend_d3,pd.prop_c4,(pd.order_qty-pd.allocated_qty-pd.bc_qty) as pure_xq_bz,pd.order_qty,pd.bc_qty," +
"(pd.order_qty-pd.allocated_qty) wcd_qty,pd.allocated_qty,pd.picked_qty,pd.shipped_qty,pd.xb_qty,\n" +
@ -359,65 +346,65 @@ public class PickDetailServiceImpl implements PickDetailService {
"left join base_area ck on ck.id=pd.area_id\n" +
"left join base_point zzkw on zzkw.id=pd.point_id )t \n" +
"where 1=1 and t.code like 'B%'";
if(criteria!=null) {
if (criteria.getCode()!=null &&!criteria.getCode().equals("") ) {
if (criteria != null) {
if (criteria.getCode() != null && !criteria.getCode().equals("")) {
sql += " and t.code like '%" + criteria.getCode() + "%'";
}
if (criteria.getItemCode()!=null &&!criteria.getItemCode().equals("") ) {
if (criteria.getItemCode() != null && !criteria.getItemCode().equals("")) {
sql += " and t.item_code like '%" + criteria.getItemCode() + "%'";
}
if (criteria.getItemName()!=null &&!criteria.getItemName().equals("") ) {
if (criteria.getItemName() != null && !criteria.getItemName().equals("")) {
sql += " and t.item_name like '%" + criteria.getItemName() + "%'";
}
if (criteria.getRkAreaCode()!=null &&!criteria.getRkAreaCode().equals("") ) {
if (criteria.getRkAreaCode() != null && !criteria.getRkAreaCode().equals("")) {
sql += " and t.rk_code like '%" + criteria.getRkAreaCode() + "%'";
}
if (criteria.getGcCode()!=null &&!criteria.getGcCode().equals("") ) {
if (criteria.getGcCode() != null && !criteria.getGcCode().equals("")) {
sql += " and t.gc_code like '%" + criteria.getGcCode() + "%'";
}
if (criteria.getCkAreaCode()!=null &&!criteria.getCkAreaCode().equals("") ) {
if (criteria.getCkAreaCode() != null && !criteria.getCkAreaCode().equals("")) {
sql += " and t.ck_code like '%" + criteria.getCkAreaCode() + "%'";
}
if (criteria.getPureXqBz()!=null &&!criteria.getPureXqBz().equals("") ) {
sql += " and t.pure_xq_bz>="+criteria.getPureXqBz();
if (criteria.getPureXqBz() != null && !criteria.getPureXqBz().equals("")) {
sql += " and t.pure_xq_bz>=" + criteria.getPureXqBz();
}
if (criteria.getStatus()!=null &&!criteria.getStatus().equals("") ) {
sql += " and t.status='"+criteria.getStatus()+"'";
if (criteria.getStatus() != null && !criteria.getStatus().equals("")) {
sql += " and t.status='" + criteria.getStatus() + "'";
}
if (criteria.getInvQty()!=null &&!criteria.getInvQty().equals("") ) {
sql += " and t.inv_qty>="+criteria.getInvQty();
if (criteria.getInvQty() != null && !criteria.getInvQty().equals("")) {
sql += " and t.inv_qty>=" + criteria.getInvQty();
}
if (criteria.getCreateTime()!=null) {
sql += " and t.order_date BETWEEN '"+criteria.getCreateTime().get(0)+"' and '"+criteria.getCreateTime().get(1)+"'";
if (criteria.getCreateTime() != null) {
sql += " and t.order_date BETWEEN '" + criteria.getCreateTime().get(0) + "' and '" + criteria.getCreateTime().get(1) + "'";
}
}
sql+=" order by t.pt_id desc";
sql += " order by t.pt_id desc";
Query query = entityManager.createNativeQuery(sql);
return query;
}
public List<Object[]> getQueryBcbl(Date blDate,Long ckAreaId,String gc){
String sql="select pd.id,ck.id ck_id," +
public List<Object[]> getQueryBcbl(Date blDate, Long ckAreaId, String gc) {
String sql = "select pd.id,ck.id ck_id," +
"(select IFNULL(sum(inv.quantity-inv.queued_qty),0) from data_inventory inv left join data_item_key ik on ik.id=inv.item_key_id where ik.item_id=it.id and inv.area_id=pt.area and inv.quantity>0) as inv_qty\n" +
" FROM `data_pick_detail` pd \n" +
"left join data_pick_ticket pt on pt.id=pd.pick_ticket_id\n" +
"left join base_item it on it.id=pd.item_id\n" +
"left join base_area rk on rk.id=pt.sh_area\n" +
"left join base_area ck on ck.id=pt.area\n" +
" where 1=1 and (pd.allocated_qty+pd.bc_qty)<pd.order_qty and pt.code like 'BH%' and pt.pc!='手工维护' and pt.gc_code='"+gc+"' and pt.area="+ckAreaId;
// sql+=" and pt.allocated_quantity>0 ";
" where 1=1 and (pd.allocated_qty+pd.bc_qty)<pd.order_qty and pt.code like 'BH%' and pt.pc!='手工维护' and pt.gc_code='" + gc + "' and pt.area=" + ckAreaId;
// sql+=" and pt.allocated_quantity>0 ";
//查找工位最后的上线计划修改日期
// sql+=" and pt.order_date>=(CURDATE() - INTERVAL 1 DAY) ";
sql+=" and DATE_FORMAT(pt.order_date,'%Y-%m-%d')='"+DateUtil.dateYmd(blDate)+"'";
Long user_id=SecurityUtils.getCurrentUserId();
List<Job> jobs=jobRepository.jobAreaCodes(user_id);
if(jobs.size()>0){
String areaCode= jobs.get(0).getAreaCode();
Area area=areaRepository.getByCode(areaCode);
sql+=" and ck.id="+ area.getId();
sql += " and DATE_FORMAT(pt.order_date,'%Y-%m-%d')='" + DateUtil.dateYmd(blDate) + "'";
Long user_id = SecurityUtils.getCurrentUserId();
List<Job> jobs = jobRepository.jobAreaCodes(user_id);
if (jobs.size() > 0) {
String areaCode = jobs.get(0).getAreaCode();
Area area = areaRepository.getByCode(areaCode);
sql += " and ck.id=" + area.getId();
}
// sql+=" and rk.id="+ automaticPlanning.getShArea().getId();
String split_sql = "SELECT t.id,t.ck_id from ("+sql+") t " +
String split_sql = "SELECT t.id,t.ck_id from (" + sql + ") t " +
" where 1=1 and t.inv_qty>0 order by t.id asc";
// log.info("query:"+split_sql);
Query query = entityManager.createNativeQuery(split_sql);
@ -429,15 +416,16 @@ public class PickDetailServiceImpl implements PickDetailService {
// .list();
return queryResultList;
}
public Double getMaxBomQty(long picktickId,String largeClass) {
String hql = "select max(pd.orderQty) from PickDetail pd where pd.pickTicket.id=" + picktickId + " and pd.item.largeClass='"+largeClass+"'";
public Double getMaxBomQty(long picktickId, String largeClass) {
String hql = "select max(pd.orderQty) from PickDetail pd where pd.pickTicket.id=" + picktickId + " and pd.item='" + largeClass + "'";
Query query = entityMapper.createQuery(hql);
Double result =(Double)query.getResultList().get(0);
Double result = (Double) query.getResultList().get(0);
return result;
}
public List<PickDetail> getBomList(long picktickId,String largeClass) {
String hql = " from PickDetail pd where pd.pickTicket.id=" + picktickId + " and pd.item.largeClass='"+largeClass+"'";
public List<PickDetail> getBomList(long picktickId, String largeClass) {
String hql = " from PickDetail pd where pd.pickTicket.id=" + picktickId + " and pd.item='" + largeClass + "'";
Query query = entityMapper.createQuery(hql);
List<PickDetail> queryResultList = query.getResultList();
return queryResultList;

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
package com.youchain.businessdata.service.impl;
import com.alibaba.fastjson.JSON;
import com.youchain.basicdata.domain.*;
import com.youchain.basicdata.repository.StockRepository;
@ -138,7 +139,7 @@ public class PickTicketServiceImpl implements PickTicketService {
List<PickDetail> pickDetails = pickDetailRepository.queryByPickTicketId(id);
if (pickDetails.isEmpty()) {
for (PickDetail p : pickDetails) {
if(p.getAllocatedQty()>0){
if (p.getAllocatedQty() > 0) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "已出单,不能删除");
}
if (p.getPickTicket().getBillType().equals(BaseStatus.BT_QTCK) && p.getPickTicket().getStatus().equals(BizStatus.ALLOCATE)) {
@ -161,9 +162,9 @@ public class PickTicketServiceImpl implements PickTicketService {
public void deletePickTicket(Long[] ids) {
for (Long id : ids) {
//循环明细进行删除
List<PickDetail> ds=pickDetailRepository.queryByPickTicketId(id);
for(PickDetail d:ds) {
//循环明细进行删除
List<PickDetail> ds = pickDetailRepository.queryByPickTicketId(id);
for (PickDetail d : ds) {
pickDetailService.deletePickDetail(d.getId());
}
pickTicketRepository.deleteById(id);
@ -172,7 +173,7 @@ public class PickTicketServiceImpl implements PickTicketService {
@Override
public void download(List<PickTicketDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"PickTicket");
List<Map<String, Object>> list = ExcelDownUtils.CreateMap(all, "PickTicket");
FileUtil.downloadExcel(list, response);
}
@ -258,7 +259,7 @@ public class PickTicketServiceImpl implements PickTicketService {
inventory.setQueuedQty(inventory.getQueuedQty() - taskDto.getPlanQty());
//存储拣货确认的库存数据
Task task = taskMapper.toEntity(taskDto);
Inventory inventory1 = inventoryService.getInventory(inventory.getItemKey(), inventory.getArea(), task.getDstPoint(), task.getZzkw(), inventory.getDept(), BizStatus.RECEIVING_UP);
Inventory inventory1 = inventoryService.getInventory(inventory.getItemKey(), inventory.getArea(), task.getDstPoint(), task.getZzkw(), inventory.getDept(), BizStatus.RECEIVING_UP);
invLogService.storeInventoryLog(BizStatus.PICK_DOWN, BizStatus.ADD, null, inventory1.getArea(), inventory1.getItemKey(), inventory1.getPoint(), inventory1.getPoint(), inventory1.getStock(), inventory1.getStock(), inventory1.getQuantity(), kcNum,
null, null, BizStatus.PICK_DOWN, inventory1.getId(), inventory1.getId(), inventory1.getDescription());
inventory1.setQuantity(inventory1.getQuantity() + kcNum);
@ -276,7 +277,7 @@ public class PickTicketServiceImpl implements PickTicketService {
taskLogService.createTaskLogData(taskDto, taskDto.getPlanQty());
//存储拣货确认的库存数据
Task task = taskMapper.toEntity(taskDto);
Inventory inventory1 = inventoryService.getInventory(inventory.getItemKey(), inventory.getArea(), task.getDstPoint(), task.getZzkw(), inventory.getDept(), BizStatus.RECEIVING_UP);
Inventory inventory1 = inventoryService.getInventory(inventory.getItemKey(), inventory.getArea(), task.getDstPoint(), task.getZzkw(), inventory.getDept(), BizStatus.RECEIVING_UP);
invLogService.storeInventoryLog(BizStatus.PICK_DOWN, BizStatus.ADD, null, inventory1.getArea(), inventory1.getItemKey(), inventory1.getPoint(), inventory1.getPoint(), inventory1.getStock(), inventory1.getStock(), inventory1.getQuantity(), kcNum,
null, null, BizStatus.PICK_DOWN, inventory1.getId(), inventory1.getId(), inventory1.getDescription());
inventory1.setQuantity(inventory1.getQuantity() + kcNum);
@ -475,20 +476,20 @@ public class PickTicketServiceImpl implements PickTicketService {
throw new BadRequestException(HttpStatus.NOT_FOUND, "拣货数量大于分配数量");
}
}
Boolean isCf= Boolean.FALSE;
double cfQty=0;
Boolean isCf = Boolean.FALSE;
double cfQty = 0;
if (pickQty > (task.getPlanQty() - task.getMoveQty())) {
fpQty = task.getPlanQty() - task.getMoveQty();
isCf=Boolean.TRUE;
cfQty=pickQty-fpQty;
isCf = Boolean.TRUE;
cfQty = pickQty - fpQty;
}
PickDetail pd = task.getPickDetail();
PickTicket pt = pd.getPickTicket();
Point zzkw=pd.getPoint();
Point zzkw = pd.getPoint();
//大部品的库存不能进去
Inventory srcInv = inventoryService.getInventory(task.getItemKey(),pt.getArea(),task.getSrcPoint(),zzkw,pt.getArea().getDept(),BizStatus.PICK_DOWN);
if (srcInv==null) {
Inventory srcInv = inventoryService.getInventory(task.getItemKey(), pt.getArea(), task.getSrcPoint(), zzkw, pt.getArea().getDept(), BizStatus.PICK_DOWN);
if (srcInv == null) {
throw new BadRequestException(HttpStatus.NOT_FOUND, task.getItem().getCode() + "未发现库存数据");
}
//扣除后的数量
@ -497,10 +498,10 @@ public class PickTicketServiceImpl implements PickTicketService {
throw new BadRequestException(HttpStatus.NOT_FOUND, "拣货数量大于库存数量");
}
//超发则需要判断库存是否还有足够未分配数量
if(isCf){
double wfp=srcInv.availableQty();
if((int)wfp<(int)cfQty){
throw new BadRequestException( "超发数"+cfQty+"大于可用库存数"+wfp);
if (isCf) {
double wfp = srcInv.availableQty();
if ((int) wfp < (int) cfQty) {
throw new BadRequestException("超发数" + cfQty + "大于可用库存数" + wfp);
}
}
//库存扣除后还要 inventoryLog
@ -524,7 +525,7 @@ public class PickTicketServiceImpl implements PickTicketService {
taskService.update(task);
srcInv.reduce(pickQty);
srcInv.setQueuedQty(srcInv.getQueuedQty() - fpQty);
if (srcInv.getQueuedQty().intValue()< 0) {
if (srcInv.getQueuedQty().intValue() < 0) {
srcInv.setQueuedQty(0d);
}
inventoryService.update(srcInv);
@ -532,8 +533,8 @@ public class PickTicketServiceImpl implements PickTicketService {
//生成备货库存,备货库存也不需要线边
Inventory dstInv = inventoryService.getInventory(srcInv.getItemKey(), srcInv.getArea(), task.getDstPoint(), zzkw, srcInv.getDept(), BizStatus.PICK_DOWN);
invLogService.storeInventoryLog(BizStatus.PICK_DOWN, BizStatus.ADD, pt.getCode(), dstInv.getArea(), dstInv.getItemKey(), dstInv.getPoint(), dstInv.getPoint(),
zzkw, dstInv.getQuantity(), kcNum, barCode, BizStatus.PICK_DOWN, taskLog.getId(),
dstInv.getId(), pd.getRemark());
zzkw, dstInv.getQuantity(), kcNum, barCode, BizStatus.PICK_DOWN, taskLog.getId(),
dstInv.getId(), pd.getRemark());
dstInv.setQuantity(dstInv.getQuantity() + kcNum);
inventoryService.update(dstInv);
pd.setPickedQty(pd.getPickedQty() + pickQty);
@ -541,15 +542,10 @@ public class PickTicketServiceImpl implements PickTicketService {
//拣货数量
pt.setPickedQuantity(pt.getPickedQuantity() + pickQty);
pt.setBhQty(pt.getBhQty() + pickQty);
// if ((pt.getOrderQuantity() - pt.getPickedQuantity()) <= 0) {
// pt.setStatus(BizStatus.PICK_ALL);
// } else {
// pt.setStatus(BizStatus.PICKUP);
// }
if(pickDetailRepository.queryPickQty(pt.getId()).size()>0){
pt.setStatus(BizStatus.PICKUP);
}else{
if ((pt.getOrderQuantity() - pt.getPickedQuantity()) == 0) {
pt.setStatus(BizStatus.PICK_ALL);
} else {
pt.setStatus(BizStatus.PICKUP);
}
this.update(pt);
if (xpp != null) {
@ -703,7 +699,7 @@ public class PickTicketServiceImpl implements PickTicketService {
}
//刷新状态
public void refreshSatus(Long pick){
public void refreshSatus(Long pick) {
}
@ -724,7 +720,7 @@ public class PickTicketServiceImpl implements PickTicketService {
//生成日志
invLogService.storeInventoryLog(BizStatus.PICK_CANCEL, BizStatus.ADD, task.getBillCode(), srcInv.getArea(), srcInv.getItemKey(), srcInv.getPoint(),
srcInv.getPoint(), zzkw, (srcInv.getQuantity() - cancelNum), cancelNum, taskLog.getSrcStockCode(),
BizStatus.PICK_CANCEL, taskLog.getId(), srcInv.getId(), srcInv.getDescription());
BizStatus.PICK_CANCEL, taskLog.getId(), srcInv.getId(), srcInv.getDescription());
//task表的修改
task.setMoveQty(task.getMoveQty() - cancelNum);
if (task.getMoveQty() == 0) {
@ -736,14 +732,14 @@ public class PickTicketServiceImpl implements PickTicketService {
pickDetailService.update(pd);
//扣库存
Inventory dstInv = inventoryService.getInventory(taskLog.getItemKey(), area, taskLog.getDstPoint(), zzkw, taskLog.getDept(), BizStatus.PICK_CANCEL);
if (dstInv==null) {
if (dstInv == null) {
throw new BadRequestException(HttpStatus.NOT_FOUND, taskLog.getItem().getCode() + "未发现库存数据");
}
if (dstInv.getQuantity() < cancelNum) {
throw new BadRequestException(HttpStatus.NOT_FOUND, taskLog.getItem().getCode() + "库存不足单子出现问题");
}
invLogService.storeInventoryLog(BizStatus.PICK_CANCEL, BizStatus.REDUCE, task.getBillCode(), dstInv.getArea(), dstInv.getItemKey(), dstInv.getPoint(), dstInv.getPoint(), zzkw, dstInv.getQuantity(), cancelNum,
taskLog.getSrcStockCode(), BizStatus.PICK_CANCEL, taskLog.getId(), dstInv.getId(), dstInv.getDescription());
taskLog.getSrcStockCode(), BizStatus.PICK_CANCEL, taskLog.getId(), dstInv.getId(), dstInv.getDescription());
dstInv.setQuantity(dstInv.getQuantity() - cancelNum);
if (dstInv.getQuantity() > 0) {
inventoryService.update(dstInv);
@ -782,9 +778,9 @@ public class PickTicketServiceImpl implements PickTicketService {
BizStatus.SHIP_CANCEL, taskLog.getId(), srcInv.getId(), "出库退回");
pd.setPickedQty(pd.getPickedQty() - cancelNum);
pickDetailService.update(pd);
PickTicket pickTicket=pd.getPickTicket();
PickTicket pickTicket = pd.getPickTicket();
pickTicket.setStatus(BizStatus.PICK_ALL);
pickTicket.setShippedQuantity(pickTicket.getShippedQuantity()-cancelNum);
pickTicket.setShippedQuantity(pickTicket.getShippedQuantity() - cancelNum);
taskService.update(task);
if (taskLog.getSrcStockCode() != null) {
XppRecord xpp = xppRecordRepository.findByCode(taskLog.getSrcStockCode());
@ -812,9 +808,9 @@ public class PickTicketServiceImpl implements PickTicketService {
if (t.getScanCode() != null && !t.getScanCode().equals("")) {
sql += " and pt.code ='" + t.getScanCode() + "'";
}
Long user_id=SecurityUtils.getCurrentUserId();
List<Job> jobs=jobRepository.jobAreaCodes(user_id);
if(jobs.size()>0){
Long user_id = SecurityUtils.getCurrentUserId();
List<Job> jobs = jobRepository.jobAreaCodes(user_id);
if (jobs.size() > 0) {
sql += " and ck.code ='" + jobs.get(0).getAreaCode() + "'";
}
sql += " ORDER BY pt.code desc";