Commit ee839055 authored by 季圣华's avatar 季圣华
Browse files

优化库存计算方式

parent 26bd6235
...@@ -603,17 +603,14 @@ ...@@ -603,17 +603,14 @@
type: "get", type: "get",
url: '/depotItem/findStockNumById', url: '/depotItem/findStockNumById',
data:{ data:{
projectId: depotId, depotId: depotId,
materialId: mId, mId: mId
monthTime: monthTime,
currentPage: 1,
pageSize: 10
}, },
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
if (res.data && res.data.page && res.data.page[0]) { if (res.data) {
var thisStock = res.data.page[0].thisSum; var thisStock = res.data.stock;
if (type == "select") { //选择下拉框的时候 if (type == "select") { //选择下拉框的时候
if (ratio != undefined && ratio != 1) { if (ratio != undefined && ratio != 1) {
loadRatio = ratio; loadRatio = ratio;
......
...@@ -71,14 +71,9 @@ ...@@ -71,14 +71,9 @@
//导出EXCEL //导出EXCEL
function exportExcel() { function exportExcel() {
$("#exprotBtn").off("click").on("click", function () { $("#exprotBtn").off("click").on("click", function () {
if (!$("#searchPanel .total-count").text()) { showEachDetails(1, 3000);
$.messager.alert('导出提示', '请先选择月份再进行查询!', 'error'); //此处直接去做get请求,用下面的查询每月统计的方法,去获取list,参数长度虽长,但还是可以用get
} //window.location.href = "/depotItem/exportExcel.action?browserType=" + getOs();
else {
showEachDetails(1, 3000);
//此处直接去做get请求,用下面的查询每月统计的方法,去获取list,参数长度虽长,但还是可以用get
//window.location.href = "/depotItem/exportExcel.action?browserType=" + getOs();
}
}); });
} }
...@@ -314,7 +309,7 @@ ...@@ -314,7 +309,7 @@
var mIds = res.data.mIds; var mIds = res.data.mIds;
if (mIds) { if (mIds) {
if (pageSize === 3000) { if (pageSize === 3000) {
window.location.href = "/depotItem/exportExcel?browserType=" + getOs() + "&currentPage=" + pageNo + "&pageSize=" + pageSize + "&projectId=" + $.trim($("#searchProjectId").val()) + "&monthTime=" + $("#searchMonth").val() + "&headIds=" + HeadIds + "&materialIds=" + mIds; window.location.href = "/depotItem/exportExcel?browserType=" + getOs() + "&currentPage=" + pageNo + "&pageSize=" + pageSize + "&depotId=" + $.trim($("#searchProjectId").val()) + "&monthTime=" + $("#searchMonth").val() + "&headIds=" + HeadIds + "&materialIds=" + mIds;
} }
else { else {
$.ajax({ $.ajax({
...@@ -324,7 +319,7 @@ ...@@ -324,7 +319,7 @@
data: ({ data: ({
currentPage: pageNo, currentPage: pageNo,
pageSize: pageSize, pageSize: pageSize,
projectId: $.trim($("#searchProjectId").val()), depotId: $.trim($("#searchProjectId").val()),
monthTime: $("#searchMonth").val(), monthTime: $("#searchMonth").val(),
headIds: HeadIds, headIds: HeadIds,
materialIds: mIds, materialIds: mIds,
...@@ -348,7 +343,7 @@ ...@@ -348,7 +343,7 @@
url: "/depotItem/totalCountMoney", url: "/depotItem/totalCountMoney",
dataType: "json", dataType: "json",
data: ({ data: ({
projectId: $.trim($("#searchProjectId").val()), depotId: $.trim($("#searchProjectId").val()),
monthTime: $("#searchMonth").val(), monthTime: $("#searchMonth").val(),
headIds: HeadIds, headIds: HeadIds,
materialIds: mIds materialIds: mIds
...@@ -360,7 +355,7 @@ ...@@ -360,7 +355,7 @@
if (count.lastIndexOf('.') > -1) { if (count.lastIndexOf('.') > -1) {
count = count.substring(0, count.lastIndexOf('.') + 3); count = count.substring(0, count.lastIndexOf('.') + 3);
} }
$("#searchPanel .total-count").text("本月合计金额:" + count + "");//本月合计金额 $("#searchTable .total-count").text("本月合计金额:" + count + "");//本月合计金额
} }
} }
}, },
......
...@@ -61,9 +61,8 @@ public class TenantConfig { ...@@ -61,9 +61,8 @@ public class TenantConfig {
return true; return true;
} else { } else {
// 这里可以判断是否过滤表 // 这里可以判断是否过滤表
if ("databasechangelog".equals(tableName) || "databasechangeloglock".equals(tableName) if ("jsh_materialproperty".equals(tableName) || "tbl_sequence".equals(tableName)
|| "jsh_materialproperty".equals(tableName) || "tbl_sequence".equals(tableName) || "jsh_userbusiness".equals(tableName) || "jsh_functions".equals(tableName)
|| "jsh_userbusiness".equals(tableName) || "jsh_app".equals(tableName) || "jsh_functions".equals(tableName)
|| "jsh_tenant".equals(tableName)) { || "jsh_tenant".equals(tableName)) {
return true; return true;
} else { } else {
...@@ -83,7 +82,8 @@ public class TenantConfig { ...@@ -83,7 +82,8 @@ public class TenantConfig {
public boolean doFilter(MetaObject metaObject) { public boolean doFilter(MetaObject metaObject) {
MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject); MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject);
// 过滤自定义查询此时无租户信息约束出现 // 过滤自定义查询此时无租户信息约束出现
if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName".equals(ms.getId())) { if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName".equals(ms.getId())||
"com.jsh.erp.datasource.mappers.DepotItemMapperEx.getStockByParam".equals(ms.getId())) {
return true; return true;
} }
return false; return false;
...@@ -108,10 +108,10 @@ public class TenantConfig { ...@@ -108,10 +108,10 @@ public class TenantConfig {
/** /**
* 性能分析拦截器,不建议生产使用 * 性能分析拦截器,不建议生产使用
*/ */
// @Bean @Bean
// public PerformanceInterceptor performanceInterceptor(){ public PerformanceInterceptor performanceInterceptor(){
// return new PerformanceInterceptor(); return new PerformanceInterceptor();
// } }
} }
...@@ -398,12 +398,13 @@ public class DepotHeadController { ...@@ -398,12 +398,13 @@ public class DepotHeadController {
@RequestParam("updated") String updated, HttpServletRequest request) throws Exception{ @RequestParam("updated") String updated, HttpServletRequest request) throws Exception{
JSONObject result = ExceptionConstants.standardSuccess(); JSONObject result = ExceptionConstants.standardSuccess();
Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString()); Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString());
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null); Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null);
if(count>= billsNumLimit) { if(count>= billsNumLimit) {
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE, throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG); ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
} else { } else {
depotHeadService.addDepotHeadAndDetail(beanJson,inserted,deleted,updated); depotHeadService.addDepotHeadAndDetail(beanJson,inserted,deleted,updated,tenantId);
} }
return result; return result;
} }
...@@ -421,12 +422,16 @@ public class DepotHeadController { ...@@ -421,12 +422,16 @@ public class DepotHeadController {
* @return java.lang.Object * @return java.lang.Object
*/ */
@RequestMapping(value = "/updateDepotHeadAndDetail") @RequestMapping(value = "/updateDepotHeadAndDetail")
public Object updateDepotHeadAndDetail(@RequestParam("id") Long id,@RequestParam("info") String beanJson,@RequestParam("inserted") String inserted, public Object updateDepotHeadAndDetail(@RequestParam("id") Long id,
@RequestParam("deleted") String deleted, @RequestParam("info") String beanJson,
@RequestParam("updated") String updated,@RequestParam("preTotalPrice") BigDecimal preTotalPrice) throws Exception{ @RequestParam("inserted") String inserted,
@RequestParam("deleted") String deleted,
@RequestParam("updated") String updated,
@RequestParam("preTotalPrice") BigDecimal preTotalPrice,
HttpServletRequest request) throws Exception{
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
JSONObject result = ExceptionConstants.standardSuccess(); JSONObject result = ExceptionConstants.standardSuccess();
depotHeadService.updateDepotHeadAndDetail(id,beanJson,inserted,deleted,updated,preTotalPrice); depotHeadService.updateDepotHeadAndDetail(id,beanJson,inserted,deleted,updated,preTotalPrice,tenantId);
return result; return result;
} }
/** /**
......
...@@ -2,6 +2,7 @@ package com.jsh.erp.datasource.mappers; ...@@ -2,6 +2,7 @@ package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount; import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import com.jsh.erp.datasource.vo.DepotItemVo4Stock;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -35,30 +36,12 @@ public interface DepotItemMapperEx { ...@@ -35,30 +36,12 @@ public interface DepotItemMapperEx {
Long findDetailByTypeAndMaterialIdCounts( Long findDetailByTypeAndMaterialIdCounts(
@Param("mId") Long mId); @Param("mId") Long mId);
List<DepotItemVo4Material> findStockNumByMaterialIdList(
@Param("mId") Long mId,
@Param("monthTime") String monthTime,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long findStockNumByMaterialIdCounts(
@Param("mId") Long mId,
@Param("monthTime") String monthTime);
Long findByTypeAndMaterialIdIn( Long findByTypeAndMaterialIdIn(
@Param("mId") Long mId); @Param("mId") Long mId);
Long findByTypeAndMaterialIdOut( Long findByTypeAndMaterialIdOut(
@Param("mId") Long mId); @Param("mId") Long mId);
int findByTypeAndDepotIdAndMaterialIdIn(
@Param("depotId") Long depotId,
@Param("mId") Long mId);
int findByTypeAndDepotIdAndMaterialIdOut(
@Param("depotId") Long depotId,
@Param("mId") Long mId);
List<DepotItemVo4WithInfoEx> getDetailList( List<DepotItemVo4WithInfoEx> getDetailList(
@Param("headerId") Long headerId); @Param("headerId") Long headerId);
...@@ -72,62 +55,6 @@ public interface DepotItemMapperEx { ...@@ -72,62 +55,6 @@ public interface DepotItemMapperEx {
@Param("headIds") String headIds, @Param("headIds") String headIds,
@Param("materialIds") String materialIds); @Param("materialIds") String materialIds);
BigDecimal findByTypeInIsPrev(
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findByTypeInIsNotPrev(
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findByTypeOutIsPrev(
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findByTypeOutIsNotPrev(
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findPriceByTypeInIsPrev(
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findPriceByTypeInIsNotPrev(
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findPriceByTypeOutIsPrev(
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findPriceByTypeOutIsNotPrev(
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findAssembleIsPrev(
@Param("subType") String subType,
@Param("mType") String mType,
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal findAssembleIsNotPrev(
@Param("subType") String subType,
@Param("mType") String mType,
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId,
@Param("MonthTime") String MonthTime);
BigDecimal buyOrSaleNumber( BigDecimal buyOrSaleNumber(
@Param("type") String type, @Param("type") String type,
@Param("subType") String subType, @Param("subType") String subType,
...@@ -142,15 +69,13 @@ public interface DepotItemMapperEx { ...@@ -142,15 +69,13 @@ public interface DepotItemMapperEx {
@Param("MonthTime") String MonthTime, @Param("MonthTime") String MonthTime,
@Param("sumType") String sumType); @Param("sumType") String sumType);
BigDecimal findGiftByTypeIn( DepotItemVo4Stock getStockByParam(
@Param("subType") String subType, @Param("depotId") Long depotId,
@Param("ProjectId") Integer ProjectId, @Param("mId") Long mId,
@Param("MId") Long MId); @Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("tenantId") Long tenantId);
BigDecimal findGiftByTypeOut(
@Param("subType") String subType,
@Param("ProjectId") Integer ProjectId,
@Param("MId") Long MId);
/** /**
* create by: cjl * create by: cjl
* description: * description:
......
package com.jsh.erp.datasource.vo;
import java.math.BigDecimal;
public class DepotItemVo4Stock {
private BigDecimal inNum;
private BigDecimal outNum;
public BigDecimal getInNum() {
return inNum;
}
public void setInNum(BigDecimal inNum) {
this.inNum = inNum;
}
public BigDecimal getOutNum() {
return outNum;
}
public void setOutNum(BigDecimal outNum) {
this.outNum = outNum;
}
}
...@@ -469,7 +469,7 @@ public class DepotHeadService { ...@@ -469,7 +469,7 @@ public class DepotHeadService {
* @return java.lang.String * @return java.lang.String
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addDepotHeadAndDetail(String beanJson, String inserted, String deleted, String updated) throws Exception { public void addDepotHeadAndDetail(String beanJson, String inserted, String deleted, String updated,Long tenantId) throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD,
BusinessConstants.LOG_OPERATION_TYPE_ADD, BusinessConstants.LOG_OPERATION_TYPE_ADD,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
...@@ -494,7 +494,7 @@ public class DepotHeadService { ...@@ -494,7 +494,7 @@ public class DepotHeadService {
} }
} }
/**入库和出库处理单据子表信息*/ /**入库和出库处理单据子表信息*/
depotItemService.saveDetials(inserted,deleted,updated,depotHead.getId()); depotItemService.saveDetials(inserted,deleted,updated,depotHead.getId(),tenantId);
/**如果关联单据号非空则更新订单的状态为2 */ /**如果关联单据号非空则更新订单的状态为2 */
if(depotHead.getLinknumber()!=null) { if(depotHead.getLinknumber()!=null) {
DepotHead depotHeadOrders = new DepotHead(); DepotHead depotHeadOrders = new DepotHead();
...@@ -522,7 +522,8 @@ public class DepotHeadService { ...@@ -522,7 +522,8 @@ public class DepotHeadService {
* @return java.lang.Object * @return java.lang.Object
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateDepotHeadAndDetail(Long id, String beanJson, String inserted, String deleted, String updated, BigDecimal preTotalPrice)throws Exception { public void updateDepotHeadAndDetail(Long id, String beanJson, String inserted, String deleted, String updated,
BigDecimal preTotalPrice, Long tenantId)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
...@@ -545,7 +546,7 @@ public class DepotHeadService { ...@@ -545,7 +546,7 @@ public class DepotHeadService {
} }
} }
/**入库和出库处理单据子表信息*/ /**入库和出库处理单据子表信息*/
depotItemService.saveDetials(inserted,deleted,updated,depotHead.getId()); depotItemService.saveDetials(inserted,deleted,updated,depotHead.getId(),tenantId);
} }
/** /**
......
...@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.DepotItemMapper; ...@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.DepotItemMapper;
import com.jsh.erp.datasource.mappers.DepotItemMapperEx; import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
import com.jsh.erp.datasource.mappers.SerialNumberMapperEx; import com.jsh.erp.datasource.mappers.SerialNumberMapperEx;
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount; import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import com.jsh.erp.datasource.vo.DepotItemVo4Stock;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException; import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
...@@ -192,38 +193,6 @@ public class DepotItemService { ...@@ -192,38 +193,6 @@ public class DepotItemService {
return result; return result;
} }
public List<DepotItemVo4Material> findStockNumByMaterialIdList(Map<String, String> map)throws Exception {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
String monthTime = map.get("monthTime");
List<DepotItemVo4Material> list =null;
try{
list = depotItemMapperEx.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map));
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long findStockNumByMaterialIdCounts(Map<String, String> map)throws Exception {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
String monthTime = map.get("monthTime");
Long result =null;
try{
result = depotItemMapperEx.findStockNumByMaterialIdCounts(mId, monthTime);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotItemWithObj(DepotItem depotItem)throws Exception { public int insertDepotItemWithObj(DepotItem depotItem)throws Exception {
int result =0; int result =0;
...@@ -260,14 +229,6 @@ public class DepotItemService { ...@@ -260,14 +229,6 @@ public class DepotItemService {
return result; return result;
} }
public int findByTypeAndMaterialIdAndDepotId(String type, Long mId, Long depotId) {
if(type.equals(TYPE)) {
return depotItemMapperEx.findByTypeAndDepotIdAndMaterialIdIn(depotId, mId);
} else {
return depotItemMapperEx.findByTypeAndDepotIdAndMaterialIdOut(depotId, mId);
}
}
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId)throws Exception { public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId)throws Exception {
List<DepotItemVo4WithInfoEx> list =null; List<DepotItemVo4WithInfoEx> list =null;
try{ try{
...@@ -298,69 +259,8 @@ public class DepotItemService { ...@@ -298,69 +259,8 @@ public class DepotItemService {
return result; return result;
} }
public BigDecimal findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception {
BigDecimal result=null;
try{
if (TYPE.equals(type)) {
if (isPrev) {
result= depotItemMapperEx.findByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
result= depotItemMapperEx.findByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public BigDecimal findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception {
BigDecimal result=null;
try{
if (TYPE.equals(type)) {
if (isPrev) {
result= depotItemMapperEx.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
result= depotItemMapperEx.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public BigDecimal findAssembleByType(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception {
BigDecimal result=null;
try{
if (isPrev) {
result= depotItemMapperEx.findAssembleIsPrev(subType, mType, ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findAssembleIsNotPrev(subType, mType, ProjectId, MId, MonthTime);
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) throws Exception{ public BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) throws Exception{
BigDecimal result=null; BigDecimal result= BigDecimal.ZERO;
try{ try{
if (SUM_TYPE.equals(sumType)) { if (SUM_TYPE.equals(sumType)) {
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, MonthTime, sumType); result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
...@@ -380,7 +280,7 @@ public class DepotItemService { ...@@ -380,7 +280,7 @@ public class DepotItemService {
* 这里重点重申一下:BasicNumber=OperNumber*ratio * 这里重点重申一下:BasicNumber=OperNumber*ratio
* */ * */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String saveDetials(String inserted, String deleted, String updated, Long headerId) throws Exception{ public String saveDetials(String inserted, String deleted, String updated, Long headerId, Long tenantId) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_ITEM, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_ITEM,
BusinessConstants.LOG_OPERATION_TYPE_ADD, BusinessConstants.LOG_OPERATION_TYPE_ADD,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
...@@ -525,12 +425,14 @@ public class DepotItemService { ...@@ -525,12 +425,14 @@ public class DepotItemService {
if(material==null){ if(material==null){
continue; continue;
} }
if(getCurrentInStock(depotItem.getMaterialid(),depotItem.getDepotid())<(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()){ BigDecimal stock = getStockByParam(depotItem.getDepotid(),depotItem.getMaterialid(),null,null,tenantId);
BigDecimal thisBasicNumber = depotItem.getBasicnumber()==null?BigDecimal.ZERO:depotItem.getBasicnumber();
if(stock.compareTo(thisBasicNumber)<0){
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE, throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE,
String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName())); String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName()));
} }
/**出库时处理序列号*/ /**出库时处理序列号*/
if(!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())) { if(!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())) {
/** /**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过 * 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
...@@ -648,14 +550,16 @@ public class DepotItemService { ...@@ -648,14 +550,16 @@ public class DepotItemService {
} }
/**出库时处理序列号*/ /**出库时处理序列号*/
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){ if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){
if(getCurrentInStock(depotItem.getMaterialid(),depotItem.getDepotid())<(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()){ BigDecimal stock = getStockByParam(depotItem.getDepotid(),depotItem.getMaterialid(),null,null,tenantId);
BigDecimal thisBasicNumber = depotItem.getBasicnumber()==null?BigDecimal.ZERO:depotItem.getBasicnumber();
if(stock.compareTo(thisBasicNumber)<0){
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE, throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE,
String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName())); String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName()));
} }
if(!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())) { if(!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())) {
/** /**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过 * 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */ * */
if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())) { if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())) {
//查询单据子表中开启序列号的数据列表 //查询单据子表中开启序列号的数据列表
serialNumberService.checkAndUpdateSerialNumber(depotItem, userInfo); serialNumberService.checkAndUpdateSerialNumber(depotItem, userInfo);
...@@ -687,17 +591,7 @@ public class DepotItemService { ...@@ -687,17 +591,7 @@ public class DepotItemService {
} }
return unitName; return unitName;
} }
/**
* 查询商品当前库存数量是否充足,
*
* */
public int getCurrentInStock(Long materialId, Long depotId){
//入库数量
int inSum = findByTypeAndMaterialIdAndDepotId(BusinessConstants.DEPOTHEAD_TYPE_STORAGE, materialId, depotId);
//出库数量
int outSum = findByTypeAndMaterialIdAndDepotId(BusinessConstants.DEPOTHEAD_TYPE_OUT, materialId ,depotId);
return (inSum-outSum);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotItemByIds(String ids)throws Exception { public int batchDeleteDepotItemByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_ITEM, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_ITEM,
...@@ -749,4 +643,45 @@ public class DepotItemService { ...@@ -749,4 +643,45 @@ public class DepotItemService {
BigDecimal count = depotItemMapperEx.getFinishNumber(mid, linkNumber); BigDecimal count = depotItemMapperEx.getFinishNumber(mid, linkNumber);
return count; return count;
} }
/**
* 库存统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getStockByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
BigDecimal intNum = stockObj.getInNum();
BigDecimal outNum = stockObj.getOutNum();
return intNum.subtract(outNum);
}
/**
* 入库统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getInNumByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
return stockObj.getInNum();
}
/**
* 出库统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getOutNumByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
return stockObj.getOutNum();
}
} }
...@@ -53,6 +53,11 @@ ...@@ -53,6 +53,11 @@
<result column="BasicLinjieNumber" jdbcType="DECIMAL" property="BasicLinjieNumber" /> <result column="BasicLinjieNumber" jdbcType="DECIMAL" property="BasicLinjieNumber" />
</resultMap> </resultMap>
<resultMap id="StockMap" type="com.jsh.erp.datasource.vo.DepotItemVo4Stock">
<result column="in_stock" jdbcType="DECIMAL" property="inNum" />
<result column="out_stock" jdbcType="DECIMAL" property="outNum" />
</resultMap>
<select id="selectByConditionDepotItem" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap"> <select id="selectByConditionDepotItem" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap">
select * select *
FROM jsh_depotitem FROM jsh_depotitem
...@@ -113,27 +118,6 @@ ...@@ -113,27 +118,6 @@
and ifnull(dh.delete_Flag,'0') !='1' and ifnull(dh.delete_Flag,'0') !='1'
</select> </select>
<select id="findStockNumByMaterialIdList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultAndMaterialMap">
select di.*,m.Name mName,m.Model mModel from jsh_depotitem di
inner join jsh_material m on di.MaterialId=m.Id and ifnull(m.delete_Flag,'0') !='1'
where 1=1
<if test="mId != null">
and di.MaterialId=${mId}
</if>
and ifnull(di.delete_Flag,'0') !='1'
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="findStockNumByMaterialIdCounts" resultType="java.lang.Long">
select count(*) from jsh_depotitem where 1=1
<if test="mId != null">
and MaterialId=${mId}
</if>
and ifnull(delete_Flag,'0') !='1'
</select>
<select id="findByTypeAndMaterialIdIn" resultType="java.lang.Long"> <select id="findByTypeAndMaterialIdIn" resultType="java.lang.Long">
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1' INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
...@@ -151,23 +135,6 @@ ...@@ -151,23 +135,6 @@
and ifnull(dh.delete_Flag,'0') !='1' and ifnull(dh.delete_Flag,'0') !='1'
</select> </select>
<select id="findByTypeAndDepotIdAndMaterialIdIn" resultType="java.lang.Integer">
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type='入库'
and di.MaterialId = ${mId} and di.DepotId = ${depotId}
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select id="findByTypeAndDepotIdAndMaterialIdOut" resultType="java.lang.Integer">
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type='出库'
and dh.SubType!='调拨'
and di.MaterialId = ${mId} and di.DepotId = ${depotId}
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select id="getDetailList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap"> <select id="getDetailList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
select di.*,m.Name MName,m.Model MModel,m.Unit MaterialUnit,m.Color MColor,m.Standard MStandard,m.Mfrs MMfrs, select di.*,m.Name MName,m.Model MModel,m.Unit MaterialUnit,m.Color MColor,m.Standard MStandard,m.Mfrs MMfrs,
m.OtherField1 MOtherField1,m.OtherField2 MOtherField2,m.OtherField3 MOtherField3, m.OtherField1 MOtherField1,m.OtherField2 MOtherField2,m.OtherField3 MOtherField3,
...@@ -217,129 +184,6 @@ ...@@ -217,129 +184,6 @@
group by m.id) cc group by m.id) cc
</select> </select>
<select id="findByTypeInIsPrev" resultType="java.math.BigDecimal">
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and
((dh.type='入库' and di.DepotId=${ProjectId})
or
(dh.SubType='调拨' and di.AnotherDepotId=${ProjectId})
or
(di.AnotherDepotId=${ProjectId}))
and di.MaterialId = ${MId}
and dh.OperTime &lt; '${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findByTypeInIsNotPrev" resultType="java.math.BigDecimal">
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and
((dh.type='入库' and di.DepotId=${ProjectId})
or
(dh.SubType='调拨' and di.AnotherDepotId=${ProjectId})
or
(di.AnotherDepotId=${ProjectId}))
and di.MaterialId = ${MId} and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findByTypeOutIsPrev" resultType="java.math.BigDecimal">
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
and dh.type='出库'
and di.DepotId= ${ProjectId}
and di.MaterialId = ${MId}
and dh.OperTime &lt; '${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findByTypeOutIsNotPrev" resultType="java.math.BigDecimal">
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and dh.type='出库'
and di.DepotId= ${ProjectId}
and di.MaterialId = ${MId}
and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findPriceByTypeInIsPrev" resultType="java.math.BigDecimal">
select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and
((dh.type='入库' and di.DepotId=${ProjectId})
or
(dh.SubType='调拨' and di.AnotherDepotId=${ProjectId})
or
(di.AnotherDepotId=${ProjectId}))
and di.MaterialId = ${MId}
and dh.OperTime &lt; '${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findPriceByTypeInIsNotPrev" resultType="java.math.BigDecimal">
select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and
((dh.type='入库' and di.DepotId=${ProjectId})
or
(dh.SubType='调拨' and di.AnotherDepotId=${ProjectId})
or
(di.AnotherDepotId=${ProjectId}))
and di.MaterialId = ${MId} and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findPriceByTypeOutIsPrev" resultType="java.math.BigDecimal">
select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and dh.type='出库'
and di.DepotId= ${ProjectId}
and di.MaterialId = ${MId}
and dh.OperTime &lt; '${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findPriceByTypeOutIsNotPrev" resultType="java.math.BigDecimal">
select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and dh.type='出库'
and di.DepotId= ${ProjectId}
and di.MaterialId = ${MId}
and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findAssembleIsPrev" resultType="java.math.BigDecimal">
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
and dh.SubType= '${subType}'
and di.MType= '${mType}'
and di.MaterialId = ${MId}
and dh.OperTime &lt; '${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="findAssembleIsNotPrev" resultType="java.math.BigDecimal">
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
and dh.SubType= '${subType}'
and di.MType= '${mType}'
and di.MaterialId = ${MId}
and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="buyOrSaleNumber" resultType="java.math.BigDecimal"> <select id="buyOrSaleNumber" resultType="java.math.BigDecimal">
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id where di.HeaderId = dh.id
...@@ -362,24 +206,33 @@ ...@@ -362,24 +206,33 @@
and ifnull(di.delete_Flag,'0') !='1' and ifnull(di.delete_Flag,'0') !='1'
</select> </select>
<select id="findGiftByTypeIn" resultType="java.math.BigDecimal"> <select id="getStockByParam" resultMap="StockMap">
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh select ifnull((curep.inTotal+curep.transfInTotal+curep.assemInTotal+curep.disAssemInTotal),0) as in_stock,
where di.HeaderId = dh.id ifnull((curep.transfOutTotal+curep.outTotal+curep.assemOutTotal+curep.disAssemOutTotal),0) out_stock
and dh.SubType='${subType}' from
and di.AnotherDepotId=${ProjectId} (select sum(if(dh.type='入库' <if test="depotId != null">and di.DepotId=#{depotId}</if>, di.BasicNumber,0)) as inTotal,
and di.MaterialId =${MId} sum(if(dh.SubType='调拨' <if test="depotId != null">and di.AnotherDepotId=#{depotId}</if>,di.BasicNumber,0)) as transfInTotal,
and ifnull(dh.delete_Flag,'0') !='1' sum(if(dh.SubType='调拨' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as transfOutTotal,
and ifnull(di.delete_Flag,'0') !='1' sum(if(dh.type='出库' and dh.SubType!='调拨' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as outTotal,
</select> sum(if(dh.SubType='组装单' and di.MType='组合件' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as assemInTotal,
sum(if(dh.SubType='组装单' and di.MType='普通子件' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as assemOutTotal,
<select id="findGiftByTypeOut" resultType="java.math.BigDecimal"> sum(if(dh.SubType='拆卸单' and di.MType='普通子件' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as disAssemInTotal,
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh sum(if(dh.SubType='拆卸单' and di.MType='组合件' <if test="depotId != null"> and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as disAssemOutTotal
where di.HeaderId = dh.id from
and dh.SubType='${subType}' jsh_depothead dh,jsh_depotitem di
and di.DepotId=${ProjectId} where 1=1
and di.MaterialId =${MId} and dh.id=di.HeaderId
and di.MaterialId=#{mId}
<if test="beginTime != null">
and dh.OperTime &gt;= '${beginTime}'
</if>
<if test="endTime != null">
and dh.OperTime &lt;= '${endTime}'
</if>
and dh.tenant_id=#{tenantId}
and di.tenant_id=#{tenantId}
and ifnull(dh.delete_Flag,'0') !='1' and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1' and ifnull(di.delete_Flag,'0') !='1') as curep
</select> </select>
<select id="findDepotItemListBydepotheadId" resultType="com.jsh.erp.datasource.entities.DepotItem"> <select id="findDepotItemListBydepotheadId" resultType="com.jsh.erp.datasource.entities.DepotItem">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment