Merge branch 'dev-cq' of http://192.168.0.56:3000/bonus/devicesmgt into dev-cq

This commit is contained in:
BianLzhaoMin 2024-07-29 11:49:32 +08:00
commit 6797a94659
22 changed files with 730 additions and 201 deletions

View File

@ -23,6 +23,9 @@
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
@ -117,4 +120,4 @@
</plugins>
</build>
</project>
</project>

View File

@ -1,19 +1,30 @@
package com.bonus.sgzb.base.controller;
import com.bonus.sgzb.base.domain.MaPartType;
import com.bonus.sgzb.base.service.ExcelService;
import com.bonus.sgzb.base.service.IPartTypeService;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
;
@ -32,25 +43,32 @@ public class MaPartTypeController extends BaseController {
@Autowired
private IPartTypeService maPartTypeService;
@Autowired
private ExcelService excelService;
private static final String UPLOAD_DIR = "D:/work/wcy";
/**
* 查询配件类型列表
*
* @param maPartType
* @return
*/
@GetMapping("/list")
public AjaxResult list(MaPartType maPartType)
{
public AjaxResult list(MaPartType maPartType) {
List<MaPartType> list = maPartTypeService.selectMaPartList(maPartType);
return AjaxResult.success(list);
}
/**
* 新增配件管理
*
* @param maPartType
* @return
*/
@PostMapping
public AjaxResult add(@Validated @RequestBody MaPartType maPartType){
public AjaxResult add(@Validated @RequestBody MaPartType maPartType) {
if (!maPartTypeService.checkPaNameUnique(maPartType)) {
return error("新增配件名称'" + maPartType.getPaName() + "'失败,配件名称已存在");
}
@ -60,53 +78,84 @@ public class MaPartTypeController extends BaseController {
/**
* 导出配件类型管理
*
* @param response
* @param maPartType
*/
@PostMapping("/export")
public void export(HttpServletResponse response, MaPartType maPartType)
{
public void export(HttpServletResponse response, MaPartType maPartType) {
List<MaPartType> list = maPartTypeService.selectMyPartTypeList(maPartType);
ExcelUtil<MaPartType> util = new ExcelUtil<MaPartType>(MaPartType.class);
util.exportExcel(response, list, "配件类型管理数据");
}
/**
* 删除配件管理类型
* @param paId
* @return
*/
@DeleteMapping("/{paId}")
public AjaxResult delete(@PathVariable("paId") Long paId){
if (maPartTypeService.hasChildBypaId(paId))
{
return warn("存在下级仓库列表,不允许删除");
@PostMapping("/readExcel")
public AjaxResult readExcelFile(@RequestParam("file") MultipartFile file) throws IOException {
// 创建上传目录如果不存在的话
File dir = new File(UPLOAD_DIR);
if (!dir.exists()) {
dir.mkdirs();
}
return toAjax(maPartTypeService.deletePaById(paId));
// 获取文件名
String fileName = file.getOriginalFilename();
// 定义文件路径
Path filePath = Paths.get(UPLOAD_DIR, fileName);
// 保存文件
file.transferTo(filePath.toFile());
Map<String, Map<String, List<String>>> stringMapMap = excelService.readExcelFile(filePath.toString());
return AjaxResult.success();
}
/**
* 根据id获取数据
* @param paId
* @return
*/
@GetMapping("/{paId}")
public AjaxResult getById(@PathVariable("paId") Long paId){
MaPartType bean = maPartTypeService.getById(paId);
return AjaxResult.success(bean);
}
/**
* 根据id修改数据
* @param maPartType
* @return
*/
@PostMapping("/updateById")
public AjaxResult updateById(@RequestBody MaPartType maPartType){
maPartType.setUpdateBy(SecurityUtils.getUsername());
return toAjax(maPartTypeService.updateById(maPartType));
@PostMapping("/downLoad")
public void downLoadExcelFile() throws IOException {
HttpServletResponse resp = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
maPartTypeService.downLoadTemplate(resp);
}
}
/**
* poi
* 删除配件管理类型
*
* @param paId
* @return
*/
@DeleteMapping("/{paId}")
public AjaxResult delete (@PathVariable("paId") Long paId){
if (maPartTypeService.hasChildBypaId(paId)) {
return warn("存在下级仓库列表,不允许删除");
}
return toAjax(maPartTypeService.deletePaById(paId));
}
/**
* 根据id获取数据
*
* @param paId
* @return
*/
@GetMapping("/{paId}")
public AjaxResult getById (@PathVariable("paId") Long paId){
MaPartType bean = maPartTypeService.getById(paId);
return AjaxResult.success(bean);
}
/**
* 根据id修改数据
*
* @param maPartType
* @return
*/
@PostMapping("/updateById")
public AjaxResult updateById (@RequestBody MaPartType maPartType){
maPartType.setUpdateBy(SecurityUtils.getUsername());
return toAjax(maPartTypeService.updateById(maPartType));
}
}

View File

@ -86,5 +86,9 @@ public class MaPartType extends BaseEntity {
// @Excel(name = "年份")
private String year;
private String firstLevel;
}

View File

@ -0,0 +1,19 @@
package com.bonus.sgzb.base.mapper;
import com.bonus.sgzb.base.domain.MaPartType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ExcelMapper {
String selectPaName(@Param("firstLevel") String firstLevel);
int insertPaName(MaPartType firstLevel);
void insertPaTwoName(MaPartType maPartType);
void insertPaThreeName(MaPartType maPartType);
}

View File

@ -0,0 +1,11 @@
package com.bonus.sgzb.base.service;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
public interface ExcelService {
Map<String, Map<String, List<String>>> readExcelFile(String filePath);
}

View File

@ -3,6 +3,8 @@ package com.bonus.sgzb.base.service;
import com.bonus.sgzb.base.domain.MaPartType;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
@ -58,6 +60,9 @@ public interface IPartTypeService {
MaPartType getById(Long paId);
int updateById(MaPartType maPartType);
void downLoadTemplate(HttpServletResponse resp) throws IOException;
}

View File

@ -0,0 +1,164 @@
package com.bonus.sgzb.base.service.impl;// ExcelServiceImpl.java
import com.bonus.sgzb.base.domain.MaPartType;
import com.bonus.sgzb.base.mapper.ExcelMapper;
import com.bonus.sgzb.base.service.ExcelService;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
@Service
public class ExcelServiceImpl implements ExcelService {
@Autowired
ExcelMapper excelMapper;
/*
* 将读取的excel文件转为
* */
@Override
public Map<String, Map<String, List<String>>> readExcelFile(String filePath) {
FileInputStream excelFile = null;
Workbook workbook = null;
try {
excelFile = new FileInputStream(new File(filePath));
workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = datatypeSheet.iterator();
String fourthLevel = "";
String fifthLevel ="";
Long id = null;
Map<String, Map<String, List<String>>> level3Relation = new HashMap<>();
while (iterator.hasNext()) {
Row currentRow = iterator.next();
if (currentRow.getRowNum() == 0) {
// 跳过标题行
continue;
}
Cell firstLevelCell = currentRow.getCell(1);
Cell secondLevelCell = currentRow.getCell(2);
Cell thirdLevelCell = currentRow.getCell(3);
Cell fourthLevelCell = currentRow.getCell(4);
Cell fifthLevelCell = currentRow.getCell(5);
String firstLevel = getCellValueAsString(firstLevelCell);
String secondLevel = getCellValueAsString(secondLevelCell);
String thirdLevel = getCellValueAsString(thirdLevelCell);
fourthLevel = getCellValueAsString(fourthLevelCell);
fifthLevel = getCellValueAsString(fifthLevelCell);
level3Relation.computeIfAbsent(firstLevel, k -> new HashMap<>())
.computeIfAbsent(secondLevel, k -> new ArrayList<>())
.add(thirdLevel);
}
// 遍历外层Map
for (Map.Entry<String, Map<String, List<String>>> entry1 : level3Relation.entrySet()) {
String firstLevel = entry1.getKey(); // 获取第一层级的键
String parentId = excelMapper.selectPaName(firstLevel);
//产生返回值并且进行判断是否是pa_name列已经有的并且返回对应的pa_id
if(parentId == null || parentId == ""){
MaPartType maPartType = new MaPartType();
maPartType.setPaName(firstLevel);
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据并且读取到parent_id
id = maPartType.getPaId();
}
//
Map<String, List<String>> secondLevelMap = entry1.getValue(); // 获取对应于第一层级键的内层Map
// 遍历内层Map
for (Map.Entry<String, List<String>> entry2 : secondLevelMap.entrySet()) {
String secondLevel = entry2.getKey(); // 获取第二层级的键
String parentIdTwo = excelMapper.selectPaName(secondLevel);
//产生返回值并且进行判断是否是pa_name列已经有的并且返回对应的pa_id
if(parentIdTwo == null || parentIdTwo == ""){
MaPartType maPartType = new MaPartType();
maPartType.setPaName(secondLevel);
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
maPartType.setParentId(id);
excelMapper.insertPaTwoName(maPartType);//第二层在数据库中查询不到则插入数据则插入时候设置关联关系
id = maPartType.getPaId();
}
//从数据库中查询
String thirdLevel = entry2.getValue().get(0); // 获取对应于第二层级键的值即第三层级的列表
String parentThreeId = excelMapper.selectPaName(thirdLevel);
if(parentThreeId == null || parentThreeId == ""){
MaPartType maPartType = new MaPartType();
maPartType.setPaName(thirdLevel);
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
maPartType.setUnitId(fourthLevel);
maPartType.setBuyPrice(fifthLevel);
maPartType.setParentId(id);
excelMapper.insertPaThreeName(maPartType);//第二层在数据库中查询不到则插入数据则插入时候设置关联关系
}
}
}
return level3Relation;
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("Error reading Excel file", e);
} finally {
if (workbook != null) {
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (excelFile != null) {
try {
excelFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
private String getCellValueAsString(Cell cell) {
if (cell == null) return "";
switch (cell.getCellType()) {
case STRING:
return cell.getStringCellValue();
case NUMERIC:
return String.valueOf(cell.getNumericCellValue());
case BOOLEAN:
return String.valueOf(cell.getBooleanCellValue());
case FORMULA:
return cell.getCellFormula();
case BLANK:
return "";
default:
return "";
}
}
}

View File

@ -5,10 +5,20 @@ import com.bonus.sgzb.base.mapper.MaPartTypeMapper;
import com.bonus.sgzb.base.service.IPartTypeService;
import com.bonus.sgzb.common.core.constant.UserConstants;
import com.bonus.sgzb.common.core.utils.StringUtils;
import org.apache.commons.io.IOUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
/**
* 配件类型管理ma_part_type(MaPartType)表服务实现类
@ -21,8 +31,10 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
@Autowired
private MaPartTypeMapper maPartTypeMapper;
/**
* 校验配件名称唯一性
*
* @param maPartType
* @return
*/
@ -30,8 +42,7 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
public boolean checkPaNameUnique(MaPartType maPartType) {
Long paId = StringUtils.isNull(maPartType.getPaId()) ? -1L : maPartType.getPaId();
MaPartType info = maPartTypeMapper.checkPartNameUnique(maPartType.getPaId());
if (StringUtils.isNotNull(info) && info.getPaId().longValue() != paId.longValue())
{
if (StringUtils.isNotNull(info) && info.getPaId().longValue() != paId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@ -39,6 +50,7 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
/**
* 新增配件管理
*
* @param maPartType
* @return
*/
@ -50,6 +62,7 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
/**
* 查询配件类型列表
*
* @param maPartType
* @return
*/
@ -60,6 +73,7 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
/**
* 导出配件管理类型
*
* @param maPartType
* @return
*/
@ -70,6 +84,7 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
/**
* 查询是否含有子集
*
* @param paId
* @return
*/
@ -81,6 +96,7 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
/**
* 删除配件类型
*
* @param paId
* @return
*/
@ -98,5 +114,38 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
public int updateById(MaPartType maPartType) {
return maPartTypeMapper.updateById(maPartType);
}
}
@Override
public void downLoadTemplate(HttpServletResponse response) throws IOException {
//模板名称
String templateName = "template.xlsx";
OutputStream out = null;
InputStream input =null;
try {
ApplicationHome h = new ApplicationHome(getClass());
String dirPath = h.getSource().toString();
String fileName = dirPath+"/template/"+templateName;
File outFile = new File(fileName);
input = new BufferedInputStream(new FileInputStream(outFile));
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment;filename=" + new String((templateName).getBytes(), "iso-8859-1"));
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
out = response.getOutputStream();
byte[] buffer = new byte[1024]; // 缓冲区
int bytesToRead = -1;
// 通过循环将读入内容输出到浏览器中
while ((bytesToRead = input.read(buffer)) != -1) {
out.write(buffer, 0, bytesToRead);
}
} catch (IOException e) {
throw new IOException("模板下载失败");
} finally {
IOUtils.closeQuietly(input);
IOUtils.closeQuietly(out);
}
}
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.sgzb.base.mapper.ExcelMapper">
<insert id="insertPaName" keyProperty="paId" useGeneratedKeys="true">
insert into ma_part_type
(pa_name, status,level,del_flag,create_by,create_time,year)
VALUES
(#{paName}, 0 , 1, 0, #{createBy}, now(),year(now()))
</insert>
<insert id="insertPaTwoName" keyProperty="paId" useGeneratedKeys="true">
insert into ma_part_type
(pa_name, parent_id, status,level,del_flag,create_by,create_time,year)
VALUES
(#{paName}, #{parentId},0 , 2, 0, #{createBy}, now(),year(now()))
</insert>
<insert id="insertPaThreeName">
insert into ma_part_type
(pa_name, parent_id, status,level,del_flag,unit_id,buy_price,create_by,create_time,year)
VALUES
(#{paName}, #{parentId},0 , 3, 0, #{unitId}, #{buyPrice}, #{createBy}, now(),year(now()))
</insert>
<select id="selectPaName" resultType="java.lang.String">
SELECT pa_id FROM ma_part_type WHERE pa_name = #{firstLevel}
</select>
</mapper>

View File

@ -54,9 +54,10 @@ public class SecondaryWarehouseController extends BaseController {
*/
@ApiOperation(value = "出库/退库操作")
@PostMapping("/operate")
@Log(title = "二级库管理--出库退库操作", businessType = BusinessType.MATERIAL)
public AjaxResult operate(TeamLeaseInfo bean){
return toAjax(service.addOperate(bean));
@Log(title = "二级库管理--出库退库操作")
public AjaxResult operate(@RequestBody TeamLeaseInfo bean){
int i = service.addNewOperate(bean);
return toAjax(i);
}
/**

View File

@ -11,7 +11,7 @@ import lombok.Data;
@Data
public class SecondaryWarehouse {
/**
*
*
*/
private Long id;
/**
@ -100,7 +100,26 @@ public class SecondaryWarehouse {
*/
@Excel(name = "计量单位")
private String nuitName;
private String keyword;
/**
* 租赁类型 0工程1长期
*/
@Excel(name = "租赁类型")
private String leaseType;
/**
* 领用数量
*/
private Integer Num;
/**
* 领用数量
*/
private Integer receiveNum;
/**
* 库存数量
*/
private Integer stockNum;
}

View File

@ -1,8 +1,12 @@
package com.bonus.sgzb.material.domain;
import com.bonus.sgzb.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author c liu
@ -11,7 +15,7 @@ import lombok.Data;
@Data
public class TeamLeaseInfo {
/**
*
*
*/
private Long id;
/**
@ -27,6 +31,14 @@ public class TeamLeaseInfo {
*机具id
*/
private String maId;
/**
*领料人
*/
private String pickName;
/**
*出库人
*/
private String nickName;
/**
* 查询时间
*/
@ -108,5 +120,9 @@ public class TeamLeaseInfo {
*/
private String queryType;
private int outNum;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date outTime;
}

View File

@ -32,4 +32,12 @@ public interface SecondaryWarehouseMapper {
* @return
*/
List<TeamLeaseInfo> getRecordsFive(TeamLeaseInfo bean);
// List<TeamLeaseInfo> getNewRecordsFive(TeamLeaseInfo bean);
int addNewOperate(TeamLeaseInfo bean);
Integer selectStockNum(SecondaryWarehouse secondaryWarehouse);
List<TeamLeaseInfo> getNewRecords(TeamLeaseInfo bean);
}

View File

@ -12,9 +12,13 @@ import java.util.List;
public interface SecondaryWarehouseService {
List<SecondaryWarehouse> getList(SecondaryWarehouse bean);
int addOperate(TeamLeaseInfo bean);
// int addOperate(TeamLeaseInfo bean);
List<TeamLeaseInfo> getOperateList(TeamLeaseInfo bean);
List<TeamLeaseInfo> getRecords(TeamLeaseInfo bean);
// List<TeamLeaseInfo> getNewRecords(TeamLeaseInfo bean);
int addNewOperate(TeamLeaseInfo bean);
}

View File

@ -25,15 +25,24 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
@Override
public List<SecondaryWarehouse> getList(SecondaryWarehouse bean) {
return mapper.getList(bean);
List<SecondaryWarehouse> list = mapper.getList(bean);
for (SecondaryWarehouse secondaryWarehouse : list) {
Integer warehouse = mapper.selectStockNum(secondaryWarehouse);
if (warehouse == null) {
warehouse = 0;
}
secondaryWarehouse.setReceiveNum(warehouse);
secondaryWarehouse.setStockNum(secondaryWarehouse.getNum() - secondaryWarehouse.getReceiveNum());
}
return list;
}
@Override
public int addOperate(TeamLeaseInfo bean) {
Long userid = SecurityUtils.getLoginUser().getUserid();
bean.setCreateBy(String.valueOf(userid));
return mapper.addOperate(bean);
}
// @Override
// public int addOperate(TeamLeaseInfo bean) {
// Long userid = SecurityUtils.getLoginUser().getUserid();
// bean.setCreateBy(String.valueOf(userid));
// return mapper.addOperate(bean);
// }
@Override
public List<TeamLeaseInfo> getOperateList(TeamLeaseInfo bean) {
@ -42,25 +51,39 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
@Override
public List<TeamLeaseInfo> getRecords(TeamLeaseInfo bean) {
List<TeamLeaseInfo> list = new ArrayList<>();
if (STRING_1.equals(bean.getQueryType())){
//进场数量
list = mapper.getRecordsOne(bean);
} else if (STRING_2.equals(bean.getQueryType())) {
//退场数量
list = mapper.getRecordsTwo(bean);
} else if (STRING_3.equals(bean.getQueryType())) {
//场内库存
list = mapper.getRecordsThree(bean);
} else if (STRING_4.equals(bean.getQueryType())) {
//已出库数量
list = mapper.getRecordsFour(bean);
} else if (STRING_5.equals(bean.getQueryType())) {
//已退库数量
list = mapper.getRecordsFive(bean);
} else {
throw new ServiceException("查询出错");
}
return list;
// System.out.println(bean.getLeaseMan());
return mapper.getNewRecords(bean);
}
@Override
public int addNewOperate(TeamLeaseInfo bean) {
Long userid = SecurityUtils.getLoginUser().getUserid();
bean.setCreateBy(String.valueOf(userid));
return mapper.addNewOperate(bean);
}
// @Override
// public List<TeamLeaseInfo> getNewRecords(TeamLeaseInfo bean) {
// List<TeamLeaseInfo> list = new ArrayList<>();
// if (STRING_1.equals(bean.getQueryType())){
// //进场数量
// list = mapper.getRecordsOne(bean);
// } else if (STRING_2.equals(bean.getQueryType())) {
// //退场数量
// list = mapper.getRecordsTwo(bean);
// } else if (STRING_3.equals(bean.getQueryType())) {
// //场内库存
// list = mapper.getRecordsThree(bean);
// } else if (STRING_4.equals(bean.getQueryType())) {
// //已出库数量
// list = mapper.getRecordsFour(bean);
// } else if (STRING_5.equals(bean.getQueryType())) {
// //已退库数量
// list = mapper.getNewRecordsFive(bean);
// } else {
// throw new ServiceException("查询出错");
// }
// return list;
// }
}

View File

@ -11,29 +11,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getList" resultType="com.bonus.sgzb.material.domain.SecondaryWarehouse">
SELECT
bui.unit_id AS unitId,
sai.agreement_id AS agreementId,
lod.id as id,
tta.agreement_id AS agreementId,
bui.unit_name AS unitName,
bp.lot_name AS proName,
mt1.type_name AS typeName,
mt.type_name AS modelName,
mt.unit_name AS nuitName,
sai.type_id AS typeId,
SUM( sai.num ) AS jcNum,
SUM( CASE WHEN sai.`status` = '1' THEN sai.num ELSE 0 END ) AS tcNum,
SUM( CASE WHEN sai.`status` = '0' THEN sai.num ELSE 0 END ) - IFNULL( tli.num, 0 ) + IFNULL( tli2.num, 0 ) AS kcNum,
IFNULL( tli.num, 0 ) AS ckNum,
IFNULL( tli2.num, 0 ) AS zkNum
FROM
slt_agreement_info sai
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
lod.type_id AS typeId,
IFNULL(SUM( lod.out_num ),0) AS Num
from lease_out_details lod
left join lease_apply_info lai on lod.parent_id=lai.id
left join tm_task_agreement tta on lai.task_id=tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN ( SELECT SUM( num ) AS num, agreement_id, type_id FROM team_lease_info WHERE type = '1' GROUP BY agreement_id, type_id ) tli ON tli.agreement_id = sai.agreement_id
AND tli.type_id = sai.type_id
LEFT JOIN ( SELECT SUM( num ) AS num, agreement_id, type_id FROM team_lease_info WHERE type = '2' GROUP BY agreement_id, type_id ) tli2 ON tli2.agreement_id = sai.agreement_id
AND tli2.type_id = sai.type_id
WHERE 1=1
<if test="unitId != null and unitId != ''">
and bui.unit_id = #{unitId}
@ -47,6 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modelId != null and modelId != ''">
and mt.type_id = #{modelId}
</if>
<if test="leaseType != null and leaseType != ''">
and lai.lease_type = #{leaseType}
</if>
<if test="keyword != null and keyword != ''">
and (bui.unit_name like concat('%', #{keyword}, '%') or
bp.lot_name like concat('%', #{keyword}, '%') or
@ -55,8 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</if>
GROUP BY
sai.agreement_id,
sai.type_id
tta.agreement_id,
lod.type_id
</select>
<select id="getOperateList" resultType="com.bonus.sgzb.material.domain.TeamLeaseInfo">
SELECT
@ -182,4 +180,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and DATE(tli.create_time) = #{startTime}
</if>
</select>
</mapper>
<select id="selectStockNum" resultType="java.lang.Integer">
SELECT
(
SUM(
IF
( rd.type = 1, rd.out_num, 0 )) - SUM(
IF
( rd.type = 2, rd.out_num, 0 ))) AS receiveNum
FROM
receive_detail rd
WHERE
parent_id = #{id}
</select>
<select id="getNewRecords" resultType="com.bonus.sgzb.material.domain.TeamLeaseInfo">
select mt.type_name modelName,
mt2.type_name typeName,
su.nick_name nickName,
rd.out_num outNum,
rd.pick_name pickName,
rd.out_time outTime
from receive_detail rd
left join ma_type mt on rd.type_id = mt.type_id
left join ma_type mt2 on mt.parent_id = mt2.type_id
left join sys_user su on rd.out_name = su.user_id
where rd.type = 1
<if test="typeId != null and typeId != ''">
and mt2.type_id = #{typeId}
</if>
<if test="modelId != null and modelId != ''">
and mt.type_id = #{modelId}
</if>
</select>
<insert id="addNewOperate">
insert into receive_detail (parent_id,type_id,out_num,out_time,type,out_name,pick_name)
values (#{id},#{typeId},#{outNum},now(),#{type},#{createBy},#{leaseMan});
</insert>
</mapper>

View File

@ -20,11 +20,11 @@ export function getOperateList(query) {
// 出库/退库操作
export function operate(query) {
export function operate(data) {
return request({
url: '/material/secondaryWarehouse/operate',
method: 'post',
params: query
data
})
}

View File

@ -23,6 +23,25 @@ export function fileUpLoad(param){
})
}
// excel文件上传
export function excelUpLoad(param){
const formData = new FormData()
formData.append('file', param.file)
return request({
url: '/base/maPartType/readExcel',
method: 'post',
data: formData,
})
}
// excel文件下载
export function downloadExcel(param){
return request({
url: '/base/maPartType/downLoad',
method: 'post',
param
})
}

View File

@ -148,6 +148,7 @@
</el-table-column> -->
<el-table-column
align="center"
key="1"
label="序号"
type="index"
:index="
@ -157,12 +158,15 @@
<el-table-column
label="单位名称"
align="center"
key="2"
prop="unitName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="工程名称"
align="center"
key="3"
prop="proName"
:show-overflow-tooltip="true"
v-if="leaseType == 0"
@ -170,86 +174,76 @@
<el-table-column
label="类型名称"
align="center"
key="4"
prop="typeName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="规格型号"
align="center"
key="5"
prop="modelName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="计量单位"
align="center"
key="6"
prop="nuitName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="进场数量"
align="center"
prop="jcNum"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<span
class="clickText"
@click="openRecords(scope.row, 1)"
>{{ scope.row.jcNum }}</span
>
</template>
</el-table-column>
<el-table-column
label="退场数量"
align="center"
prop="tcNUm"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<span
class="clickText"
@click="openRecords(scope.row, 2)"
>{{ scope.row.tcNUm }}</span
>
</template>
</el-table-column>
<el-table-column
label="场内库存量"
align="center"
prop="kcNum"
:show-overflow-tooltip="true"
label="总量"
align="center"
key="7"
prop="num"
:show-overflow-tooltip="true"
v-if="leaseType == 1"
/>
<el-table-column
label="已出库数量"
align="center"
prop="ckNum"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<span
class="clickText"
@click="openRecords(scope.row, 4)"
>{{ scope.row.ckNum }}</span
>
</template>
</el-table-column>
label="库存数量"
align="center"
key="8"
prop="stockNum"
:show-overflow-tooltip="true"
v-if="leaseType == 1"
/>
<el-table-column
label="已退库数量"
label="领用数量"
align="center"
prop="zkNum"
key="9"
prop="receiveNum"
:show-overflow-tooltip="true"
v-if="leaseType == 1"
>
<template slot-scope="scope">
<span
class="clickText"
@click="openRecords(scope.row, 5)"
>{{ scope.row.zkNum }}</span
>{{ scope.row.receiveNum }}</span
>
</template>
</el-table-column>
<el-table-column
label="在用数量"
align="center"
key="10"
prop="receiveNum"
:show-overflow-tooltip="true"
v-if="leaseType == 0"
/>
<el-table-column
label="操作"
align="center"
key="11"
width="150"
v-if="leaseType == 1"
>
@ -258,7 +252,7 @@
size="mini"
type="primary"
@click="handleOut(scope.row)"
v-if="parseInt(scope.row.kcNum) > 0"
v-if="parseInt(scope.row.stockNum) > 0"
>
出库
</el-button>
@ -267,9 +261,9 @@
type="warning"
@click="handleIn(scope.row)"
v-if="
parseInt(scope.row.ckNum) > 0 &&
parseInt(scope.row.zkNum) <
parseInt(scope.row.ckNum)
parseInt(scope.row.receiveNum) > 0 &&
parseInt(scope.row.stockNum) <
parseInt(scope.row.num)
"
>
退库
@ -316,14 +310,18 @@
</el-form-item>
<el-form-item label="在库数量" prop="kcNum">
<el-input
v-model="form.kcNum"
v-model="form.zkNum"
placeholder="请输入在库数量"
disabled
/>
</el-form-item>
<el-form-item label="出库数量" prop="num">
<el-input v-model="form.num" placeholder="请输入出库数量" maxlength="20" />
<el-form-item label="出库数量" prop="outNum">
<el-input
v-model="form.outNum"
placeholder="请输入出库数量"
maxlength="20"
/>
</el-form-item>
<el-form-item label="班组名称" prop="teamName">
<el-input
@ -384,13 +382,19 @@
disabled
/>
</el-form-item>
<el-form-item label="已出库数量" prop="ckNum">
<el-input v-model="nform.ckNum" disabled />
<el-form-item label="领用数量" prop="ckNum">
<el-input
v-model="nform.ckNum"
disabled
/>
</el-form-item>
<!-- <el-form-item label="已出库数量" prop="ckNum">
<el-input v-model="nform.ckNum" disabled />
</el-form-item>-->
<el-form-item label="退库数量" prop="num">
<el-form-item label="退库数量" prop="outNum">
<el-input
v-model="nform.num"
v-model="nform.outNum"
placeholder="请输入退库数量"
maxlength="50"
/>
@ -433,14 +437,14 @@
width="1200px"
append-to-body
>
<el-form
<!-- <el-form
:model="dialogQuery"
ref="dialogQuery"
size="small"
:inline="true"
label-width="80px"
>
<el-form-item label="记录时间" prop="startTime">
&lt;!&ndash; <el-form-item label="记录时间" prop="startTime">
<el-date-picker
v-model="dialogQuery.startTime"
style="width: 240px"
@ -448,7 +452,7 @@
type="date"
placeholder="记录时间"
></el-date-picker>
</el-form-item>
</el-form-item>&ndash;&gt;
<el-form-item label="类型名称" prop="typeName">
<el-input v-model="dialogQuery.typeName" disabled />
</el-form-item>
@ -471,8 +475,7 @@
>重置</el-button
>
</el-form-item>
</el-form>
</el-form>-->
<el-table v-loading="loading" :data="dialogList">
<el-table-column
label="序号"
@ -500,23 +503,29 @@
:show-overflow-tooltip="true"
/>
<el-table-column
label="数量"
label="出库数量"
align="center"
prop="num"
prop="outNum"
:show-overflow-tooltip="true"
/>
<el-table-column
label="记录时间"
label="领料人员"
align="center"
prop="startTime"
prop="pickName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="操作类型"
label="出库人员"
align="center"
prop=""
prop="outName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="出库时间"
align="center"
prop="outTime"
:show-overflow-tooltip="true"
/>
</el-table>
<pagination
@ -589,7 +598,7 @@ export default {
form: {},
//
rules: {
num: [
outNum: [
{
required: true,
message: '出库数量不能为空',
@ -617,7 +626,7 @@ export default {
// 退
nform: {},
nrules: {
num: [
outNum: [
{
required: true,
message: '退库数量不能为空',
@ -769,15 +778,16 @@ export default {
//1
this.reset()
// this.form = row;
// console.log(row)
console.log(row)
this.$set(this.form, 'id', row.id)
this.$set(this.form, 'agreementId', row.agreementId)
this.$set(this.form, 'unitId', row.unitId)
this.$set(this.form, 'typeId', row.typeId)
this.$set(this.form, 'unitName', row.unitName)
this.$set(this.form, 'typeName', row.typeName)
this.$set(this.form, 'modelName', row.modelName)
this.$set(this.form, 'zkNum', row.zkNum)
this.$set(this.form, 'kcNum', row.kcNum)
this.$set(this.form, 'zkNum', row.stockNum)
this.$set(this.form, 'kcNum', row.num)
// console.log(this.form)
this.openOut = true
this.title = '出库'
@ -785,7 +795,9 @@ export default {
handleIn(row) {
//2
this.reset()
console.log(row)
// this.nform = row;
this.$set(this.nform, 'id', row.id)
this.$set(this.nform, 'agreementId', row.agreementId)
this.$set(this.nform, 'unitId', row.unitId)
this.$set(this.nform, 'typeId', row.typeId)
@ -793,7 +805,7 @@ export default {
this.$set(this.nform, 'typeName', row.typeName)
this.$set(this.nform, 'modelName', row.modelName)
this.$set(this.nform, 'ckNum', row.ckNum)
this.$set(this.nform, 'ckNum', row.receiveNum)
this.openIn = true
this.title = '退库'
},
@ -803,7 +815,7 @@ export default {
this.$refs['form'].validate((valid) => {
if (valid) {
if (
parseInt(this.form.num) > parseInt(this.form.kcNum)
parseInt(this.form.outNum) > parseInt(this.form.zkNum)
) {
this.$message.error('出库数量不可大于在库数量')
return
@ -811,6 +823,7 @@ export default {
let param = {}
param = this.form
param.type = 1
console.log(param)
operate(param).then((response) => {
this.$modal.msgSuccess('操作成功')
this.openOut = false
@ -823,10 +836,10 @@ export default {
this.$refs['nform'].validate((valid) => {
if (valid) {
if (
parseInt(this.nform.num) >
parseInt(this.nform.outNum) >
parseInt(this.nform.ckNum)
) {
this.$message.error('退库数量不可大于出库数量')
this.$message.error('退库数量不可大于领用数量')
return
}
let param = {}
@ -844,21 +857,21 @@ export default {
//
openRecords(row, type) {
this.title = undefined
this.title = '领用记录'
this.openRecord = true
this.queryType = type
/*this.queryType = type
this.dialogQuery.typeName = row.typeName
this.dialogQuery.agreementId = row.agreementId
this.dialogQuery.modelName = row.modelName
this.dialogQuery.unitId = row.unitId
this.dialogQuery.typeId = row.typeId
this.dialogQuery.typeId = row.typeId*/
this.getDialogList()
},
/** 查询列表 */
getDialogList() {
this.dialogQuery.queryType = this.queryType
getRecords(this.dialogQuery).then((response) => {
getRecords().then((response) => {
this.dialogList = response.rows
this.dialogTotal = response.total
})

View File

@ -135,17 +135,17 @@
>删除</el-button
>
</el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="info"-->
<!-- plain-->
<!-- icon="el-icon-upload2"-->
<!-- size="mini"-->
<!-- @click="handleImport"-->
<!-- v-hasPermi="['system:user:import']"-->
<!-- >导入</el-button-->
<!-- >-->
<!-- </el-col>-->
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['system:user:import']"
>导入</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"

View File

@ -77,6 +77,7 @@
plain
icon="el-icon-top"
size="mini"
@click="downloadExcelTemplate"
>下载导入模板</el-button
>
</el-col>
@ -260,10 +261,13 @@
>
<el-upload
ref="excelUpload"
:http-request="(file) => excelUpload(file)"
action="#"
:http-request="(file) => uploadExcel(file)"
accept=".xlsx, .xls"
:limit="1"
:file-list="excelList"
:file-list="fileList"
:on-remove="handleRemoveExcel"
:on-exceed="excelExceed"
>
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
@ -284,8 +288,14 @@
align-items: center;
margin-top: 20px
">
<el-button type="primary" style="margin-right: 15px;">确定</el-button>
<el-button>取消</el-button>
<el-button
type="primary"
style="margin-right: 6px;"
@click="confirmUpload"
>确定</el-button>
<el-button
@click="closeExcelDialog"
>取消</el-button>
</div>
</el-dialog>
@ -301,7 +311,7 @@ import {
updatePartTypeById,
delPartType,
} from '@/api/store/tools'
import { fileUpLoad } from '@/api/system/upload'
import { excelUpLoad, downloadExcel } from '@/api/system/upload'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
@ -376,16 +386,59 @@ export default {
},
isEdit: false,
// excel
excelList: []
fileList: [],
excelList: undefined
}
},
created() {
this.getList()
},
methods: {
/** 确认上传excel */
confirmUpload() {
if (this.excelList != undefined) {
let ifSize = this.excelList.file.size / 1024 / 1024 < 20;
if (!ifSize) {
this.$modal.msgError('上传文件大于20M请重新选择文件上传')
} else {
console.log(this.excelList)
excelUpLoad(this.excelList).then(res => {
console.log(res)
if (res.code == 200) {
this.$modal.msgSuccess(res.msg)
this.openUpload = false
this.reset()
this.getList()
} else {
this.$modal.msgError(res.msg)
}
}).catch(err => {
console.log(err)
})
}
} else {
this.$modal.msgError('请选择上传文件!')
}
},
/** 点击下载excel导入模板 */
downloadExcelTemplate() {
this.download(
'base/maPartType/downLoad',
{},
`配件模板.xlsx`,
)
},
/** 上传excel文件 */
uploadExcel(file) {
console.log(file)
uploadExcel(obj) {
this.excelList = obj
},
/** 移除excel文件 */
handleRemoveExcel() {
this.excelList = undefined
},
/** 上传的excel数超出限制 */
excelExceed(files, fileList) {
this.$modal.msgError('上传的excel文件数量超出限制')
},
/** 上传excel文件前 */
beforeExcelUpload(file) {
@ -399,6 +452,11 @@ export default {
excelError() {
console.log('上传失败')
},
/** 关闭excel弹窗 */
closeExcelDialog() {
this.excelList = undefined
this.openUpload = false
},
/** 查询部门列表 */
getList() {
console.log(this.queryParams)
@ -464,7 +522,7 @@ export default {
handleUploadExcel() {
this.reset()
this.openUpload = true
},
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false