8) 采购退货
This commit is contained in:
parent
342c54999d
commit
3e9ea3c6cc
@ -2,8 +2,12 @@ package com.cim.idm.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cim.idm.dao.PurchaseReturnServiceDao;
|
||||
import com.cim.idm.framework.IDMFrameServiceProxy;
|
||||
import com.cim.idm.model.MaterialReceiveRequest;
|
||||
import com.cim.idm.model.PurchaseReturnDto;
|
||||
import com.cim.idm.model.StockOutDto;
|
||||
import com.cim.idm.service.PurchaseReturnService;
|
||||
import com.cim.idm.utils.AjaxResult;
|
||||
import com.cim.idm.wmsextend.generic.errorHandler.CustomException;
|
||||
import com.cim.idm.wmspackage.materialpacking.MaterialPackingServiceProxy;
|
||||
@ -20,10 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import com.cim.idm.service.Impl.InvoiceServiceImpl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
@Api("单据接口")
|
||||
@RestController
|
||||
@ -34,6 +35,12 @@ public class PurchaseReturnController {
|
||||
@Autowired
|
||||
private InvoiceServiceImpl InvoiceServiceImpl;
|
||||
|
||||
@Autowired
|
||||
private PurchaseReturnServiceDao purchaseReturnServiceDao;
|
||||
|
||||
@Autowired
|
||||
private PurchaseReturnService purchaseReturnService;
|
||||
|
||||
/**
|
||||
* 获取采购退货单号列表
|
||||
* @param in
|
||||
@ -47,31 +54,41 @@ public class PurchaseReturnController {
|
||||
String receiverequestname = materialReceiveRequest.getReceiveRequestName() == null ? "" : materialReceiveRequest.getReceiveRequestName();
|
||||
String erpfactory = materialReceiveRequest.getErpFactory();
|
||||
String siteName = materialReceiveRequest.getSiteName();
|
||||
|
||||
String sql = "SELECT\r\n" +
|
||||
" DISTINCT M.RECEIVEREQUESTNAME\r\n" +
|
||||
"FROM\r\n" +
|
||||
" MATERIALRECEIVEREQUESTDETAIL M\r\n" +
|
||||
" LEFT JOIN MATERIALRECEIVEREQUEST R ON\r\n" +
|
||||
" R.RECEIVEREQUESTNAME = M.RECEIVEREQUESTNAME\r\n" +
|
||||
"WHERE\r\n" +
|
||||
" M.SITENAME = :SITENAME\r\n" +
|
||||
// " AND R.RECEIVEREQUESTTYPE = '45'\r\n" +
|
||||
" AND R.RETURNFLAG = 'Y'\r\n" +
|
||||
" AND R.RECEIVEREQUESTSTATE <> 'Completed'\r\n" +
|
||||
" AND M.ERPFACTORY = :ERPFACTORY\r\n" +
|
||||
" AND M.RECEIVEREQUESTNAME LIKE :RECEIVEREQUESTNAME";
|
||||
|
||||
Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||
bindMap.put("SITENAME",siteName);
|
||||
bindMap.put("RECEIVEREQUESTNAME","%" + receiverequestname + "%");
|
||||
bindMap.put("ERPFACTORY",erpfactory);
|
||||
List<Map<String,Object>> list = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bindMap);
|
||||
String user = materialReceiveRequest.getUser();
|
||||
receiverequestname = "%" + receiverequestname + "%";
|
||||
|
||||
if(Objects.isNull(list) || list.isEmpty()) {
|
||||
try {
|
||||
List<PurchaseReturnDto> purchaseReturnList =
|
||||
purchaseReturnServiceDao.getPurchaseReturnList(siteName, user, receiverequestname);
|
||||
return AjaxResult.me().setResultObj(purchaseReturnList);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.me().setErrorCode(500).setMessage("未找到对应的数据!");
|
||||
}
|
||||
return AjaxResult.me().setResultObj(list);
|
||||
}
|
||||
//
|
||||
// String sql = "SELECT\r\n" +
|
||||
// " DISTINCT M.RECEIVEREQUESTNAME\r\n" +
|
||||
// "FROM\r\n" +
|
||||
// " MATERIALRECEIVEREQUESTDETAIL M\r\n" +
|
||||
// " LEFT JOIN MATERIALRECEIVEREQUEST R ON\r\n" +
|
||||
// " R.RECEIVEREQUESTNAME = M.RECEIVEREQUESTNAME\r\n" +
|
||||
// "WHERE\r\n" +
|
||||
// " M.SITENAME = :SITENAME\r\n" +
|
||||
//// " AND R.RECEIVEREQUESTTYPE = '45'\r\n" +
|
||||
// " AND R.RETURNFLAG = 'Y'\r\n" +
|
||||
// " AND R.RECEIVEREQUESTSTATE <> 'Completed'\r\n" +
|
||||
// " AND M.ERPFACTORY = :ERPFACTORY\r\n" +
|
||||
// " AND M.RECEIVEREQUESTNAME LIKE :RECEIVEREQUESTNAME";
|
||||
//
|
||||
// Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||
// bindMap.put("SITENAME",siteName);
|
||||
// bindMap.put("RECEIVEREQUESTNAME","%" + receiverequestname + "%");
|
||||
// bindMap.put("ERPFACTORY",erpfactory);
|
||||
// List<Map<String,Object>> list = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bindMap);
|
||||
//
|
||||
// if(Objects.isNull(list) || list.isEmpty()) {
|
||||
// return AjaxResult.me().setErrorCode(500).setMessage("未找到对应的数据!");
|
||||
// }
|
||||
// return AjaxResult.me().setResultObj(list);
|
||||
|
||||
}
|
||||
|
||||
@ -88,28 +105,36 @@ public class PurchaseReturnController {
|
||||
String receiverequestname = materialReceiveRequest.getReceiveRequestName() == null ? "" : materialReceiveRequest.getReceiveRequestName();
|
||||
String erpfactory = materialReceiveRequest.getErpFactory();
|
||||
String siteName = materialReceiveRequest.getSiteName();
|
||||
|
||||
String sql = "SELECT A.RECEIVEREQUESTNAME,A.RECEIVEREQUESTDETAILNAME,C.MATERIALSPECNAME,A.DESCRIPTION,\r\n" +
|
||||
"m.FNAME MATERIALUNIT,A.REQUESTQUANTITY,A.CHARGE,A.RECEIVEDQUANTITY,C.DESC_CN,\r\n" +
|
||||
"A.ERPLOCATION,D.ERPFACTORY,D.RETURNFLAG,D.SITENAME,'0' AS SELECTEDQUANTITY,A.SDK_ID,A.PHASE\r\n" +
|
||||
"from\r\n" +
|
||||
"MATERIALRECEIVEREQUESTDETAIL A LEFT JOIN MATERIALUNIT m ON A.MATERIALUNIT = m.FNUMBER ,MATERIALSPEC C,MATERIALRECEIVEREQUEST D \r\n" +
|
||||
"where A.SITENAME = :SITENAME\r\n" +
|
||||
"AND A.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME\r\n" +
|
||||
"AND D.RECEIVEREQUESTNAME = A.RECEIVEREQUESTNAME\r\n" +
|
||||
"AND A.MATERIALSPECNAME = C.MATERIALSPECNAME\r\n" +
|
||||
"AND D.RETURNFLAG='Y'\r\n" +
|
||||
"ORDER BY A.RECEIVEREQUESTDETAILNAME";
|
||||
|
||||
Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||
bindMap.put("SITENAME",siteName);
|
||||
bindMap.put("RECEIVEREQUESTNAME",receiverequestname);
|
||||
List<Map<String,Object>> list = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bindMap);
|
||||
|
||||
if(Objects.isNull(list) || list.isEmpty()) {
|
||||
try {
|
||||
List<PurchaseReturnDto> purchaseReturnInfo =
|
||||
purchaseReturnServiceDao.getPurchaseReturnInfo(siteName, materialReceiveRequest.getUser(), receiverequestname);
|
||||
return AjaxResult.me().setResultObj(purchaseReturnInfo);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.me().setErrorCode(500).setMessage("未找到对应的数据!");
|
||||
}
|
||||
return AjaxResult.me().setResultObj(list);
|
||||
}
|
||||
//
|
||||
// String sql = "SELECT A.RECEIVEREQUESTNAME,A.RECEIVEREQUESTDETAILNAME,C.MATERIALSPECNAME,A.DESCRIPTION,\r\n" +
|
||||
// "m.FNAME MATERIALUNIT,A.REQUESTQUANTITY,A.CHARGE,A.RECEIVEDQUANTITY,C.DESC_CN,\r\n" +
|
||||
// "A.ERPLOCATION,D.ERPFACTORY,D.RETURNFLAG,D.SITENAME,'0' AS SELECTEDQUANTITY,A.SDK_ID,A.PHASE\r\n" +
|
||||
// "from\r\n" +
|
||||
// "MATERIALRECEIVEREQUESTDETAIL A LEFT JOIN MATERIALUNIT m ON A.MATERIALUNIT = m.FNUMBER ,MATERIALSPEC C,MATERIALRECEIVEREQUEST D \r\n" +
|
||||
// "where A.SITENAME = :SITENAME\r\n" +
|
||||
// "AND A.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME\r\n" +
|
||||
// "AND D.RECEIVEREQUESTNAME = A.RECEIVEREQUESTNAME\r\n" +
|
||||
// "AND A.MATERIALSPECNAME = C.MATERIALSPECNAME\r\n" +
|
||||
// "AND D.RETURNFLAG='Y'\r\n" +
|
||||
// "ORDER BY A.RECEIVEREQUESTDETAILNAME";
|
||||
//
|
||||
// Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||
// bindMap.put("SITENAME",siteName);
|
||||
// bindMap.put("RECEIVEREQUESTNAME",receiverequestname);
|
||||
// List<Map<String,Object>> list = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bindMap);
|
||||
//
|
||||
// if(Objects.isNull(list) || list.isEmpty()) {
|
||||
// return AjaxResult.me().setErrorCode(500).setMessage("未找到对应的数据!");
|
||||
// }
|
||||
// return AjaxResult.me().setResultObj(list);
|
||||
|
||||
}
|
||||
|
||||
@ -325,4 +350,18 @@ public class PurchaseReturnController {
|
||||
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(ressSql, hashMap);
|
||||
return AjaxResult.me().setResultObj(queryForList);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/CompleteReceiveRequest", method = RequestMethod.POST)
|
||||
public AjaxResult completeShipRequest(@RequestBody JSONObject in ){
|
||||
StockOutDto ms = JSON.toJavaObject(in, StockOutDto.class);
|
||||
String shipRequestName = ms.getShipRequestName();
|
||||
String siteName = "SDK";
|
||||
String user = ms.getUser();
|
||||
try {
|
||||
purchaseReturnService.completeReceiveRequest(siteName, user, shipRequestName);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.me().setErrorCode(500).setMessage(e.toString());
|
||||
}
|
||||
return AjaxResult.me().setResultObj(null);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.cim.idm.dao;
|
||||
|
||||
import com.cim.idm.model.PurchaseReturnDto;
|
||||
import com.cim.idm.wmspackage.materialpacking.management.data.MaterialPacking;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Mapper
|
||||
public interface PurchaseReturnServiceDao {
|
||||
//获取库存BoxList
|
||||
public List<MaterialPacking> getPurchaseReturnBoxList(@Param("siteName") String siteName, @Param("receiverequestname") String receiverequestname) throws Exception;
|
||||
|
||||
public List<PurchaseReturnDto> getPurchaseReturnList(@Param("siteName") String siteName, @Param("user") String user, @Param("receiverequestname") String receiverequestname) throws Exception;
|
||||
|
||||
public List<PurchaseReturnDto> getPurchaseReturnInfo(@Param("siteName") String siteName, @Param("user") String user, @Param("receiverequestname") String receiverequestname) throws Exception;
|
||||
|
||||
public List<PurchaseReturnDto> getPurPackingInfo(@Param("siteName") String siteName, @Param("user") String user, @Param("receiverequestname") String receiverequestname) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.cim.idm.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PurchaseReturnDto {
|
||||
|
||||
private String siteName;
|
||||
|
||||
private String user;
|
||||
|
||||
private String receiverequestname;
|
||||
|
||||
private String receiverequestdetailname;
|
||||
|
||||
private String receiveactno;
|
||||
|
||||
private String acttype;
|
||||
|
||||
private String receivequantity;
|
||||
|
||||
private String materialQuantity;
|
||||
|
||||
private String materialSpecName;
|
||||
|
||||
private String charge;
|
||||
|
||||
private String selectquantity;
|
||||
|
||||
private String materialUnit;
|
||||
|
||||
private String erpFactory;
|
||||
|
||||
private String erpLocation;
|
||||
|
||||
private String locationName;
|
||||
|
||||
private String description;
|
||||
|
||||
private String requestQuantity;
|
||||
|
||||
private String shipRequestName;
|
||||
|
||||
private String shipRequestDetailName;
|
||||
|
||||
private String packinggrade;
|
||||
|
||||
private String oqaresult;
|
||||
|
||||
private String oqaresultState;
|
||||
|
||||
private String materiaQuantity2;
|
||||
|
||||
private String specialState;
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package com.cim.idm.service.Impl;
|
||||
|
||||
import com.cim.idm.dao.PurchaseReturnServiceDao;
|
||||
import com.cim.idm.dao.ToSapDao;
|
||||
import com.cim.idm.service.PurchaseReturnService;
|
||||
import com.cim.idm.service.impl.ToSAPServiceImpl;
|
||||
import com.cim.idm.wmspackage.materialpacking.management.data.MaterialPacking;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class PurchaseReturnServiceImpl implements PurchaseReturnService {
|
||||
|
||||
@Autowired
|
||||
private PurchaseReturnServiceDao purchaseReturnServiceDao;
|
||||
|
||||
private ToSapDao toSapDao;
|
||||
|
||||
@Autowired
|
||||
private ToSAPServiceImpl toSAPServiceImpl;
|
||||
/**
|
||||
* @param siteName
|
||||
* @param user
|
||||
* @param receiverequestname
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String getPurchaseReturnList(String siteName, String user, String receiverequestname) throws Exception {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param siteName
|
||||
* @param user
|
||||
* @param receiverequestname
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String getPurchaseReturnInfo(String siteName, String user, String receiverequestname) throws Exception {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param siteName
|
||||
* @param user
|
||||
* @param receiverequestname
|
||||
* @param receiverequestdetailname
|
||||
* @param receiveactno
|
||||
* @param acttype
|
||||
* @param receivequantity
|
||||
* @param submaterialspecname
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String purDessignOrAssign(String siteName, String user, String receiverequestname, String receiverequestdetailname, String receiveactno, String acttype, String receivequantity, String submaterialspecname) throws Exception {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param siteName
|
||||
* @param user
|
||||
* @param receiverequestname
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String getPurPackingInfo(String siteName, String user, String receiverequestname) throws Exception {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param siteName
|
||||
* @param user
|
||||
* @param receiverequestname
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String completeReceiveRequest(String siteName, String user, String receiverequestname) throws Exception {
|
||||
//查找需要过账的采购退库信息
|
||||
List<MaterialPacking> purchaseReturnBoxList = purchaseReturnServiceDao.getPurchaseReturnBoxList(siteName, receiverequestname);
|
||||
//将 MaterialPacking的MaterialPackingName放入一个List<String>中
|
||||
List<String> purchaseReturnBoxListName = new ArrayList<>();
|
||||
for (MaterialPacking materialPacking : purchaseReturnBoxList) {
|
||||
purchaseReturnBoxListName.add(materialPacking.getMaterialPackingName());
|
||||
}
|
||||
//过账SAP
|
||||
String undoId = toSAPServiceImpl.orderStockOut(receiverequestname, siteName, user, purchaseReturnBoxListName);
|
||||
//更新库存状态
|
||||
toSapDao.updateStockState(purchaseReturnBoxList, "StockOut", undoId);
|
||||
//更新出入库流水
|
||||
toSapDao.saveUnDoInfo(purchaseReturnBoxList, undoId, "");
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.cim.idm.service;
|
||||
|
||||
public interface PurchaseReturnService {
|
||||
|
||||
public String getPurchaseReturnList(String siteName, String user, String receiverequestname) throws Exception;
|
||||
|
||||
public String getPurchaseReturnInfo(String siteName, String user, String receiverequestname) throws Exception;
|
||||
|
||||
public String purDessignOrAssign(String siteName, String user, String receiverequestname, String receiverequestdetailname, String receiveactno, String acttype, String receivequantity, String submaterialspecname) throws Exception;
|
||||
|
||||
|
||||
public String getPurPackingInfo(String siteName, String user, String receiverequestname) throws Exception;
|
||||
|
||||
public String completeReceiveRequest(String siteName, String user, String receiverequestname) throws Exception;
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.cim.idm.dao.PurchaseReturnServiceDao">
|
||||
|
||||
<select id="getPurchaseReturnList" resultType="com.cim.idm.model.PurchaseReturnDto">
|
||||
SELECT
|
||||
DISTINCT M.RECEIVEREQUESTNAME
|
||||
FROM
|
||||
MATERIALRECEIVEREQUESTDETAIL M
|
||||
LEFT JOIN MATERIALRECEIVEREQUEST R ON
|
||||
R.RECEIVEREQUESTNAME = M.RECEIVEREQUESTNAME
|
||||
WHERE
|
||||
M.SITENAME = #{SITENAME}
|
||||
AND R.RETURNFLAG = 'Y'
|
||||
AND R.RECEIVEREQUESTSTATE != 'Completed'
|
||||
AND M.ERPFACTORY = #{ERPFACTORY}
|
||||
AND M.RECEIVEREQUESTNAME LIKE #{RECEIVEREQUESTNAME}
|
||||
</select>
|
||||
<select id="getPurchaseReturnInfo" resultType="com.cim.idm.model.PurchaseReturnDto">
|
||||
SELECT
|
||||
A.RECEIVEREQUESTNAME,
|
||||
A.RECEIVEREQUESTDETAILNAME,
|
||||
C.MATERIALSPECNAME,
|
||||
A.DESCRIPTION,
|
||||
m.FNAME AS MATERIALUNIT,
|
||||
A.REQUESTQUANTITY,
|
||||
A.CHARGE,
|
||||
A.RECEIVEDQUANTITY,
|
||||
C.DESC_CN,
|
||||
A.ERPLOCATION,
|
||||
D.ERPFACTORY,
|
||||
D.RETURNFLAG,
|
||||
D.SITENAME,
|
||||
'0' AS SELECTEDQUANTITY,
|
||||
A.SDK_ID,
|
||||
A.PHASE
|
||||
FROM
|
||||
MATERIALRECEIVEREQUESTDETAIL A
|
||||
LEFT JOIN MATERIALUNIT m ON
|
||||
A.MATERIALUNIT = m.FNUMBER
|
||||
LEFT JOIN MATERIALSPEC C ON
|
||||
A.MATERIALSPECNAME = C.MATERIALSPECNAME
|
||||
LEFT JOIN MATERIALRECEIVEREQUEST D ON
|
||||
D.RECEIVEREQUESTNAME = A.RECEIVEREQUESTNAME
|
||||
WHERE
|
||||
A.SITENAME = #{SITENAME}
|
||||
AND A.RECEIVEREQUESTNAME = #{RECEIVEREQUESTNAME}
|
||||
AND D.RETURNFLAG = 'Y'
|
||||
ORDER BY
|
||||
A.RECEIVEREQUESTDETAILNAME
|
||||
</select>
|
||||
<!-- 删除: <select id="getPurPackingInfo" resultType="com.cim.idm.model.PurchaseReturnDto"></select> -->
|
||||
<select id="getPurchaseReturnBoxList"
|
||||
resultType="com.cim.idm.wmspackage.materialpacking.management.data.MaterialPacking">
|
||||
SELECT * FROM MATERIALPACKING WHERE 1=1
|
||||
AND SHIPREQUESTNAME = #{RECEIVEREQUESTNAME}
|
||||
AND STOCKSTATE = 'Stocked'
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user