Commit d85b632c by 肖洋洋
parents b9155a67 1253dd21
......@@ -8,14 +8,12 @@ import org.springframework.web.bind.annotation.*;
import orthopedics.controller.error.ErrorEnum;
import orthopedics.controller.v1.TransactionController;
import orthopedics.model.*;
import orthopedics.service.InvCountService;
import orthopedics.service.InventoryServer;
import orthopedics.service.TransactionServer;
import orthopedics.service.UserServer;
import orthopedics.service.*;
import orthopedics.util.Result;
import orthopedics.util.StatusCode;
import orthopedics.vo.InvCountHeaderPage;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
......@@ -95,6 +93,10 @@ public class CheckController {
return userServer.checkAccessToken(accessToken);
}
@Autowired
private InvTransacationCostService invTransacationCostService;
//封装json数据
private JSONObject getJson(InvCountHeaderPage invCountHeaderPage, InvCountLine invCountLine){
JSONObject jsonObject = new JSONObject();
......@@ -114,6 +116,13 @@ public class CheckController {
quantity = -invCountLine.getDifferentQuantity();
}
Double unit_price = Double.valueOf(invItem.getPurchasePrice());
InvTransactionCost lastTranCost = invTransacationCostService.findCostByInvIdAndItemId(inventory.getId(),invCountLine.getItemId());
if(lastTranCost != null){
unit_price = lastTranCost.getLastCost();
}
BigDecimal b = new BigDecimal(unit_price*quantity);
Double price = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
JSONObject tempData = new JSONObject();
tempData.put("inv_code",inventory.getInvCode());
tempData.put("subinv_code",subinventory.getSubinvCode());
......@@ -122,7 +131,7 @@ public class CheckController {
tempData.put("tx_type_code",txTypeCode);
tempData.put("tx_date",LocalDateTime.now());
tempData.put("tx_quantity",quantity);
tempData.put("tx_price",invItem.getPurchasePrice());
tempData.put("tx_price",price);
tempData.put("source_code","INVENTORY");//来源与库存
tempData.put("source_header_id",invCountHeaderPage.getId());
tempData.put("source_line_id",invCountLine.getId());
......
......@@ -47,7 +47,7 @@ public class InvItemChangeController {
//对比价格是否有变化
if (LastInvItemChange.getPurchasePrice().equals(invItemChange.getPurchasePrice())) {
//无则不做任何操作
return new Result(false,StatusCode.ERROR,ErrorEnum.DataHaveNotChange.getErrorMsg());
return new Result(true,StatusCode.OK,ErrorEnum.DataHaveNotChange.getErrorMsg());
} else {
//先将版本号转化为数字+1,再转化成String
String editVersion = String.valueOf(Integer.parseInt(LastInvItemChange.getEditVersions()) + 1);
......
......@@ -336,6 +336,7 @@ public class PurOrderHeaderController {
}
RcvReceiptHeader rcvReceiptHeader=new RcvReceiptHeader();
rcvReceiptHeader.setId(UuidUtil.get32UUIDString());
rcvReceiptHeader.setCreateBy(sysAccessToken.getUserName());
......@@ -396,7 +397,7 @@ public class PurOrderHeaderController {
}catch (Exception e){
return new Result(false, StatusCode.ERROR,"数量类型错误");
}
rcvReceiptLine.setAttribute3(purOrderLine.getFixedPrice());
rcvReceiptLine.setShippedQuantity(i);
rcvReceiptLine.setReceivedQuantity(i);
rcvReceiptLine.setUnitCode(purOrderLine.getUnitCode());
......
......@@ -13,6 +13,7 @@ import orthopedics.util.StatusCode;
import orthopedics.util.UuidUtil;
import orthopedics.vo.RcvReceiptHeaderPage;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
......@@ -146,7 +147,8 @@ public class RcvReceiptController {
//获取当前时间
LocalDateTime updateTime = LocalDateTime.now();
//验收入库判断操作
for(RcvReceiptHeaderPage rcvRecHeaderPage:rcvReceiptHeaderPageList){
for(RcvReceiptHeaderPage rcvPage:rcvReceiptHeaderPageList){
RcvReceiptHeaderPage rcvRecHeaderPage = rcvReceiptHeaderService.findRcvReceiptHeaderPage(rcvPage.getId());
String lineStatus = null;
//调用验收通过
if ("accept".equals(status)) {
......@@ -217,9 +219,12 @@ public class RcvReceiptController {
jsonObject.put("tx_type_code",receiptType);
jsonObject.put("tx_date",LocalDateTime.now());
jsonObject.put("tx_quantity",quantity);
jsonObject.put("tx_price",invItem.getPurchasePrice());
jsonObject.put("source_header_id",id);
jsonObject.put("source_line_id",rcvReceiptLine.getId());
BigDecimal b = new BigDecimal(Double.valueOf(rcvReceiptLine.getAttribute3()) * quantity);
Double tx_amount = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
jsonObject.put("tx_amount",tx_amount);
jsonObject.put("tx_price",tx_amount);
JSONObject data = new JSONObject();
data.put("data",jsonObject);
return data;
......
......@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.*;
import orthopedics.controller.error.ErrorEnum;
import orthopedics.controller.v1.TransactionController;
import orthopedics.model.*;
import orthopedics.service.InvTransacationCostService;
import orthopedics.service.InventoryServer;
import orthopedics.service.TransferService;
import orthopedics.service.UserServer;
......@@ -16,7 +17,11 @@ import orthopedics.util.StatusCode;
import orthopedics.util.StringUtil;
import orthopedics.vo.WarTransferPage;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/bookcity/transfer")
......@@ -30,7 +35,8 @@ public class TransferController {
private UserServer userServer;
@Autowired
private InventoryServer inventoryServer;
@Autowired
private InvTransacationCostService invTransacationCostService;
/**
*描述:库存调拨的审核接口,将状态从新建new修改为已审核approval,
* 调用库存转移接口,生成两条出入库事务处理类型为“跨库在途调拨-发放”“跨库在途调拨-接收”
......@@ -85,6 +91,9 @@ public class TransferController {
if(warTransferLine.getQuantity() == null || "".equals(warTransferLine.getQuantity())){
return new Result(false,StatusCode.ERROR,"调拨单号为:"+warTransferPage.getOrderNumber()+"的调拨单行的调出数量需填入");
}
if("0".equals(warTransferLine.getQuantity())){
return new Result(false,StatusCode.ERROR,"调拨单号为:"+warTransferPage.getOrderNumber()+"的调拨单行的调出数量不能为0");
}
JSONObject json = getJson(warTransferPage,warTransferLine);
transactionController.invItemeTransfer(token,json);
}
......@@ -158,6 +167,7 @@ public class TransferController {
checkLocatorCode(inInvId,inSubinvId,inLocatorCode);
String inLocatorId = getLocatorCode(inInvId,inSubInvCode,inLocatorCode);
transferService.updateInvTranAtSure(inSubinvId,inLocatorId,headerId,lineId,inInvId);
invTransacationCostService.updateInvTranCostAtSure(inSubinvId,inLocatorId,headerId,lineId,inInvId);
InvTransaction invTransaction = transferService.findInvTranAtSure(headerId,lineId,inInvId,inSubinvId,inLocatorId);
if(invTransaction == null){
return new Result(false,StatusCode.ERROR,"调拨单号为"+orderNum+"对应的库存现有量数据不存在,请检查!");
......@@ -166,19 +176,21 @@ public class TransferController {
if(warTransferLine.getFinalQty() == null || "".equals(warTransferLine.getFinalQty())){
return new Result(false,StatusCode.ERROR,"调拨单号为"+orderNum+"的调拨单行的二次确认数量需填入!");
}
if(!warTransferLine.getQuantity().equals(warTransferLine.getFinalQty())){
//修改调拨的库存事务处理数量
transferService.updateInvTranQuantity(warTransferLine.getFinalQty(),headerId,lineId,inInvId,inSubinvId,inLocatorId);//修改调入数量
InvTransaction outInvTran = transferService.findOutInvTran(headerId,lineId);
InvTransaction inInvTran = transferService.findInInvTran(headerId,lineId);
InvTransaction outInvTran = transferService.findOutInvTran(headerId,lineId);
InvTransaction inInvTran = transferService.findInInvTran(headerId,lineId);
if(!warTransferLine.getQuantity().equals(warTransferLine.getFinalQty()) || !warTransferLine.getUnitPrice().equals(outInvTran.getTxPrice())) {
//修改调拨的库存事务处理数量或金额
transferService.updateInvTranQuantity(warTransferLine.getFinalQty(),inInvTran.getId(),warTransferLine.getUnitPrice());//修改调入数量或金额
if(outInvTran == null || inInvTran == null){
return new Result(false,StatusCode.ERROR,"调拨单号为"+orderNum+"对应的库存现有量数据不存在,请检查!");
}
transferService.updateInvTranQuantity("-"+warTransferLine.getFinalQty(),headerId,lineId,outInvTran.getInvId(),outInvTran.getSubinvId(),outInvTran.getLocatorId());//修改调出数量
transferService.updateInvTranQuantity("-"+warTransferLine.getFinalQty(),outInvTran.getId(),warTransferLine.getUnitPrice());//修改调出数量
Integer quantity = Integer.valueOf(warTransferLine.getQuantity()) - Integer.valueOf(warTransferLine.getFinalQty());
transferService.updateInvItemOnHandByLastTxId(quantity,outInvTran.getId());
Integer quantityOut = -quantity;
transferService.updateInvItemOnHandByOriginTxId(quantityOut,inInvTran.getId());
//修改成本表的计算
updateInvTranCost(headerId,lineId,warTransferLine.getFinalQty(),warTransferLine.getUnitPrice());
}
transferService.updateInvItemOnhandAtSure(inSubinvId,inLocatorId,invTransaction.getId());
}
......@@ -189,6 +201,7 @@ public class TransferController {
if(uCount == 0){
return new Result(false,StatusCode.ERROR,"调拨单号为:"+warTransferPage.getOrderNumber()+"确认失败!");
}
invTransacationCostService.updateInvTransactionCost(warTransferPage.getId(),warTransferLine.getId());
}
}
int count = transferService.updateTransferStatus(null,"completed",updateBy,updateTime,id);
......@@ -222,6 +235,7 @@ public class TransferController {
jsonObject.put("destination_locator_code",inLocatorCode);
jsonObject.put("item_code",warTransferLine.getItemCode());
jsonObject.put("tx_type_code",warTransfer.getOrderType());
jsonObject.put("tx_amount",warTransferLine.getUnitPrice());
jsonObject.put("tx_price",warTransferLine.getUnitPrice());
jsonObject.put("tx_date",LocalDateTime.now());
jsonObject.put("source_code","INVENTORY");//来源于库存
......@@ -254,4 +268,39 @@ public class TransferController {
}
return invLocatorId;
}
//修改成本表的记录
private void updateInvTranCost(String headerId,String lineId,String quantity,String price){
List<InvTransactionCost> costList = invTransacationCostService.findInvTranCostBySource(headerId, lineId);
if(costList.size() != 0){
for(InvTransactionCost invTransactionCost:costList){
if(invTransactionCost.getTxQuantity() > 0){
Integer tx_quantity = Integer.valueOf(quantity);
Double tx_price = Double.valueOf(price);
Map<String,Object> map = getCost(tx_quantity,tx_price,invTransactionCost.getFirstQuantity(),invTransactionCost.getFirstAmount());
invTransacationCostService.updateInvTranCost(tx_quantity,tx_price,(Double) map.get("lastAmount"),(Integer) map.get("lastQuantity"),(Double)map.get("lastCost"),invTransactionCost.getId());
}
if(invTransactionCost.getTxQuantity() < 0){
Integer tx_quantity = Integer.valueOf("-"+quantity);
Double tx_price = Double.valueOf("-"+price);
Map<String,Object> map = getCost(tx_quantity,tx_price,invTransactionCost.getFirstQuantity(),invTransactionCost.getFirstAmount());
invTransacationCostService.updateInvTranCost(tx_quantity,tx_price,(Double) map.get("lastAmount"),(Integer) map.get("lastQuantity"),(Double)map.get("lastCost"),invTransactionCost.getId());
}
}
}
}
//成本计算公式
private Map<String,Object> getCost(Integer tx_quantity,Double tx_amount,Integer first_quantity,Double first_amount){
Map<String,Object> map = new HashMap<>();
BigDecimal b = new BigDecimal(first_amount + tx_amount);
Double lastAmount = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
Integer lastQuantity = first_quantity+ tx_quantity;
BigDecimal c = new BigDecimal(lastAmount/lastQuantity);
Double lastCost = c.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
map.put("lastAmount",lastAmount);
map.put("lastQuantity",lastQuantity);
map.put("lastCost",lastCost);
return map;
}
}
package orthopedics.controller.bookcity;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.language.DoubleMetaphone;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
......@@ -17,6 +18,7 @@ import orthopedics.util.UuidUtil;
import orthopedics.vo.RcvReceiptHeaderPage;
import orthopedics.vo.WshShipmentHeaderPage;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -225,9 +227,14 @@ public class WshShipmentController {
//获取当前时间
LocalDateTime updateTime = LocalDateTime.now();
//提交出库
for(WshShipmentHeaderPage wshShipmentHeaderPage:wshShipmentHeaderPageList){
for(WshShipmentHeaderPage wshShipPage:wshShipmentHeaderPageList){
WshShipmentHeaderPage wshShipmentHeaderPage = shipServer.findWshShipById(wshShipPage.getId());
for(WshShipmentLine wshShipmentLine:wshShipmentHeaderPage.getWshShipmentLineList()){
JSONObject jsonObject = getJson(wshShipmentHeaderPage.getShipmentNumber(),wshShipmentHeaderPage.getId(),wshShipmentLine);
String tx_amount = null;
if("PURCHASE_RETURN".equals(wshShipmentHeaderPage.getShipmentType())){
tx_amount = "-"+wshShipmentLine.getAttribute3();
}
JSONObject jsonObject = getJson(tx_amount,wshShipmentHeaderPage.getShipmentNumber(),wshShipmentHeaderPage.getId(),wshShipmentLine);
transactionController.invItemInOut(token,jsonObject);
}
//修改状态为已交货DELIVERED
......@@ -240,7 +247,7 @@ public class WshShipmentController {
return new Result(true,StatusCode.OK,"出库成功!");
}
public JSONObject getJson(String number,String id,WshShipmentLine wshShipmentLine){
public JSONObject getJson(String tx_amount,String number,String id,WshShipmentLine wshShipmentLine){
JSONObject jsonObject = new JSONObject();
InvItem invItem = invItemService.findInvItemById(wshShipmentLine.getItemId());
if(invItem == null){
......@@ -249,17 +256,6 @@ public class WshShipmentController {
if(invItem.getItemCode() == null || "".equals(invItem.getItemCode())){
throw ErrorEnum.Error.createException("发运单号为:"+number+",行号为:"+wshShipmentLine.getLineNumber()+"的商品信息:商品代码不完整!");
}
String price = null;
if(!"".equals(wshShipmentLine.getAttribute1()) && wshShipmentLine.getAttribute1() != null){
price = wshShipmentLine.getAttribute1();
}else{
if(invItem.getPurchasePrice() == null || "".equals(invItem.getPurchasePrice())){
throw ErrorEnum.Error.createException("发运单号为:"+number+",行号为:"+wshShipmentLine.getLineNumber()+"的商品信息:商品没有价格!");
}
else{
price = invItem.getPurchasePrice();
}
}
Inventory inventory = inventoryServer.selectInventoryById(wshShipmentLine.getInvId());
if(inventory == null){
throw ErrorEnum.Error.createException("发运单号为:"+number+",行号为:"+wshShipmentLine.getLineNumber()+"的库存不存在!");
......@@ -289,9 +285,10 @@ public class WshShipmentController {
jsonObject.put("tx_type_code","SALE_ISSUE");
jsonObject.put("tx_date",LocalDateTime.now());
jsonObject.put("tx_quantity",wshShipmentLine.getQuantity());
jsonObject.put("tx_price",price);
jsonObject.put("tx_price",wshShipmentLine.getAttribute3());
jsonObject.put("source_header_id",id);
jsonObject.put("source_line_id",wshShipmentLine.getId());
jsonObject.put("tx_amount",tx_amount);
JSONObject data = new JSONObject();
data.put("data",jsonObject);
return data;
......
......@@ -131,8 +131,8 @@ public class TransactionController {
BigDecimal sourcePrice = null;
BigDecimal destinationPrice = null;
if (StringUtil.notEmpty(price)) {
destinationPrice = new BigDecimal(price);
sourcePrice = new BigDecimal(price);
destinationPrice = new BigDecimal(price).setScale(2, BigDecimal.ROUND_HALF_UP);
sourcePrice = new BigDecimal(price).setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
InvTransactionAction invTransactionAction = transactionServer.selectActionById(invTransactionType.getTxActionId());
destinationPrice = BigDecimal.ZERO;
......@@ -204,6 +204,7 @@ public class TransactionController {
sourceInvTransaction.setSummaryFlag("N");
//创建转移源的事务记录
transactionServer.createTransaction(sourceInvTransaction);
insertInvTransactionCost(sourceInvTransaction,data.getDouble("-"+"tx_amount"));
InvTransaction destinationInvTransaction = new InvTransaction();
BeanUtils.copyProperties(sourceInvTransaction, destinationInvTransaction);
......@@ -229,6 +230,7 @@ public class TransactionController {
destinationInvTransaction.setCosignmentEndDate(consignmentEndDate);
//创建转移目标的事务记录
transactionServer.createTransaction(destinationInvTransaction);
insertInvTransactionCost(destinationInvTransaction,data.getDouble("tx_amount"));
InvItemOnhand sourceInvItemOnhand = new InvItemOnhand();
......@@ -411,8 +413,6 @@ public class TransactionController {
outInvItemOnhand.setLastTxId(invTransaction.getId());
transactionServer.outItemOnhand(outInvItemOnhand);
}else if ("RECEIPT_INTO_STORE".equals(invTransactionAction.getTxActionCode())){
logger.info("------入库-------");
LocalDateTime consignmentStartDate = TimeUtil.fromDateToLocalDateTime(data.getString("consignment_start_date"));
......@@ -445,6 +445,8 @@ public class TransactionController {
}
transactionServer.createTransaction(invTransaction);
//入库成本记录表
insertInvTransactionCost(invTransaction,data.getDouble("tx_amount"));
Map<String, Object> reponseResult = new HashMap<>();
ErrorEnum.SUCCESS.putIntoMap(reponseResult);
return JSON.toJSONString(reponseResult);
......@@ -749,4 +751,49 @@ public class TransactionController {
}
return locatorCode;
}
@Autowired
private InvTransacationCostService invTransacationCostService;
//入库成本记录表
private void insertInvTransactionCost(InvTransaction invTransaction,Double tx_amount){
InvTransactionCost invTransactionCost = new InvTransactionCost();
BeanUtils.copyProperties(invTransaction,invTransactionCost);
invTransactionCost.setId(UuidUtil.get32UUIDString());
InvTransactionCost lastTranCost = invTransacationCostService.findCostByInvIdAndItemId(invTransaction.getInvId(),invTransaction.getItemId());
Integer firstQuantity = 0;
Double firstCost = 0.0;
Double firstAmount = 0.0;
if(lastTranCost != null){
firstQuantity = lastTranCost.getLastQuantity();
firstCost = lastTranCost.getLastCost();
firstAmount = lastTranCost.getLastAmount();
}
invTransactionCost.setFirstCost(firstCost);
invTransactionCost.setFirstQuantity(firstQuantity);
invTransactionCost.setFirstAmount(firstAmount);
Integer txQuantity = invTransaction.getTxQuantity();
if("".equals(tx_amount) || tx_amount == null){
BigDecimal a = new BigDecimal(txQuantity*firstCost);
tx_amount = a.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
}
invTransactionCost.setTxAmount(tx_amount);
BigDecimal b = new BigDecimal(firstAmount + tx_amount);
Double lastAmount = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
Integer lastQuantity = firstQuantity + txQuantity;
invTransactionCost.setLastAmount(lastAmount);
invTransactionCost.setLastQuantity(lastQuantity);
Double lastCost = 0.00;
if(!(Math.abs(lastAmount)<0.00001) && !"0".equals(lastQuantity)){
BigDecimal c = new BigDecimal(lastAmount / lastQuantity);
lastCost = c.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
}
if(lastCost < 0){
lastCost = firstCost;
invTransactionCost.setRemark("无法计算成本,沿用期初成本");
}
invTransactionCost.setLastCost(lastCost);
invTransactionCost.setStatus("1");
invTransacationCostService.insertInvTransactionCost(invTransactionCost);
}
}
package orthopedics.dao;
import java.util.List;
import org.apache.ibatis.annotations.*;
import orthopedics.model.InvTransactionCost;
import org.apache.ibatis.annotations.Param;
import javax.crypto.interfaces.DHPublicKey;
/**
* @author ice
*/
public interface InvTransactionCostMapper{
@Select("SELECT * FROM inv_transaction_cost")
@Results(id = "invtransactioncost", value ={
@Result(property = "id", column = "id"),
@Result(property = "createBy", column = "create_by"),
@Result(property = "createTime", column = "create_time"),
@Result(property = "updateBy", column = "update_by"),
@Result(property = "updateTime", column = "update_time"),
@Result(property = "attributeCategory", column = "attribute_category"),
@Result(property = "attribute1", column = "attribute1"),
@Result(property = "attribute2", column = "attribute2"),
@Result(property = "attribute3", column = "attribute3"),
@Result(property = "attribute4", column = "attribute4"),
@Result(property = "attribute5", column = "attribute5"),
@Result(property = "attribute6", column = "attribute6"),
@Result(property = "attribute7", column = "attribute7"),
@Result(property = "attribute8", column = "attribute8"),
@Result(property = "attribute9", column = "attribute9"),
@Result(property = "attribute10", column = "attribute10"),
@Result(property = "txTypeId", column = "tx_type_id"),
@Result(property = "txSourceTypeId", column = "tx_source_type_id"),
@Result(property = "txActionId", column = "tx_action_id"),
@Result(property = "txDate", column = "tx_date"),
@Result(property = "txUnit", column = "tx_unit"),
@Result(property = "sourceHeaderId", column = "source_header_id"),
@Result(property = "sourceLineId", column = "source_line_id"),
@Result(property = "invId", column = "inv_id"),
@Result(property = "subinvId", column = "subinv_id"),
@Result(property = "locatorId", column = "locator_id"),
@Result(property = "itemId", column = "item_id"),
@Result(property = "firstCost", column = "first_cost"),
@Result(property = "firstQuantity", column = "first_quantity"),
@Result(property = "firstAmount", column = "first_amount"),
@Result(property = "txQuantity", column = "tx_quantity"),
@Result(property = "txAmount", column = "tx_amount"),
@Result(property = "lastQuantity", column = "last_quantity"),
@Result(property = "lastAmount", column = "last_amount"),
@Result(property = "lastCost", column = "last_cost"),
@Result(property = "status", column = "status"),
@Result(property = "remark", column = "remark"),
})
public List<InvTransactionCost> select();
@Insert("<script>" +
"INSERT INTO inv_transaction_cost(id,create_by,create_time,update_by,update_time,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,tx_type_id,tx_source_type_id,tx_action_id,tx_date,tx_unit,source_header_id,source_line_id,inv_id,subinv_id,locator_id,item_id,first_cost,first_quantity,first_amount,tx_quantity,tx_amount,last_quantity,last_amount,last_cost,status,remark) VALUES" +
"<foreach collection='invtransactioncosts' item='item' index='index' separator=','>" +
"(#{item.id},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.attributeCategory},#{item.attribute1},#{item.attribute2},#{item.attribute3},#{item.attribute4},#{item.attribute5},#{item.attribute6},#{item.attribute7},#{item.attribute8},#{item.attribute9},#{item.attribute10},#{item.txTypeId},#{item.txSourceTypeId},#{item.txActionId},#{item.txDate},#{item.txUnit},#{item.sourceHeaderId},#{item.sourceLineId},#{item.invId},#{item.subinvId},#{item.locatorId},#{item.itemId},#{item.firstCost},#{item.firstQuantity},#{item.firstAmount},#{item.txQuantity},#{item.txAmount},#{item.lastQuantity},#{item.lastAmount},#{item.lastCost},#{item.status},#{item.remark})" +
"</foreach>" +
"</script>")
Integer insertBatch(@Param("invtransactioncosts")List<InvTransactionCost> InvTransactionCostList);
@Insert(
"INSERT INTO inv_transaction_cost(id,create_by,create_time,update_by,update_time,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,tx_type_id,tx_source_type_id,tx_action_id,tx_date,tx_unit,source_header_id,source_line_id,inv_id,subinv_id,locator_id,item_id,first_cost,first_quantity,first_amount,tx_quantity,tx_amount,last_quantity,last_amount,last_cost,status,remark) VALUES" +
"(#{id},#{createBy},#{createTime},#{updateBy},#{updateTime},#{attributeCategory},#{attribute1},#{attribute2},#{attribute3},#{attribute4},#{attribute5},#{attribute6},#{attribute7},#{attribute8},#{attribute9},#{attribute10},#{txTypeId},#{txSourceTypeId},#{txActionId},#{txDate},#{txUnit},#{sourceHeaderId},#{sourceLineId},#{invId},#{subinvId},#{locatorId},#{itemId},#{firstCost},#{firstQuantity},#{firstAmount},#{txQuantity},#{txAmount},#{lastQuantity},#{lastAmount},#{lastCost},#{status},#{remark})"
)
Integer insert(InvTransactionCost InvTransactionCost);
@Select("select * from inv_transaction_cost where inv_id = #{invId} and item_id =#{itemId} ORDER BY tx_date desc LIMIT 1")
@ResultMap("invtransactioncost")
InvTransactionCost selectCostByInvIdAndItemId(@Param("invId")String invId,@Param("itemId")String itemId);
@Update("UPDATE inv_transaction_cost set tx_quantity=#{tx_quantity},tx_amount=#{tx_amount},last_amount=#{last_amount},last_quantity=#{last_quantity},last_cost=#{last_cost} where id=#{id}")
Integer updateInvTranCost(@Param("tx_quantity")Integer tx_quantity, @Param("tx_amount")Double tx_amount, @Param("last_amount")Double last_amount, @Param("last_quantity")Integer last_quantity, @Param("last_cost")Double last_cost,@Param("id")String id);
@Select("select * from inv_transaction_cost where source_header_id = #{headerId} and source_line_id = #{lineId}")
@ResultMap("invtransactioncost")
List<InvTransactionCost> selectInvTranCostBySource(@Param("headerId")String headerId,@Param("lineId")String lineId);
//调拨确认时修改跨库为跨库直接调拨
@Update("UPDATE inv_transaction_cost SET tx_action_id = '2c9f8d286bf8b3de016bfa1012a7008t' WHERE source_header_id = #{headerId} AND source_line_id = #{lineId}")
Integer updateInvTransactionCost(@Param("headerId")String headerId,@Param("lineId")String lineId);
//调拨确认时增加调入库区货架
@Update("UPDATE inv_transaction_cost SET subinv_id=#{subinvId},locator_id=#{locatorId} WHERE source_header_id = #{headerId} AND source_line_id = #{lineId} and inv_id=#{invId} and tx_quantity > 0")
Integer updateInvTranCostAtSure(@Param("subinvId")String subinvId,@Param("locatorId")String locatorId,@Param("headerId")String headerId,@Param("lineId")String lineId,@Param("invId")String invId);
}
\ No newline at end of file
......@@ -90,12 +90,16 @@ public interface InvTransactionMapper{
@ResultMap("invtransaction")
List<InvTransaction> findInvTranAtSure(@Param("headerId")String headerId,@Param("lineId")String lineId,@Param("invId")String invId,@Param("subinvId")String subinvId,@Param("locatorId")String locatorId);
// //二次数量不一致时需修改
// @Update({"<script>" +
// "update inv_transaction SET tx_quantity = #{quantity} where source_header_id = #{headerId} AND source_line_id = #{lineId} and inv_id=#{invId} and subinv_id= #{subinvId} and source_code ='INVENTORY'" +
// "<if test = 'locatorId != null '>and locator_id = #{locatorId}</if>" +
// "</script>"})
// Integer updateInvTranQuantity(@Param("quantity")String quantity,@Param("headerId")String headerId,@Param("lineId")String lineId,@Param("invId")String invId,@Param("subinvId")String subinvId,@Param("locatorId")String locatorId);
//二次数量不一致时需修改
@Update({"<script>" +
"update inv_transaction SET tx_quantity = #{quantity} where source_header_id = #{headerId} AND source_line_id = #{lineId} and inv_id=#{invId} and subinv_id= #{subinvId} and source_code ='INVENTORY'" +
"<if test = 'locatorId != null '>and locator_id = #{locatorId}</if>" +
"</script>"})
Integer updateInvTranQuantity(@Param("quantity")String quantity,@Param("headerId")String headerId,@Param("lineId")String lineId,@Param("invId")String invId,@Param("subinvId")String subinvId,@Param("locatorId")String locatorId);
@Update("update inv_transaction SET tx_quantity = #{quantity},tx_price = #{price} where id = #{id} and source_code ='INVENTORY'")
Integer updateInvTranQuantity(@Param("quantity")String quantity,@Param("id")String id,@Param("price")String price);
//查询库存调拨的出库信息
@Select("select * from inv_transaction where source_header_id = #{headerId} AND source_line_id = #{lineId} and tx_quantity < 0 and source_code ='INVENTORY'")
......
......@@ -45,6 +45,7 @@ public interface RcvReceiptLineMapper{
@Result(property = "sourceHeaderNumber", column = "source_header_number"),
@Result(property = "sourceLineId", column = "source_line_id"),
@Result(property = "sourceLineNumber", column = "source_line_number"),
@Result(property = "invId", column = "inv_id"),
})
public List<RcvReceiptLine> select();
......
......@@ -90,4 +90,8 @@ public interface WshShipmentHeaderMapper{
@Update("update wsh_shipment_header set update_by = #{updateBy},update_time = #{updateTime},header_status = #{status} where id = #{id}")
boolean updateWshHeaderStatus(@Param("updateBy")String updateBy, @Param("updateTime")LocalDateTime updateTime,@Param("status")String status,@Param("id")String id);
@Select("select * from wsh_shipment_header where id = #{id}")
@ResultMap("wshshipmentheader")
WshShipmentHeader selectWshShipHeaderById(@Param("id")String id);
}
\ No newline at end of file
......@@ -98,4 +98,8 @@ public interface WshShipmentLineMapper{
@Update("update wsh_shipment_line set update_by = #{updateBy},update_time = #{updateTime},line_status = #{status} where wsh_shipment_header_id = #{id}")
boolean updateLineStatus(@Param("updateBy")String updateBy, @Param("updateTime") LocalDateTime updateTime,@Param("status")String status,@Param("id")String id);
@Select("select * from wsh_shipment_line where wsh_shipment_header_id = #{id}")
@ResultMap("wshshipmentline")
List<WshShipmentLine> selectWshShipLineByHeaderId(@Param("id")String id);
}
\ No newline at end of file
package orthopedics.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
/**
*
* @author ice
*/
public class InvTransactionCost implements Serializable {
private static final long serialVersionUID = 1574327039458L;
/**
* 主键
* 主键
* isNullAble:0
*/
@JSONField(name = "id")
private String id;
/**
* 创建人
* isNullAble:1
*/
@JSONField(name = "create_by")
private String createBy;
/**
* 创建日期
* isNullAble:1
*/
@JSONField(name = "create_time")
private java.time.LocalDateTime createTime;
/**
* 更新人
* isNullAble:1
*/
@JSONField(name = "update_by")
private String updateBy;
/**
* 更新日期
* isNullAble:1
*/
@JSONField(name = "update_time")
private java.time.LocalDateTime updateTime;
/**
* 备用字段分类
* isNullAble:1
*/
@JSONField(name = "attribute_category")
private String attributeCategory;
/**
* 备用字段1
* isNullAble:1
*/
@JSONField(name = "attribute1")
private String attribute1;
/**
* 备用字段2
* isNullAble:1
*/
@JSONField(name = "attribute2")
private String attribute2;
/**
* 备用字段3
* isNullAble:1
*/
@JSONField(name = "attribute3")
private String attribute3;
/**
* 备用字段4
* isNullAble:1
*/
@JSONField(name = "attribute4")
private String attribute4;
/**
* 备用字段5
* isNullAble:1
*/
@JSONField(name = "attribute5")
private String attribute5;
/**
* 备用字段6
* isNullAble:1
*/
@JSONField(name = "attribute6")
private String attribute6;
/**
* 备用字段7
* isNullAble:1
*/
@JSONField(name = "attribute7")
private String attribute7;
/**
* 备用字段8
* isNullAble:1
*/
@JSONField(name = "attribute8")
private String attribute8;
/**
* 备用字段9
* isNullAble:1
*/
@JSONField(name = "attribute9")
private String attribute9;
/**
* 备用字段10
* isNullAble:1
*/
@JSONField(name = "attribute10")
private String attribute10;
/**
* 事务处理类型
* isNullAble:0
*/
@JSONField(name = "tx_type_id")
private String txTypeId;
/**
* 事务处理来源类型
* isNullAble:0
*/
@JSONField(name = "tx_source_type_id")
private String txSourceTypeId;
/**
* 事务处理动作
* isNullAble:0
*/
@JSONField(name = "tx_action_id")
private String txActionId;
/**
* 事务处理日期
* isNullAble:0
*/
@JSONField(name = "tx_date")
private java.time.LocalDateTime txDate;
/**
* 事务处理单位
* isNullAble:1
*/
@JSONField(name = "tx_unit")
private String txUnit;
/**
* 来源头
* isNullAble:0
*/
@JSONField(name = "source_header_id")
private String sourceHeaderId;
/**
* 来源行
* isNullAble:0
*/
@JSONField(name = "source_line_id")
private String sourceLineId;
/**
* 库存
* isNullAble:0
*/
@JSONField(name = "inv_id")
private String invId;
/**
* 库区
* isNullAble:1
*/
@JSONField(name = "subinv_id")
private String subinvId;
/**
* 货架
* isNullAble:1
*/
@JSONField(name = "locator_id")
private String locatorId;
/**
* 商品
* isNullAble:0
*/
@JSONField(name = "item_id")
private String itemId;
/**
* 期初成本
* isNullAble:0
*/
@JSONField(name = "first_cost")
private Double firstCost;
/**
* 期初数量
* isNullAble:0
*/
@JSONField(name = "first_quantity")
private Integer firstQuantity;
/**
* 期初金额
* isNullAble:0
*/
@JSONField(name = "first_amount")
private Double firstAmount;
/**
* 发生数量
* isNullAble:0
*/
@JSONField(name = "tx_quantity")
private Integer txQuantity;
/**
* 发生金额
* isNullAble:0
*/
@JSONField(name = "tx_amount")
private Double txAmount;
/**
* 期末数量
* isNullAble:0
*/
@JSONField(name = "last_quantity")
private Integer lastQuantity;
/**
* 期末金额
* isNullAble:0
*/
@JSONField(name = "last_amount")
private Double lastAmount;
/**
* 期末成本
* isNullAble:0
*/
@JSONField(name = "last_cost")
private Double lastCost;
/**
* 状态
* isNullAble:0,defaultVal:1
*/
@JSONField(name = "status")
private String status;
/**
* 说明
* isNullAble:1
*/
@JSONField(name = "remark")
private String remark;
public void setId(String id){this.id = id;}
public String getId(){return this.id;}
public void setCreateBy(String createBy){this.createBy = createBy;}
public String getCreateBy(){return this.createBy;}
public void setCreateTime(java.time.LocalDateTime createTime){this.createTime = createTime;}
public java.time.LocalDateTime getCreateTime(){return this.createTime;}
public void setUpdateBy(String updateBy){this.updateBy = updateBy;}
public String getUpdateBy(){return this.updateBy;}
public void setUpdateTime(java.time.LocalDateTime updateTime){this.updateTime = updateTime;}
public java.time.LocalDateTime getUpdateTime(){return this.updateTime;}
public void setAttributeCategory(String attributeCategory){this.attributeCategory = attributeCategory;}
public String getAttributeCategory(){return this.attributeCategory;}
public void setAttribute1(String attribute1){this.attribute1 = attribute1;}
public String getAttribute1(){return this.attribute1;}
public void setAttribute2(String attribute2){this.attribute2 = attribute2;}
public String getAttribute2(){return this.attribute2;}
public void setAttribute3(String attribute3){this.attribute3 = attribute3;}
public String getAttribute3(){return this.attribute3;}
public void setAttribute4(String attribute4){this.attribute4 = attribute4;}
public String getAttribute4(){return this.attribute4;}
public void setAttribute5(String attribute5){this.attribute5 = attribute5;}
public String getAttribute5(){return this.attribute5;}
public void setAttribute6(String attribute6){this.attribute6 = attribute6;}
public String getAttribute6(){return this.attribute6;}
public void setAttribute7(String attribute7){this.attribute7 = attribute7;}
public String getAttribute7(){return this.attribute7;}
public void setAttribute8(String attribute8){this.attribute8 = attribute8;}
public String getAttribute8(){return this.attribute8;}
public void setAttribute9(String attribute9){this.attribute9 = attribute9;}
public String getAttribute9(){return this.attribute9;}
public void setAttribute10(String attribute10){this.attribute10 = attribute10;}
public String getAttribute10(){return this.attribute10;}
public void setTxTypeId(String txTypeId){this.txTypeId = txTypeId;}
public String getTxTypeId(){return this.txTypeId;}
public void setTxSourceTypeId(String txSourceTypeId){this.txSourceTypeId = txSourceTypeId;}
public String getTxSourceTypeId(){return this.txSourceTypeId;}
public void setTxActionId(String txActionId){this.txActionId = txActionId;}
public String getTxActionId(){return this.txActionId;}
public void setTxDate(java.time.LocalDateTime txDate){this.txDate = txDate;}
public java.time.LocalDateTime getTxDate(){return this.txDate;}
public void setTxUnit(String txUnit){this.txUnit = txUnit;}
public String getTxUnit(){return this.txUnit;}
public void setSourceHeaderId(String sourceHeaderId){this.sourceHeaderId = sourceHeaderId;}
public String getSourceHeaderId(){return this.sourceHeaderId;}
public void setSourceLineId(String sourceLineId){this.sourceLineId = sourceLineId;}
public String getSourceLineId(){return this.sourceLineId;}
public void setInvId(String invId){this.invId = invId;}
public String getInvId(){return this.invId;}
public void setSubinvId(String subinvId){this.subinvId = subinvId;}
public String getSubinvId(){return this.subinvId;}
public void setLocatorId(String locatorId){this.locatorId = locatorId;}
public String getLocatorId(){return this.locatorId;}
public void setItemId(String itemId){this.itemId = itemId;}
public String getItemId(){return this.itemId;}
public void setFirstCost(Double firstCost){this.firstCost = firstCost;}
public Double getFirstCost(){return this.firstCost;}
public void setFirstQuantity(Integer firstQuantity){this.firstQuantity = firstQuantity;}
public Integer getFirstQuantity(){return this.firstQuantity;}
public void setFirstAmount(Double firstAmount){this.firstAmount = firstAmount;}
public Double getFirstAmount(){return this.firstAmount;}
public void setTxQuantity(Integer txQuantity){this.txQuantity = txQuantity;}
public Integer getTxQuantity(){return this.txQuantity;}
public void setTxAmount(Double txAmount){this.txAmount = txAmount;}
public Double getTxAmount(){return this.txAmount;}
public void setLastQuantity(Integer lastQuantity){this.lastQuantity = lastQuantity;}
public Integer getLastQuantity(){return this.lastQuantity;}
public void setLastAmount(Double lastAmount){this.lastAmount = lastAmount;}
public Double getLastAmount(){return this.lastAmount;}
public void setLastCost(Double lastCost){this.lastCost = lastCost;}
public Double getLastCost(){return this.lastCost;}
public void setStatus(String status){this.status = status;}
public String getStatus(){return this.status;}
public void setRemark(String remark){this.remark = remark;}
public String getRemark(){return this.remark;}
@Override
public String toString() {
return "InvTransactionCost{" +
"id='" + id + '\'' +
"createBy='" + createBy + '\'' +
"createTime='" + createTime + '\'' +
"updateBy='" + updateBy + '\'' +
"updateTime='" + updateTime + '\'' +
"attributeCategory='" + attributeCategory + '\'' +
"attribute1='" + attribute1 + '\'' +
"attribute2='" + attribute2 + '\'' +
"attribute3='" + attribute3 + '\'' +
"attribute4='" + attribute4 + '\'' +
"attribute5='" + attribute5 + '\'' +
"attribute6='" + attribute6 + '\'' +
"attribute7='" + attribute7 + '\'' +
"attribute8='" + attribute8 + '\'' +
"attribute9='" + attribute9 + '\'' +
"attribute10='" + attribute10 + '\'' +
"txTypeId='" + txTypeId + '\'' +
"txSourceTypeId='" + txSourceTypeId + '\'' +
"txActionId='" + txActionId + '\'' +
"txDate='" + txDate + '\'' +
"txUnit='" + txUnit + '\'' +
"sourceHeaderId='" + sourceHeaderId + '\'' +
"sourceLineId='" + sourceLineId + '\'' +
"invId='" + invId + '\'' +
"subinvId='" + subinvId + '\'' +
"locatorId='" + locatorId + '\'' +
"itemId='" + itemId + '\'' +
"firstCost='" + firstCost + '\'' +
"firstQuantity='" + firstQuantity + '\'' +
"firstAmount='" + firstAmount + '\'' +
"txQuantity='" + txQuantity + '\'' +
"txAmount='" + txAmount + '\'' +
"lastQuantity='" + lastQuantity + '\'' +
"lastAmount='" + lastAmount + '\'' +
"lastCost='" + lastCost + '\'' +
"status='" + status + '\'' +
"remark='" + remark + '\'' +
'}';
}
}
package orthopedics.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import orthopedics.dao.InvTransactionCostMapper;
import orthopedics.model.InvTransactionCost;
import java.util.List;
@Service
public class InvTransacationCostService {
@Autowired
private InvTransactionCostMapper invTransactionCostMapper;
public InvTransactionCost findCostByInvIdAndItemId(String invId,String itemId){
return invTransactionCostMapper.selectCostByInvIdAndItemId(invId,itemId);
}
public Integer insertInvTransactionCost(InvTransactionCost invTransactionCost){
return invTransactionCostMapper.insert(invTransactionCost);
}
public Integer updateInvTranCost(Integer tx_quantity,Double tx_amount,Double last_amount,Integer last_quantity,Double last_cost,String id){
return invTransactionCostMapper.updateInvTranCost(tx_quantity,tx_amount,last_amount,last_quantity,last_cost,id);
}
public List<InvTransactionCost> findInvTranCostBySource(String headerId,String lineId){
return invTransactionCostMapper.selectInvTranCostBySource(headerId, lineId);
}
public Integer updateInvTransactionCost(String headerId,String lineId){
return invTransactionCostMapper.updateInvTransactionCost(headerId, lineId);
}
public Integer updateInvTranCostAtSure(String subinvId,String locatorId,String headerId,String lineId,String invId){
return invTransactionCostMapper.updateInvTranCostAtSure(subinvId, locatorId, headerId, lineId, invId);
}
}
......@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import org.springframework.beans.BeanUtils;
import orthopedics.dao.CstItemCostMapper;
import orthopedics.dao.FunctionMapper;
import orthopedics.dao.WshShipmentHeaderMapper;
......@@ -25,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import orthopedics.vo.WshShipmentHeaderPage;
/**
* @author: su.yongpeng
......@@ -175,4 +177,13 @@ public class ShipServer {
public boolean updateWshLineStatus(String updateBy,LocalDateTime updateTime,String status,String id){
return wshShipmentLineMapper.updateLineStatus(updateBy, updateTime, status, id);
}
public WshShipmentHeaderPage findWshShipById(String id){
WshShipmentHeaderPage wshShipmentHeaderPage = new WshShipmentHeaderPage();
WshShipmentHeader wshShipmentHeader = wshShipmentHeaderMapper.selectWshShipHeaderById(id);
BeanUtils.copyProperties(wshShipmentHeader,wshShipmentHeaderPage);
List<WshShipmentLine> wshShipmentLineList = wshShipmentLineMapper.selectWshShipLineByHeaderId(id);
wshShipmentHeaderPage.setWshShipmentLineList(wshShipmentLineList);
return wshShipmentHeaderPage;
}
}
......@@ -60,8 +60,8 @@ public class TransferService {
return invItemOnhandMapper.updateInvItemOnhandAtSure(subinvId, locatorId, id);
}
public int updateInvTranQuantity(String quantity,String headerId,String lineId,String invId,String subinvId,String locatorId){
return invTransactionMapper.updateInvTranQuantity(quantity, headerId, lineId, invId, subinvId, locatorId);
public int updateInvTranQuantity(String quantity,String id,String price){
return invTransactionMapper.updateInvTranQuantity(quantity,id,price);
}
public InvTransaction findInInvTran(String headerId,String lineId){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment