Commit 7af1919d authored by 耿迪迪's avatar 耿迪迪

库存变化

parent 25dfb6b3
......@@ -2,7 +2,7 @@ package com.zehong.web.controller.track;
import java.util.List;
import com.zehong.system.domain.vo.InHouseVo;
import com.zehong.system.domain.vo.HouseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -115,7 +115,7 @@ public class TProductStoreController extends BaseController
* @return
*/
@PostMapping("/inHouse")
public AjaxResult inHouse(@RequestBody List<InHouseVo> storeInfo){
return toAjax(tProductStoreService.inHouse(storeInfo));
public AjaxResult inHouse(@RequestBody List<HouseVo> storeInfo){
return toAjax(tProductStoreService.inHouse(storeInfo,true));
}
}
......@@ -105,6 +105,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
"/**/*.css",
"/**/*.js"
).permitAll()
.antMatchers("/track/store/**").permitAll()
.antMatchers("/profile/**").anonymous()
.antMatchers("/common/download**").anonymous()
.antMatchers("/common/download/resource**").anonymous()
......
package com.zehong.system.service.impl.track;
import java.util.Date;
import java.util.List;
import com.zehong.common.exception.CustomException;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TProductInspectDetailMapper;
import com.zehong.system.domain.track.TProductInspectDetail;
import com.zehong.system.domain.track.TProductStore;
import com.zehong.system.domain.vo.HouseVo;
import com.zehong.system.mapper.TProductInspectDetailMapper;
import com.zehong.system.service.track.ITProductInspectDetailService;
import com.zehong.system.service.track.ITProductStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 生产执行中间Service业务层处理
......@@ -22,6 +31,9 @@ public class TProductInspectDetailServiceImpl implements ITProductInspectDetailS
@Autowired
private TProductInspectDetailMapper tProductInspectDetailMapper;
@Autowired
private ITProductStoreService itProductStoreService;
/**
* 查询生产执行中间
*
......@@ -79,8 +91,20 @@ public class TProductInspectDetailServiceImpl implements ITProductInspectDetailS
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteTProductInspectDetailByIds(Long[] ids)
{
List<HouseVo> storeInfo = new ArrayList<>();
for(Long id : ids){
TProductInspectDetail detail = tProductInspectDetailMapper.selectTProductInspectDetailById(id);
if(2 == detail.getType()){
HouseVo house = new HouseVo();
house.setId(detail.getTypeId());
house.setNum(detail.getNumber());
storeInfo.add(house);
}
}
if(!CollectionUtils.isEmpty(storeInfo)) itProductStoreService.inHouse(storeInfo,false);
return tProductInspectDetailMapper.deleteTProductInspectDetailByIds(ids);
}
......@@ -102,10 +126,50 @@ public class TProductInspectDetailServiceImpl implements ITProductInspectDetailS
* @return
*/
public int batchAddDetailInfo(List<TProductInspectDetail> productInspectDetailList){
validateDetailInfo(productInspectDetailList);
for(TProductInspectDetail detail : productInspectDetailList){
detail.setCreateTime(new Date());
detail.setCreateId(SecurityUtils.getLoginUser().getUser().getUserId());
}
synchronized (this){
return subtractStoreStock(productInspectDetailList);
}
}
/**
* 详情校验
* @param productInspectDetailList
*/
private void validateDetailInfo(List<TProductInspectDetail> productInspectDetailList){
//校验图库和模版是否存在
List<TProductInspectDetail> detailList = productInspectDetailList.stream().filter(item -> (1 == item.getType() || 3 == item.getType())).collect(Collectors.toList());
for(TProductInspectDetail detail :detailList){
TProductInspectDetail tProductInspectDetail = new TProductInspectDetail();
tProductInspectDetail.setTypeId(detail.getTypeId());
tProductInspectDetail.setType(detail.getType());
List<TProductInspectDetail> detailInfo = tProductInspectDetailMapper.selectTProductInspectDetailList(tProductInspectDetail);
if(!CollectionUtils.isEmpty(detailInfo)){
throw new CustomException((1 == detailInfo.get(0).getType() ? "图纸" : "装配模版") + detailInfo.get(0).getTypeName() + "已存在");
}
}
}
/**
* 扣出库存
* @param productInspectDetailList
* @return
*/
@Transactional(rollbackFor = Exception.class)
public int subtractStoreStock(List<TProductInspectDetail> productInspectDetailList){
List<TProductInspectDetail> storeList = productInspectDetailList.stream().filter(item -> 2 == item.getType()).collect(Collectors.toList());
for(TProductInspectDetail detail : storeList){
TProductStore store = itProductStoreService.selectTProductStoreById(detail.getTypeId());
if(store.getTotal().compareTo(detail.getNumber()) == -1){
throw new CustomException(store.getTitle() + "库存不足");
}
store.setTotal(store.getTotal() - detail.getNumber());
itProductStoreService.updateTProductStore(store);
}
return tProductInspectDetailMapper.batchAddDetailInfo(productInspectDetailList);
}
}
......@@ -2,9 +2,10 @@ package com.zehong.system.service.impl.track;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.system.domain.track.TProductInspectDetail;
import com.zehong.system.domain.track.TProductStore;
import com.zehong.system.domain.track.TProductStoreLog;
import com.zehong.system.domain.vo.InHouseVo;
import com.zehong.system.domain.vo.HouseVo;
import com.zehong.system.mapper.track.TProductStoreMapper;
import com.zehong.system.service.track.ITProductStoreLogService;
import com.zehong.system.service.track.ITProductStoreService;
......@@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -112,20 +114,35 @@ public class TProductStoreServiceImpl implements ITProductStoreService
/**
* 配件批量入库
* @param storeInfo 配件信息
* @param isAddLog 是否插入日志
* @return
*/
@Override
public int inHouse(List<HouseVo> storeInfo,boolean isAddLog){
synchronized (this){
addStoreStock(storeInfo,isAddLog);
}
return 1;
}
/**
* 增加库存
* @param storeInfo
* @param isAddLog
*/
@Transactional(rollbackFor = Exception.class)
public int inHouse(List<InHouseVo> storeInfo){
for(InHouseVo house : storeInfo){
public void addStoreStock(List<HouseVo> storeInfo,boolean isAddLog){
for(HouseVo house : storeInfo){
TProductStore store = tProductStoreMapper.selectTProductStoreById(house.getId());
store.setTotal(store.getTotal() + house.getNum());
tProductStoreMapper.updateTProductStore(store);
TProductStoreLog log = new TProductStoreLog();
log.setNumber(house.getNum());
log.setStoreId(house.getId());
itProductStoreLogService.insertTProductStoreLog(log);
if(isAddLog){
TProductStoreLog log = new TProductStoreLog();
log.setNumber(house.getNum());
log.setStoreId(house.getId());
itProductStoreLogService.insertTProductStoreLog(log);
}
}
return 1;
}
}
package com.zehong.system.service.track;
import java.util.List;
import com.zehong.system.domain.track.TProductInspectDetail;
import com.zehong.system.domain.track.TProductStore;
import com.zehong.system.domain.vo.InHouseVo;
import com.zehong.system.domain.vo.HouseVo;
/**
* 配件Service接口
......@@ -63,7 +65,9 @@ public interface ITProductStoreService
/**
* 配件批量入库
* @param storeInfo 配件信息
* @param isAddLog 是否记录日志
* @return
*/
int inHouse(List<InHouseVo> storeInfo);
int inHouse(List<HouseVo> storeInfo,boolean isAddLog);
}
......@@ -43,6 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null "> and type = #{type}</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
</where>
order by create_time desc
</select>
<select id="selectTProductInspectDetailById" parameterType="Long" resultMap="TProductInspectDetailResult">
......
......@@ -41,7 +41,7 @@
</div>
<div class="execute-detail-info">
<el-input type="number" v-model.number="item.number" placeholder="请输入数量" size="small"/>
<el-input :disabled="item.type != 2" type="number" v-model.number="item.number" placeholder="请输入数量" size="small"/>
</div>
<div class="execute-detail-operate">
......@@ -138,7 +138,7 @@
}
},
submitStore(){
this.validateData();
if(this.validateData()) return;
batchAddDetailInfo(this.detailInfoList).then(res =>{
if(res.code == 200){
this.executeDetailOpen = false;
......@@ -150,23 +150,29 @@
validateData(){
//检查信息是否完整
for(var i = 0; i< this.detailInfoList.length; i++){
if(!(this.detailInfoList[i].typeId && this.detailInfoList[i].number && this.detailInfoList[i].type)){
console.log("=============================",(this.detailInfoList[i].typeId && this.detailInfoList[i].type))
if(!(this.detailInfoList[i].typeId && this.detailInfoList[i].type && this.detailInfoList[i].number) && 2 == this.detailInfoList[i].type){
console.log("=============================")
this.$message.error("请检查信息是否填完整");
return
return true;
}
if(!(this.detailInfoList[i].typeId && this.detailInfoList[i].type) && 2 !== this.detailInfoList[i].type){
this.$message.error("请检查信息是否填完整");
return true;
}
}
if(this.detailInfoList.findIndex(item => item.type == '1') == -1){
/*if(this.detailInfoList.findIndex(item => item.type == '1') == -1){
this.$message.error("未选择图纸");
return
return true;
}
if(this.detailInfoList.findIndex(item => item.type == '2') == -1){
this.$message.error("未选择配件");
return
return true;
}
if(this.detailInfoList.findIndex(item => item.type == '3') == -1){
this.$message.error("未选择装配模版");
return
}
return true;
}*/
},
cancel(){
this.executeDetailOpen = false;
......
......@@ -24,7 +24,7 @@
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<!-- <el-col :span="1.5">
<el-button
type="success"
plain
......@@ -33,7 +33,7 @@
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
</el-col>-->
<el-col :span="1.5">
<el-button
type="danger"
......@@ -68,17 +68,23 @@
</template>
</el-table-column>
<el-table-column label="名称" align="center" prop="typeName" />
<el-table-column label="配件数量" align="center" prop="number" />
<el-table-column label="配件数量" align="center" prop="number">
<template slot-scope="scope">
<span v-if="scope.row.type == '2'">{{ scope.row.number }}</span>
<span v-else>-</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" />
<el-table-column label="创建人" align="center" prop="createBy" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
<!-- <el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
>修改</el-button>-->
<el-button
size="mini"
type="text"
......@@ -135,7 +141,7 @@
/>
</el-select>
</el-form-item>
<el-form-item label="配件数量" prop="number">
<el-form-item label="配件数量" prop="number" v-if="form.type == 2">
<el-input type="number" v-model="form.number" placeholder="请输入配件数量" />
</el-form-item>
</el-form>
......
......@@ -5,7 +5,7 @@
<RecordInfo tab="import" :id="storeInfo.id" v-if="activeName == 'import'"/>
</el-tab-pane>
<el-tab-pane label="出库记录" name="export">
出库记录
<RecordInfo tab="export" :id="storeInfo.id" v-if="activeName == 'export'"/>
</el-tab-pane>
</el-tabs>
</el-dialog>
......
......@@ -18,6 +18,7 @@
<script>
import { listLog } from "@/api/track/storeLog.js";
import { listDetail } from "@/api/track/executeDetail";
export default {
name: "record-info",
props:{
......@@ -42,7 +43,6 @@
}
},
created(){
this.queryParams.storeId = this.id;
this.getList();
},
methods:{
......@@ -50,13 +50,14 @@
if(this.tab == 'import'){
this.getImportRecord();
}else{
this.getExportRecord();
}
},
//入库信息
getImportRecord(){
this.loading = true;
this.queryParams.storeId = this.id;
listLog(this.queryParams).then(res =>{
this.loading = false;
if(res.code == 200){
......@@ -67,7 +68,16 @@
},
//出库记录
getExportRecord(){
this.loading = true;
this.queryParams.typeId = this.id;
this.queryParams.type = 2;
listDetail(this.queryParams).then(res =>{
this.loading = false;
if(res.code == 200){
this.total = res.total;
this.recordList = res.rows;
}
})
}
}
}
......
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 to comment