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 { } else {
return new ResponseEntity(ApiResult.fail(BAD_REQUEST.value(), "参数错误或者为null", ""), HttpStatus.BAD_REQUEST); 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") @PostMapping("/sbPickdetail")

View File

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

View File

@ -126,7 +126,7 @@ public class PickDetailServiceImpl implements PickDetailService {
PickTicket pickTicket = resources.getPickTicket(); PickTicket pickTicket = resources.getPickTicket();
PickDetailDto byId = this.findById(resources.getId()); PickDetailDto byId = this.findById(resources.getId());
pickTicket.setOrderQuantity(pickTicket.getOrderQuantity() - byId.getOrderQty() + resources.getOrderQty()); pickTicket.setOrderQuantity(pickTicket.getOrderQuantity() - byId.getOrderQty() + resources.getOrderQty());
pickTicketRepository.updataOrderQuantity(pickTicket.getOrderQuantity(),pickTicket.getId()); pickTicketRepository.updataOrderQuantity(pickTicket.getOrderQuantity(), pickTicket.getId());
pickDetail.copy(resources); pickDetail.copy(resources);
pickDetailRepository.save(pickDetail); pickDetailRepository.save(pickDetail);
} }
@ -138,25 +138,25 @@ public class PickDetailServiceImpl implements PickDetailService {
} }
} }
public void deletePickDetail(Long id){ public void deletePickDetail(Long id) {
//扣主表的订单数量 //扣主表的订单数量
PickDetail detail = pickDetailRepository.getById(id); PickDetail detail = pickDetailRepository.getById(id);
PickTicket pt=detail.getPickTicket(); PickTicket pt = detail.getPickTicket();
Boolean bcbl=Boolean.FALSE; Boolean bcbl = Boolean.FALSE;
if(pt.getBillType().getName().equals(BaseStatus.BT_BCBL)){ if (pt.getBillType().getName().equals(BaseStatus.BT_BCBL)) {
bcbl=Boolean.TRUE; bcbl = Boolean.TRUE;
} }
if(detail.getAllocatedQty()+detail.getBcQty()>0){ if (detail.getAllocatedQty() + detail.getBcQty() > 0) {
throw new BadRequestException("已出单,不能删除"); throw new BadRequestException("已出单,不能删除");
} }
if(bcbl){ if (bcbl) {
PickDetail oldDetail=pickDetailRepository.getById(detail.getSourceId()); PickDetail oldDetail = pickDetailRepository.getById(detail.getSourceId());
if(oldDetail!=null){ if (oldDetail != null) {
oldDetail.setBcQty(oldDetail.getBcQty()- detail.getOrderQty()); oldDetail.setBcQty(oldDetail.getBcQty() - detail.getOrderQty());
this.update(oldDetail); this.update(oldDetail);
} }
} }
pt.setOrderQuantity(pt.getOrderQuantity()-detail.getOrderQty()); pt.setOrderQuantity(pt.getOrderQuantity() - detail.getOrderQty());
// pickTicketService.update(pt); // pickTicketService.update(pt);
pickTicketRepository.save(pt); pickTicketRepository.save(pt);
pickDetailRepository.deleteById(id); pickDetailRepository.deleteById(id);
@ -164,38 +164,35 @@ public class PickDetailServiceImpl implements PickDetailService {
@Override @Override
public void download(List<PickDetailZscDto> all, HttpServletResponse response) throws Exception { 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); FileUtil.downloadExcel(list, response);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public synchronized void allocate(long id, double quantity){ public synchronized void allocate(long id, double quantity) {
PickDetailDto pickDetailDto = findById(id); PickDetailDto pickDetailDto = findById(id);
PickDetail pd = toEntity(pickDetailDto);//Dto转实体 PickDetail pd = toEntity(pickDetailDto);//Dto转实体
PickTicket pickTicket = pd.getPickTicket(); PickTicket pickTicket = pd.getPickTicket();
ItemDto itemDto = pickDetailDto.getItem(); ItemDto itemDto = pickDetailDto.getItem();
Item item = itemService.toEntity(itemDto); Item item = itemService.toEntity(itemDto);
if (pd.getOrderQty() > pd.getAllocatedQty()) { if (pd.getOrderQty() - pd.getAllocatedQty() == 0) {
Long zzkwId=null; throw new BadRequestException(HttpStatus.NOT_FOUND, "已分配,请勿重复操作!");
if(pd.getPoint()!=null&&pickTicket.getArea().getBexb()){
zzkwId=pd.getPoint().getId();
} }
List<Inventory> invs = inventoryService.queryInventoryAllocate(item.getId(), pickTicket.getArea().getId(),zzkwId); 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) { if (invs.size() > 0) {
double allocateQty = 0; double allocateQty = 0;
double unQty = quantity;//未分配数量 double unQty = quantity;//未分配数量
double srs=0;
for (Inventory inv : invs) { for (Inventory inv : invs) {
Point startPoint = inv.getPoint();//原库位 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) { if (unQty <= 0) {
break; break;
} }
@ -203,16 +200,6 @@ public class PickDetailServiceImpl implements PickDetailService {
if (allocateQty <= 0) { if (allocateQty <= 0) {
continue; 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) { if (unQty < allocateQty) {
allocateQty = unQty; allocateQty = unQty;
} }
@ -222,38 +209,36 @@ public class PickDetailServiceImpl implements PickDetailService {
pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty); pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty);
pickDetailRepository.save(pd); pickDetailRepository.save(pd);
pickTicket.setAllocatedQuantity(pickTicket.getAllocatedQuantity() + allocateQty); pickTicket.setAllocatedQuantity(pickTicket.getAllocatedQuantity() + allocateQty);
if (pickTicket.getAllocatedQuantity()>0) { if (pickTicket.getAllocatedQuantity() > 0) {
pickTicket.setStatus(BizStatus.ALLOCATE); pickTicket.setStatus(BizStatus.ALLOCATE);
} }
//备货表上出单日期(审核写) //备货表上出单日期(审核写)
pickTicket.setOutOrderDate(new Timestamp(new Date().getTime())); pickTicket.setOutOrderDate(new Timestamp(new Date().getTime()));
pickTicketRepository.save(pickTicket); pickTicketRepository.save(pickTicket);
Task task = taskService.storeTask(null,pd,pickTicket.getArea(),inv.getItemKey(),startPoint,endPoint,allocateQty); taskService.storeTask(null, pd, pickTicket.getArea(), inv.getItemKey(), startPoint, endPoint, allocateQty);
} }
} }
} else {
throw new BadRequestException(HttpStatus.NOT_FOUND,"已分配,请勿重复操作!");
}
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public synchronized void cancelAllocate(long id){ public synchronized void cancelAllocate(long id) {
PickDetailDto pickDetailDto = findById(id); PickDetailDto pickDetailDto = findById(id);
PickDetail pd = toEntity(pickDetailDto); PickDetail pd = toEntity(pickDetailDto);
List<Task> Tasks = taskRepository.getPickNotAllTask(id); List<Task> Tasks = taskRepository.getPickNotAllTask(id);
for (Task task : Tasks) { for (Task task : Tasks) {
//根据Taskz找到对应的库存 //根据Taskz找到对应的库存
double quantity=task.getPlanQty(); double quantity = task.getPlanQty();
Inventory inv = inventoryRepository.findById(task.getInvId()).get(); Inventory inv = inventoryRepository.findById(task.getInvId()).get();
inv.setQueuedQty(inv.getQueuedQty() - quantity); inv.setQueuedQty(inv.getQueuedQty() - quantity);
inventoryRepository.save(inv); inventoryRepository.save(inv);
//删除Task //删除Task
taskRepository.delete(task); taskRepository.delete(task);
pd.setAllocatedQty(pd.getAllocatedQty() - quantity); pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
pd.setPureXqBz(pd.getPropC4()-pd.getAllocatedQty()); pd.setPureXqBz(pd.getPropC4() - pd.getAllocatedQty());
if (pd.getAllocatedQty() <= 0) { if (pd.getAllocatedQty() <= 0) {
pd.setAllocatedQty(0d); pd.setAllocatedQty(0d);
pd.setStatus(BizStatus.OPEN); pd.setStatus(BizStatus.OPEN);
@ -294,7 +279,7 @@ public class PickDetailServiceImpl implements PickDetailService {
} }
@Override @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(); PickDetail d = new PickDetail();
d.setItem(item); d.setItem(item);
d.setLineNo(1l); d.setLineNo(1l);
@ -315,37 +300,39 @@ public class PickDetailServiceImpl implements PickDetailService {
List<PickDetail> queryResultList = query.getResultList(); List<PickDetail> queryResultList = query.getResultList();
return queryResultList; return queryResultList;
} }
public List<PickDetailZscDto> queryZscAll(PickDetailQueryCriteria criteria) { public List<PickDetailZscDto> queryZscAll(PickDetailQueryCriteria criteria) {
Query query = getQuery(criteria); Query query = getQuery(criteria);
List ts= query List ts = query
.unwrap(SQLQuery.class) .unwrap(SQLQuery.class)
.setResultTransformer( .setResultTransformer(
AliasToEntityMapResultTransformer.INSTANCE AliasToEntityMapResultTransformer.INSTANCE
) )
.list(); .list();
List<PickDetailZscDto> list = JSON.parseArray(JSON.toJSONString(ts),PickDetailZscDto.class); List<PickDetailZscDto> list = JSON.parseArray(JSON.toJSONString(ts), PickDetailZscDto.class);
return list; return list;
} }
public Map<String,Object> queryPickDetailAll(PickDetailQueryCriteria criteria, Pageable pageable) { public Map<String, Object> queryPickDetailAll(PickDetailQueryCriteria criteria, Pageable pageable) {
int pageNum=pageable.getPageNumber();//当前页 int pageNum = pageable.getPageNumber();//当前页
int pageSize=pageable.getPageSize();//条数 int pageSize = pageable.getPageSize();//条数
Query query = getQuery(criteria); Query query = getQuery(criteria);
int pageCount=query.getResultList().size(); int pageCount = query.getResultList().size();
query.setFirstResult((pageNum)*pageSize); query.setFirstResult((pageNum) * pageSize);
query.setMaxResults((pageNum+1)*pageSize); query.setMaxResults((pageNum + 1) * pageSize);
List<PickDetailZscDto> queryResultList = query.unwrap(SQLQuery.class) List<PickDetailZscDto> queryResultList = query.unwrap(SQLQuery.class)
.setResultTransformer( .setResultTransformer(
AliasToEntityMapResultTransformer.INSTANCE AliasToEntityMapResultTransformer.INSTANCE
) )
.list(); .list();
Map<String,Object> map=new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("content",queryResultList); map.put("content", queryResultList);
map.put("totalElements",pageCount); map.put("totalElements", pageCount);
return map; 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" + 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.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" + "(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_area ck on ck.id=pd.area_id\n" +
"left join base_point zzkw on zzkw.id=pd.point_id )t \n" + "left join base_point zzkw on zzkw.id=pd.point_id )t \n" +
"where 1=1 and t.code like 'B%'"; "where 1=1 and t.code like 'B%'";
if(criteria!=null) { if (criteria != null) {
if (criteria.getCode()!=null &&!criteria.getCode().equals("") ) { if (criteria.getCode() != null && !criteria.getCode().equals("")) {
sql += " and t.code like '%" + criteria.getCode() + "%'"; 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() + "%'"; 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() + "%'"; 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() + "%'"; 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() + "%'"; 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() + "%'"; sql += " and t.ck_code like '%" + criteria.getCkAreaCode() + "%'";
} }
if (criteria.getPureXqBz()!=null &&!criteria.getPureXqBz().equals("") ) { if (criteria.getPureXqBz() != null && !criteria.getPureXqBz().equals("")) {
sql += " and t.pure_xq_bz>="+criteria.getPureXqBz(); sql += " and t.pure_xq_bz>=" + criteria.getPureXqBz();
} }
if (criteria.getStatus()!=null &&!criteria.getStatus().equals("") ) { if (criteria.getStatus() != null && !criteria.getStatus().equals("")) {
sql += " and t.status='"+criteria.getStatus()+"'"; sql += " and t.status='" + criteria.getStatus() + "'";
} }
if (criteria.getInvQty()!=null &&!criteria.getInvQty().equals("") ) { if (criteria.getInvQty() != null && !criteria.getInvQty().equals("")) {
sql += " and t.inv_qty>="+criteria.getInvQty(); sql += " and t.inv_qty>=" + criteria.getInvQty();
} }
if (criteria.getCreateTime()!=null) { if (criteria.getCreateTime() != null) {
sql += " and t.order_date BETWEEN '"+criteria.getCreateTime().get(0)+"' and '"+criteria.getCreateTime().get(1)+"'"; 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); Query query = entityManager.createNativeQuery(sql);
return query; return query;
} }
public List<Object[]> getQueryBcbl(Date blDate,Long ckAreaId,String gc){ public List<Object[]> getQueryBcbl(Date blDate, Long ckAreaId, String gc) {
String sql="select pd.id,ck.id ck_id," + 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" + "(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" + " FROM `data_pick_detail` pd \n" +
"left join data_pick_ticket pt on pt.id=pd.pick_ticket_id\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_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 rk on rk.id=pt.sh_area\n" +
"left join base_area ck on ck.id=pt.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; " 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.allocated_quantity>0 ";
//查找工位最后的上线计划修改日期 //查找工位最后的上线计划修改日期
// sql+=" and pt.order_date>=(CURDATE() - INTERVAL 1 DAY) "; // sql+=" and pt.order_date>=(CURDATE() - INTERVAL 1 DAY) ";
sql+=" and DATE_FORMAT(pt.order_date,'%Y-%m-%d')='"+DateUtil.dateYmd(blDate)+"'"; sql += " and DATE_FORMAT(pt.order_date,'%Y-%m-%d')='" + DateUtil.dateYmd(blDate) + "'";
Long user_id=SecurityUtils.getCurrentUserId(); Long user_id = SecurityUtils.getCurrentUserId();
List<Job> jobs=jobRepository.jobAreaCodes(user_id); List<Job> jobs = jobRepository.jobAreaCodes(user_id);
if(jobs.size()>0){ if (jobs.size() > 0) {
String areaCode= jobs.get(0).getAreaCode(); String areaCode = jobs.get(0).getAreaCode();
Area area=areaRepository.getByCode(areaCode); Area area = areaRepository.getByCode(areaCode);
sql+=" and ck.id="+ area.getId(); sql += " and ck.id=" + area.getId();
} }
// sql+=" and rk.id="+ automaticPlanning.getShArea().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"; " where 1=1 and t.inv_qty>0 order by t.id asc";
// log.info("query:"+split_sql); // log.info("query:"+split_sql);
Query query = entityManager.createNativeQuery(split_sql); Query query = entityManager.createNativeQuery(split_sql);
@ -429,15 +416,16 @@ public class PickDetailServiceImpl implements PickDetailService {
// .list(); // .list();
return queryResultList; 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); Query query = entityMapper.createQuery(hql);
Double result =(Double)query.getResultList().get(0); Double result = (Double) query.getResultList().get(0);
return result; return result;
} }
public List<PickDetail> getBomList(long picktickId,String largeClass) { public List<PickDetail> getBomList(long picktickId, String largeClass) {
String hql = " from PickDetail pd where pd.pickTicket.id=" + picktickId + " and pd.item.largeClass='"+largeClass+"'"; String hql = " from PickDetail pd where pd.pickTicket.id=" + picktickId + " and pd.item='" + largeClass + "'";
Query query = entityMapper.createQuery(hql); Query query = entityMapper.createQuery(hql);
List<PickDetail> queryResultList = query.getResultList(); List<PickDetail> queryResultList = query.getResultList();
return queryResultList; return queryResultList;

View File

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