diff --git a/src/main/java/com/bonus/gzgqj/business/app/entity/PartApplyDetailAppVo.java b/src/main/java/com/bonus/gzgqj/business/app/entity/PartApplyDetailAppVo.java index 3527c47..68c0b68 100644 --- a/src/main/java/com/bonus/gzgqj/business/app/entity/PartApplyDetailAppVo.java +++ b/src/main/java/com/bonus/gzgqj/business/app/entity/PartApplyDetailAppVo.java @@ -37,6 +37,11 @@ public class PartApplyDetailAppVo { * 配件 型号 */ private String partModel; + + /** + * 配件 型号 + */ + private String partUnit; /** * 金钱 */ diff --git a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartApplyController.java b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartApplyController.java index ed3797a..cfd37e5 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartApplyController.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartApplyController.java @@ -84,5 +84,14 @@ public class PartApplyController { + /** + * 出库-接口 + * @return + */ + @PostMapping("partOutInfo") + @DecryptAndVerify(decryptedClass = PartApplyAppVo.class) + public ServerResponse partOutInfo(EncryptedReq dto) { + return service.partOutInfo(dto.getData()); + } } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartBackController.java b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartBackController.java new file mode 100644 index 0000000..9507341 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartBackController.java @@ -0,0 +1,98 @@ +package com.bonus.gzgqj.business.bases.controller; + + +import com.bonus.gzgqj.business.app.entity.PartApplyAppVo; +import com.bonus.gzgqj.business.bases.entity.PartBackVo; +import com.bonus.gzgqj.business.bases.entity.UserPatypeInfo; +import com.bonus.gzgqj.business.bases.service.PartBackService; +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.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * 配件 退料申请 + * @author 黑子 + */ + +@RestController +@RequestMapping("/backstage/partBack") +@Slf4j +public class PartBackController { + + @Autowired + private PartBackService service; + + + + /** + * 领料出库 查询 + * @param dto + * @return + */ + @GetMapping("findByPage") + @DecryptAndVerify(decryptedClass = PartBackVo.class) + public PageInfo findByPage(EncryptedReq dto) { + PageHelper.startPage(dto.getPageNum(),dto.getPageSize()); + List list = service.findByPage(dto.getData());; + PageInfo pageInfo = new PageInfo<>(list); + return pageInfo; + } + + + + + /** + * 退料人下拉选 + * @param dto + * @return + */ + @GetMapping("getUserList") + @DecryptAndVerify(decryptedClass = UserPatypeInfo.class) + public ServerResponse getUserList(EncryptedReq dto) { + return service.getUserList(dto.getData()); + } + + + /** + * 退料人下拉选 + * @param dto + * @return + */ + @GetMapping("getInfoDetails") + @DecryptAndVerify(decryptedClass = PartBackVo.class) + public ServerResponse getInfoDetails(EncryptedReq dto) { + return service.getInfoDetails(dto.getData()); + } + /** + * 分页查询配件类型 + * @param dto + * @return + */ + @GetMapping("getPaTypeList") + @DecryptAndVerify(decryptedClass = UserPatypeInfo.class) + public PageInfo getPaTypeList(EncryptedReq dto) { + PageHelper.startPage(dto.getPageNum(),dto.getPageSize()); + List list = service.getPaTypeList(dto.getData());; + PageInfo pageInfo = new PageInfo<>(list); + return pageInfo; + } + /** + * 配件 退料 + * @return + */ + @PostMapping("backInfo") + public ServerResponse backInfo(HttpServletRequest request, @RequestParam(value = "file[]",required = false) MultipartFile[] files) { + return service.backInfo(request,files); + } + + +} diff --git a/src/main/java/com/bonus/gzgqj/business/bases/entity/PaTypeVo.java b/src/main/java/com/bonus/gzgqj/business/bases/entity/PaTypeVo.java index e0e260b..fd45b2d 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/entity/PaTypeVo.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/entity/PaTypeVo.java @@ -25,7 +25,7 @@ public class PaTypeVo { /** * 数量 */ - private String num; + private int num; /** * 价格 */ @@ -61,7 +61,18 @@ public class PaTypeVo { private String parentName; + /** + * 申请数量 + */ private String sqNum; + /** + * 出库数量 + */ + private int ckNum; + /** + * 总入库量 + */ + private int allNum; } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/entity/PartBackDetailsVo.java b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartBackDetailsVo.java new file mode 100644 index 0000000..aaed0fc --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartBackDetailsVo.java @@ -0,0 +1,50 @@ +package com.bonus.gzgqj.business.bases.entity; + +import lombok.Data; + +/** + * 退料详情记录 + * @author 黑子 + */ +@Data +public class PartBackDetailsVo { + + /** + * 主键 + */ + private String id; + + private String backId; + /** + * 回退 + */ + private int backNum; + + + /** + * 配件id + */ + private String partId; + /** + * 配件类型 + */ + private String partType; + /** + * 配件名称 + */ + private String partName; + + /** + * 配件类型 + */ + private String partModel; + + /** + * 配件类型 + */ + private String partUnit; + /** + * 备注 + */ + private String remark; +} diff --git a/src/main/java/com/bonus/gzgqj/business/bases/entity/PartBackVo.java b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartBackVo.java new file mode 100644 index 0000000..42da1c2 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartBackVo.java @@ -0,0 +1,78 @@ +package com.bonus.gzgqj.business.bases.entity; + +import com.bonus.gzgqj.business.plan.entity.FileUploadVo; +import lombok.Data; + +import java.util.List; + +/** + * 配件退回 + * + * @author 黑子 + */ +@Data +public class PartBackVo { + /** + * 主键 + */ + private String id; + /** + * 编码 + */ + private String code; + /** + * 回退人 + */ + private String creator; + /** + * 回退人名称 + */ + private String userName; + + /** + * 回退日期 + */ + private String backDay; + /** + * 创建时间 + */ + private String createTime; + /** + * 创建人 + */ + private String createId; + + private String updateTime; + + private String updater; + /** + * 备注 + */ + private String remark; + + private String type; + /** + * 关键字 + */ + private String keyWord; + /** + * 开始时间 + */ + private String startDay; + /** + * 结束时间 + */ + private String endDay; + + private int backNum; + /** + * 详情集合 + */ + private List detailsVoList; + + + /** + * 文件上传 集合 + */ + private List fileList; +} diff --git a/src/main/java/com/bonus/gzgqj/business/bases/entity/UserPatypeInfo.java b/src/main/java/com/bonus/gzgqj/business/bases/entity/UserPatypeInfo.java new file mode 100644 index 0000000..ab4e065 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/entity/UserPatypeInfo.java @@ -0,0 +1,52 @@ +package com.bonus.gzgqj.business.bases.entity; + +import lombok.Data; + +/** + * 人员领用详情服务 + * @author 黑子 + */ +@Data +public class UserPatypeInfo { + + + private String userId; + /** + * 领用人名称 + */ + private String userName; + + /** + * 配件id + */ + private String partId; + /** + * 配件类型 + */ + private String partType; + /** + * 配件名称 + */ + private String partName; + /** + * 配件类型 + */ + private String partModel; + + /** + * 单位 + */ + private String partUnit; + /** + * 领用数量 + */ + private int lyNum; + /** + * 归还数量 + */ + private int ghNum; + + + + +} diff --git a/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartApplyMapper.java b/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartApplyMapper.java index 3c09aa1..791fc40 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartApplyMapper.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartApplyMapper.java @@ -3,6 +3,7 @@ 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 com.bonus.gzgqj.business.bases.entity.PaTypeVo; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -54,4 +55,17 @@ public interface PartApplyMapper { * @param data */ void updatePartInfo(PartApplyAppVo data); + + /** + * 查询 + * @param partId + * @return + */ + PaTypeVo getPaTypeVoById(String partId); + + /** + * 更新出库数量 + * @param paTypeVo + */ + void updatePaTypeVoById(PaTypeVo paTypeVo); } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartBackMapper.java b/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartBackMapper.java new file mode 100644 index 0000000..f71df05 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartBackMapper.java @@ -0,0 +1,66 @@ +package com.bonus.gzgqj.business.bases.mapper; + +import com.bonus.gzgqj.business.bases.entity.PartBackDetailsVo; +import com.bonus.gzgqj.business.bases.entity.PartBackVo; +import com.bonus.gzgqj.business.bases.entity.UserPatypeInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author 黑子 + * 退料申请接口成 + */ +@Repository +public interface PartBackMapper { + /** + * 人员下拉选查询 + * @param data + * @return + */ + List getUserList(UserPatypeInfo data); + + /** + * 查询配置 + * @param data + * @return + */ + List getPaTypeList(UserPatypeInfo data); + + /** + * 查询当日回退数量 + * @return + */ + int getBackNum(); + + /** + * 插入回退数据 + * @param vo + * @return + */ + int insertBack(PartBackVo vo); + + int insertBackDetails(PartBackVo vo, List list); + + /** + * 分页查询 退料数据 + * @param data + * @return + */ + List findByPage(PartBackVo data); + + /** + * 查询入库信息 + * @param data + * @return + */ + PartBackVo getInfoDetails(PartBackVo data); + + /** + * 查询 回退详情 + * @param data + * @return + */ + List getInfoDetailList(PartBackVo data); +} 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 3ad878d..8c762a2 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 @@ -1,5 +1,6 @@ package com.bonus.gzgqj.business.bases.mapper; +import com.bonus.gzgqj.business.bases.entity.PaTypeVo; import com.bonus.gzgqj.business.bases.entity.PartInputDetails; import com.bonus.gzgqj.business.bases.entity.PartInputVo; @@ -40,14 +41,14 @@ public interface PartInputMapper { * @param detail * @return */ - int getPaTypeById(PartInputDetails detail); + PaTypeVo getPaTypeById(PartInputDetails detail); /** * 修改入库后库存数量 * @param partId * @param nowNum */ - void updateTypeNum(@Param("id") String partId,@Param("num") int nowNum,@Param("price")String price); + void updateTypeNum(PaTypeVo paTypeVo); void updateTypeNum2(@Param("id") String partId,@Param("price")String price); diff --git a/src/main/java/com/bonus/gzgqj/business/bases/mapper/UserPartInfoMapper.java b/src/main/java/com/bonus/gzgqj/business/bases/mapper/UserPartInfoMapper.java new file mode 100644 index 0000000..30e1406 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/mapper/UserPartInfoMapper.java @@ -0,0 +1,38 @@ +package com.bonus.gzgqj.business.bases.mapper; + +import com.bonus.gzgqj.business.bases.entity.UserPatypeInfo; +import lombok.Data; +import org.springframework.stereotype.Repository; + +/** + * 人员领用详情记录表 + * @author 黑子 + */ +@Repository +public interface UserPartInfoMapper { + + /** + * 查询 历史数据 + * @param user + * @return + */ + UserPatypeInfo getInfo(UserPatypeInfo user); + + /** + * 插入数据 + * @param user + */ + void insertData(UserPatypeInfo user); + + /** + * + * @param user + */ + void updateData(UserPatypeInfo user); + + /** + * 更新归还数量 + * @param user + */ + void updateBackData(UserPatypeInfo user); +} diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/PartApplyService.java b/src/main/java/com/bonus/gzgqj/business/bases/service/PartApplyService.java index 312a107..1362b36 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/service/PartApplyService.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/PartApplyService.java @@ -40,4 +40,11 @@ public interface PartApplyService { * @return */ ServerResponse uploadImage(HttpServletRequest request, MultipartFile[] files); + + /** + * 出库 + * @param data + * @return + */ + ServerResponse partOutInfo(PartApplyAppVo data); } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/PartApplyServiceImpl.java b/src/main/java/com/bonus/gzgqj/business/bases/service/PartApplyServiceImpl.java index be77111..0f4a688 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/service/PartApplyServiceImpl.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/PartApplyServiceImpl.java @@ -3,6 +3,7 @@ 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.entity.PaTypeVo; import com.bonus.gzgqj.business.bases.mapper.PartApplyMapper; import com.bonus.gzgqj.business.plan.entity.FileUploadVo; import com.bonus.gzgqj.business.utils.FileUploadService; @@ -38,6 +39,9 @@ public class PartApplyServiceImpl implements PartApplyService{ @Autowired private FileUploadService uploadService; + @Autowired + UserPartInfoServiceImpl userPartInfoService; + /** * 申请记录列表查询 * @param data @@ -47,10 +51,6 @@ public class PartApplyServiceImpl implements PartApplyService{ public List findByPage(PartApplyAppVo data) { List 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); @@ -106,9 +106,9 @@ public class PartApplyServiceImpl implements PartApplyService{ voo.setAuditRemark(data.getRemark()); voo.setApplyId(data.getId()); voo.setAuditStatus(status); + voo.setAuditType("2"); //通过 if("2".equals(status)){ - vo.setAuditType("3"); data.setStatusType("3"); } int num=mapper.insertAuditRecord(voo); @@ -151,6 +151,56 @@ public class PartApplyServiceImpl implements PartApplyService{ } + /** + * 出库-接口 + * @param data + * @return + */ + @Override + public ServerResponse partOutInfo(PartApplyAppVo data) { + List list=new ArrayList<>(); + try{ + String id=data.getId(); + PartApplyAppVo vo=mapper.getAuditStatus(data); + if(!"2".equals(vo.getStatus())){ + return ServerResponse.createSuccess("该数据状态已变更,请刷新数据重试"); + } + 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){ + //出库 + data.setCkUser(userId.toString()); + data.setStatus("4"); + data.setStatusType("1"); + mapper.updatePartInfo(data); + //计算出库数量 + List details=mapper.getDetailsList(data); + String userName=UserUtil.getLoginUser().getUsername(); + //出库数据 维护 + userPartInfoService.insert(details,vo.getCreater(),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("出库成功","出库成功"); + } + + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createErroe("出库失败"); + } + public String transBast64(String url){ try{ diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/PartBackService.java b/src/main/java/com/bonus/gzgqj/business/bases/service/PartBackService.java new file mode 100644 index 0000000..c87a0a0 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/PartBackService.java @@ -0,0 +1,46 @@ +package com.bonus.gzgqj.business.bases.service; + +import com.bonus.gzgqj.business.bases.entity.PaTypeVo; +import com.bonus.gzgqj.business.bases.entity.PartBackVo; +import com.bonus.gzgqj.business.bases.entity.UserPatypeInfo; +import com.bonus.gzgqj.manager.webResult.ServerResponse; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * 退料入库 + */ +public interface PartBackService { + /** + * 查询已领用人员详情 + * @param data + * @return + */ + ServerResponse getUserList(UserPatypeInfo data); + + /** + * 分页查询 配件 + * @param data + * @return + */ + List getPaTypeList(UserPatypeInfo data); + + /** + * 配件退料接口 + * @param request + * @param files + * @return + */ + ServerResponse backInfo(HttpServletRequest request, MultipartFile[] files); + + /** + * 分页查询 退料数据 + * @param data + * @return + */ + List findByPage(PartBackVo data); + + ServerResponse getInfoDetails(PartBackVo data); +} diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/PartBackServiceImpl.java b/src/main/java/com/bonus/gzgqj/business/bases/service/PartBackServiceImpl.java new file mode 100644 index 0000000..5707f0f --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/PartBackServiceImpl.java @@ -0,0 +1,183 @@ +package com.bonus.gzgqj.business.bases.service; + +import com.alibaba.fastjson.JSON; +import com.bonus.gzgqj.business.bases.entity.*; +import com.bonus.gzgqj.business.bases.mapper.PartApplyMapper; +import com.bonus.gzgqj.business.bases.mapper.PartBackMapper; +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.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 org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 退料申请业务层 + * + * @author 黑子 + */ +@Service +@Slf4j +public class PartBackServiceImpl implements PartBackService { + + @Autowired + private PartBackMapper mapper; + @Autowired + private PartApplyMapper partApplyMapper; + + @Autowired + private FileUploadService uploadService; + + + @Autowired + private UserPartInfoServiceImpl userPartInfoService; + + + + @Override + public List findByPage(PartBackVo data) { + List list=new ArrayList<>(); + try{ + list= mapper.findByPage(data); + }catch (Exception e){ + log.error(e.toString(),e); + } + return list; + } + + /** + * 查询详情数据 + * @param data + * @return + */ + @Override + public ServerResponse getInfoDetails(PartBackVo data) { + try{ + PartBackVo vo=mapper.getInfoDetails(data); + List detailList=mapper.getInfoDetailList(data); + List flieList=uploadService.getFileList(data.getId(),"t_part_back",null); + vo.setFileList(flieList); + vo.setDetailsVoList(detailList); + return ServerResponse.createSuccess(vo); + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createSuccess(new PartBackVo()); + } + + + @Override + public ServerResponse getUserList(UserPatypeInfo data) { + List list=new ArrayList<>(); + try{ + list= mapper.getUserList(data); + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createSuccess(list); + } + + @Override + public List getPaTypeList(UserPatypeInfo data) { + List list=new ArrayList<>(); + try{ + list= mapper.getPaTypeList(data); + }catch (Exception e){ + log.error(e.toString(),e); + } + return list; + } + + /** + * 配件退料申请接口 + * @param request + * @param files + * @return + */ + @Override + public ServerResponse backInfo(HttpServletRequest request, MultipartFile[] files) { + try{ + Long userId= Objects.requireNonNull(UserUtil.getLoginUser()).getUserId(); + String params=request.getParameter("params"); + PartBackVo vo= JSON.parseObject(params,PartBackVo.class); + if(StringHelper.isEmpty(vo.getCreator())){ + return ServerResponse.createErroe("请选择退料人"); + } + if(StringHelper.isEmpty(vo.getBackDay())){ + return ServerResponse.createErroe("请选择退料日期"); + } + if(files==null || files.length<=0){ + return ServerResponse.createErroe("未上传附件"); + } + List list=vo.getDetailsVoList(); + if(list==null || list.isEmpty()){ + return ServerResponse.createErroe("请填写回退明细"); + } + String code=getCode(); + vo.setCode(code); + vo.setCreateId(userId.toString()); + vo.setUpdater(userId.toString()); + // 使用Stream API对quantity属性求和 + int backNum = list.stream() + .mapToInt(PartBackDetailsVo::getBackNum) + .sum(); + vo.setBackNum(backNum); + int num=mapper.insertBack(vo); + if(num>0){ + List fileList=uploadService.uploadImage(files,vo.getId(),"t_part_back","退料附件"); + if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){ + return ServerResponse.createErroe("退料失败"); + } + int nums= mapper.insertBackDetails(vo,list); + if(nums==list.size()){ + //退料 + userPartInfoService.backInfo(list,vo.getCreator()); + //更新库存数量 + list.forEach(detail->{ + String partId=detail.getPartId(); + int backNum=detail.getBackNum(); + PaTypeVo paTypeVo=partApplyMapper.getPaTypeVoById(partId); + paTypeVo.setNum(paTypeVo.getNum()+backNum); + paTypeVo.setCkNum(paTypeVo.getCkNum()-backNum); + //更新当前库存 + partApplyMapper.updatePaTypeVoById(paTypeVo); + }); + return ServerResponse.createSuccess("退料成功","退料成功"); + } + + + } + + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createErroe("退料失败"); + } + + + + + public String getCode( ) { + int num =mapper.getBackNum(); + num++; + String year= DateTimeHelper.getNowYMD(); + if(num<10) { + return year+"00"+num; + }else if(num<100) { + return year+"0"+num; + } + return year+num; + } + +} 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 32c13fd..67b493c 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 @@ -15,6 +15,7 @@ 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.CORBA.INTERNAL; import org.omg.PortableInterceptor.INACTIVE; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -118,11 +119,15 @@ public class PartInputServiceImpl implements PartInputService{ if(num2==list.size()){ list.forEach(detail->{ //更新 库存数量-及平准单价 - int typeNum=mapper.getPaTypeById(detail); - int nowNum= detail.getInputNum()+typeNum; + PaTypeVo paTypeVo=mapper.getPaTypeById(detail); + int nowNum= detail.getInputNum()+paTypeVo.getNum(); + int allNum=detail.getInputNum()+paTypeVo.getAllNum(); + paTypeVo.setNum(nowNum); + paTypeVo.setAllNum(allNum); + paTypeVo.setPrice(detail.getPartPrice()); // String pzPrice=mapper.getPzPrice(detail); //最后入库就是最终价格 - mapper.updateTypeNum(detail.getPartId(),nowNum,detail.getPartPrice()); + mapper.updateTypeNum(paTypeVo); }); return ServerResponse.createSuccess("入库成功"); } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/UserPartInfoServiceImpl.java b/src/main/java/com/bonus/gzgqj/business/bases/service/UserPartInfoServiceImpl.java new file mode 100644 index 0000000..32c9134 --- /dev/null +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/UserPartInfoServiceImpl.java @@ -0,0 +1,75 @@ +package com.bonus.gzgqj.business.bases.service; + +import com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo; +import com.bonus.gzgqj.business.bases.entity.PartBackDetailsVo; +import com.bonus.gzgqj.business.bases.entity.PartInputDetails; +import com.bonus.gzgqj.business.bases.entity.UserPatypeInfo; +import com.bonus.gzgqj.business.bases.mapper.UserPartInfoMapper; +import com.bonus.gzgqj.manager.common.util.StringHelper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author 黑子 + */ +@Service +@Slf4j +public class UserPartInfoServiceImpl { + + + @Autowired + private UserPartInfoMapper mapper; + + /** + * 新增 领料数据 + * @param list + */ + public void insert(List list, String userId, String userName){ + try{ + if(list!=null && !list.isEmpty()){ + UserPatypeInfo user=new UserPatypeInfo(); + for (PartApplyDetailAppVo vo:list){ + user.setPartId(vo.getPartId()); + user.setUserId(userId); + UserPatypeInfo info=mapper.getInfo(user); + //无数据 + if(info==null || StringHelper.isEmpty(info.getUserId())){ + user.setPartName(vo.getPartName()); + user.setPartType(vo.getPartType()); + user.setPartModel(vo.getPartModel()); + user.setUserName(userName); + user.setLyNum(vo.getApplyNum()); + user.setGhNum(0); + mapper.insertData(user); + }else{ + info.setLyNum(info.getLyNum()+vo.getApplyNum()); + mapper.updateData(user); + } + } + } + }catch (Exception e){ + log.error(e.toString(),e); + } + } + + /** + * 退料 数据 + * @param list + */ + public void backInfo(List list, String userId ){ + if(list!=null && !list.isEmpty()){ + UserPatypeInfo user=new UserPatypeInfo(); + for (PartBackDetailsVo vo:list){ + user.setPartId(vo.getPartId()); + user.setUserId(userId); + UserPatypeInfo info=mapper.getInfo(user); + info.setGhNum(info.getGhNum()+vo.getBackNum()); + mapper.updateBackData(user); + } + } + } + +} diff --git a/src/main/resources/mappers/app/PartApplyAppMapper.xml b/src/main/resources/mappers/app/PartApplyAppMapper.xml index 9d1359a..6796ec5 100644 --- a/src/main/resources/mappers/app/PartApplyAppMapper.xml +++ b/src/main/resources/mappers/app/PartApplyAppMapper.xml @@ -12,12 +12,12 @@ - insert into t_part_put_details( + insert into t_part_apply_details( apply_id, part_id, apply_num, - part_type, part_name, part_model ) values + part_type, part_name, part_model,part_unit ) values (#{param.id},#{item.partId},#{item.applyNum}, - #{item.partType},#{item.partName},#{item.partModel}) + #{item.partType},#{item.partName},#{item.partModel},#{item.partUnit}) diff --git a/src/main/resources/mappers/bases/PaTypeMapper.xml b/src/main/resources/mappers/bases/PaTypeMapper.xml index 27f05c7..c9a6c4d 100644 --- a/src/main/resources/mappers/bases/PaTypeMapper.xml +++ b/src/main/resources/mappers/bases/PaTypeMapper.xml @@ -3,7 +3,7 @@ - insert into pa_type(parent_id, name,remarks,unit,is_active,level,price)VALUES(#{parentId},#{name},#{remarks},#{unit},1,#{level},0) + insert into pa_type(parent_id, name,remarks,unit,is_active,level,price,ck_num,bf_num,all_num)VALUES(#{parentId},#{name},#{remarks},#{unit},1,#{level},0,0,0,0) update pa_type set name=#{name},remarks=#{remarks},unit=#{unit} where id=#{id} diff --git a/src/main/resources/mappers/bases/PartApplyMapper.xml b/src/main/resources/mappers/bases/PartApplyMapper.xml index edb58b4..2ad3300 100644 --- a/src/main/resources/mappers/bases/PartApplyMapper.xml +++ b/src/main/resources/mappers/bases/PartApplyMapper.xml @@ -4,13 +4,20 @@ insert into t_part_apply_record( apply_id, auditor, audit_time, - audit_status, audit_remark - )values (#{applyId},#{auditor},now(),#{auditStatus},#{auditRemark}) + audit_status, audit_remark,audit_type + )values (#{applyId},#{auditor},now(),#{auditStatus},#{auditRemark},#{auditType}) - update t_part_apply set fz_user=#{fzUser},fz_time=now() ,status=#{status},status_type=#{statusType} + update t_part_apply set status=#{status},status_type=#{statusType} + + ,fz_user=#{fzUser} ,fz_time=now() + + + ,ck_user=#{ckUser} ,ck_time=now() + where id=#{id} + @@ -71,4 +78,13 @@ FROM t_part_apply tpa where tpa.id=#{id} + + + + update pa_type set num=#{num},ck_num=#{ckNum} where id=#{id} + \ No newline at end of file diff --git a/src/main/resources/mappers/bases/PartBackMapper.xml b/src/main/resources/mappers/bases/PartBackMapper.xml new file mode 100644 index 0000000..2b0727c --- /dev/null +++ b/src/main/resources/mappers/bases/PartBackMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + insert into t_part_back( + code,creator,back_day, + create_time, type, remark, + status,updater, update_time, create_id,back_num,user_name + )values (#{code},#{creator},#{backDay},now(),#{type},#{remark},#{status},#{updater},now(),#{createId},#{backNum},#{userName}) + + + insert into t_part_back_details( + back_id, back_num, part_id, + part_type, part_name, part_model, + part_unit, remark ) values + + (#{param.id},#{item.backNum},#{item.partId},#{item.partType},#{item.partName}, + #{item.partModel},#{item.partUnit},#{item.remark}) + + + + + + + + + + + + \ 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 f4ca1d3..e1ea049 100644 --- a/src/main/resources/mappers/bases/PartInputMapper.xml +++ b/src/main/resources/mappers/bases/PartInputMapper.xml @@ -21,7 +21,8 @@ - update pa_type set num=#{num},price=#{price} where id=#{id} + update pa_type set num=#{num},price=#{price},all_num=#{allNum} + where id=#{id} @@ -64,9 +65,9 @@ from t_part_input where DATE_FORMAT(create_time,'%Y-%m-%d')=CURRENT_DATE - + select id ,num,ck_num ckNum,all_num allNum + from pa_type where id=#{partId} + select + user_id userId, part_id partId,part_type partType, + part_name partName, part_model partModel, + ly_num lyNum, gh_num ghNum, user_name userName,part_unit partUnit + from tb_user_pa_type_info + where user_id=#{userId} and part_id=#{partId} + + \ No newline at end of file