hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/controller/SysEmbedmentGoodsController.java
@@ -43,8 +43,8 @@ } //查询规格 @GetMapping("/findAllDetails") public BasicResult findAllDetails(){ return sysEmbedmentGoodsService.findAllDetails(); public BasicResult findAllDetails(String id){ return sysEmbedmentGoodsService.findAllDetails(id); } //查询dict类型 hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/controller/SysInsetRecordsController.java
@@ -31,7 +31,9 @@ */ @PostMapping(value = "insert") public BasicResult insert (@RequestBody SysEmbedmentRecordEntity sysEmbedmentRecordEntity){ return sysEmbedmentRecordService.insert(sysEmbedmentRecordEntity); synchronized (this){ return sysEmbedmentRecordService.insert(sysEmbedmentRecordEntity); } } /** @@ -51,7 +53,9 @@ */ @PostMapping(value = "update") BasicResult update(@RequestBody SysEmbedmentRecordEntity sysEmbedmentRecordEntity){ return sysEmbedmentRecordService.update(sysEmbedmentRecordEntity); synchronized (this){ return sysEmbedmentRecordService.update(sysEmbedmentRecordEntity); } } /** @@ -110,7 +114,9 @@ * @param request */ @PostMapping(value = "variateExcel") void variateExcel(@RequestParam MultipartFile file, HttpServletRequest request){ this.sysEmbedmentRecordService.variateExcel(file,request); BasicResult variateExcel(@RequestParam MultipartFile file, HttpServletRequest request){ synchronized (this){ return this.sysEmbedmentRecordService.variateExcel(file,request); } } } hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/controller/SysInventoryManagementController.java
@@ -41,7 +41,7 @@ * @return */ @PostMapping("/alarmSet") public BasicResult alarmSet(EmbedmentGoodsDto embedmentGoodsDto){ public BasicResult alarmSet(@RequestBody EmbedmentGoodsDto embedmentGoodsDto){ return sysEmbedmentGoodsService.alarmSet(embedmentGoodsDto); } @@ -51,7 +51,7 @@ * @return */ @PostMapping("/inventoryCorrection") public BasicResult inventoryCorrection(EmbedmentGoodsDto embedmentGoodsDto){ public BasicResult inventoryCorrection(@RequestBody EmbedmentGoodsDto embedmentGoodsDto){ return sysEmbedmentGoodsService.inventoryCorrection(embedmentGoodsDto); } } hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/dto/EmbedmentGoodsDto.java
@@ -14,7 +14,7 @@ private Integer pageSize; private String embedmentGoodsName; private String embedmentName; private String companyId; hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/entity/SysEmbedmentRecordEntity.java
@@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.thhy.general.annotations.Excel; import com.thhy.general.annotations.Idkey; import lombok.Data; import lombok.Getter; import lombok.Setter; @@ -18,6 +19,7 @@ /** * */ @Idkey("id") private String id; /** hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/mapper/SysEmbedmentGoodsMapper.java
@@ -26,7 +26,7 @@ SysEmbedmentGoodsEntity findEntity(String id); String embedmentNameAndType(@Param("embedmentGoodsName") String embedmentGoodsName, @Param("embedmentType") String embedmentType); String embedmentNameAndType(@Param("embedmentName") String embedmentGoodsName, @Param("embedmentType") String embedmentType,@Param("embedmentModel")String embedmentModel); void alarmSet(EmbedmentGoodsDto embedmentGoodsDto); hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/service/SysEmbedmentGoodsService.java
@@ -21,7 +21,7 @@ BasicResult findAll(EmbedmentGoodsDto embedmentGoodsDto); BasicResult findAllDetails(); BasicResult findAllDetails(String id); BasicResult findEntity(String id); hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/service/impl/SysEmbedmentGoodsServiceImpl.java
@@ -21,11 +21,9 @@ import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; /** * @Author QiuYuHao @@ -56,7 +54,8 @@ sysEmbedmentGoodsEntity.setCompanyId(sysUserInfo.getCompanyId()); String embedmentName = sysEmbedmentGoodsEntity.getEmbedmentName(); String embedmentType = sysEmbedmentGoodsEntity.getEmbedmentType(); String id = sysEmbedmentGoodsMapper.embedmentNameAndType(embedmentName,embedmentType); String embedmentModel = sysEmbedmentGoodsEntity.getEmbedmentModel(); String id = sysEmbedmentGoodsMapper.embedmentNameAndType(embedmentName,embedmentType, embedmentModel); if(!StringUtil.isEmpty(id)){ return BasicResult.faild("11111","error","名称和规格型号不可重复"); } @@ -76,8 +75,9 @@ sysEmbedmentGoodsEntity.setCompanyId(sysUserInfo.getCompanyId()); String embedmentName = sysEmbedmentGoodsEntity.getEmbedmentName(); String embedmentType = sysEmbedmentGoodsEntity.getEmbedmentType(); String id = sysEmbedmentGoodsMapper.embedmentNameAndType(embedmentName,embedmentType); if(!StringUtil.isEmpty(id)){ String embedmentModel = sysEmbedmentGoodsEntity.getEmbedmentModel(); String id = sysEmbedmentGoodsMapper.embedmentNameAndType(embedmentName,embedmentType, embedmentModel); if(!StringUtil.isEmpty(id) && !sysEmbedmentGoodsEntity.getId().equals(id)){ return BasicResult.faild("11111","error","名称和规格型号不可重复"); } sysEmbedmentGoodsMapper.update(sysEmbedmentGoodsEntity); @@ -102,10 +102,8 @@ @Override public BasicResult findAllDetails() { List<String> modelList = sysEmbedmentGoodsMapper.findAll(null) .stream().map(s -> s.getEmbedmentModel()).collect(Collectors.toList()); return BasicResult.success(modelList); public BasicResult findAllDetails(String id) { return BasicResult.success(sysEmbedmentGoodsMapper.findEntity(id).getEmbedmentModel()); } //=======================种类到此结束======================= hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/embedment/service/impl/SysEmbedmentRecordServiceImpl.java
@@ -1,10 +1,10 @@ package com.thhy.materials.modules.biz.embedment.service.impl; import cn.hutool.core.text.StrBuilder; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.thhy.general.common.BasicMessage; import com.thhy.general.common.BasicResult; import com.thhy.general.common.IBasicStatus; import com.thhy.general.config.SysUserInfo; import com.thhy.general.exception.BasicException; import com.thhy.general.utils.ExcelUtils; @@ -15,7 +15,17 @@ import com.thhy.materials.modules.biz.embedment.mapper.SysEmbedmentGoodsMapper; import com.thhy.materials.modules.biz.embedment.mapper.SysEmbedmentRecordMapper; import com.thhy.materials.modules.biz.embedment.service.SysEmbedmentRecordService; import com.thhy.materials.modules.biz.materials.entity.SysAssistGood; import com.thhy.materials.modules.biz.utils.ExcelUtil; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationConstraint; import org.apache.poi.ss.usermodel.DataValidationHelper; import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,10 +33,14 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.OutputStream; import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; /** * @Author QiuYuHao @@ -44,28 +58,30 @@ @Override @Transactional(rollbackFor = Exception.class) public BasicResult insert(SysEmbedmentRecordEntity sysEmbedmentRecordEntity) { SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(); sysEmbedmentRecordEntity.setCreateUser(sysUserInfo.getRealName()); sysEmbedmentRecordEntity.setCompanyId(sysUserInfo.getCompanyId()); SysEmbedmentGoodsEntity entity = sysEmbedmentGoodsMapper.findEntity(sysEmbedmentRecordEntity.getEmbedmentId()); if(entity!=null){ String stockType = sysEmbedmentRecordEntity.getStockType(); //stockType 1入库 2出库 int result = entity.getStock(); if("1".equals(stockType)){ result= entity.getStock() + sysEmbedmentRecordEntity.getChangeStock(); }else{ result= entity.getStock() - sysEmbedmentRecordEntity.getChangeStock(); if(entity!=null){ String stockType = sysEmbedmentRecordEntity.getStockType(); //stockType 1入库 2出库 int result = entity.getStock(); if("1".equals(stockType)){ result= entity.getStock() + sysEmbedmentRecordEntity.getChangeStock(); }else{ result= entity.getStock() - sysEmbedmentRecordEntity.getChangeStock(); } if(result < 0 ){ return BasicResult.faild("11111","库存不足","库存不足"); } entity.setStock(result); sysEmbedmentGoodsMapper.update(entity);//更改库存 }else { return BasicResult.faild("11111","库存没有该预埋件,请到【预埋件种类】添加","库存没有该预埋件,请到【预埋件种类】添加"); } if(result < 0 ){ return BasicResult.faild("11111","库存不足","库存不足"); } entity.setStock(result); sysEmbedmentGoodsMapper.update(entity);//更改库存 }else { return BasicResult.faild("11111","库存没有该预埋件,请到【预埋件种类】添加","库存没有该预埋件,请到【预埋件种类】添加"); } sysEmbedmentRecordMapper.insert(sysEmbedmentRecordEntity); sysEmbedmentRecordMapper.insert(sysEmbedmentRecordEntity); return BasicResult.success(); } @@ -76,7 +92,18 @@ } @Override @Transactional(rollbackFor = Exception.class) public BasicResult update(SysEmbedmentRecordEntity sysEmbedmentRecordEntity) { String id = sysEmbedmentRecordEntity.getId();//记录id String embedmentId = sysEmbedmentRecordEntity.getEmbedmentId();//库存id SysEmbedmentRecordEntity queryRecordData = sysEmbedmentRecordMapper.embedmentRecordInfo(id);//查询到的记录 Integer dataChangeStock = queryRecordData.getChangeStock();//拿到修改前的入库数量 Integer paramChangeStock = sysEmbedmentRecordEntity.getChangeStock();//当前传输入库数量 Integer nowChangeStock = paramChangeStock - dataChangeStock;//当前传的和库里的取差值 SysEmbedmentGoodsEntity entity = sysEmbedmentGoodsMapper.findEntity(embedmentId); Integer resultStock = entity.getStock() + nowChangeStock; entity.setStock(resultStock); sysEmbedmentGoodsMapper.update(entity); sysEmbedmentRecordMapper.update(sysEmbedmentRecordEntity); return BasicResult.success(); } @@ -116,8 +143,38 @@ @Override public void recordExportTemplate(EmbedmentRecordDto embedmentRecordDto, HttpServletResponse response) { List<SysEmbedmentRecordEntity> sysEmbedmentRecordEntities = new ArrayList<>(); ExcelUtils.downExcel(sysEmbedmentRecordEntities,SysEmbedmentRecordEntity.class,response,"预埋件出入库"); SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(); String companyId = sysUserInfo.getCompanyId(); XSSFWorkbook book = new XSSFWorkbook(); XSSFSheet sheet = book.createSheet(); XSSFRow row = sheet.createRow(0); row.createCell(0).setCellValue("物品名称-规格型号"); row.createCell(1).setCellValue("入库数量"); row.createCell(2).setCellValue("单价"); row.createCell(3).setCellValue("金额"); row.createCell(4).setCellValue("备注"); embedmentRecordDto.setCompanyId(companyId); List<String> lx = sysEmbedmentRecordMapper.embedmentRecordList(embedmentRecordDto).stream().map(s -> s.getEmbedmentNameAndModel()).collect(Collectors.toList()); String[] gjlx = lx.toArray(new String[lx.size()]); //物品名称-规格型号 CellRangeAddressList regions1 = new CellRangeAddressList(1, 500, 0, 0); DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper(); DataValidationConstraint createExplicitListConstraint1 = dataValidationHelper.createExplicitListConstraint(gjlx); DataValidation createValidation1 = dataValidationHelper.createValidation(createExplicitListConstraint1, regions1); sheet.addValidationData(createValidation1); response.setContentType("application/vnd.ms-excel;charset=UTF-8"); response.setHeader("Content-Disposition", "attachment;filename=test.xls"); OutputStream out = null; try { out = response.getOutputStream(); book.write(out); out.close(); } catch (Exception e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(out); } } @Override @@ -135,23 +192,34 @@ String embedmentNameAndModel = list.get(0).toString(); String[] split = embedmentNameAndModel.split("-"); String embedmentName = split[0]; String embedmentModel = split[1]; String id = sysEmbedmentGoodsMapper.embedmentNameAndType(embedmentName,null); StringBuilder embedmentModel = new StringBuilder(); for (int i = 1; i < split.length; i++) { if (StringUtils.isBlank(embedmentModel)){ embedmentModel.append(split[i]); }else { embedmentModel.append("-"+split[i]); } } String id = sysEmbedmentGoodsMapper.embedmentNameAndType(embedmentName,null, embedmentModel.toString()); if(StringUtils.isBlank(id)) { throw new BasicException(new BasicMessage("500","库存没有【"+embedmentName+"】,请到预埋件种类新增,新增完可重新导入!")); } SysEmbedmentRecordEntity sysEmbedmentRecordEntity = new SysEmbedmentRecordEntity(); sysEmbedmentRecordEntity.setEmbedmentId(id); //入库数量 Integer changeStock = Integer.valueOf(list.get(2).toString()); Integer changeStock = Integer.valueOf(list.get(1).toString()); sysEmbedmentRecordEntity.setChangeStock(changeStock); //单价 String dj = list.get(3).toString(); String dj = list.get(2).toString(); BigDecimal singlePrice = new BigDecimal(dj); sysEmbedmentRecordEntity.setSinglePrice(singlePrice); //金额 String je = list.get(4).toString(); String je = list.get(3).toString(); BigDecimal amount = new BigDecimal(je); sysEmbedmentRecordEntity.setAmount(amount); //备注 String remark = list.get(5).toString(); String remark = list.get(4).toString(); sysEmbedmentRecordEntity.setRemark(remark); //入库人 SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(); hd/pipe/materialsManage/src/main/resources/mapping/SysEmbedmentGoodsMapper.xml
@@ -27,6 +27,10 @@ <if test="embedmentType != null"> and embedment_type=#{embedmentType} </if> <if test="embedmentModel != null"> and embedment_model=#{embedmentModel} </if> </select> <insert id="insert" > @@ -129,14 +133,18 @@ sag.remark as remark, sd.dict_name as dictName from sys_embedment_goods sag left join sys_dict sd on sag.assist_type=sd.dict_id left join sys_dict sd on sag.embedment_type=sd.dict_id where sag.is_use=1 <if test="assistName!=null and assistName!='' "> and sag.assist_name like concat('%',#{assistName},'%') <if test="embedmentName!=null and embedmentName!='' "> and sag.embedment_name like concat('%',#{embedmentName},'%') </if> <if test="companyId!=null and companyId!='' "> and sag.company_id=#{companyId} </if> <if test="id!=null and id!='' "> and sag.id=#{id} </if> order by sag.create_time desc </select> <select id="findEntity" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.embedment.entity.SysEmbedmentGoodsEntity"> @@ -152,8 +160,8 @@ sag.create_time as createTime, sag.remark as remark, sd.dict_name as dictName from sys_embedment_goods sag left join sys_dict sd on sag.assist_type=sd.dict_id where sag.is_use=1 and sag.id=#{assistId} on sag.embedment_type=sd.dict_id where sag.is_use=1 and sag.id=#{id} </select> <update id="delete" parameterType="java.lang.String" > update sys_embedment_goods set @@ -220,8 +228,5 @@ </set> where id = #{id,jdbcType=VARCHAR} </update> <select id="assistGood" parameterType="java.lang.String" resultType="java.lang.String"> select id from sys_assist_record where assist_id=#{assistId} and is_use=1 </select> </mapper> hd/pipe/materialsManage/src/main/resources/mapping/SysEmbedmentRecordMapper.xml
@@ -53,9 +53,6 @@ <if test="createTime != null"> create_time = #{createTime,jdbcType=TIMESTAMP}, </if> <if test="isUse != null"> is_use = #{isUse,jdbcType=INTEGER}, </if> <if test="companyId != null"> company_id = #{companyId,jdbcType=VARCHAR}, </if> @@ -99,9 +96,6 @@ <if test="createTime != null"> create_time, </if> <if test="isUse != null"> is_use, </if> <if test="companyId != null"> company_id, </if> @@ -140,9 +134,6 @@ <if test="createTime != null"> #{createTime,jdbcType=TIMESTAMP}, </if> <if test="isUse != null"> #{isUse,jdbcType=INTEGER}, </if> <if test="companyId != null"> #{companyId,jdbcType=VARCHAR}, </if> @@ -151,6 +142,7 @@ <select id="embedmentRecordList" resultType="com.thhy.materials.modules.biz.embedment.entity.SysEmbedmentRecordEntity"> select CONCAT(seg.embedment_name,"-",seg.embedment_model) embedmentNameAndModel, ser.id, ser.embedment_id as embedmentId, ser.stock_type as stockType, @@ -188,7 +180,7 @@ <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' "> and ser.create_time between #{strTime} and #{endTime} </if> order by sar.create_time desc order by ser.create_time desc </select> <select id="embedmentRecordOutList" resultType="com.thhy.materials.modules.biz.embedment.entity.SysEmbedmentRecordEntity"> select @@ -229,7 +221,7 @@ <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' "> and ser.create_time between #{strTime} and #{endTime} </if> order by sar.create_time desc order by ser.create_time desc </select> <select id="embedmentRecordInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.embedment.entity.SysEmbedmentRecordEntity"> select @@ -254,22 +246,6 @@ where ser.is_use=1 and ser.id=#{id} </select> <select id="assistIdSelect" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.materials.entity.SysAssistRecord"> select sar.id, sar.assist_id as assistId, sar.stock_type as stockType, sar.change_stock as changeStock, sar.supplier_id as supplierId, sar.single_price as singlePrice, sar.amount as amount, sar.remark as remark, sar.get_depart as getDepart, sar.create_user as createUser, sar.create_time as createTime, sar.is_use as isUse from sys_assist_record sar where sar.id=#{id} </select> <update id="embedmentRecordDel" > update sys_embedment_record set is_use=2