diff --git a/src/main/java/com/bonus/gzgqj/business/app/controller/PartApplyAppController.java b/src/main/java/com/bonus/gzgqj/business/app/controller/PartApplyAppController.java new file mode 100644 index 0000000..7db3575 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/app/controller/PartApplyAppController.java @@ -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); + } + + + +} diff --git a/src/main/java/com/bonus/gzgqj/business/app/entity/MachinesVo.java b/src/main/java/com/bonus/gzgqj/business/app/entity/MachinesVo.java new file mode 100644 index 0000000..dade5b5 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/app/entity/MachinesVo.java @@ -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; + +} diff --git a/src/main/java/com/bonus/gzgqj/business/app/entity/PartApplyAppVo.java b/src/main/java/com/bonus/gzgqj/business/app/entity/PartApplyAppVo.java new file mode 100644 index 0000000..e4706af --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/app/entity/PartApplyAppVo.java @@ -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; + + + + + + + +} diff --git a/src/main/java/com/bonus/gzgqj/business/app/mapper/PartApplyAppMapper.java b/src/main/java/com/bonus/gzgqj/business/app/mapper/PartApplyAppMapper.java new file mode 100644 index 0000000..28ce145 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/app/mapper/PartApplyAppMapper.java @@ -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 getDevList(MachinesVo dto); + + /** + * 查询记录 + * @param dto + * @return + */ + String getWfRecordList(MachinesVo dto); +} diff --git a/src/main/java/com/bonus/gzgqj/business/app/service/PartApplyAppServiceImp.java b/src/main/java/com/bonus/gzgqj/business/app/service/PartApplyAppServiceImp.java new file mode 100644 index 0000000..a5b8f2d --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/app/service/PartApplyAppServiceImp.java @@ -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 list=mapper.getDevList(dto); + ServerResponse.createSuccess(list); + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createSuccess(new ArrayList()); + } + + /** + * 获取使用单位 + * @param dto + * @return + */ + public ServerResponse getProInfo(MachinesVo dto) { + try{ + String id=mapper.getWfRecordList(dto); + + + + List list=mapper.getDevList(dto); + ServerResponse.createSuccess(list); + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createSuccess(new ArrayList()); + } +} diff --git a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartInputController.java b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartInputController.java index 149c536..887720d 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartInputController.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartInputController.java @@ -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 dto) { + return service.getInputDetails(dto.getData()); + } + /** + * 分页查询入库明细 + * @param dto + * @return + */ + @GetMapping("getInputDetailListByPage") + @DecryptAndVerify(decryptedClass = PartInputVo.class) + public PageInfo getInputDetailListByPage(EncryptedReq dto) { + PageHelper.startPage(dto.getPageNum(),dto.getPageSize()); + List list = service.getInputDetailList(dto.getData());; + PageInfo pageInfo = new PageInfo<>(list); + return pageInfo; + } - + /** + * 部分查询入库明细 + * @param dto + * @return + */ + @GetMapping("getInputDetailList") + @DecryptAndVerify(decryptedClass = PartInputVo.class) + public ServerResponse getInputDetailList(EncryptedReq dto) { + List list = service.getInputDetailList(dto.getData());; + return ServerResponse.createSuccess(list); + } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputVo.java b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputVo.java index 465286c..073745f 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputVo.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputVo.java @@ -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 details; + /** + * + */ + private String info; + + /** + * 文件上传 集合 + */ + private List fileList; } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartInputMapper.java b/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartInputMapper.java index 5812147..25d2719 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartInputMapper.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartInputMapper.java @@ -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 findByPage(PartInputVo data); @@ -32,4 +35,51 @@ public interface PartInputMapper { * @param list */ int addDetails(@Param("param") PartInputVo vo,@Param("list") List 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 getInputDetailList(PartInputVo data); + + /** + * 修改 入库信息 + * @param list + */ + int uploadDetails(List list); + + /** + * 更新1数据 + * @param vo + */ + int updateInputData(PartInputVo vo); } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/PaTypeServiceImpl.java b/src/main/java/com/bonus/gzgqj/business/bases/service/PaTypeServiceImpl.java index 9f5e2b2..a36beb1 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/service/PaTypeServiceImpl.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/PaTypeServiceImpl.java @@ -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("删除失败!"); } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputService.java b/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputService.java index fe00c31..6bac0d3 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputService.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputService.java @@ -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 getInputDetailList(PartInputVo data); + + /** + * 修改入库信息 + * @param request + * @param files + * @return + */ + ServerResponse updateInputData(HttpServletRequest request, MultipartFile[] files); } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputServiceImpl.java b/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputServiceImpl.java index b315cac..2f203c5 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputServiceImpl.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputServiceImpl.java @@ -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 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 fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input"); + if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){ + return ServerResponse.createErroe("入库失败"); + } + } + List childerList=mapper.getInputDetailList(vo); + AtomicReference 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 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 getInputDetailList(PartInputVo data) { + List list=new ArrayList<>(); + try{ + list=mapper.getInputDetailList(data); + }catch (Exception e){ + log.error(e.toString(),e); + } + return list; + } + public String getCode( ) { diff --git a/src/main/java/com/bonus/gzgqj/business/plan/controller/PlanOutController.java b/src/main/java/com/bonus/gzgqj/business/plan/controller/PlanOutController.java index 9e8a42a..dd3db64 100644 --- a/src/main/java/com/bonus/gzgqj/business/plan/controller/PlanOutController.java +++ b/src/main/java/com/bonus/gzgqj/business/plan/controller/PlanOutController.java @@ -78,6 +78,7 @@ public class PlanOutController { PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } + /** * X详情接口 * @param dto diff --git a/src/main/java/com/bonus/gzgqj/business/plan/mapper/FileUploadMapper.java b/src/main/java/com/bonus/gzgqj/business/plan/mapper/FileUploadMapper.java index 059d5bb..6377cc5 100644 --- a/src/main/java/com/bonus/gzgqj/business/plan/mapper/FileUploadMapper.java +++ b/src/main/java/com/bonus/gzgqj/business/plan/mapper/FileUploadMapper.java @@ -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 getFileListById(@Param("list") List list); + + /** + * 删除文件 + * @param list + */ + void deleteFile(List list); } diff --git a/src/main/java/com/bonus/gzgqj/business/utils/FileUploadService.java b/src/main/java/com/bonus/gzgqj/business/utils/FileUploadService.java index ade25e0..0312bd7 100644 --- a/src/main/java/com/bonus/gzgqj/business/utils/FileUploadService.java +++ b/src/main/java/com/bonus/gzgqj/business/utils/FileUploadService.java @@ -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 list= Arrays.asList(delId.split("@")); + List 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; + } + + + } } diff --git a/src/main/resources/mappers/app/PartApplyAppMapper.xml b/src/main/resources/mappers/app/PartApplyAppMapper.xml new file mode 100644 index 0000000..e1de0d5 --- /dev/null +++ b/src/main/resources/mappers/app/PartApplyAppMapper.xml @@ -0,0 +1,37 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mappers/bases/PartInputMapper.xml b/src/main/resources/mappers/bases/PartInputMapper.xml index e616eda..b423439 100644 --- a/src/main/resources/mappers/bases/PartInputMapper.xml +++ b/src/main/resources/mappers/bases/PartInputMapper.xml @@ -9,7 +9,7 @@ #{allPrice},#{inputDay},#{inputNum},#{inputUser}) - 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 @@ -19,9 +19,27 @@ + + + update pa_type set num=#{num} where id=#{id} + + + + + 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} + + + + update t_part_input set updater=#{updater},update_time=now(),all_price=#{allPrice}, + input_user=#{inputUser},input_day=#{inputDay},remark=#{remark} + WHERE id=#{id} + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mappers/plan/FileUploadMapper.xml b/src/main/resources/mappers/plan/FileUploadMapper.xml index 973a1d3..349cd56 100644 --- a/src/main/resources/mappers/plan/FileUploadMapper.xml +++ b/src/main/resources/mappers/plan/FileUploadMapper.xml @@ -17,6 +17,13 @@ )values(#{fileName},#{fileUrl},now(),#{creator},#{modelTable},#{ownId},#{suffix},#{fileType},#{createName}) + + delete from bm_file_upload + where id in + + #{item} + + + \ No newline at end of file