shenji 1 рік тому
батько
коміт
9219f8f38e

+ 2 - 3
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/AssetMapper.java

@@ -1,10 +1,8 @@
 package org.jeecg.modules.oa.mapper;
 
-import java.util.List;
-
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.oa.entity.Asset;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 /**
  * @Description: 固定资产
@@ -14,4 +12,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface AssetMapper extends BaseMapper<Asset> {
 
+    public boolean deleteByAssetInId(@Param("assetInId") String assetInId);
 }

+ 6 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/AssetMapper.xml

@@ -2,4 +2,10 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.oa.mapper.AssetMapper">
 
+    <delete id="deleteByAssetInId" parameterType="java.lang.String">
+        DELETE
+        FROM  cd_asset
+        WHERE
+        cd_asset_in_id = #{assetInId} 	</delete>
+
 </mapper>

+ 2 - 2
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/CarfareDetailMapper.xml

@@ -6,11 +6,11 @@
         DELETE
         FROM  cd_carfare_detail
         WHERE
-        carfare_id = #{mainId} 	</delete>
+        cd_carfare_id = #{mainId} 	</delete>
 
     <select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.oa.entity.CarfareDetail">
         SELECT *
         FROM  cd_carfare_detail
         WHERE
-        carfare_id = #{mainId} 	</select>
+        cd_carfare_id = #{mainId} 	</select>
 </mapper>

+ 2 - 2
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/MaterialInDetailMapper.xml

@@ -6,11 +6,11 @@
         DELETE
         FROM  cd_material_in_detail
         WHERE
-        material_in_id = #{mainId} 	</delete>
+        cd_material_in_id = #{mainId} 	</delete>
 
     <select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.oa.entity.MaterialInDetail">
         SELECT *
         FROM  cd_material_in_detail
         WHERE
-        material_in_id = #{mainId} 	</select>
+        cd_material_in_id = #{mainId} 	</select>
 </mapper>

+ 2 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/IMaterialInDetailService.java

@@ -14,4 +14,6 @@ import java.util.List;
 public interface IMaterialInDetailService extends IService<MaterialInDetail> {
 
     public List<MaterialInDetail> selectByMainId(String mainId);
+
+    void deleteByMainId(String id);
 }

+ 14 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/AssetInServiceImpl.java

@@ -6,6 +6,7 @@ import org.jeecg.modules.oa.entity.AssetIn;
 import org.jeecg.modules.oa.entity.AssetInDetail;
 import org.jeecg.modules.oa.mapper.AssetInDetailMapper;
 import org.jeecg.modules.oa.mapper.AssetInMapper;
+import org.jeecg.modules.oa.mapper.AssetMapper;
 import org.jeecg.modules.oa.service.IAssetInService;
 import org.jeecg.modules.oa.service.IAssetService;
 import org.springframework.beans.BeanUtils;
@@ -33,6 +34,8 @@ public class AssetInServiceImpl extends ServiceImpl<AssetInMapper, AssetIn> impl
 
 	@Autowired
 	private IAssetService assetService;
+	@Autowired
+	private AssetMapper assetMapper;
 	
 	@Override
 	@Transactional
@@ -61,12 +64,21 @@ public class AssetInServiceImpl extends ServiceImpl<AssetInMapper, AssetIn> impl
 		
 		//1.先删除子表数据
 		assetInDetailMapper.deleteByMainId(assetIn.getId());
+
+		assetMapper.deleteByAssetInId(assetIn.getId());
 		
 		//2.子表数据重新插入
 		if(assetInDetailList!=null && assetInDetailList.size()>0) {
 			for(AssetInDetail entity:assetInDetailList) {
 				//外键设置
 				entity.setCdAssetInId(assetIn.getId());
+				entity.setOperator(assetIn.getOperator());
+				entity.setOperatorDept(assetIn.getOperatorDept());
+				entity.setOperatorDate(assetIn.getOperatorDate());
+
+				Asset asset = new Asset();
+				BeanUtils.copyProperties(entity, asset);
+				this.assetService.save(asset);
 				assetInDetailMapper.insert(entity);
 			}
 		}
@@ -76,6 +88,7 @@ public class AssetInServiceImpl extends ServiceImpl<AssetInMapper, AssetIn> impl
 	@Transactional
 	public void delMain(String id) {
 		assetInDetailMapper.deleteByMainId(id);
+		assetMapper.deleteByAssetInId(id);
 		assetInMapper.deleteById(id);
 	}
 
@@ -84,6 +97,7 @@ public class AssetInServiceImpl extends ServiceImpl<AssetInMapper, AssetIn> impl
 	public void delBatchMain(Collection<? extends Serializable> idList) {
 		for(Serializable id:idList) {
 			assetInDetailMapper.deleteByMainId(id.toString());
+			assetMapper.deleteByAssetInId(id.toString());
 			assetInMapper.deleteById(id);
 		}
 	}

+ 5 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/CarfareServiceImpl.java

@@ -58,6 +58,11 @@ public class CarfareServiceImpl extends ServiceImpl<CarfareMapper, Carfare> impl
 			for(CarfareDetail entity:carfareDetailList) {
 				//外键设置
 				entity.setCdCarfareId(carfare.getId());
+				entity.setRegistrant(carfare.getRegistrant());
+				entity.setRegistrantDept(carfare.getRegistrantDept());
+				entity.setFinanceOperator(carfare.getFinanceOperator());
+				entity.setFinanceDept(carfare.getFinanceDept());
+				entity.setFinanceHead(carfare.getFinanceHead());
 				carfareDetailMapper.insert(entity);
 			}
 		}

+ 15 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/MaterialInDetailServiceImpl.java

@@ -68,4 +68,19 @@ public class MaterialInDetailServiceImpl extends ServiceImpl<MaterialInDetailMap
         }
         return super.updateById(entity);
     }
+
+    @Override
+    public void deleteByMainId(String id) {
+        List<MaterialInDetail> details = materialInDetailMapper.selectByMainId(id);
+        details.forEach(detail->{
+            MaterialInDetail existedDetail = this.getById(detail.getId());
+            if(existedDetail!=null){
+                Material materialOld = materialService.getById(existedDetail.getCdMaterialId());
+                materialOld.setQuantity(materialOld.getQuantity().subtract(existedDetail.getQuantity()));
+                materialService.saveOrUpdate(materialOld);
+            }
+
+        });
+        this.materialInDetailMapper.deleteByMainId(id.toString());
+    }
 }

+ 9 - 4
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/MaterialInServiceImpl.java

@@ -55,14 +55,19 @@ public class MaterialInServiceImpl extends ServiceImpl<MaterialInMapper, Materia
 		materialInMapper.updateById(materialIn);
 		
 		//1.先删除子表数据
-		materialInDetailMapper.deleteByMainId(materialIn.getId());
+		materialInDetailService.deleteByMainId(materialIn.getId());
 		
 		//2.子表数据重新插入
 		if(materialInDetailList!=null && materialInDetailList.size()>0) {
 			for(MaterialInDetail entity:materialInDetailList) {
 				//外键设置
 				entity.setCdMaterialInId(materialIn.getId());
-				materialInDetailMapper.insert(entity);
+				entity.setOperator(materialIn.getOperator());
+				entity.setOperatorDept(materialIn.getOperatorDept());
+				entity.setOperateDate(materialIn.getOperateDate());
+				entity.setRemark(materialIn.getRemark());
+				entity.setAttachment(materialIn.getAttachment());
+				materialInDetailService.save(entity);
 			}
 		}
 	}
@@ -70,7 +75,7 @@ public class MaterialInServiceImpl extends ServiceImpl<MaterialInMapper, Materia
 	@Override
 	@Transactional
 	public void delMain(String id) {
-		materialInDetailMapper.deleteByMainId(id);
+		materialInDetailService.deleteByMainId(id);
 		materialInMapper.deleteById(id);
 	}
 
@@ -78,7 +83,7 @@ public class MaterialInServiceImpl extends ServiceImpl<MaterialInMapper, Materia
 	@Transactional
 	public void delBatchMain(Collection<? extends Serializable> idList) {
 		for(Serializable id:idList) {
-			materialInDetailMapper.deleteByMainId(id.toString());
+			materialInDetailService.deleteByMainId(id.toString());
 			materialInMapper.deleteById(id);
 		}
 	}