数据接口开发

This commit is contained in:
haozq 2024-11-12 20:19:09 +08:00
parent 7a7306af63
commit 8c5c2da5ff
21 changed files with 925 additions and 39 deletions

View File

@ -1,6 +1,7 @@
package com.bonus.gzgqj.business.app.controller;
import com.bonus.gzgqj.business.app.entity.MachinesVo;
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
import com.bonus.gzgqj.business.app.service.PartApplyAppServiceImp;
import com.bonus.gzgqj.business.bases.entity.PaTypeVo;
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
@ -11,11 +12,10 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@ -63,4 +63,44 @@ public class PartApplyAppController {
}
/**
* 新增配件信息接口
* @param dto
* @return
*/
@PostMapping("addPartApply")
public ServerResponse addPartApply(PartApplyAppVo dto) {
return service.addPartApply(dto);
}
/**
* 配件申请记录-查询
* @param dto
* @return
*/
@PostMapping("getPartApplyList")
public ServerResponse getPartApplyList(PartApplyAppVo dto) {
return service.getPartApplyList(dto);
}
/**
* 配件申请记录-详情
* @param dto
* @return
*/
@PostMapping("getPartApplyDetails")
public ServerResponse getPartApplyDetails(PartApplyAppVo dto) {
return service.getPartApplyDetails(dto);
}
/**
* 图片文件上传
* @return
*/
@PostMapping("uploadImage")
public ServerResponse uploadImage(HttpServletRequest request, @RequestParam("file[]") MultipartFile[] files) {
return service.uploadImage(request,files);
}
}

View File

@ -15,13 +15,14 @@ public class MachinesVo {
*/
private String id;
/**
* 编码
*/
private String deviceCode;
/**
* 类型
* 配件类型
*/
private String type;
/**
@ -36,9 +37,20 @@ public class MachinesVo {
* 使用单位
*/
private String unit;
/**
* 工程id
*/
private String proId;
/**
* 工程名称
*/
private String proName;
/**
* 创建人
*/
private String creater;
}

View File

@ -1,22 +1,152 @@
package com.bonus.gzgqj.business.app.entity;
import com.bonus.gzgqj.business.plan.entity.FileUploadVo;
import com.bonus.gzgqj.business.plan.entity.PageInfo;
import lombok.Data;
import org.omg.CORBA.PRIVATE_MEMBER;
import java.util.List;
/**
* 领料申请
* @author 黑子
*/
@Data
public class PartApplyAppVo {
public class PartApplyAppVo extends PageInfo {
private String id;
/**
* 编码
*/
private String code;
/**
* 状态
*/
private String status;
/**
* 审核节点类型
*/
private String statusType;
/**
* 领料人
*/
private String userName;
/**
* 配件类型
*/
private String type;
/**
* 备注
*/
private String remark;
/**
* 申请总数量
*/
private int applyNum;
private String name;
/**
* 设备id
*/
private String deviceId;
/**
* 设备id
*/
private String devCode;
/**
* 设备类型
*/
private String devType;
/**
* 配件明细
*/
private String details;
/**
* 工程id
*/
private String proId;
/**
* 工程名称
*/
private String proName;
/**
* 创建人
*/
private String creater;
/**
* 创建人
*/
private String createTime;
/**
* 更新人
*/
private String updater;
/**
* 更新时间
*/
private String updateTime;
/**
* 申请节点
*/
private String auditType;
/**
* 申请节点
*/
private String keyWord;
/**
* 出库人
*/
private String ckUser;
/**
* 制单人
*/
private String zdUser;
/**
* 出库时间
*/
private String ckTime;
/**
* 制单时间
*/
private String zdTime;
/**
* 负责人(审核人)
*/
private String fzUser;
/**
* 负责时间
*/
private String fzTime;
/**
* 文件上传 集合
*/
private List<FileUploadVo> fileList;
private List<PartApplyDetailAppVo> detailsList;
/**
* 查询时间
*/
private String times;
private String startDay;
private String endDay;
private String lyUrl;
private String zdUrl;
private String ckUrl;
private String shUrl;
}

View File

@ -0,0 +1,49 @@
package com.bonus.gzgqj.business.app.entity;
import lombok.Data;
import org.omg.CORBA.INTERNAL;
/**
* @author 黑子
*/
@Data
public class PartApplyDetailAppVo {
/**
* id
*/
private String id;
/**
* 申请单id
*/
private String applyId;
/**
* 配件id
*/
private String partId;
/**
* 申请数量
*/
private int applyNum;
/**
* 配件类型
*/
private String partType;
/**
* 配件名称
*/
private String partName;
/**
* 配件 型号
*/
private String partModel;
/**
* 金钱
*/
private String money;
/**
* 平准单价
*/
private String price;
}

View File

@ -1,7 +1,10 @@
package com.bonus.gzgqj.business.app.mapper;
import com.bonus.gzgqj.business.app.entity.MachinesVo;
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
import com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo;
import com.bonus.gzgqj.business.bases.entity.PaTypeVo;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -33,4 +36,45 @@ public interface PartApplyAppMapper {
* @return
*/
List<PaTypeVo> getPaTypeList(PaTypeVo dto);
/**
* 新增配件申请
* @param dto
* @return
*/
int addPartApply(PartApplyAppVo dto);
/**
* 查询 领料条数
* @return
*/
int getSqList();
/**
* 插入向
* @param list
* @param dto
*/
int insertDetails(@Param("list") List<PartApplyDetailAppVo> list, @Param("param") PartApplyAppVo dto);
/**
* 配件申请记录查询
* @param dto
* @return
*/
List<PartApplyAppVo> getPartApplyList(PartApplyAppVo dto);
/**
* 查询申请详情
* @param dto
* @return
*/
PartApplyAppVo getPartApplyDetails(PartApplyAppVo dto);
/**
* 申请记录详情 清单
* @param dto
* @return
*/
List<PartApplyDetailAppVo> getDetailsList(PartApplyAppVo dto);
}

View File

@ -1,14 +1,25 @@
package com.bonus.gzgqj.business.app.service;
import cn.afterturn.easypoi.cache.manager.IFileLoader;
import com.alibaba.fastjson.JSON;
import com.bonus.gzgqj.business.app.entity.MachinesVo;
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
import com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo;
import com.bonus.gzgqj.business.app.mapper.PartApplyAppMapper;
import com.bonus.gzgqj.business.bases.entity.PaTypeVo;
import com.bonus.gzgqj.business.plan.entity.FileUploadVo;
import com.bonus.gzgqj.business.utils.FileUploadService;
import com.bonus.gzgqj.manager.common.util.DateTimeHelper;
import com.bonus.gzgqj.manager.common.util.StringHelper;
import com.bonus.gzgqj.manager.common.util.StringUtils;
import com.bonus.gzgqj.manager.webResult.ServerResponse;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.lang.ref.PhantomReference;
import java.util.ArrayList;
import java.util.List;
@ -23,6 +34,9 @@ public class PartApplyAppServiceImp {
@Autowired
private PartApplyAppMapper mapper;
@Autowired
private FileUploadService uploadService;
/**
* 查询设备接口
* @param dto
@ -61,9 +75,134 @@ public class PartApplyAppServiceImp {
public ServerResponse getPaTypeList(PaTypeVo dto) {
try{
List<PaTypeVo> list=mapper.getPaTypeList(dto);
ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createSuccess(new ArrayList<MachinesVo>());
}
/**
* 新增配件信息
* @param dto
* @return
*/
public ServerResponse addPartApply(PartApplyAppVo dto) {
try{
String detail=dto.getDetails();
if(StringHelper.isEmpty(detail)){
return ServerResponse.createErroe("请上传配件明细");
}
List<PartApplyDetailAppVo> list=JSON.parseArray(detail,PartApplyDetailAppVo.class);
String code=getCode();
dto.setCode(code);
final int[] applyNum = {0};
list.forEach(vo->{
applyNum[0] = applyNum[0] +vo.getApplyNum();
});
dto.setApplyNum(applyNum[0]);
dto.setStatus("1");
dto.setStatusType("2");
int num=mapper.addPartApply(dto);
if(num<1){
return ServerResponse.createErroe("配件申请失败");
}
int num2= mapper.insertDetails(list,dto);
if(num2==list.size()){
return ServerResponse.createSuccess("申请成功","申请成功");
}
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createSuccess(new ArrayList<MachinesVo>());
}
/**
* 获取编码
* @return
*/
private String getCode() {
try{
int num =mapper.getSqList();
num++;
String year= "XS-"+DateTimeHelper.getNowDay();
if(num<10) {
return year+"-000"+num;
}else if(num<100) {
return year+"-00"+num;
}else if(num<1000) {
return year+"-0"+num;
}
return year+"-"+num;
}catch (Exception e){
log.error(e.toString(),e);
}
return "XF-0000000000";
}
/**
* 上传图片
* @param request
* @param files
* @return
*/
public ServerResponse uploadImage(HttpServletRequest request, MultipartFile[] files) {
try{
String id=request.getParameter("params");
if(StringHelper.isEmpty(id)){
return ServerResponse.createErroe("请选择申请记录");
}
if(files==null || files.length<=0){
return ServerResponse.createErroe("请先上传文件");
}
List<FileUploadVo> fileList=uploadService.uploadImage(files,id,"t_part_apply","使用照片");
if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){
return ServerResponse.createErroe("文件上传失败");
}
return ServerResponse.createSuccess("文件上传成功","文件上传成功");
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("文件上传失败");
}
/**
* 配件申请记录查询
* @param dto
* @return
*/
public ServerResponse getPartApplyList(PartApplyAppVo dto) {
try{
List<PartApplyAppVo> list=mapper.getPartApplyList(dto);
return ServerResponse.createSuccess("查询成功",list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createSuccess("查询失败",new ArrayList<PartApplyAppVo>());
}
/**
* 配件申请详情
* @param dto
* @return
*/
public ServerResponse getPartApplyDetails(PartApplyAppVo dto) {
try{
PartApplyAppVo vo=mapper.getPartApplyDetails(dto);
List<FileUploadVo> flieList=uploadService.getFileList(dto.getId(),"t_part_apply","使用照片");
vo.setFileList(flieList);
List<PartApplyDetailAppVo> details=mapper.getDetailsList(dto);
vo.setDetailsList(details);
return ServerResponse.createSuccess("查询成功",vo);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createSuccess("查询失败",new ArrayList<PartApplyAppVo>());
}
}

View File

@ -1,24 +1,75 @@
package com.bonus.gzgqj.business.bases.controller;
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
import com.bonus.gzgqj.business.bases.service.PartApplyService;
import com.bonus.gzgqj.manager.annotation.DecryptAndVerify;
import com.bonus.gzgqj.manager.core.entity.EncryptedReq;
import com.bonus.gzgqj.manager.webResult.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author 黑子
* 配件管理
* 配件管理 领料出库
*/
@RestController
@RequestMapping("/backstage/partApply")
@Slf4j
public class PartApplyController {
@Autowired
private PartApplyService service;
/**
* 领料出库 查询
* @param dto
* @return
*/
@GetMapping("findByPage")
@DecryptAndVerify(decryptedClass = PartApplyAppVo.class)
public PageInfo<PartApplyAppVo> findByPage(EncryptedReq<PartApplyAppVo> dto) {
PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
List<PartApplyAppVo> list = service.findByPage(dto.getData());;
PageInfo<PartApplyAppVo> pageInfo = new PageInfo<>(list);
return pageInfo;
}
/**
* 查询领料详情
* @param dto
* @return
*/
@GetMapping("getPartDetails")
@DecryptAndVerify(decryptedClass = PartApplyAppVo.class)
public ServerResponse getPartDetails(EncryptedReq<PartApplyAppVo> dto) {
return service.getPartDetails(dto.getData());
}
/**
* 数据审核
* @param dto
* @return
*/
@GetMapping("auditData")
@DecryptAndVerify(decryptedClass = PartApplyAppVo.class)
public ServerResponse auditData(EncryptedReq<PartApplyAppVo> dto) {
return service.auditData(dto.getData());
}

View File

@ -0,0 +1,25 @@
package com.bonus.gzgqj.business.bases.entity;
import lombok.Data;
/**
* 审核 状态
* @author 黑子
*/
@Data
public class AuditRecord {
private String applyId;
private String id;
private String auditor;
private String auditTime;
private String auditStatus;
private String auditType;
private String auditRemark;
}

View File

@ -49,11 +49,19 @@ public class PaTypeVo {
* 备注
*/
private String remarks;
/**
* 信号
*/
private String model;
/**
* 类型
*/
private String type;
private String parentName;
private String sqNum;
}

View File

@ -1,15 +1,57 @@
package com.bonus.gzgqj.business.bases.mapper;
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
import com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo;
import com.bonus.gzgqj.business.bases.entity.AuditRecord;
import org.omg.CORBA.INTERNAL;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* @author 黑子
*/
@Repository
public interface PartApplyMapper {
public class PartApplyMapper {
/**
* 查询申请记录
* @param data
* @return
*/
List<PartApplyAppVo> findByPage(PartApplyAppVo data);
/**
* 查询详情
* @param data
* @return
*/
PartApplyAppVo getPartDetails(PartApplyAppVo data);
/**
* 查询 详情 领用
* @param data
* @return
*/
List<PartApplyDetailAppVo> getDetailsList(PartApplyAppVo data);
/**
* 审核数据 查询
* @param data
* @return
*/
PartApplyAppVo getAuditStatus(PartApplyAppVo data);
/**
* 插入数据
* @param voo
*/
int insertAuditRecord(AuditRecord voo);
/**
* 更新审核信息
* @param data
*/
void updatePartInfo(PartApplyAppVo data);
}

View File

@ -48,7 +48,9 @@ public interface PartInputMapper {
* @param partId
* @param nowNum
*/
void updateTypeNum(@Param("id") String partId,@Param("num") int nowNum);
void updateTypeNum(@Param("id") String partId,@Param("num") int nowNum,@Param("price")String price);
void updateTypeNum2(@Param("id") String partId,@Param("price")String price);
/**
* 查询入库详情
@ -82,4 +84,11 @@ public interface PartInputMapper {
* @param vo
*/
int updateInputData(PartInputVo vo);
/**
* 计算 平准价
* @param detail
* @return
*/
String getPzPrice(PartInputDetails detail);
}

View File

@ -1,7 +1,33 @@
package com.bonus.gzgqj.business.bases.service;
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
import com.bonus.gzgqj.manager.webResult.ServerResponse;
import java.util.List;
/**
* 配件管理 -入库
* @author 黑子
*/
public interface PartApplyService {
/**
* 查询申请记录
* @param data
* @return
*/
List<PartApplyAppVo> findByPage(PartApplyAppVo data);
/**
* 查询申请记录详情
* @param data
* @return
*/
ServerResponse getPartDetails(PartApplyAppVo data);
/**
* 数据审核
* @param data
* @return
*/
ServerResponse auditData(PartApplyAppVo data);
}

View File

@ -1,7 +1,139 @@
package com.bonus.gzgqj.business.bases.service;
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
import com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo;
import com.bonus.gzgqj.business.bases.entity.AuditRecord;
import com.bonus.gzgqj.business.bases.mapper.PartApplyMapper;
import com.bonus.gzgqj.business.plan.entity.FileUploadVo;
import com.bonus.gzgqj.business.utils.FileUploadService;
import com.bonus.gzgqj.manager.common.util.StringHelper;
import com.bonus.gzgqj.manager.common.util.UserUtil;
import com.bonus.gzgqj.manager.webResult.ServerResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Objects;
/**
* 配件管理 入库
* @author 黑子
*/
public class PartApplyServiceImpl {
@Service
@Slf4j
public class PartApplyServiceImpl implements PartApplyService{
@Autowired
private PartApplyMapper mapper;
@Autowired
private FileUploadService uploadService;
/**
* 申请记录列表查询
* @param data
* @return
*/
@Override
public List<PartApplyAppVo> findByPage(PartApplyAppVo data) {
List<PartApplyAppVo> list=new ArrayList<>();
try{
if(StringHelper.isNotEmpty(data.getTimes())){
data.setStartDay(data.getTimes().split(" ~ ")[0]);
data.setEndDay(data.getTimes().split(" ~ ")[1]);
}
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);
//图片转换
String bast641=transBast64(vo.getLyUrl());
String bast642=transBast64(vo.getCkUrl());
String bast643=transBast64(vo.getShUrl());
String bast644=transBast64(vo.getZdUrl());
vo.setLyUrl(bast641);
vo.setCkUser(bast642);
vo.setShUrl(bast643);
vo.setZdUrl(bast644);
List<FileUploadVo> flieList=uploadService.getFileList(data.getId(),"t_part_apply",null);
vo.setFileList(flieList);
List<PartApplyDetailAppVo> details=mapper.getDetailsList(data);
vo.setDetailsList(details);
return ServerResponse.createSuccess(vo);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createSuccess(new PartApplyAppVo());
}
/**
* 审核 数据
* @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.createSuccess("该数据已被审核,请刷新重试");
}
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);
//通过
if("2".equals(status)){
vo.setAuditType("3");
data.setStatusType("3");
}
int num=mapper.insertAuditRecord(voo);
if(num>0){
data.setFzUser(userId.toString());
mapper.updatePartInfo(data);
return ServerResponse.createSuccess("审核成功","审核成功");
}
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("审核失败");
}
public String transBast64(String url){
try{
Path path = Paths.get(url);
byte[] fileBytes = Files.readAllBytes(path);
return Base64.getEncoder().encodeToString(fileBytes);
}catch (Exception e){
log.error(e.toString(),e);
}
return "";
}
}

View File

@ -106,10 +106,6 @@ public class PartInputServiceImpl implements PartInputService{
BigDecimal totalPrice = price.multiply(num);
detail.setTotalPrice(totalPrice.toString());
allPrice.add(totalPrice);
//更新 库存数量
int typeNum=mapper.getPaTypeById(detail);
int nowNum= detail.getInputNum()+typeNum;
mapper.updateTypeNum(detail.getPartId(),nowNum);
});
vo.setAllPrice(allPrice.toString());
@ -117,12 +113,19 @@ public class PartInputServiceImpl implements PartInputService{
vo.setIsFlag(isFlag.get());
int num=mapper.addInputData(vo);
if(num>0){
List<FileUploadVo> fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input");
List<FileUploadVo> fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input",null);
if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){
return ServerResponse.createErroe("入库失败");
}
int num2= mapper.addDetails(vo,list);
if(num2==list.size()){
list.forEach(detail->{
//更新 库存数量-及平准单价
int typeNum=mapper.getPaTypeById(detail);
int nowNum= detail.getInputNum()+typeNum;
String pzPrice=mapper.getPzPrice(detail);
mapper.updateTypeNum(detail.getPartId(),nowNum,pzPrice);
});
return ServerResponse.createSuccess("入库成功");
}
return ServerResponse.createErroe("入库失败");
@ -175,11 +178,17 @@ public class PartInputServiceImpl implements PartInputService{
int num2= mapper.uploadDetails(list);
if(num2!=list.size()){
return ServerResponse.createErroe("修改失败");
}else{
list.forEach(detail->{
//更新 -及平准单价
String pzPrice=mapper.getPzPrice(detail);
mapper.updateTypeNum2(detail.getPartId(),pzPrice);
});
}
}
//文件上传
if(files!=null || files.length>0){
List<FileUploadVo> fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input");
List<FileUploadVo> fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input",null);
if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){
return ServerResponse.createErroe("入库失败");
}
@ -219,7 +228,7 @@ public class PartInputServiceImpl implements PartInputService{
PartInputVo vo=mapper.getInputDetails(data);
String info=mapper.getInfoById(data);
vo.setInfo(info);
List<FileUploadVo> flieList=uploadService.getFileList(data.getId(),"t_part_input");
List<FileUploadVo> flieList=uploadService.getFileList(data.getId(),"t_part_input",null);
vo.setFileList(flieList);
return ServerResponse.createSuccess(vo);
}catch (Exception e){

View File

@ -2,6 +2,9 @@ package com.bonus.gzgqj.business.plan.entity;
import lombok.Data;
/**
* @author 黑子
*/
@Data
public class FileUploadVo {
/**
@ -44,6 +47,10 @@ public class FileUploadVo {
* 业务表名称
*/
private String suffix;
/**
* 类型
*/
private String type;
}

View File

@ -215,7 +215,7 @@ public class PlanOutServiceImpl implements PlanOutService{
vo.setCreater(userId+"");
int num=mapper.insertProOutInfo(vo);
//存储文件
List<FileUploadVo> fileList=uploadService.uploadImage(files,vo.getId(),"t_plan_out");
List<FileUploadVo> fileList=uploadService.uploadImage(files,vo.getId(),"t_plan_out",null);
if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){
return ServerResponse.createErroe("发货失败");
}
@ -304,7 +304,7 @@ public class PlanOutServiceImpl implements PlanOutService{
public ServerResponse getOutDetails(ProNeedInfo data) {
try{
OutDetailInfoVo vo=mapper.getOutDetails(data);
List<FileUploadVo> flieList=uploadService.getFileList(data.getId(),"t_plan_out");
List<FileUploadVo> flieList=uploadService.getFileList(data.getId(),"t_plan_out",null);
List<String> msg=mapper.getOutDetailsInfo(data);
String result = String.join(",", msg); // 结果为 "apple, banana, orange"
vo.setDetails(result);

View File

@ -4,6 +4,7 @@ import com.bonus.gzgqj.business.plan.entity.FileUploadVo;
import com.bonus.gzgqj.business.plan.mapper.FileUploadMapper;
import com.bonus.gzgqj.manager.common.util.DateTimeHelper;
import com.bonus.gzgqj.manager.common.util.SecurityUtils;
import com.bonus.gzgqj.manager.common.util.StringHelper;
import com.bonus.gzgqj.manager.common.util.UserUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -35,7 +36,7 @@ public class FileUploadService {
/**
* 上传文件
*/
public List<FileUploadVo> uploadImage(MultipartFile[] files , String outId, String table){
public List<FileUploadVo> uploadImage(MultipartFile[] files , String outId, String table,String type){
List<FileUploadVo> list=new ArrayList<>();
try {
for (MultipartFile file : files) {
@ -62,6 +63,9 @@ public class FileUploadService {
String userName=UserUtil.getLoginUser().getUsername();
vo.setCreator(userId);
vo.setCreateName(userName);
if(StringHelper.isNotEmpty(type)){
vo.setType(type);
}
list.add(vo);
mapper.insertFileUpload(vo);
}
@ -74,7 +78,7 @@ public class FileUploadService {
}
public List<FileUploadVo> getFileList( String outId, String table){
public List<FileUploadVo> getFileList( String outId, String table,String type){
List<FileUploadVo> list=new ArrayList<>();
try {
FileUploadVo vo=new FileUploadVo();

View File

@ -2,6 +2,25 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bonus.gzgqj.business.app.mapper.PartApplyAppMapper" >
<insert id="addPartApply" useGeneratedKeys="true" keyProperty="id">
INSERT INTO t_part_apply(
code, creator, user_name, create_time, type, remark, status, updater,
update_time, dev_id,dev_code, dev_type, pro_id, pro_name,
apply_num,audit_type)values(
#{code},#{creater},#{userName},now(), #{type},#{remark},#{status},#{updater}, now(),#{deviceId},#{devCode}, #{devType},#{proId},#{proName}
,#{applyNum},#{statusType})
</insert>
<!--差人申请详情-->
<insert id="insertDetails">
insert into t_part_put_details(
apply_id, part_id, apply_num,
part_type, part_name, part_model ) values
<foreach collection="list" item="item" separator=",">
(#{param.id},#{item.partId},#{item.applyNum},
#{item.partType},#{item.partName},#{item.partModel})
</foreach>
</insert>
<select id="getDevList" resultType="com.bonus.gzgqj.business.app.entity.MachinesVo">
select mm.id ,mt2.NAME name ,mt3.`NAME` type ,mt.name model ,mm.DEVICE_CODE deviceCode
from mm_machines mm
@ -36,6 +55,69 @@
</select>
<!--配件下拉选集合-->
<select id="getPaTypeList" resultType="com.bonus.gzgqj.business.bases.entity.PaTypeVo">
select pt.id, pt.parent_id parentId,pt.name model ,pt.num,
pt.price,pt.unit ,pt.weight,pt.is_consumables ,
pt.remarks,pt.is_active ,pt.level,pt.warn_num,pt1.`name` name ,pt2.name type
FROM pa_type pt
left join pa_type pt1 on pt.parent_id=pt1.id and pt1.`level`=2 and pt1.is_active=1
left join pa_type pt2 on pt1.parent_id=pt2.id and pt2.`level`=1 and pt2.is_active=1
WHERE pt.is_active=1 and pt.`level`=3
<if test="type!=null and type !=''">
and pt2.name like concat('%',#{type},'%')
</if>
<if test="name!=null and name !=''">
and pt1.name like concat('%',#{name},'%')
</if>
<if test="model!=null and model !=''">
and pt.name like concat('%',#{model},'%')
</if>
</select>
<select id="getSqList" resultType="java.lang.Integer">
select count(1)
from t_part_apply
where DATE_FORMAT(create_time,'%Y-%m-%d')=CURRENT_DATE
</select>
<!--配件申请查询记录-->
<select id="getPartApplyList" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
tpa.create_time createTime,tpa.type ,
tpa.remark,tpa.status ,tpa.updater,
tpa.update_time updateTime,tpa.dev_id deviceId,tpa.dev_code devCode,
tpa.dev_type devType,tpa.pro_id proId,tpa.pro_name proName,
tpa.status_type statusType,tpa.apply_num applyNum,
tpa.zd_user zdUser,fz_user fzUser,ck_user ckUser,zd_time zdTime,fz_time fzTime,ck_time ckTime
FROM t_part_apply tpa
<where>
<if test="keyWord!=null and keyWord!=''">
and (
tpa.code like('%',#{keyWord},'%') or
tpa.user_name like('%',#{keyWord},'%') or
tpa.remark like('%',#{keyWord},'%') or
tpa.pro_name like('%',#{keyWord},'%')
)
</if>
</where>
</select>
<select id="getPartApplyDetails" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
tpa.create_time createTime,tpa.type ,
tpa.remark,tpa.status ,tpa.updater,
tpa.update_time updateTime,tpa.dev_id deviceId,tpa.dev_code devCode,
tpa.dev_type devType,tpa.pro_id proId,tpa.pro_name proName,
tpa.status_type statusType,tpa.apply_num applyNum,
tpa.zd_user zdUser,fz_user fzUser,ck_user ckUser,zd_time zdTime,fz_time fzTime,ck_time ckTime
FROM t_part_apply tpa
where tpa.id=#{id}
</select>
<select id="getDetailsList" resultType="com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo">
select ppd.id,ppd.apply_id applyId, ppd.part_id partId, ppd.apply_num applyNum,
ppd.part_type partType, ppd.part_name partName, ppd.part_model partModel,
pt.price ,(ppd.apply_num*pt.price ) money
from t_part_apply_details ppd
LEFT JOIN pa_type pt on pt.id=ppd.part_id
where ppd.apply_id=#{id}
</select>
</mapper>

View File

@ -1,5 +1,74 @@
<?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.gzgqj.business.bases.mapper.PartApplyMapper" >
<insert id="insertAuditRecord">
insert into t_part_apply_record(
apply_id, auditor, audit_time,
audit_status, audit_remark
)values (#{applyId},#{auditor},now(),#{auditStatus},#{auditRemark})
</insert>
<update id="updatePartInfo">
update t_part_apply set fz_user=#{fzUser},fz_time=now() ,status=#{status},status_type=#{statusType}
where id=#{id}
</update>
<!-- 领料 申请-->
<select id="findByPage" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
tpa.create_time createTime,tpa.type ,
tpa.remark,tpa.status ,tpa.updater,pu.TELPHONE phone,
tpa.update_time updateTime,tpa.dev_id deviceId,tpa.dev_code devCode,
tpa.dev_type devType,tpa.pro_id proId,tpa.pro_name proName,
tpa.status_type statusType,tpa.apply_num applyNum,
tpa.zd_user zdUser,fz_user fzUser,ck_user ckUser,zd_time zdTime,fz_time fzTime,ck_time ckTime
FROM t_part_apply tpa
left join pm_user pu on tpa.creator=pu.id
<where>
<if test="keyWord!=null and keyWord!=''">
and (
tpa.code like('%',#{keyWord},'%') or
tpa.user_name like('%',#{keyWord},'%') or
tpa.remark like('%',#{keyWord},'%') or
tpa.pro_name like('%',#{keyWord},'%')
)
</if>
<if test="times!=null and times!='' and startDay!=null and endDay!=null ">
and STR_TO_DATE(tpa.create_time, '%Y-%m-%d') between STR_TO_DATE(#{startDay} ,'%Y-%m-%d') AND STR_TO_DATE(#{endDay},'%Y-%m-%d')
</if>
</where>
</select>
<select id="getPartDetails" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
tpa.create_time createTime,tpa.type ,
tpa.remark,tpa.status ,tpa.updater,pu.TELPHONE phone,
tpa.update_time updateTime,tpa.dev_id deviceId,tpa.dev_code devCode,
tpa.dev_type devType,tpa.pro_id proId,tpa.pro_name proName,
tpa.status_type statusType,tpa.apply_num applyNum,
tpa.zd_user zdUser,fz_user fzUser,ck_user ckUser,zd_time zdTime,fz_time fzTime,ck_time ckTime,
pu.SIGN_URL lyUrl, pu2.SIGN_URL zdUrl ,pu3.SIGN_URL ckUrl ,pu4.SIGN_URL shUrl
FROM t_part_apply tpa
left join pm_user pu on tpa.creator=pu.id -- 领用人
left join pm_user pu2 on tpa.zd_user=pu2.id -- 制单人
left join pm_user pu3 on tpa.ck_user=pu3.id -- 出库人
left join pm_user pu4 on tpa.fz_user=pu4.id -- 审核人
where tpa.id=#{id}
</select>
<select id="getDetailsList" resultType="com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo">
select ppd.id,ppd.apply_id applyId, ppd.part_id partId, ppd.apply_num applyNum,
ppd.part_type partType, ppd.part_name partName, ppd.part_model partModel
from t_part_put_details ppd
where ppd.apply_id=#{id}
</select>
<!--审核状态-->
<select id="getAuditStatus" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
tpa.create_time createTime,tpa.type ,
tpa.remark,tpa.status ,tpa.updater,
tpa.update_time updateTime,tpa.dev_id deviceId,tpa.dev_code devCode,
tpa.dev_type devType,tpa.pro_id proId,tpa.pro_name proName,
tpa.status_type statusType,tpa.apply_num applyNum,
tpa.zd_user zdUser,fz_user fzUser,ck_user ckUser,zd_time zdTime,fz_time fzTime,ck_time ckTime
FROM t_part_apply tpa
where tpa.id=#{id}
</select>
</mapper>

View File

@ -21,7 +21,11 @@
</insert>
<update id="updateTypeNum">
update pa_type set num=#{num} where id=#{id}
update pa_type set num=#{num},price=#{price} where id=#{id}
</update>
<update id="updateTypeNum2">
update pa_type set price=#{price} where id=#{id}
</update>
<update id="uploadDetails">
@ -87,4 +91,9 @@
FROM t_part_put_details ppd
where ppd.put_id=#{id}
</select>
<select id="getPzPrice" resultType="java.lang.String">
select ROUND(IFNULL(AVG(part_price),0),2) price
from t_part_put_details
where ppd.part_id=#{partId}
</select>
</mapper>

View File

@ -6,15 +6,11 @@
<insert id="insertFileUpload" useGeneratedKeys="true" keyProperty="id">
insert into bm_file_upload(
file_name,
file_url,
create_time,
creator,
model_table,
own_id,
suffix,
file_type,create_name
)values(#{fileName},#{fileUrl},now(),#{creator},#{modelTable},#{ownId},#{suffix},#{fileType},#{createName})
file_name, file_url,
create_time,creator,
model_table, own_id,
suffix,file_type,create_name,type
)values(#{fileName},#{fileUrl},now(),#{creator},#{modelTable},#{ownId},#{suffix},#{fileType},#{createName},#{type})
</insert>
<delete id="deleteFile">
@ -31,10 +27,13 @@
creator creator,
model_table,
own_id ownId ,
suffix,
suffix,type,
file_type fileType,create_name createName
from bm_file_upload
where own_id=#{ownId} and model_table=#{modelTable}
<if test="type!=null and type!=''">
and type=#{type}
</if>
</select>
@ -51,7 +50,7 @@
creator creator,
model_table,
own_id ownId ,
suffix,
suffix,type,
file_type fileType,create_name createName
from bm_file_upload
where id in