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

库存变化

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