优化消息通知
parent
dd7594d758
commit
d164425bc2
|
|
@ -1,21 +1,22 @@
|
|||
/*
|
||||
* 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.basicdata.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.domain.Stock;
|
||||
|
|
@ -37,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;
|
||||
|
|
@ -47,11 +49,11 @@ import java.util.ArrayList;
|
|||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author liuxue
|
||||
* @date 2023-07-28
|
||||
**/
|
||||
* @author liuxue
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @date 2023-07-28
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
|
|
@ -62,38 +64,38 @@ public class StockServiceImpl implements StockService {
|
|||
private final EntityManager entityMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(StockQueryCriteria criteria, Pageable pageable){
|
||||
Page<Stock> page = stockRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
public Map<String, Object> queryAll(StockQueryCriteria criteria, Pageable pageable) {
|
||||
Page<Stock> page = stockRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
return PageUtil.toPage(page.map(stockMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StockDto> queryAll(StockQueryCriteria criteria){
|
||||
return stockMapper.toDto(stockRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
public List<StockDto> queryAll(StockQueryCriteria criteria) {
|
||||
return stockMapper.toDto(stockRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StockSmallDto> queryKyStockList(String code){
|
||||
List<Map<String,String>> maps=stockRepository.getKyStockList(code);
|
||||
public List<StockSmallDto> queryKyStockList(String code) {
|
||||
List<Map<String, String>> maps = stockRepository.getKyStockList(code);
|
||||
String irsStr = JSON.toJSONString(maps);
|
||||
log.info(irsStr);
|
||||
List<StockSmallDto> evaUserResps = JSON.parseArray(irsStr,StockSmallDto.class);
|
||||
return evaUserResps;
|
||||
List<StockSmallDto> evaUserResps = JSON.parseArray(irsStr, StockSmallDto.class);
|
||||
return evaUserResps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StockSmallDto> queryStockList2(String code){
|
||||
List<Object[]> objs=stockRepository.getStockList2(code);
|
||||
List<StockSmallDto> list= EntityUtils.castEntity(objs, StockSmallDto.class, new StockSmallDto());
|
||||
log.info("fangfa2 "+list.toString());
|
||||
return list;
|
||||
public List<StockSmallDto> queryStockList2(String code) {
|
||||
List<Object[]> objs = stockRepository.getStockList2(code);
|
||||
List<StockSmallDto> list = EntityUtils.castEntity(objs, StockSmallDto.class, new StockSmallDto());
|
||||
log.info("fangfa2 " + list.toString());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public StockDto findById(Long id) {
|
||||
Stock stock = stockRepository.findById(id).orElseGet(Stock::new);
|
||||
ValidationUtil.isNull(stock.getId(),"Stock","id",id);
|
||||
ValidationUtil.isNull(stock.getId(), "Stock", "id", id);
|
||||
return stockMapper.toDto(stock);
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +109,7 @@ public class StockServiceImpl implements StockService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Stock resources) {
|
||||
Stock stock = stockRepository.findById(resources.getId()).orElseGet(Stock::new);
|
||||
ValidationUtil.isNull( stock.getId(),"Stock","id",resources.getId());
|
||||
ValidationUtil.isNull(stock.getId(), "Stock", "id", resources.getId());
|
||||
stock.copy(resources);
|
||||
stockRepository.save(stock);
|
||||
}
|
||||
|
|
@ -123,7 +125,7 @@ public class StockServiceImpl implements StockService {
|
|||
public void download(List<StockDto> all, HttpServletResponse response) throws Exception {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (StockDto stock : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("容器代码", stock.getCode());
|
||||
map.put("上级容器ID", stock.getPid());
|
||||
map.put("仓库ID", stock.getDept().getName());
|
||||
|
|
@ -146,89 +148,93 @@ public class StockServiceImpl implements StockService {
|
|||
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stock toEntity(StockDto stockDto) {
|
||||
return stockMapper.toEntity(stockDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stock findByCode(String code, String status){
|
||||
String hql="select t from Stock t where t.code='"+code+"'";
|
||||
if(status!=null && status.length()>0){
|
||||
hql+=" and t.status='"+status+"'";
|
||||
public Stock findByCode(String code, String status) {
|
||||
String hql = "select t from Stock t where t.code='" + code + "'";
|
||||
if (status != null && status.length() > 0) {
|
||||
hql += " and t.status='" + status + "'";
|
||||
}
|
||||
Query query=entityMapper.createQuery(hql);
|
||||
List<Stock> ts=query.getResultList();
|
||||
if(ts.size()>0){
|
||||
Query query = entityMapper.createQuery(hql);
|
||||
List<Stock> ts = query.getResultList();
|
||||
if (ts.size() > 0) {
|
||||
return ts.get(0);
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stock findByPointCode(String code) {
|
||||
String hql=" from Stock t where t.point.code='"+code+"'";
|
||||
Query query=entityMapper.createQuery(hql);
|
||||
List<Stock> stockList=query.getResultList();
|
||||
if(stockList.size()>0){
|
||||
String hql = " from Stock t where t.point.code='" + code + "'";
|
||||
Query query = entityMapper.createQuery(hql);
|
||||
List<Stock> stockList = query.getResultList();
|
||||
if (stockList.size() > 0) {
|
||||
return stockList.get(0);
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stock findByKStock(String areaName) {
|
||||
String hql=" from Stock t where t.point.id>0 and t.point.status='USED' and t.status='FREE' and t.point.type='STORAGE' ";
|
||||
if(areaName.equals(AreaNameDic.QTYK) ||areaName.equals(AreaNameDic.HTYK)){
|
||||
hql+=" and t.point.area.name in ('前后桶空车区','前后桶部装空车缓存区')";
|
||||
}else{
|
||||
hql+=" and t.point.area.name ='"+areaName+"'";
|
||||
String hql = " from Stock t where t.point.id>0 and t.point.status='USED' and t.status='FREE' and t.point.type='STORAGE' ";
|
||||
if (areaName.equals(AreaNameDic.QTYK) || areaName.equals(AreaNameDic.HTYK)) {
|
||||
hql += " and t.point.area.name in ('前后桶空车区','前后桶部装空车缓存区')";
|
||||
} else {
|
||||
hql += " and t.point.area.name ='" + areaName + "'";
|
||||
}
|
||||
Query query=entityMapper.createQuery(hql);
|
||||
List<Stock> stockList=query.getResultList();
|
||||
if(stockList.size()>0){
|
||||
Query query = entityMapper.createQuery(hql);
|
||||
List<Stock> stockList = query.getResultList();
|
||||
if (stockList.size() > 0) {
|
||||
return stockList.get(0);
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Stock findStockByPoint(String areaName) {
|
||||
String hql=" from Stock t where t.point.id>0 and t.point.status='USED' and t.status='FREE' and t.point.type='STORAGE' ";
|
||||
if(areaName!=null){
|
||||
hql+=" and t.point.area.name ='"+areaName+"'";
|
||||
String hql = " from Stock t where t.point.id>0 and t.point.status='USED' and t.status='FREE' and t.point.type='STORAGE' ";
|
||||
if (areaName != null) {
|
||||
hql += " and t.point.area.name ='" + areaName + "'";
|
||||
}
|
||||
Query query=entityMapper.createQuery(hql);
|
||||
List<Stock> stockList=query.getResultList();
|
||||
if(stockList.size()>0){
|
||||
Query query = entityMapper.createQuery(hql);
|
||||
List<Stock> stockList = query.getResultList();
|
||||
if (stockList.size() > 0) {
|
||||
return stockList.get(0);
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Stock> findByKStockList(String areaName) {
|
||||
String hql=" from Stock t where t.point.id>0 and t.point.status='USED' and t.status='FREE' and t.point.type='STORAGE' ";
|
||||
if(areaName!=null){
|
||||
hql+=" and t.point.area.name ='"+areaName+"'";
|
||||
String hql = " from Stock t where t.point.id>0 and t.point.status='USED' and t.status='FREE' and t.point.type='STORAGE' ";
|
||||
if (areaName != null) {
|
||||
hql += " and t.point.area.name ='" + areaName + "'";
|
||||
}
|
||||
Query query=entityMapper.createQuery(hql);
|
||||
List<Stock> stockList=query.getResultList();
|
||||
if(stockList.size()>0){
|
||||
Query query = entityMapper.createQuery(hql);
|
||||
List<Stock> stockList = query.getResultList();
|
||||
if (stockList.size() > 0) {
|
||||
return stockList;
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stockMsg() {
|
||||
try {
|
||||
String msg="\n" +
|
||||
"上海友仓信息技术有限公司,作为一家国家级高新技术企业,致力于软件和信息技术服务的前沿探索与创新实践。自成立以来,友仓信息凭借卓越的技术实力和服务品质,在行业内树立了良好的口碑,成为众多知名企业信赖的合作伙伴。";
|
||||
String msg = "上海友仓信息技术有限公司,作为一家国家级高新技术企业,致力于软件和信息技术服务的前沿探索与创新实践。自成立以来,友仓信息凭借卓越的技术实力和服务品质,在行业内树立了良好的口碑,成为众多知名企业信赖的合作伙伴。";
|
||||
String message = JSONObject.toJSONString(new SocketMsg(msg, MsgType.INFO));
|
||||
WebSocketServer.sendInfo(new SocketMsg(msg, MsgType.INFO), "stock");
|
||||
return message;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "ok";
|
||||
return "error";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue