|
@@ -12,6 +12,7 @@ import com.platform.dao.dto.longyanpurchaseorder.LongYanPurchaseDetailDTO;
|
|
import com.platform.dao.dto.longyanpurchaseorder.LongYanPurchaseOrderDTO;
|
|
import com.platform.dao.dto.longyanpurchaseorder.LongYanPurchaseOrderDTO;
|
|
import com.platform.dao.dto.sb.SbInfoDTO;
|
|
import com.platform.dao.dto.sb.SbInfoDTO;
|
|
import com.platform.dao.dto.sb.SbModelSpareBomDTO;
|
|
import com.platform.dao.dto.sb.SbModelSpareBomDTO;
|
|
|
|
+import com.platform.dao.dto.sb.SpareVO;
|
|
import com.platform.dao.dto.spareAdd.Inventory;
|
|
import com.platform.dao.dto.spareAdd.Inventory;
|
|
import com.platform.dao.dto.spareAdd.InventoryTest;
|
|
import com.platform.dao.dto.spareAdd.InventoryTest;
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
|
|
@@ -59,6 +60,7 @@ import java.math.BigDecimal;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -364,6 +366,7 @@ public class YongyouServiceImpl implements YongyouService {
|
|
myVOPage.setRows(partInfoVOS);
|
|
myVOPage.setRows(partInfoVOS);
|
|
return myVOPage;
|
|
return myVOPage;
|
|
}
|
|
}
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public AbstractPageResultBean<SpareStoreVO> selectPageList2(SpareStoreDTO record, int pageNum, int pageSize) {
|
|
public AbstractPageResultBean<SpareStoreVO> selectPageList2(SpareStoreDTO record, int pageNum, int pageSize) {
|
|
List<String> spareIds = null;
|
|
List<String> spareIds = null;
|
|
@@ -421,10 +424,10 @@ public class YongyouServiceImpl implements YongyouService {
|
|
req.setPageNum(pageNum);
|
|
req.setPageNum(pageNum);
|
|
req.setPageSize(pageSize);
|
|
req.setPageSize(pageSize);
|
|
StringBuffer whereStr = new StringBuffer(" 1=1 ");
|
|
StringBuffer whereStr = new StringBuffer(" 1=1 ");
|
|
- // 仓库编码搜索
|
|
|
|
- if (StringUtils.isNotBlank(record.getStoreNo())) {
|
|
|
|
- whereStr.append(" and cWhCode like '%" + record.getStoreNo() + "%' ");
|
|
|
|
- }
|
|
|
|
|
|
+ // 仓库编码搜索
|
|
|
|
+ if (StringUtils.isNotBlank(record.getStoreNo())) {
|
|
|
|
+ whereStr.append(" and cWhCode like '%" + record.getStoreNo() + "%' ");
|
|
|
|
+ }
|
|
// 仓库名称搜索
|
|
// 仓库名称搜索
|
|
if (StringUtils.isNotBlank(record.getStoreName())) {
|
|
if (StringUtils.isNotBlank(record.getStoreName())) {
|
|
whereStr.append(" and cWhName like '%" + record.getStoreName() + "%' ");
|
|
whereStr.append(" and cWhName like '%" + record.getStoreName() + "%' ");
|
|
@@ -493,6 +496,164 @@ public class YongyouServiceImpl implements YongyouService {
|
|
return myVOPage;
|
|
return myVOPage;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<SpareStoreVO> selectPageList3(SpareStoreDTO record) {
|
|
|
|
+
|
|
|
|
+ List<SpareVO> spareVOS = record.getSpareVOS();
|
|
|
|
+ Map<Integer, List<SpareVO>> map = new HashMap<>();
|
|
|
|
+ if (spareVOS != null && spareVOS.size() > 0) {
|
|
|
|
+ List<SpareVO> unknow = new ArrayList<>();
|
|
|
|
+ List<SpareVO> newF = new ArrayList<>();
|
|
|
|
+ List<SpareVO> oldF = new ArrayList<>();
|
|
|
|
+ for (SpareVO spareVO : spareVOS) {
|
|
|
|
+ if (spareVO.getOldOrNew() == 0) {
|
|
|
|
+ unknow.add(spareVO);
|
|
|
|
+ } else if (spareVO.getOldOrNew() == 1) {
|
|
|
|
+ newF.add(spareVO);
|
|
|
|
+ } else {
|
|
|
|
+ oldF.add(spareVO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (unknow.size() > 0) {
|
|
|
|
+ map.put(0, unknow);
|
|
|
|
+ }
|
|
|
|
+ if (newF.size() > 0) {
|
|
|
|
+ map.put(1, newF);
|
|
|
|
+ }
|
|
|
|
+ if (oldF.size() > 0) {
|
|
|
|
+ map.put(2, oldF);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean isDev = BeanUtils.isDev();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String sqlStr = "";
|
|
|
|
+ List<SpareStoreVO> returnList = new ArrayList<>();
|
|
|
|
+ for (Map.Entry<Integer, List<SpareVO>> entry : map.entrySet()) {
|
|
|
|
+ GetCurrentStockHandler handler = new GetCurrentStockHandler();
|
|
|
|
+ GetCurrentStockRequest req = new GetCurrentStockRequest();
|
|
|
|
+ StringBuffer whereStr = new StringBuffer(" 1=1 ");
|
|
|
|
+
|
|
|
|
+ if (entry.getValue().size() > 0) {
|
|
|
|
+ if (!isDev) {
|
|
|
|
+ whereStr.append(" and cInvCode in (");
|
|
|
|
+ if (entry.getKey() == 1) {
|
|
|
|
+ req.setCAcc_ID("005");
|
|
|
|
+ req.setToken(geToken(1));
|
|
|
|
+ req.setConn(getConn2(1));
|
|
|
|
+ for (SpareVO spareVO : newF) {
|
|
|
|
+ whereStr.append(spareVO.getCInvCode() + ",");
|
|
|
|
+ }
|
|
|
|
+ sqlStr = whereStr.toString().substring(0, whereStr.toString().length() - 1) + ")";
|
|
|
|
+ if (!sqlStr.equals("")) {
|
|
|
|
+ req.setStrWhere(sqlStr);
|
|
|
|
+ } else {
|
|
|
|
+ req.setStrWhere(whereStr.toString());
|
|
|
|
+ }
|
|
|
|
+ returnList.addAll(getList(handler, req));
|
|
|
|
+
|
|
|
|
+ } else if (entry.getKey() == 2) {
|
|
|
|
+ req.setCAcc_ID("004");
|
|
|
|
+ req.setToken(geToken(2));
|
|
|
|
+ req.setConn(getConn2(2));
|
|
|
|
+ for (SpareVO spareVO : newF) {
|
|
|
|
+ whereStr.append(spareVO.getCInvCode() + ",");
|
|
|
|
+ }
|
|
|
|
+ sqlStr = whereStr.toString().substring(0, whereStr.toString().length() - 1) + ")";
|
|
|
|
+ if (!sqlStr.equals("")) {
|
|
|
|
+ req.setStrWhere(sqlStr);
|
|
|
|
+ } else {
|
|
|
|
+ req.setStrWhere(whereStr.toString());
|
|
|
|
+ }
|
|
|
|
+ returnList.addAll(getList(handler, req));
|
|
|
|
+ }else if (entry.getKey()==0){
|
|
|
|
+ req.setCAcc_ID("004");
|
|
|
|
+ req.setToken(geToken(2));
|
|
|
|
+ req.setConn(getConn2(2));
|
|
|
|
+ for (SpareVO spareVO : unknow) {
|
|
|
|
+ whereStr.append(spareVO.getCInvCode() + ",");
|
|
|
|
+ }
|
|
|
|
+ sqlStr = whereStr.toString().substring(0, whereStr.toString().length() - 1) + ")";
|
|
|
|
+ if (!sqlStr.equals("")) {
|
|
|
|
+ req.setStrWhere(sqlStr);
|
|
|
|
+ } else {
|
|
|
|
+ req.setStrWhere(whereStr.toString());
|
|
|
|
+ }
|
|
|
|
+ List<SpareStoreVO> oldSpareStoreVOS = getList(handler,req);
|
|
|
|
+ List<String> spareNos = oldSpareStoreVOS.stream().map(SpareStoreVO::getNo).collect(Collectors.toList());
|
|
|
|
+ sbModelSpareBomMapper.updateBatch2(spareNos,2,record.getSbId());
|
|
|
|
+ returnList.addAll(oldSpareStoreVOS);
|
|
|
|
+
|
|
|
|
+ req.setCAcc_ID("005");
|
|
|
|
+ req.setToken(geToken(1));
|
|
|
|
+ req.setConn(getConn2(1));
|
|
|
|
+ for (SpareVO spareVO : unknow) {
|
|
|
|
+ whereStr.append(spareVO.getCInvCode() + ",");
|
|
|
|
+ }
|
|
|
|
+ sqlStr = whereStr.toString().substring(0, whereStr.toString().length() - 1) + ")";
|
|
|
|
+ if (!sqlStr.equals("")) {
|
|
|
|
+ req.setStrWhere(sqlStr);
|
|
|
|
+ } else {
|
|
|
|
+ req.setStrWhere(whereStr.toString());
|
|
|
|
+ }
|
|
|
|
+ List<SpareStoreVO> oldSpareStoreVOS2 = getList(handler,req);
|
|
|
|
+ List<String> spareNos2 = oldSpareStoreVOS.stream().map(SpareStoreVO::getNo).collect(Collectors.toList());
|
|
|
|
+ sbModelSpareBomMapper.updateBatch2(spareNos2,2,record.getSbId());
|
|
|
|
+ returnList.addAll(oldSpareStoreVOS2);
|
|
|
|
+ }
|
|
|
|
+ return returnList;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ req.setCAcc_ID("993");
|
|
|
|
+ req.setToken(geToken(1));
|
|
|
|
+ req.setConn(getConn2(1));
|
|
|
|
+ for (SpareVO spareVO : newF) {
|
|
|
|
+ whereStr.append(spareVO.getCInvCode() + ",");
|
|
|
|
+ }
|
|
|
|
+ sqlStr = whereStr.toString().substring(0, whereStr.toString().length() - 1) + ")";
|
|
|
|
+ if (!sqlStr.equals("")) {
|
|
|
|
+ req.setStrWhere(sqlStr);
|
|
|
|
+ } else {
|
|
|
|
+ req.setStrWhere(whereStr.toString());
|
|
|
|
+ }
|
|
|
|
+ returnList.addAll(getList(handler, req));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private List<SpareStoreVO> getList(GetCurrentStockHandler handler, GetCurrentStockRequest req) {
|
|
|
|
+ handler.setRequest(req);
|
|
|
|
+ String responseStr = handler.handler();
|
|
|
|
+ GetCurrentStockResponse response = JSONObject.parseObject(responseStr, GetCurrentStockResponse.class);
|
|
|
|
+ if (!response.getResult()) {
|
|
|
|
+ throw new BusinessException(response.getMsg());
|
|
|
|
+ }
|
|
|
|
+ GetCurrentStockResponseData data = response.getData();
|
|
|
|
+ List<GetCurrentStock> stocks = data.getStock();
|
|
|
|
+ List<SpareStoreVO> partInfoVOS = new ArrayList<>();
|
|
|
|
+ for (GetCurrentStock stockResponse : stocks) {
|
|
|
|
+ SpareStoreVO partInfoVO = new SpareStoreVO();
|
|
|
|
+ partInfoVO.setId(stockResponse.getAutoId() + "");
|
|
|
|
+ partInfoVO.setNo(stockResponse.getCInvCode());
|
|
|
|
+ partInfoVO.setSpareId(stockResponse.getPartId() + "");
|
|
|
|
+ partInfoVO.setSpareName(stockResponse.getCInvName());
|
|
|
|
+ partInfoVO.setGgxh(stockResponse.getCInvStd());
|
|
|
|
+ partInfoVO.setNum(stockResponse.getIQuantity());
|
|
|
|
+ partInfoVO.setStoreName(stockResponse.getCWhName());
|
|
|
|
+ partInfoVO.setStoreId(stockResponse.getCWhCode());
|
|
|
|
+ partInfoVO.setUnit(stockResponse.getCComUnitName());
|
|
|
|
+ partInfoVO.setCBatch(stockResponse.getCBatch());
|
|
|
|
+ partInfoVO.setAutoId(stockResponse.getAutoId());
|
|
|
|
+ partInfoVO.setStorePosition(stockResponse.getCInvDefine1());
|
|
|
|
+ partInfoVOS.add(partInfoVO);
|
|
|
|
+ }
|
|
|
|
+ return partInfoVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
private void addBom(LongYanPurchaseOrderVO model, List<LongYanPurchaseDetailVO> detailVOS) {
|
|
private void addBom(LongYanPurchaseOrderVO model, List<LongYanPurchaseDetailVO> detailVOS) {
|
|
List<String> sbIds = new ArrayList<>();
|
|
List<String> sbIds = new ArrayList<>();
|
|
SbInfo sbInfo = sbInfoMapper.selectByPrimaryKey(model.getSbId());
|
|
SbInfo sbInfo = sbInfoMapper.selectByPrimaryKey(model.getSbId());
|