|
@@ -8,6 +8,7 @@ import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.platform.common.enums.DataFilterTypeEnum;
|
|
|
+import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
import com.platform.common.util.*;
|
|
|
import com.platform.common.yongyou.request.*;
|
|
@@ -19,6 +20,7 @@ import com.platform.dao.dto.store.SparePickDetailDTO;
|
|
|
import com.platform.dao.dto.store.SparePickFormDTO;
|
|
|
import com.platform.dao.dto.store.SpareRestoreFormDTO;
|
|
|
import com.platform.dao.dto.store.SpareStoreDTO;
|
|
|
+import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
|
import com.platform.dao.entity.store.*;
|
|
|
import com.platform.dao.enums.SparePickFormStatusEnum;
|
|
|
import com.platform.dao.mapper.sqarepartmanage.SparePartInfoMapper;
|
|
@@ -30,6 +32,7 @@ import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
import com.platform.service.store.*;
|
|
|
import com.platform.service.yongyou.YongyouService;
|
|
|
import handler.yongyou.GetCurrentStockHandler;
|
|
|
+import handler.yongyou.GetInventoryListHandler;
|
|
|
import handler.yongyou.LoginHandler;
|
|
|
import handler.yongyou.OtherOutHandler;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -39,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -56,10 +60,10 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@Service("yongyouService")
|
|
|
public class YongyouServiceImpl implements YongyouService {
|
|
|
- private SparePickFormService sparePickFormService;
|
|
|
- private SparePickDetailService sparePickDetailService;
|
|
|
- private SpareRestoreFormService spareRestoreFormService;
|
|
|
- private SpareRestoreDetailService spareRestoreDetailService;
|
|
|
+ @Resource
|
|
|
+ private OutStoreFormService outStoreFormService;
|
|
|
+ @Resource
|
|
|
+ private OutStoreDetailService outStoreDetailService;
|
|
|
private String token_key = "yongyou-token";
|
|
|
private String Conn_key = "yongyou-Conn";
|
|
|
private String cAcc_ID_key = "yongyou-cAcc_ID";
|
|
@@ -89,6 +93,9 @@ public class YongyouServiceImpl implements YongyouService {
|
|
|
handler.setRequest(req);
|
|
|
String responseStr = handler.handler();
|
|
|
LoginResponse response = JSONObject.parseObject(responseStr, LoginResponse.class);
|
|
|
+ if(!response.getResult()){
|
|
|
+ throw new BusinessException(response.getMsg());
|
|
|
+ }
|
|
|
Login login = response.getData();
|
|
|
String token = login.getToken();
|
|
|
RedisUtils.setString(token_key, token, 1800);
|
|
@@ -126,6 +133,9 @@ public class YongyouServiceImpl implements YongyouService {
|
|
|
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<>();
|
|
@@ -149,7 +159,6 @@ public class YongyouServiceImpl implements YongyouService {
|
|
|
myVOPage.setPageNum(pageNum);
|
|
|
myVOPage.setPageSize(pageSize);
|
|
|
Page page = new Page(pageNum, pageSize);
|
|
|
- page.setTotal(322);
|
|
|
page.setTotal(data.getTotal());
|
|
|
myVOPage.setPages(data.getPages().intValue());
|
|
|
myVOPage.setTotal(page.getTotal());
|
|
@@ -158,122 +167,94 @@ public class YongyouServiceImpl implements YongyouService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 提交领用单到出库单
|
|
|
+ * 查询存量分页
|
|
|
*
|
|
|
- * @param id 领用单id
|
|
|
+ * @param record
|
|
|
+ * @param pageNum
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public void addOutForm(String id) {
|
|
|
- SparePickFormVO sparePickFormVO = sparePickFormService.getDetail(id);
|
|
|
- OtherOutVouch otherOutVouch = new OtherOutVouch();
|
|
|
- OtherOutMain otherOutMain = new OtherOutMain();
|
|
|
- List<OtherOutDetail> otherOutDetail = new ArrayList<>();
|
|
|
- otherOutVouch.setOtherOutMain(otherOutMain);
|
|
|
- otherOutVouch.setOtherOutDetail(otherOutDetail);
|
|
|
- otherOutMain.setBrdflag(0);
|
|
|
- otherOutMain.setCvouchtype("0");
|
|
|
- otherOutMain.setCbustype("其他出库");
|
|
|
- otherOutMain.setCwhcode("034");
|
|
|
- otherOutMain.setDdate(DateUtils.dateToString(LocalDateTime.now()));
|
|
|
- otherOutMain.setVt_id("85");
|
|
|
- otherOutMain.setBisstqc(false);
|
|
|
- otherOutMain.setCcode("0000000006");
|
|
|
- otherOutMain.setCrdcode("2a");
|
|
|
- otherOutMain.setCsource("库存");
|
|
|
-
|
|
|
- otherOutMain.setCdefine1(sparePickFormVO.getId());// 保存设备系统的id
|
|
|
- otherOutMain.setCmaker(sparePickFormVO.getCreatedUserName());// 申请人名称
|
|
|
- List<SparePickDetailVO> detailVOS = sparePickFormVO.getDetailList();
|
|
|
- for (SparePickDetailVO vo : detailVOS) {
|
|
|
- OtherOutDetail detail = new OtherOutDetail();
|
|
|
- detail.setId(vo.getSpareId());
|
|
|
- detail.setCinvcode(vo.getNo());
|
|
|
- detail.setIquantity(vo.getNum());
|
|
|
- detail.setIunitcost(vo.getPrice());
|
|
|
- detail.setIprice(vo.getTotalPrice());
|
|
|
- otherOutDetail.add(detail);
|
|
|
- }
|
|
|
-
|
|
|
- // 推送数据
|
|
|
- OtherOutHandler handler = new OtherOutHandler();
|
|
|
- OtherOutAddRequest req = new OtherOutAddRequest();
|
|
|
- req.setOtherOutVouch(otherOutVouch);
|
|
|
+ public AbstractPageResultBean<SparePartInfoVO> selectPageList(SparePartInfoDTO record, int pageNum, int pageSize) {
|
|
|
+ // 已生成情况,直接推送
|
|
|
+ GetInventoryListHandler handler = new GetInventoryListHandler();
|
|
|
+ GetInventoryListRequest req = new GetInventoryListRequest();
|
|
|
req.setToken(geToken());
|
|
|
req.setConn(getConn());
|
|
|
req.setCAcc_ID(getCAccId());
|
|
|
+ req.setPageNum(pageNum);
|
|
|
+ req.setPageSize(pageSize);
|
|
|
+ req.setCcode("1=1");
|
|
|
handler.setRequest(req);
|
|
|
String responseStr = handler.handler();
|
|
|
- OtherOutAddResponse response = JSONObject.parseObject(responseStr, OtherOutAddResponse.class);
|
|
|
- String data = response.getData();
|
|
|
-
|
|
|
- // 保存用友出库单数据
|
|
|
- sparePickFormService.updateModelByIdYongyou(sparePickFormVO.getId(), data);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 领用单用友回调,回写实际数量和状态
|
|
|
- *
|
|
|
- * @param jsonStr
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void backOutForm(String jsonStr) {
|
|
|
- JSONObject jsonObject = JSON.parseObject(jsonStr);
|
|
|
- String id = (String) jsonObject.get("id");
|
|
|
- String status = (String) jsonObject.get("status");
|
|
|
- String time = (String) jsonObject.get("time");
|
|
|
- JSONArray detailList = (JSONArray) jsonObject.get("detailList");
|
|
|
-
|
|
|
- for (Iterator<Object> iterator = detailList.iterator(); iterator.hasNext(); ) {
|
|
|
- JSONObject next = (JSONObject) iterator.next();
|
|
|
- String spareId = next.getString("spareId");
|
|
|
- String spareNum = next.getString("spareNum");
|
|
|
- String detailId = next.getString("detailId");
|
|
|
- String spareGGXH = next.getString("spareGGXH");
|
|
|
- SparePickDetail sparePickDetail = new SparePickDetail();
|
|
|
- sparePickDetail.setId(detailId);
|
|
|
- sparePickDetail.setNum(new BigDecimal(spareNum));
|
|
|
- sparePickDetail.setSpareGgxh(spareGGXH);
|
|
|
- sparePickDetailService.modModelByPrimaryKey(sparePickDetail);
|
|
|
+ GetInventoryListResponse response = JSONObject.parseObject(responseStr, GetInventoryListResponse.class);
|
|
|
+ if(!response.getResult()){
|
|
|
+ throw new BusinessException(response.getMsg());
|
|
|
+ }
|
|
|
+ GetInventoryListResponseData data = response.getData();
|
|
|
+ List<GetInventoryList> stocks = data.getInventory();
|
|
|
+ List<SparePartInfoVO> partInfoVOS = new ArrayList<>();
|
|
|
+ for (GetInventoryList inventory : stocks) {
|
|
|
+ SparePartInfoVO partInfoVO = new SparePartInfoVO();
|
|
|
+ partInfoVO.setId(inventory.getCInvCode() + "");
|
|
|
+ partInfoVO.setNo(inventory.getCInvAddCode());
|
|
|
+ partInfoVO.setName(inventory.getCInvName());
|
|
|
+ partInfoVO.setGgxh(inventory.getCInvStd());
|
|
|
+ partInfoVO.setUnit(inventory.getCProductUnit());
|
|
|
+ partInfoVOS.add(partInfoVO);
|
|
|
}
|
|
|
- SparePickForm sparePickForm = new SparePickForm();
|
|
|
- sparePickForm.setStatus(2);
|
|
|
- sparePickForm.setId(id);
|
|
|
- sparePickFormService.modModelByPrimaryKey(sparePickForm);
|
|
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ MyVOPage<SparePartInfoVO> myVOPage = new MyVOPage<>();
|
|
|
+ myVOPage.setPageNum(pageNum);
|
|
|
+ myVOPage.setPageSize(pageSize);
|
|
|
+ Page page = new Page(pageNum, pageSize);
|
|
|
+ page.setTotal(data.getTotal());
|
|
|
+ myVOPage.setPages(data.getPages().intValue());
|
|
|
+ myVOPage.setTotal(page.getTotal());
|
|
|
+ myVOPage.setRows(partInfoVOS);
|
|
|
+ return myVOPage;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 提交退库单到出库单
|
|
|
+ * 提交出库单到用友
|
|
|
*
|
|
|
* @param id 领用单id
|
|
|
*/
|
|
|
@Override
|
|
|
- public void addRestoreForm(String id) {
|
|
|
- SpareRestoreFormVO sparePickFormVO = spareRestoreFormService.getDetail(id);
|
|
|
+ public void addOutForm(String id) {
|
|
|
+ OutStoreFormVO outStoreFormVO = outStoreFormService.getDetail(id);
|
|
|
OtherOutVouch otherOutVouch = new OtherOutVouch();
|
|
|
OtherOutMain otherOutMain = new OtherOutMain();
|
|
|
List<OtherOutDetail> otherOutDetail = new ArrayList<>();
|
|
|
otherOutVouch.setOtherOutMain(otherOutMain);
|
|
|
otherOutVouch.setOtherOutDetail(otherOutDetail);
|
|
|
otherOutMain.setBrdflag(0);
|
|
|
- otherOutMain.setCvouchtype("0");
|
|
|
+ otherOutMain.setCvouchtype("09");
|
|
|
otherOutMain.setCbustype("其他出库");
|
|
|
- otherOutMain.setCwhcode("034");
|
|
|
+ otherOutMain.setCwhcode(outStoreFormVO.getStoreId());
|
|
|
otherOutMain.setDdate(DateUtils.dateToString(LocalDateTime.now()));
|
|
|
otherOutMain.setVt_id("85");
|
|
|
otherOutMain.setBisstqc(false);
|
|
|
otherOutMain.setCcode("0000000006");
|
|
|
- otherOutMain.setCrdcode("2a");
|
|
|
+ otherOutMain.setCrdcode("202"); // 材料出库
|
|
|
otherOutMain.setCsource("库存");
|
|
|
|
|
|
- otherOutMain.setCdefine1(sparePickFormVO.getId());// 保存设备系统的id
|
|
|
- otherOutMain.setCmaker(sparePickFormVO.getCreatedUserName());// 申请人名称
|
|
|
- List<SpareRestoreDetailVO> detailVOS = sparePickFormVO.getDetailList();
|
|
|
- for (SpareRestoreDetailVO vo : detailVOS) {
|
|
|
+ otherOutMain.setCdefine1(outStoreFormVO.getId());// 保存设备系统的id
|
|
|
+ otherOutMain.setCmaker(outStoreFormVO.getCreatedUserName());// 申请人名称
|
|
|
+ List<OutStoreDetailVO> detailVOS = outStoreFormVO.getDetailList();
|
|
|
+ for (OutStoreDetailVO vo : detailVOS) {
|
|
|
OtherOutDetail detail = new OtherOutDetail();
|
|
|
detail.setId(vo.getSpareId());
|
|
|
- detail.setIquantity(vo.getNum().negate() );// 取负数
|
|
|
+ detail.setCinvcode(vo.getNo());
|
|
|
+ if(vo.getIsOut()){
|
|
|
+ detail.setIquantity(vo.getNum());
|
|
|
+ }else{// 负数为退库
|
|
|
+ detail.setIquantity(vo.getNum().negate());
|
|
|
+ }
|
|
|
+ detail.setIunitcost(vo.getPrice());
|
|
|
+ detail.setIprice(vo.getTotalPrice());
|
|
|
+ detail.setCbatch(vo.getCBatch());
|
|
|
otherOutDetail.add(detail);
|
|
|
}
|
|
|
|
|
@@ -284,22 +265,27 @@ public class YongyouServiceImpl implements YongyouService {
|
|
|
req.setToken(geToken());
|
|
|
req.setConn(getConn());
|
|
|
req.setCAcc_ID(getCAccId());
|
|
|
+ req.setTradeID("");
|
|
|
handler.setRequest(req);
|
|
|
String responseStr = handler.handler();
|
|
|
OtherOutAddResponse response = JSONObject.parseObject(responseStr, OtherOutAddResponse.class);
|
|
|
+ if(!response.getResult()){
|
|
|
+ throw new BusinessException(response.getMsg());
|
|
|
+ }
|
|
|
String data = response.getData();
|
|
|
|
|
|
// 保存用友出库单数据
|
|
|
- spareRestoreFormService.updateModelByIdYongyou(sparePickFormVO.getId(), data);
|
|
|
+ outStoreFormService.updateModelByIdYongyou(outStoreFormVO.getId(), data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 退库单用友回调
|
|
|
+ * 领用单用友回调,回写实际数量和状态
|
|
|
*
|
|
|
* @param jsonStr
|
|
|
*/
|
|
|
@Override
|
|
|
- public void backRestoreForm(String jsonStr) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void backOutForm(String jsonStr) {
|
|
|
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
|
|
String id = (String) jsonObject.get("id");
|
|
|
String status = (String) jsonObject.get("status");
|
|
@@ -312,15 +298,16 @@ public class YongyouServiceImpl implements YongyouService {
|
|
|
String spareNum = next.getString("spareNum");
|
|
|
String detailId = next.getString("detailId");
|
|
|
String spareGGXH = next.getString("spareGGXH");
|
|
|
- SpareRestoreDetail sparePickDetail = new SpareRestoreDetail();
|
|
|
+ OutStoreDetail sparePickDetail = new OutStoreDetail();
|
|
|
sparePickDetail.setId(detailId);
|
|
|
sparePickDetail.setNum(new BigDecimal(spareNum));
|
|
|
- sparePickDetail.setSpareGgxh(spareGGXH);
|
|
|
- spareRestoreDetailService.modModelByPrimaryKey(sparePickDetail);
|
|
|
+ sparePickDetail.setGgxh(spareGGXH);
|
|
|
+ outStoreDetailService.modModelByPrimaryKey(sparePickDetail);
|
|
|
}
|
|
|
- SpareRestoreForm sparePickForm = new SpareRestoreForm();
|
|
|
+ OutStoreForm sparePickForm = new OutStoreForm();
|
|
|
sparePickForm.setStatus(2);
|
|
|
sparePickForm.setId(id);
|
|
|
- spareRestoreFormService.modModelByPrimaryKey(sparePickForm);
|
|
|
+ outStoreFormService.modModelByPrimaryKey(sparePickForm);
|
|
|
}
|
|
|
+
|
|
|
}
|