whycxzp
2022-08-26 3ec8bb1ceb56bbe46c152379257200c816acaea0
产品更新,关联关系迁移;规范命名问题
15个文件已修改
165 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/ProductBomController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/MaterialProductApprovingMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/MaterialProductHistoryMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ProductBomMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/MaterialApprovingService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/MaterialProductApprovingService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/MaterialProductHistoryService.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductBomService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/WorksheetLinkService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MaterialMapper.xml 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MaterialProductApprovingMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MaterialProductHistoryMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ProductBomHistoryMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ProductBomMapper.xml 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/WorksheetMainMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/ProductBomController.java
@@ -13,9 +13,7 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
@Api(tags = "图纸管理")
@RestController
@@ -74,8 +72,8 @@
    }*/
    @ApiOperation(tags = "散装件管理",value = "查询所有产品中没有与指定散装件关联的子件")
    @GetMapping("getAllSubWithOutMaterial")
    public Response getAllSubWithOutMaterial(@RequestParam int MaterialId){
        return  service.getAllSubWithOutMaterial(MaterialId);
    public Response getAllSubWithOutMaterial(@RequestParam int materialId){
        return  service.getAllSubWithOutMaterial(materialId);
    }
}
src/main/java/com/whyc/mapper/MaterialProductApprovingMapper.java
@@ -1,12 +1,11 @@
package com.whyc.mapper;
import com.whyc.pojo.MaterialProductApproving;
import com.whyc.pojo.MaterialProductHistory;
import java.util.List;
public interface MaterialProductApprovingMapper extends CustomMapper<MaterialProductApproving> {
    List<MaterialProductApproving> getLatestExistListByMaterialId(Integer MaterialId);
    List<MaterialProductApproving> getLatestExistListByMaterialId(Integer materialId);
}
src/main/java/com/whyc/mapper/MaterialProductHistoryMapper.java
@@ -8,7 +8,7 @@
public interface MaterialProductHistoryMapper extends CustomMapper<MaterialProductHistory>{
    void updateVersionBatch(List<MaterialProductHistory> cphList);
    List<MaterialProductHistory> getLatestExistListByMaterialId(Integer MaterialId);
    List<MaterialProductHistory> getLatestExistListByMaterialId(Integer materialId);
    void updateVersionSubtractBatch(List<MaterialProductApproving> removedList);
src/main/java/com/whyc/mapper/ProductBomMapper.java
@@ -13,7 +13,7 @@
    void updateUrl(List<ProductBomApproving> fileBomApprovingList);
    //查询所有产品中没有与指定散装件关联的子件
    List<ProductBom> getAllSubWithOutMaterial(int MaterialId);
    List<ProductBom> getAllSubWithOutMaterial(int materialId);
    /*//根据母料型号查询子件信息及有关联的散装件信息
    List<ProductBom> getSubByMaterialProduct(String parentModel);*/
src/main/java/com/whyc/service/MaterialApprovingService.java
@@ -162,9 +162,9 @@
        return mapper.selectList(query);
    }
    public MaterialApproving getListByMaterialId(Integer MaterialId) {
    public MaterialApproving getListByMaterialId(Integer materialId) {
        QueryWrapper<MaterialApproving> query = Wrappers.query();
        query.eq("Material_id",MaterialId).last(" limit 1");
        query.eq("material_id",materialId).last(" limit 1");
        return mapper.selectOne(query);
    }
}
src/main/java/com/whyc/service/MaterialProductApprovingService.java
@@ -25,7 +25,7 @@
        return mapper.selectList(query);
    }
    public List<MaterialProductApproving> getLatestExistListByMaterialId(Integer MaterialId) {
        return mapper.getLatestExistListByMaterialId(MaterialId);
    public List<MaterialProductApproving> getLatestExistListByMaterialId(Integer materialId) {
        return mapper.getLatestExistListByMaterialId(materialId);
    }
}
src/main/java/com/whyc/service/MaterialProductHistoryService.java
@@ -35,8 +35,8 @@
        mapper.insertBatchSomeColumn(newHistoryList);
    }
    public List<MaterialProductHistory> getLatestExistListByMaterialId(Integer MaterialId) {
        return mapper.getLatestExistListByMaterialId(MaterialId);
    public List<MaterialProductHistory> getLatestExistListByMaterialId(Integer materialId) {
        return mapper.getLatestExistListByMaterialId(materialId);
    }
    /**
@@ -47,4 +47,12 @@
    public void updateVersionSubtractBatch(List<MaterialProductApproving> removedList) {
        mapper.updateVersionSubtractBatch(removedList);
    }
    public List<MaterialProductHistory> getListByParentCodeAndCustomCodeAndVersion(String parentCode, String customCode, Integer version) {
        QueryWrapper<MaterialProductHistory> query = Wrappers.query();
        query.eq("parent_code",parentCode).eq("custom_code",customCode)
                .le("s_version",version)
                .ge("e_version",version);
        return mapper.selectList(query);
    }
}
src/main/java/com/whyc/service/ProductBomService.java
@@ -368,8 +368,8 @@
        }
    }
    //查询所有产品中没有与指定散装件关联的子件
    public Response getAllSubWithOutMaterial(int MaterialId) {
        List<ProductBom> list=mapper.getAllSubWithOutMaterial(MaterialId);
    public Response getAllSubWithOutMaterial(int materialId) {
        List<ProductBom> list=mapper.getAllSubWithOutMaterial(materialId);
        return new Response().setII(1,list.size()>0?true:false,list,"返回数据");
    }
   //根据母料型号查询子件信息及有最新版本关联的散装件信息
src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -145,11 +145,27 @@
                String parentCode = productApproving.getParentCode();
                String customCode = productApproving.getCustomCode();
                ProductHistory latestProduct = phService.getLatestVersion(parentCode, customCode);
                ProductHistory enabledProduct = phService.getEnabledByParentCodeAndCustomCode(parentCode, customCode);
                int currentVersion = 0;
                if (latestProduct != null) {
                    currentVersion = latestProduct.getVersion();
                }
                Integer nextVersion = currentVersion + 1;
                //产品物料关系迁移
                //查询生效版本的关联关系
                List<MaterialProductHistory> mpList = mphService.getListByParentCodeAndCustomCodeAndVersion(parentCode, customCode, enabledProduct.getVersion());
                if(latestProduct.getVersion().intValue() == enabledProduct.getVersion()){
                    //最新版本生效,关联关系版本连着的
                    mphService.updateVersionBatch(mpList);
                }else{
                    //旧版本生效,关联关系版本不连着
                    mpList.forEach(mp->{
                        mp.setSVersion(nextVersion);
                        mp.setEVersion(nextVersion);
                    });
                    mphService.insertBatch(mpList);
                }
                //将产品文件复制至正式路径
                //文件转移,未跟子件挂钩的所有图纸图片转移到产品版本下:doc_file/product/{产品型号}/standard或者{customCode}}/{version}/
                //跟子件挂钩的转移到子件图纸下:doc_file/material/
src/main/resources/mapper/MaterialMapper.xml
@@ -5,8 +5,8 @@
    <!--<select id="getMaterialWithoutSub" resultType="com.whyc.pojo.Material">
        select * from  db_doc.tb_Material  b
        where (select count(1) as num from  db_doc.tb_Material_product_history  c
               where b.id= c.Material_id   and c.sub_name=#{subName} and parent_model=#{parentModel}
        where (select count(1) as num from  db_doc.tb_material_product_history  c
               where b.id= c.material_id   and c.sub_name=#{subName} and parent_model=#{parentModel}
               and c.e_version=#{version}
             ) = 0
        and b.status=1;
@@ -56,9 +56,9 @@
        order by id asc
    </select>-->
    <!--<select id="selectMaterialProductHistory"  resultType="com.whyc.pojo.MaterialProductHistory">
        select DISTINCT tb_Material_product_history.*  FROM db_doc.tb_product_bom,db_doc.tb_Material_product_history
        where  tb_product_bom.version=tb_Material_product_history.e_version
        and tb_product_bom.parent_model=tb_Material_product_history.parent_model and tb_Material_product_history.Material_id=#{id}
        select DISTINCT tb_material_product_history.*  FROM db_doc.tb_product_bom,db_doc.tb_material_product_history
        where  tb_product_bom.version=tb_material_product_history.e_version
        and tb_product_bom.parent_model=tb_material_product_history.parent_model and tb_material_product_history.material_id=#{id}
    </select>-->
@@ -89,15 +89,15 @@
        &lt;!&ndash;<result property="parentVersion" column="parent_version"></result>&ndash;&gt;
    </resultMap>-->
    <!--<select id="getReplaceMaterial" resultMap="replaceBom">
        select distinct tb_Material.*,tb_Material_product_history.sub_name as old_subName
        select distinct tb_Material.*,tb_material_product_history.sub_name as old_subName
             ,tb_product_bom.parent_model,tb_product_bom.parent_code,tb_product_bom.parent_name
        ,tb_Material_product_history.e_version as version
        from db_doc.tb_Material,db_doc.tb_Material_product_history,tb_product_bom
        where tb_Material.id=tb_Material_product_history.Material_id
        and tb_Material_product_history.parent_model=tb_product_bom.parent_model
        and tb_product_bom.version=tb_Material_product_history.e_version
        and tb_Material_product_history.parent_model=#{parentModel}
        and tb_Material_product_history.link_type=2
        ,tb_material_product_history.e_version as version
        from db_doc.tb_Material,db_doc.tb_material_product_history,tb_product_bom
        where tb_Material.id=tb_material_product_history.material_id
        and tb_material_product_history.parent_model=tb_product_bom.parent_model
        and tb_product_bom.version=tb_material_product_history.e_version
        and tb_material_product_history.parent_model=#{parentModel}
        and tb_material_product_history.link_type=2
    </select>-->
   <!-- <resultMap id="replaceHisBom" type="productBomHistory">
        &lt;!&ndash;<result property="parentCode" column="parent_code"></result>
@@ -124,15 +124,15 @@
       &lt;!&ndash; <result property="parentVersion" column="parent_version"></result>&ndash;&gt;
    </resultMap>-->
    <!--<select id="getReplaceHisMaterial" resultMap="replaceHisBom">
        select distinct tb_Material.*,tb_Material_product_history.sub_name as old_subName
        select distinct tb_Material.*,tb_material_product_history.sub_name as old_subName
                      ,tb_product_bom.parent_model,tb_product_bom.parent_code,tb_product_bom.parent_name
        from db_doc.tb_Material,db_doc.tb_Material_product_history,tb_product_bom
        where tb_Material.id=tb_Material_product_history.Material_id
          and tb_Material_product_history.parent_model=tb_product_bom.parent_model
          and tb_Material_product_history.parent_model=#{parentModel}
          and tb_Material_product_history.link_type=2
          and tb_Material_product_history.s_version&lt;=#{version}
          and tb_Material_product_history.e_version>=#{version}
        from db_doc.tb_Material,db_doc.tb_material_product_history,tb_product_bom
        where tb_Material.id=tb_material_product_history.material_id
          and tb_material_product_history.parent_model=tb_product_bom.parent_model
          and tb_material_product_history.parent_model=#{parentModel}
          and tb_material_product_history.link_type=2
          and tb_material_product_history.s_version&lt;=#{version}
          and tb_material_product_history.e_version>=#{version}
    </select>-->
    <resultMap id="materialList" type="Material">
        <id property="id" column="id"></id>
@@ -182,11 +182,11 @@
         order by id asc
    </select>
    <select id="selectMaterialProductHistory"  resultType="com.whyc.pojo.MaterialProductHistory">
        select DISTINCT tb_Material_product_history.*  FROM db_doc.tb_material_product_history,db_doc.tb_product
        where  tb_product.version>=tb_Material_product_history.s_version and tb_product.version&lt;=tb_Material_product_history.e_version
          and tb_product.parent_code=tb_Material_product_history.parent_code
          and tb_product.custom_code=tb_Material_product_history.custom_code
          and tb_Material_product_history.material_id=#{id}
        select DISTINCT tb_material_product_history.*  FROM db_doc.tb_material_product_history,db_doc.tb_product
        where  tb_product.version>=tb_material_product_history.s_version and tb_product.version&lt;=tb_material_product_history.e_version
          and tb_product.parent_code=tb_material_product_history.parent_code
          and tb_product.custom_code=tb_material_product_history.custom_code
          and tb_material_product_history.material_id=#{id}
    </select>
    <select id="selectMaterialInProduct"  resultType="com.whyc.pojo.Product">
        select DISTINCT tb_product.*  FROM db_doc.tb_material,db_doc.tb_product, db_doc.tb_product_bom
src/main/resources/mapper/MaterialProductApprovingMapper.xml
@@ -7,6 +7,6 @@
        SELECT a.* FROM db_doc.tb_Material_product_approving a,db_doc.tb_worksheet_main m
        where a.main_id = m.id
        and m.status not in(0,5)
        and Material_id = #{MaterialId}
        and material_id = #{materialId}
    </select>
</mapper>
src/main/resources/mapper/MaterialProductHistoryMapper.xml
@@ -5,23 +5,23 @@
    <update id="updateVersionBatch">
        <foreach collection="list" item="his" separator=";">
            update db_doc.tb_Material_product_history set e_version = e_version+1 where id = #{his.id}
            update db_doc.tb_material_product_history set e_version = e_version+1 where id = #{his.id}
        </foreach>
    </update>
    <update id="updateVersionSubtractBatch">
        <foreach collection="list" item="his" separator=";">
            update db_doc.tb_Material_product_history set e_version = e_version-1 where id = #{his.id}
            update db_doc.tb_material_product_history set e_version = e_version-1 where id = #{his.id}
        </foreach>
    </update>
    <select id="getLatestExistListByMaterialId" resultType="com.whyc.pojo.MaterialProductHistory">
        SELECT
        h.*
        FROM
        db_doc.tb_Material_product_history h,
        db_doc.tb_material_product_history h,
        db_doc.tb_product_bom b
        WHERE
        h.parent_model = b.parent_model
        AND b.version = h.e_version
        AND h.Material_id = #{MaterialId}
        AND h.material_id = #{materialId}
    </select>
</mapper>
src/main/resources/mapper/ProductBomHistoryMapper.xml
@@ -42,11 +42,11 @@
        order by id asc
    </select>
    <select id="selectMaterial"  resultType="com.whyc.pojo.Material">
        select DISTINCT tb_Material.*  FROM db_doc.tb_Material,db_doc.tb_Material_product_history
        where tb_Material.id=tb_Material_product_history.Material_id
        and tb_Material_product_history.product_id=#{productId}
        and tb_Material_product_history.sub_code=#{subCode}
        and tb_Material_product_history.version=#{version}
        select DISTINCT tb_Material.*  FROM db_doc.tb_Material,db_doc.tb_material_product_history
        where tb_Material.id=tb_material_product_history.material_id
        and tb_material_product_history.product_id=#{productId}
        and tb_material_product_history.sub_code=#{subCode}
        and tb_material_product_history.version=#{version}
    </select>
src/main/resources/mapper/ProductBomMapper.xml
@@ -55,9 +55,9 @@
    </select>
    <select id="getAllSubWithOutMaterial" resultType="com.whyc.pojo.ProductBom">
        select * from  db_doc.tb_product_bom  b
        where (select count(1) as num from  db_doc.tb_Material_product_history  c
        where (select count(1) as num from  db_doc.tb_material_product_history  c
               where b.parent_model= c.parent_model  and b.sub_name= c.sub_name  and b.version=c.e_version
                and c.Material_id=#{MaterialId}
                and c.material_id=#{materialId}
              ) = 0
    </select>
@@ -100,18 +100,18 @@
    </select>
    <select id="selectMaterial"  resultType="com.whyc.pojo.Material">
        select DISTINCT tb_Material.*  FROM db_doc.tb_Material,db_doc.tb_Material_product_history where tb_Material.id=tb_Material_product_history.Material_id
        and tb_Material_product_history.sub_name=#{subName} and tb_Material_product_history.parent_model=#{parentModel}
        and tb_Material_product_history.e_version=#{eVersion}
        select DISTINCT tb_Material.*  FROM db_doc.tb_Material,db_doc.tb_material_product_history where tb_Material.id=tb_material_product_history.material_id
        and tb_material_product_history.sub_name=#{subName} and tb_material_product_history.parent_model=#{parentModel}
        and tb_material_product_history.e_version=#{eVersion}
    </select>-->
    <select id="getOldMaterial"  resultType="com.whyc.pojo.Material">
        select DISTINCT tb_Material.*
        FROM db_doc.tb_Material,db_doc.tb_Material_product_history,tb_product_bom
        where tb_Material.id=tb_Material_product_history.Material_id
        and tb_Material_product_history.parent_model=tb_product_bom.parent_model
        and tb_Material_product_history.sub_name=#{oldSubName} and tb_Material_product_history.link_type=1
        and tb_Material_product_history.e_version=tb_product_bom.version
        FROM db_doc.tb_Material,db_doc.tb_material_product_history,tb_product_bom
        where tb_Material.id=tb_material_product_history.material_id
        and tb_material_product_history.parent_model=tb_product_bom.parent_model
        and tb_material_product_history.sub_name=#{oldSubName} and tb_material_product_history.link_type=1
        and tb_material_product_history.e_version=tb_product_bom.version
    </select>
    <resultMap id="MaterialList" type="productBom">
        <id property="id" column="id"></id>
@@ -146,10 +146,10 @@
        order by id asc
    </select>
    <select id="selectMaterial"  resultType="com.whyc.pojo.Material">
        select DISTINCT tb_Material.*  FROM db_doc.tb_Material,db_doc.tb_Material_product_history
        where tb_Material.id=tb_Material_product_history.Material_id
        and tb_Material_product_history.product_id=#{productId}
        and tb_Material_product_history.sub_code=#{subCode}
        and tb_Material_product_history.version=#{version}
        select DISTINCT tb_Material.*  FROM db_doc.tb_Material,db_doc.tb_material_product_history
        where tb_Material.id=tb_material_product_history.material_id
        and tb_material_product_history.product_id=#{productId}
        and tb_material_product_history.sub_code=#{subCode}
        and tb_material_product_history.version=#{version}
    </select>
</mapper>
src/main/resources/mapper/WorksheetMainMapper.xml
@@ -78,8 +78,8 @@
            <result column="create_date" property="createDate"/>
            <result column="update_date" property="updateDate"/>
           <!-- <result column="operation_type" property="operationType"/>
            <result column="Material_id" property="MaterialId"/>
            <association column="Material_id" property="Material" javaType="Material" select="getMaterial">
            <result column="material_id" property="MaterialId"/>
            <association column="material_id" property="Material" javaType="Material" select="getMaterial">
                <result column="category" property="category"/>
                <result column="sub_code" property="subCode"/>
                <result column="sub_name" property="subName"/>
@@ -96,8 +96,8 @@
           <!-- <result column="parent_model" property="parentModel" />
            <result column="sub_name" property="subName"/>
            <result column="link_type" property="linkType"/>
            <result column="Material_id" property="MaterialId"/>
            <association column="Material_id" property="Material" javaType="Material" select="getMaterial">
            <result column="material_id" property="MaterialId"/>
            <association column="material_id" property="Material" javaType="Material" select="getMaterial">
                <result column="category" property="category"/>
                <result column="sub_code" property="subCode"/>
                <result column="sub_name" property="subName"/>
@@ -129,7 +129,7 @@
        select name from db_doc.tb_doc_user where id =#{user_id}
    </select>
    <select id="getMaterial" resultType="Material">
        select category,sub_code,sub_name,sub_model,unit,quantity,producer,notes from db_doc.tb_Material where id =#{Material_id}
        select category,sub_code,sub_name,sub_model,unit,quantity,producer,notes from db_doc.tb_Material where id =#{material_id}
    </select>
    <select id="getLinkListWithMaterials" resultMap="Map_WorksheetMain3">
        SELECT