配件批量审核
This commit is contained in:
parent
f815734fda
commit
8a283c3bfa
|
|
@ -13,12 +13,15 @@ import java.util.List;
|
|||
* @author 黑子
|
||||
*/
|
||||
@Data
|
||||
public class PartApplyAppVo extends PageInfo {
|
||||
|
||||
public class PartApplyAppVo extends PageInfo implements java.io.Serializable {
|
||||
|
||||
@Excel(name = "序号", width = 10.0, orderNum = "0")
|
||||
private int xh;
|
||||
|
||||
private String id;
|
||||
|
||||
private List<String> idList;
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.gzgqj.business.bases.controller;
|
|||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
|
||||
import com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo;
|
||||
import com.bonus.gzgqj.business.bases.entity.PartInputDetails;
|
||||
|
|
@ -36,6 +37,7 @@ import java.util.List;
|
|||
@RequestMapping("/backstage/partApply")
|
||||
@Slf4j
|
||||
public class PartApplyController {
|
||||
|
||||
@Autowired
|
||||
private PartApplyService service;
|
||||
|
||||
|
|
@ -62,6 +64,7 @@ public class PartApplyController {
|
|||
public ServerResponse getPartDetails(EncryptedReq<PartApplyAppVo> dto) {
|
||||
return service.getPartDetails(dto.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 领料出库 查询
|
||||
* @param dto
|
||||
|
|
@ -75,6 +78,7 @@ public class PartApplyController {
|
|||
PageInfo<PartApplyDetailAppVo> pageInfo = new PageInfo<>(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出需求计划
|
||||
* @param
|
||||
|
|
@ -102,6 +106,7 @@ public class PartApplyController {
|
|||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出需求计划详情
|
||||
* @param request
|
||||
|
|
@ -131,7 +136,6 @@ public class PartApplyController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 数据审核
|
||||
* @param dto
|
||||
|
|
@ -143,7 +147,21 @@ public class PartApplyController {
|
|||
return service.auditData(dto.getData());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据审核--批量审核
|
||||
*/
|
||||
@PostMapping("batchAudit")
|
||||
@DecryptAndVerify(decryptedClass = PartApplyAppVo.class)
|
||||
public ServerResponse batchAudit(EncryptedReq<PartApplyAppVo> dto) {
|
||||
PartApplyAppVo data = dto.getData();
|
||||
ServerResponse serverResponse = null;
|
||||
for (String id : data.getIdList()) {
|
||||
PartApplyAppVo cloned = ObjectUtil.cloneByStream(data);
|
||||
cloned.setId(id);
|
||||
serverResponse = service.auditData(cloned);
|
||||
}
|
||||
return serverResponse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,209 +28,206 @@ import java.util.Objects;
|
|||
|
||||
/**
|
||||
* 配件管理 入库
|
||||
*
|
||||
* @author 黑子
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PartApplyServiceImpl implements PartApplyService{
|
||||
|
||||
@Autowired
|
||||
private PartApplyMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private FileUploadService uploadService;
|
||||
public class PartApplyServiceImpl implements PartApplyService {
|
||||
|
||||
@Autowired
|
||||
UserPartInfoServiceImpl userPartInfoService;
|
||||
@Autowired
|
||||
private PartApplyMapper mapper;
|
||||
@Autowired
|
||||
private FileUploadService uploadService;
|
||||
|
||||
public static String transBast64(String url) {
|
||||
try {
|
||||
if (StringHelper.isEmpty(url)) {
|
||||
return "";
|
||||
}
|
||||
Path path = Paths.get(url);
|
||||
byte[] fileBytes = Files.readAllBytes(path);
|
||||
return Base64.getEncoder().encodeToString(fileBytes);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请记录列表查询
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PartApplyAppVo> findByPage(PartApplyAppVo data) {
|
||||
List<PartApplyAppVo> list=new ArrayList<>();
|
||||
try{
|
||||
list=mapper.findByPage(data);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return list;
|
||||
List<PartApplyAppVo> list = new ArrayList<>();
|
||||
try {
|
||||
list = mapper.findByPage(data);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询申请记录详情
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse getPartDetails(PartApplyAppVo data) {
|
||||
try{
|
||||
PartApplyAppVo vo=mapper.getPartDetails(data);
|
||||
List<String> info=mapper.getInfoMsg(data);
|
||||
try {
|
||||
PartApplyAppVo vo = mapper.getPartDetails(data);
|
||||
List<String> info = mapper.getInfoMsg(data);
|
||||
String infoMsg = String.join(",", info);
|
||||
vo.setInfoMsg(infoMsg);
|
||||
//图片转换
|
||||
String bast641=transBast64(vo.getLyUrl());
|
||||
String bast642=transBast64(vo.getCkUrl());
|
||||
String bast643=transBast64(vo.getShUrl());
|
||||
String bast644=transBast64(vo.getZdUrl());
|
||||
String bast641 = transBast64(vo.getLyUrl());
|
||||
String bast642 = transBast64(vo.getCkUrl());
|
||||
String bast643 = transBast64(vo.getShUrl());
|
||||
String bast644 = transBast64(vo.getZdUrl());
|
||||
vo.setLyUrl(bast641);
|
||||
vo.setCkUrl(bast642);
|
||||
vo.setShUrl(bast643);
|
||||
vo.setZdUrl(bast644);
|
||||
List<FileUploadVo> flieList=uploadService.getFileList(data.getId(),"t_part_apply",null);
|
||||
List<FileUploadVo> flieList = uploadService.getFileList(data.getId(), "t_part_apply", null);
|
||||
vo.setFileList(flieList);
|
||||
return ServerResponse.createSuccess(vo);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
return ServerResponse.createSuccess(vo);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createSuccess(new PartApplyAppVo());
|
||||
return ServerResponse.createSuccess(new PartApplyAppVo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询申请记录详情
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PartApplyDetailAppVo> getPartDetailsList(PartApplyDetailAppVo data) {
|
||||
try{
|
||||
List<PartApplyDetailAppVo> details=mapper.getDetailsList(data);
|
||||
public List<PartApplyDetailAppVo> getPartDetailsList(PartApplyDetailAppVo data) {
|
||||
try {
|
||||
List<PartApplyDetailAppVo> details = mapper.getDetailsList(data);
|
||||
return details;
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return new ArrayList<PartApplyDetailAppVo>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核 数据
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse auditData(PartApplyAppVo data) {
|
||||
try{
|
||||
String status=data.getStatus();
|
||||
PartApplyAppVo vo=mapper.getAuditStatus(data);
|
||||
if(!"1".equals(vo.getStatus())){
|
||||
return ServerResponse.createErroe("该数据已被审核,请刷新重试");
|
||||
}
|
||||
Long userId= Objects.requireNonNull(UserUtil.getLoginUser()).getUserId();
|
||||
AuditRecord voo=new AuditRecord();
|
||||
voo.setAuditor(userId.toString());
|
||||
voo.setAuditRemark(data.getRemark());
|
||||
voo.setApplyId(data.getId());
|
||||
voo.setAuditStatus(status);
|
||||
voo.setAuditType("2");
|
||||
try {
|
||||
String status = data.getStatus();
|
||||
PartApplyAppVo vo = mapper.getAuditStatus(data);
|
||||
if (!"1".equals(vo.getStatus())) {
|
||||
return ServerResponse.createErroe("该数据已被审核,请刷新重试");
|
||||
}
|
||||
Long userId = Objects.requireNonNull(UserUtil.getLoginUser()).getUserId();
|
||||
AuditRecord voo = new AuditRecord();
|
||||
voo.setAuditor(userId.toString());
|
||||
voo.setAuditRemark(data.getRemark());
|
||||
voo.setApplyId(data.getId());
|
||||
voo.setAuditStatus(status);
|
||||
voo.setAuditType("2");
|
||||
//通过
|
||||
if("2".equals(status)){
|
||||
if ("2".equals(status)) {
|
||||
data.setStatusType("3");
|
||||
}
|
||||
int num=mapper.insertAuditRecord(voo);
|
||||
if(num>0){
|
||||
int num = mapper.insertAuditRecord(voo);
|
||||
if (num > 0) {
|
||||
data.setFzUser(userId.toString());
|
||||
mapper.updatePartInfo(data);
|
||||
return ServerResponse.createSuccess("审核成功","审核成功");
|
||||
return ServerResponse.createSuccess("审核成功", "审核成功");
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return ServerResponse.createErroe("审核失败");
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createErroe("审核失败");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 出库-接口
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse partOutInfo(HttpServletRequest request, MultipartFile[] files) {
|
||||
List<PartApplyAppVo> list=new ArrayList<>();
|
||||
try{
|
||||
String param=request.getParameter("params");
|
||||
PartApplyAppVo data= JSON.parseObject(param,PartApplyAppVo.class);
|
||||
String id=data.getId();
|
||||
if(StringHelper.isEmpty(id)){
|
||||
return ServerResponse.createErroe("请选择出库记录");
|
||||
List<PartApplyAppVo> list = new ArrayList<>();
|
||||
try {
|
||||
String param = request.getParameter("params");
|
||||
PartApplyAppVo data = JSON.parseObject(param, PartApplyAppVo.class);
|
||||
String id = data.getId();
|
||||
if (StringHelper.isEmpty(id)) {
|
||||
return ServerResponse.createErroe("请选择出库记录");
|
||||
}
|
||||
if(files==null || files.length <= 0){
|
||||
if (files == null || files.length <= 0) {
|
||||
System.out.println("本次未上传附件");
|
||||
//return ServerResponse.createErroe("请先上传文件");
|
||||
} else {
|
||||
List<FileUploadVo> fileList=uploadService.uploadImage(files,id,"t_part_apply","出库附件");
|
||||
if(fileList.size()!=files.length){
|
||||
return ServerResponse.createErroe("出库失败,附件上传缺失");
|
||||
List<FileUploadVo> fileList = uploadService.uploadImage(files, id, "t_part_apply", "出库附件");
|
||||
if (fileList.size() != files.length) {
|
||||
return ServerResponse.createErroe("出库失败,附件上传缺失");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PartApplyAppVo vo=mapper.getAuditStatus(data);
|
||||
if(!"2".equals(vo.getStatus())){
|
||||
return ServerResponse.createErroe("该数据状态已变更,请刷新数据重试");
|
||||
PartApplyAppVo vo = mapper.getAuditStatus(data);
|
||||
if (!"2".equals(vo.getStatus())) {
|
||||
return ServerResponse.createErroe("该数据状态已变更,请刷新数据重试");
|
||||
}
|
||||
Long userId= Objects.requireNonNull(UserUtil.getLoginUser()).getUserId();
|
||||
AuditRecord voo=new AuditRecord();
|
||||
Long userId = Objects.requireNonNull(UserUtil.getLoginUser()).getUserId();
|
||||
AuditRecord voo = new AuditRecord();
|
||||
voo.setAuditor(userId.toString());
|
||||
voo.setApplyId(data.getId());
|
||||
voo.setAuditStatus("4");
|
||||
voo.setAuditType("3");
|
||||
int num=mapper.insertAuditRecord(voo);
|
||||
if(num>0){
|
||||
int num = mapper.insertAuditRecord(voo);
|
||||
if (num > 0) {
|
||||
//出库
|
||||
data.setCkUser(userId.toString());
|
||||
data.setStatus("4");
|
||||
data.setStatusType("1");
|
||||
mapper.updatePartInfo(data);
|
||||
//
|
||||
PartApplyDetailAppVo det=new PartApplyDetailAppVo();
|
||||
PartApplyDetailAppVo det = new PartApplyDetailAppVo();
|
||||
det.setId(data.getId());
|
||||
//计算出库数量
|
||||
List<PartApplyDetailAppVo> details=mapper.getDetailsList(det);
|
||||
String userName=UserUtil.getLoginUser().getUsername();
|
||||
List<PartApplyDetailAppVo> details = mapper.getDetailsList(det);
|
||||
String userName = UserUtil.getLoginUser().getUsername();
|
||||
//出库数据 维护
|
||||
userPartInfoService.insert(details,vo.getCreator(),vo.getUserName());
|
||||
details.forEach(detail->{
|
||||
String partId=detail.getPartId();
|
||||
int applyNum=detail.getApplyNum();
|
||||
PaTypeVo paTypeVo=mapper.getPaTypeVoById(partId);
|
||||
paTypeVo.setNum(paTypeVo.getNum()-applyNum);
|
||||
paTypeVo.setCkNum(paTypeVo.getCkNum()+applyNum);
|
||||
userPartInfoService.insert(details, vo.getCreator(), vo.getUserName());
|
||||
details.forEach(detail -> {
|
||||
String partId = detail.getPartId();
|
||||
int applyNum = detail.getApplyNum();
|
||||
PaTypeVo paTypeVo = mapper.getPaTypeVoById(partId);
|
||||
paTypeVo.setNum(paTypeVo.getNum() - applyNum);
|
||||
paTypeVo.setCkNum(paTypeVo.getCkNum() + applyNum);
|
||||
//更新当前库存
|
||||
mapper.updatePaTypeVoById(paTypeVo);
|
||||
});
|
||||
return ServerResponse.createSuccess("出库成功","出库成功");
|
||||
return ServerResponse.createSuccess("出库成功", "出库成功");
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createErroe("出库失败");
|
||||
}
|
||||
|
||||
|
||||
public static String transBast64(String url){
|
||||
try{
|
||||
if(StringHelper.isEmpty(url)){
|
||||
return "";
|
||||
}
|
||||
Path path = Paths.get(url);
|
||||
byte[] fileBytes = Files.readAllBytes(path);
|
||||
return Base64.getEncoder().encodeToString(fileBytes);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.err.println(transBast64("D:\\files\\zg_gqj\\20241109\\173113057456537938315.jpg"));
|
||||
return ServerResponse.createErroe("出库失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,10 +212,10 @@ public class PlanApplicationServiceImp implements PlanApplicationService {
|
|||
Row row = sheet.getRow(i);
|
||||
PlanDevBean data = new PlanDevBean();
|
||||
// 获取全部列的值
|
||||
data.setPpName(row.getCell(1).getStringCellValue()); //物资类型
|
||||
data.setpName(row.getCell(2).getStringCellValue()); //物资名称
|
||||
data.setName(row.getCell(3).getStringCellValue()); //物资型号
|
||||
data.setUnit(row.getCell(4).getStringCellValue()); //单位
|
||||
data.setPpName(row.getCell(1).getStringCellValue().trim()); //物资类型
|
||||
data.setpName(row.getCell(2).getStringCellValue().trim()); //物资名称
|
||||
data.setName(row.getCell(3).getStringCellValue().trim()); //物资型号
|
||||
data.setUnit(row.getCell(4).getStringCellValue().trim()); //单位
|
||||
data.setNeedNum((int)row.getCell(5).getNumericCellValue()); //数量
|
||||
// data.setTimes(row.getCell(6).getStringCellValue()); //时间
|
||||
Cell cell = row.getCell(6); // 假设时间是在第7列(0-based index 6)
|
||||
|
|
@ -255,20 +255,21 @@ public class PlanApplicationServiceImp implements PlanApplicationService {
|
|||
workbook.close();
|
||||
}
|
||||
}
|
||||
if(dataList!=null && !dataList.isEmpty()){
|
||||
if (!dataList.isEmpty()) {
|
||||
for (PlanDevBean planDevBean : dataList) {
|
||||
//根据物资类型,物资名称,物资型号 去数据库查询是否存在
|
||||
PlanDevBean bean = dao.getExist(planDevBean);
|
||||
if(bean == null){
|
||||
if (bean == null) {
|
||||
// 在数据库中不存在,则记录下,全部判断完,返回到前段,提示
|
||||
nonExistList.add(planDevBean);
|
||||
}else{
|
||||
} else {
|
||||
planDevBean.setId(bean.getId());
|
||||
}
|
||||
}
|
||||
// 如果存在数据库中不存在的数据,返回提示
|
||||
if (!nonExistList.isEmpty()) {
|
||||
return ServerResponse.createError("导入失败,以下数据在数据库中不存在", nonExistList);
|
||||
return ServerResponse.createSuccess("导入成功,有部分物资不存在", dataList);
|
||||
// return ServerResponse.createError("导入失败,以下数据在数据库中不存在", nonExistList);
|
||||
}
|
||||
}
|
||||
return ServerResponse.createSuccess("导入成功", dataList);
|
||||
|
|
|
|||
|
|
@ -238,7 +238,6 @@
|
|||
LEFT JOIN mm_type mt1 on mt.PARENT_ID=mt1.id and mt1.IS_ACTIVE=1
|
||||
LEFT JOIN mm_type mt2 on mt1.PARENT_ID=mt2.id and mt2.IS_ACTIVE=1
|
||||
WHERE mt.IS_ACTIVE=1
|
||||
and mt.IS_LABEL=1
|
||||
and mt2.`NAME` = #{param.ppName}
|
||||
and mt1.`NAME` = #{param.pName}
|
||||
and mt.`NAME` = #{param.name}
|
||||
|
|
|
|||
Loading…
Reference in New Issue