From 4670572a41833c9981d2fe9f07a5257fa597671a Mon Sep 17 00:00:00 2001 From: haozq <1611483981@qq.com> Date: Tue, 12 Nov 2024 13:53:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bases/controller/PaTypeController.java | 2 +- .../bases/entity/PartInputDetails.java | 4 +- .../business/bases/entity/PartInputVo.java | 4 +- .../bases/mapper/PartInputMapper.java | 22 ++++++ .../bases/service/PaTypeServiceImpl.java | 4 +- .../bases/service/PartInputServiceImpl.java | 74 ++++++++++++++++--- .../resources/mappers/bases/PaTypeMapper.xml | 6 +- .../mappers/bases/PartInputMapper.xml | 24 ++++++ 8 files changed, 122 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/bonus/gzgqj/business/bases/controller/PaTypeController.java b/src/main/java/com/bonus/gzgqj/business/bases/controller/PaTypeController.java index 3eaf37b..74dccf5 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/controller/PaTypeController.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/controller/PaTypeController.java @@ -68,7 +68,7 @@ public class PaTypeController { * @param dto * @return */ - @GetMapping("deleteTypeData") + @PostMapping("deleteTypeData") @DecryptAndVerify(decryptedClass = PaTypeVo.class) public ServerResponse deleteTypeData(EncryptedReq dto) { return service.deleteTypeData(dto.getData()); diff --git a/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputDetails.java b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputDetails.java index 93c377c..fd58f67 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputDetails.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputDetails.java @@ -23,11 +23,11 @@ public class PartInputDetails { /** * 单个价格 */ - private Decimal partPrice; + private String partPrice; /** * 总价格 */ - private Decimal totalPrice; + private String totalPrice; /** * 厂家id 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 503289c..465286c 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 @@ -52,7 +52,7 @@ public class PartInputVo { /** * 总金额 */ - private Decimal allPrice; + private String allPrice; /** * 入库数量 */ @@ -63,6 +63,8 @@ public class PartInputVo { */ private String startDay; + private String inputUser; + /** 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 b4119a8..5812147 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,6 +1,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 java.util.List; @@ -10,4 +12,24 @@ import java.util.List; */ public interface PartInputMapper { List findByPage(PartInputVo data); + + /** + * 查询今日入库数量 + * @return + */ + int getInputNum(); + + /** + * 新增 入库数据 + * @param vo + * @return + */ + int addInputData(PartInputVo vo); + + /** + * 新增入库 + * @param vo + * @param list + */ + int addDetails(@Param("param") PartInputVo vo,@Param("list") List list); } 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 b359d86..9f5e2b2 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 @@ -98,7 +98,7 @@ public class PaTypeServiceImpl implements PaTypeService{ }else{ int nums=mapper.updateTypeData(data); if(nums>0){ - return ServerResponse.createSuccess("修改成功"); + return ServerResponse.createSuccess("修改成功",data); }else{ return ServerResponse.createErroe("修改失败"); } @@ -123,7 +123,7 @@ public class PaTypeServiceImpl implements PaTypeService{ int id=data.getId(); if(id>0){ List idList=mapper.getChildList(data.getId()); - if(idList!=null && !idList.isEmpty()){ + if(idList==null || idList.isEmpty()){ int num= mapper.deleteTypeData(data); if(num>0){ return ServerResponse.createSuccess("删除成功"); 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 cc73b50..b315cac 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 @@ -4,8 +4,11 @@ import com.alibaba.fastjson.JSON; import com.bonus.gzgqj.business.bases.entity.PartInputDetails; import com.bonus.gzgqj.business.bases.entity.PartInputVo; import com.bonus.gzgqj.business.bases.mapper.PartInputMapper; -import com.bonus.gzgqj.business.plan.entity.ProOutInfoVo; +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; @@ -14,8 +17,11 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; /** * 配件入库 业务层 @@ -27,6 +33,8 @@ public class PartInputServiceImpl implements PartInputService{ @Autowired private PartInputMapper mapper; + @Autowired + private FileUploadService uploadService; /** * 分页查询配件入库 * @param data @@ -59,7 +67,7 @@ public class PartInputServiceImpl implements PartInputService{ try{ String params=request.getParameter("params"); PartInputVo vo= JSON.parseObject(params,PartInputVo.class); - if(StringHelper.isEmpty(vo.getCreator())){ + if(StringHelper.isEmpty(vo.getInputUser())){ return ServerResponse.createErroe("请填写入库人"); } if(StringHelper.isEmpty(vo.getInputDay())){ @@ -72,19 +80,67 @@ public class PartInputServiceImpl implements PartInputService{ if(list==null || list.isEmpty()){ return ServerResponse.createErroe("请上传入库配件"); } + Long userId= Objects.requireNonNull(UserUtil.getLoginUser()).getUserId(); + // String userName=UserUtil.getLoginUser().getUsername(); + String code=getCode(); + vo.setCode(code); + vo.setCreator(userId.toString()); + vo.setUpdater(userId.toString()); + AtomicReference isFlag= new AtomicReference<>("1"); + final int[] inputNum = {0}; + BigDecimal allPrice = new BigDecimal("0"); + list.forEach(detail->{ + inputNum[0] = inputNum[0] +detail.getInputNum(); + //单价 + BigDecimal price = new BigDecimal(detail.getPartPrice()); + if("0".equals(detail.getPartPrice())){ + isFlag.set("0"); + } + //数量 + BigDecimal num = new BigDecimal(detail.getInputNum()); + //总价 + BigDecimal totalPrice = price.multiply(num); + detail.setTotalPrice(totalPrice.toString()); + allPrice.add(totalPrice); - long userId= UserUtil.getLoginUser().getUserId(); - String userName=UserUtil.getLoginUser().getUsername(); - //int num=mapper.addInputData(vo); - - + }); + vo.setAllPrice(allPrice.toString()); + vo.setInputNum(inputNum[0]); + vo.setIsFlag(isFlag.get()); + int num=mapper.addInputData(vo); + if(num>0){ + List fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input"); + if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){ + return ServerResponse.createErroe("入库失败"); + } + int num2= mapper.addDetails(vo,list); + if(num2==list.size()){ + return ServerResponse.createSuccess("入库成功"); + } + return ServerResponse.createErroe("入库失败"); + }else{ + return ServerResponse.createErroe("入库失败"); + } }catch (Exception e){ - + log.error(e.toString(),e); } - return null; + return ServerResponse.createErroe("入库失败"); + } + + + public String getCode( ) { + int num =mapper.getInputNum(); + 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/resources/mappers/bases/PaTypeMapper.xml b/src/main/resources/mappers/bases/PaTypeMapper.xml index ca83f64..343faa1 100644 --- a/src/main/resources/mappers/bases/PaTypeMapper.xml +++ b/src/main/resources/mappers/bases/PaTypeMapper.xml @@ -3,10 +3,10 @@ - insert into pa_type(parent_id, name,remarks,is_active,level)VALUES(#{parentId},#{name},#{remarks},1,#{level}) + insert into pa_type(parent_id, name,remarks,unit,is_active,level)VALUES(#{parentId},#{name},#{remarks},#{unit},1,#{level}) - update pa_type set name=#{name},remarks=#{remarks} where id=#{id} + update pa_type set name=#{name},remarks=#{remarks},unit=#{unit} where id=#{id} update pa_type set is_active=0 where id=#{id} @@ -20,7 +20,7 @@ select tpi.id,tpi.code,tpi.creator,tpi.input_day inputDay, @@ -19,4 +37,10 @@ + + \ No newline at end of file