数据接口

This commit is contained in:
haozq 2024-11-12 16:38:35 +08:00
parent 4670572a41
commit 15f3e45bca
17 changed files with 597 additions and 8 deletions

View File

@ -0,0 +1,51 @@
package com.bonus.gzgqj.business.app.controller;
import com.bonus.gzgqj.business.app.entity.MachinesVo;
import com.bonus.gzgqj.business.app.service.PartApplyAppServiceImp;
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
*
* app 领料申请
*
* @author 黑子
*/
@RestController
@RequestMapping("/app/partApply")
@Slf4j
public class PartApplyAppController {
@Autowired
private PartApplyAppServiceImp service;
/**
* 配件申请-设备 下拉选集合
* @param dto
* @return
*/
@PostMapping("getDevList")
public ServerResponse getDevList(MachinesVo dto) {
return service.getDevList(dto);
}
@PostMapping("getProInfo")
public ServerResponse getProInfo(MachinesVo dto) {
return service.getProInfo(dto);
}
}

View File

@ -0,0 +1,44 @@
package com.bonus.gzgqj.business.app.entity;
import lombok.Data;
import java.util.List;
/**
* 设备接口
* @author 黑子
*/
@Data
public class MachinesVo {
/**
* 设备id
*/
private String id;
/**
* 编码
*/
private String deviceCode;
/**
* 类型
*/
private String type;
/**
* 名称
*/
private String name;
/**
* 规格
*/
private String module;
/**
* 使用单位
*/
private String unit;
private String proId;
private String proName;
}

View File

@ -0,0 +1,22 @@
package com.bonus.gzgqj.business.app.entity;
import lombok.Data;
/**
* 领料申请
* @author 黑子
*/
@Data
public class PartApplyAppVo {
private String id;
private String name;
}

View File

@ -0,0 +1,28 @@
package com.bonus.gzgqj.business.app.mapper;
import com.bonus.gzgqj.business.app.entity.MachinesVo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author 黑子
* 配件申请
*/
@Repository
public interface PartApplyAppMapper {
/**
* 查询设备集合
* @param dto
* @return
*/
List<MachinesVo> getDevList(MachinesVo dto);
/**
* 查询记录
* @param dto
* @return
*/
String getWfRecordList(MachinesVo dto);
}

View File

@ -0,0 +1,58 @@
package com.bonus.gzgqj.business.app.service;
import com.bonus.gzgqj.business.app.entity.MachinesVo;
import com.bonus.gzgqj.business.app.mapper.PartApplyAppMapper;
import com.bonus.gzgqj.manager.common.util.StringHelper;
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.lang.ref.PhantomReference;
import java.util.ArrayList;
import java.util.List;
/**
* @author 黑子
* app 配件申请
*/
@Service
@Slf4j
public class PartApplyAppServiceImp {
@Autowired
private PartApplyAppMapper mapper;
/**
* 查询设备接口
* @param dto
* @return
*/
public ServerResponse getDevList(MachinesVo dto) {
try{
List<MachinesVo> list=mapper.getDevList(dto);
ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createSuccess(new ArrayList<MachinesVo>());
}
/**
* 获取使用单位
* @param dto
* @return
*/
public ServerResponse getProInfo(MachinesVo dto) {
try{
String id=mapper.getWfRecordList(dto);
List<MachinesVo> list=mapper.getDevList(dto);
ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createSuccess(new ArrayList<MachinesVo>());
}
}

View File

@ -1,8 +1,10 @@
package com.bonus.gzgqj.business.bases.controller;
import com.bonus.gzgqj.business.bases.entity.PartInputDetails;
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
import com.bonus.gzgqj.business.bases.service.PartInputService;
import com.bonus.gzgqj.business.plan.entity.PlanApplyBean;
import com.bonus.gzgqj.business.plan.entity.ProNeedInfo;
import com.bonus.gzgqj.manager.annotation.DecryptAndVerify;
import com.bonus.gzgqj.manager.core.entity.EncryptedReq;
import com.bonus.gzgqj.manager.webResult.ServerResponse;
@ -54,13 +56,53 @@ public class PartInputController {
/**
* 配件 入库修改接口
* @return
*/
@PostMapping("updateInputData")
public ServerResponse updateInputData(HttpServletRequest request, @RequestParam("file[]") MultipartFile[] files) {
return service.updateInputData(request,files);
}
/**
* 查询配件详情
* @return
*/
@PostMapping("getInputDetails")
@DecryptAndVerify(decryptedClass = PartInputVo.class)
public ServerResponse getInputDetails(EncryptedReq<PartInputVo> dto) {
return service.getInputDetails(dto.getData());
}
/**
* 分页查询入库明细
* @param dto
* @return
*/
@GetMapping("getInputDetailListByPage")
@DecryptAndVerify(decryptedClass = PartInputVo.class)
public PageInfo<PartInputDetails> getInputDetailListByPage(EncryptedReq<PartInputVo> dto) {
PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
List<PartInputDetails> list = service.getInputDetailList(dto.getData());;
PageInfo<PartInputDetails> pageInfo = new PageInfo<>(list);
return pageInfo;
}
/**
* 部分查询入库明细
* @param dto
* @return
*/
@GetMapping("getInputDetailList")
@DecryptAndVerify(decryptedClass = PartInputVo.class)
public ServerResponse getInputDetailList(EncryptedReq<PartInputVo> dto) {
List<PartInputDetails> list = service.getInputDetailList(dto.getData());;
return ServerResponse.createSuccess(list);
}

View File

@ -1,5 +1,6 @@
package com.bonus.gzgqj.business.bases.entity;
import com.bonus.gzgqj.business.plan.entity.FileUploadVo;
import lombok.Data;
import org.apache.poi.hpsf.Decimal;
@ -64,7 +65,10 @@ public class PartInputVo {
private String startDay;
private String inputUser;
/**
* 删除文件id @ 连接
*/
private String delId;
/**
@ -78,5 +82,14 @@ public class PartInputVo {
private List<PartInputDetails> details;
/**
*
*/
private String info;
/**
* 文件上传 集合
*/
private List<FileUploadVo> fileList;
}

View File

@ -3,6 +3,8 @@ package com.bonus.gzgqj.business.bases.mapper;
import com.bonus.gzgqj.business.bases.entity.PartInputDetails;
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -10,6 +12,7 @@ import java.util.List;
* 配件入库 -数据层
* @author 黑子
*/
@Repository
public interface PartInputMapper {
List<PartInputVo> findByPage(PartInputVo data);
@ -32,4 +35,51 @@ public interface PartInputMapper {
* @param list
*/
int addDetails(@Param("param") PartInputVo vo,@Param("list") List<PartInputDetails> list);
/**
* 查询类型数量
* @param detail
* @return
*/
int getPaTypeById(PartInputDetails detail);
/**
* 修改入库后库存数量
* @param partId
* @param nowNum
*/
void updateTypeNum(@Param("id") String partId,@Param("num") int nowNum);
/**
* 查询入库详情
* @param vo
* @return
*/
PartInputVo getInputDetails(PartInputVo vo);
/**
* 查询概诉
* @param data
* @return
*/
String getInfoById(PartInputVo data);
/**
* 查询入库详情
* @param data
* @return
*/
List<PartInputDetails> getInputDetailList(PartInputVo data);
/**
* 修改 入库信息
* @param list
*/
int uploadDetails(List<PartInputDetails> list);
/**
* 更新1数据
* @param vo
*/
int updateInputData(PartInputVo vo);
}

View File

@ -126,7 +126,7 @@ public class PaTypeServiceImpl implements PaTypeService{
if(idList==null || idList.isEmpty()){
int num= mapper.deleteTypeData(data);
if(num>0){
return ServerResponse.createSuccess("删除成功");
return ServerResponse.createSuccess("删除成功","删除成功");
}else{
return ServerResponse.createErroe("删除失败!");
}

View File

@ -1,5 +1,6 @@
package com.bonus.gzgqj.business.bases.service;
import com.bonus.gzgqj.business.bases.entity.PartInputDetails;
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
import com.bonus.gzgqj.manager.webResult.ServerResponse;
import org.springframework.web.multipart.MultipartFile;
@ -25,4 +26,26 @@ public interface PartInputService {
* @return
*/
ServerResponse addInputData(HttpServletRequest request, MultipartFile[] files);
/**
* 查询入库详情
* @param data
* @return
*/
ServerResponse getInputDetails(PartInputVo data);
/**
* 查询入库明细详情
* @param data
* @return
*/
List<PartInputDetails> getInputDetailList(PartInputVo data);
/**
* 修改入库信息
* @param request
* @param files
* @return
*/
ServerResponse updateInputData(HttpServletRequest request, MultipartFile[] files);
}

View File

@ -1,6 +1,8 @@
package com.bonus.gzgqj.business.bases.service;
import cn.afterturn.easypoi.cache.manager.IFileLoader;
import com.alibaba.fastjson.JSON;
import com.bonus.gzgqj.business.bases.entity.PaTypeVo;
import com.bonus.gzgqj.business.bases.entity.PartInputDetails;
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
import com.bonus.gzgqj.business.bases.mapper.PartInputMapper;
@ -12,6 +14,8 @@ import com.bonus.gzgqj.manager.common.util.StringUtils;
import com.bonus.gzgqj.manager.common.util.UserUtil;
import com.bonus.gzgqj.manager.webResult.ServerResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@ -102,7 +106,10 @@ 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());
@ -130,6 +137,113 @@ public class PartInputServiceImpl implements PartInputService{
}
return ServerResponse.createErroe("入库失败");
}
/**
* 修改入库信息
* @param request
* @param files
* @return
*/
@Override
public ServerResponse updateInputData(HttpServletRequest request, MultipartFile[] files) {
try{
String params=request.getParameter("params");
PartInputVo vo= JSON.parseObject(params,PartInputVo.class);
if(StringHelper.isEmpty(vo.getInputUser())){
return ServerResponse.createErroe("请填写入库人");
}
if(StringHelper.isEmpty(vo.getInputDay())){
return ServerResponse.createErroe("请填写入库日期");
}
if(StringHelper.isNotEmpty(vo.getDelId())){
boolean del= uploadService.deleteFile(vo.getDelId());
if(!del){
return ServerResponse.createErroe("文件删除失败");
}
}
List<PartInputDetails> list=vo.getDetails();
//计算价格
if (list!=null && !list.isEmpty()){
list.forEach(detail->{
BigDecimal price = new BigDecimal(detail.getPartPrice());
//数量
BigDecimal num = new BigDecimal(detail.getInputNum());
//总价
BigDecimal totalPrice = price.multiply(num);
detail.setTotalPrice(totalPrice.toString());
});
//修改详情
int num2= mapper.uploadDetails(list);
if(num2!=list.size()){
return ServerResponse.createErroe("修改失败");
}
}
//文件上传
if(files!=null || files.length>0){
List<FileUploadVo> fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input");
if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){
return ServerResponse.createErroe("入库失败");
}
}
List<PartInputDetails> childerList=mapper.getInputDetailList(vo);
AtomicReference<String> isFlag= new AtomicReference<>("1");
BigDecimal allPrice = new BigDecimal("0");
childerList.forEach(data->{
BigDecimal price = new BigDecimal(data.getPartPrice());
BigDecimal num = new BigDecimal(data.getInputNum());
BigDecimal totalPrice = price.multiply(num);
allPrice.add(totalPrice);
if("0".equals(data.getPartPrice())){
isFlag.set("0");
}
});
vo.setIsFlag(isFlag.get());
vo.setAllPrice(allPrice.toString());
int num3= mapper.updateInputData(vo);
if(num3>0){
return ServerResponse.createSuccess("修改成功","修改成功");
}
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("修改失败");
}
/**
* 查询入库详情
* @param data
* @return
*/
@Override
public ServerResponse getInputDetails(PartInputVo data) {
try{
PartInputVo vo=mapper.getInputDetails(data);
String info=mapper.getInfoById(data);
vo.setInfo(info);
List<FileUploadVo> flieList=uploadService.getFileList(data.getId(),"t_part_input");
vo.setFileList(flieList);
return ServerResponse.createSuccess(vo);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createSuccess(new PartInputVo());
}
/**
* 查询入库明细
* @param data
* @return
*/
@Override
public List<PartInputDetails> getInputDetailList(PartInputVo data) {
List<PartInputDetails> list=new ArrayList<>();
try{
list=mapper.getInputDetailList(data);
}catch (Exception e){
log.error(e.toString(),e);
}
return list;
}
public String getCode( ) {

View File

@ -78,6 +78,7 @@ public class PlanOutController {
PageInfo<ProNeedInfo> pageInfo = new PageInfo<>(list);
return pageInfo;
}
/**
* X详情接口
* @param dto

View File

@ -1,6 +1,7 @@
package com.bonus.gzgqj.business.plan.mapper;
import com.bonus.gzgqj.business.plan.entity.FileUploadVo;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -29,4 +30,17 @@ public interface FileUploadMapper {
* @return
*/
String getFilePath(String fileId);
/**
* 查询 文件
* @param list
* @return
*/
List<FileUploadVo> getFileListById(@Param("list") List<String> list);
/**
* 删除文件
* @param list
*/
void deleteFile(List<String> list);
}

View File

@ -10,8 +10,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.swing.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.bonus.gzgqj.business.utils.IDUtils.getSuffix;
@ -79,8 +81,6 @@ public class FileUploadService {
vo.setOwnId(outId);
vo.setModelTable(table);
list=mapper.getFileList(vo);
}catch (Exception e){
log.error(e.toString(),e);
}
@ -97,4 +97,30 @@ public class FileUploadService {
}
return "";
}
/**
* 删除文件
* @param delId
*/
public boolean deleteFile(String delId) {
try{
List<String> list= Arrays.asList(delId.split("@"));
List<FileUploadVo> fileList=mapper.getFileListById(list);
if(fileList!=null && !fileList.isEmpty()){
fileList.forEach(file->{
String newPath= SystemUtils.getUploadPath()+file.getFileUrl();
File file1 = new File(newPath);
file1.delete();
});
}
mapper.deleteFile(list);
return true;
}catch (Exception e){
log.error(e.toString(),e);
return false;
}
}
}

View File

@ -0,0 +1,37 @@
<?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.app.mapper.PartApplyAppMapper" >
<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
left join mm_type mt on mt.id=mm.TYPE and mt.`LEVEL`=4 and mt.IS_ACTIVE=1
left join mm_type mt2 on mt.PARENT_ID=mt2.id
left join mm_type mt3 on mt2.PARENT_ID=mt3.id
where mm.BATCH_STATUS=7
<where >
<if test="name!=null and name!=''">
and mt2.NAME like concat('%',#{name},'%')
</if>
<if test="type!=null and type!=''">
and mt3.NAME like concat('%',#{type},'%')
</if>
<if test="model!=null and model!=''">
and mt.NAME like concat('%',#{model},'%')
</if>
</where>
</select>
<select id="getWfRecordList" resultType="java.lang.String">
select wir.sup_id ,wat.AGREEMENT_ID,
wir.id ,pro.`NAME` proName ,pro.Id proId
from wf_info_record wir
LEFT JOIN wf_return_material_details rmd on wir.SUP_ID=rmd.id
LEFT JOIN wf_agreement_task wat on rmd.TASK_ID=wat.TASK_ID
LEFT JOIN wf_lease_agreement wla on wat.AGREEMENT_ID=wla.id
left join bm_project pro on pro.id=wla.PROJECT
where TYPE=4 AND wir.MA_ID=#{id}
ORDER BY wir.TIME DESC
limit 1
</select>
</mapper>

View File

@ -9,7 +9,7 @@
#{allPrice},#{inputDay},#{inputNum},#{inputUser})
</insert>
<insert id="addDetails">
insert into (
insert into t_part_put_details(
put_id,part_id,part_type,part_name,part_model,part_unit,input_num,part_price,
total_price,vender_id,vender_name) values
<foreach collection="list" item="item" separator=",">
@ -19,9 +19,27 @@
</foreach>
</insert>
<update id="updateTypeNum">
update pa_type set num=#{num} where id=#{id}
</update>
<update id="uploadDetails">
<foreach close="" collection="list" index="index" item="item" open="" separator=";">
update t_part_put_details set part_price=#{item.partPrice}, vender_id=#{item.vendId},
total_price=#{item.totalPrice}, set vender_name=#{item.vendName}
where id=#{item.id}
</foreach>
</update>
<update id="updateInputData">
update t_part_input set updater=#{updater},update_time=now(),all_price=#{allPrice},
input_user=#{inputUser},input_day=#{inputDay},remark=#{remark}
WHERE id=#{id}
</update>
<!--分页查询-->
<select id="findByPage" resultType="com.bonus.gzgqj.business.bases.entity.PartInputVo">
select tpi.id,tpi.code,tpi.creator,tpi.input_day inputDay,
select tpi.id,tpi.code,tpi.creator,tpi.input_day inputDay,tpi.input_user inputUser,
tpi.input_num inputNum,tpi.all_price allPrice,tpi.remark,tpi.is_flag isFlag
from t_part_input tpi
<where>
@ -43,4 +61,30 @@
from t_part_input
where DATE_FORMAT(create_time,'%Y-%m-%d')=CURRENT_DATE
</select>
<select id="getPaTypeById" resultType="java.lang.Integer">
select IFNULL(num,0) num
from pa_type where id=#{partId}
</select>
<!--查询 入库详情-->
<select id="getInputDetails" resultType="com.bonus.gzgqj.business.bases.entity.PartInputVo">
select tpi.id,tpi.code,tpi.creator,tpi.input_day inputDay,tpi.input_user inputUser,
tpi.input_num inputNum,tpi.all_price allPrice,tpi.remark,tpi.is_flag isFlag
from t_part_input tpi
WHERE tpi.id=#{id}
</select>
<select id="getInfoById" resultType="java.lang.String">
select CONCAT(part_name,":",SUM(input_num)) detail
from t_part_put_details
where put_id=#{id}
GROUP BY part_name
</select>
<!--入库详情查询-->
<select id="getInputDetailList" resultType="com.bonus.gzgqj.business.bases.entity.PartInputDetails">
select ppd.id, ppd.put_id inputId,ppd.part_id partId, ppd.part_type partType,
ppd.part_name partName, ppd.part_model partModel, ppd.part_unit partUnit, ppd.input_num inputNum,
ppd.part_price partPrice, ppd.total_price totalPrice, ppd.vender_id vendId,
ppd.vender_name vendName
FROM t_part_put_details ppd
where ppd.put_id=#{id}
</select>
</mapper>

View File

@ -17,6 +17,13 @@
)values(#{fileName},#{fileUrl},now(),#{creator},#{modelTable},#{ownId},#{suffix},#{fileType},#{createName})
</insert>
<delete id="deleteFile">
delete from bm_file_upload
where id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<select id="getFileList" resultType="com.bonus.gzgqj.business.plan.entity.FileUploadVo">
select id, file_name fileName,
file_url fileUrl,
@ -37,4 +44,19 @@
WHERE id=#{id}
</select>
<select id="getFileListById" resultType="com.bonus.gzgqj.business.plan.entity.FileUploadVo">
select id, file_name fileName,
file_url fileUrl,
create_time createTime,
creator creator,
model_table,
own_id ownId ,
suffix,
file_type fileType,create_name createName
from bm_file_upload
where id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>