| | |
| | | import com.whyc.dto.FileUrlDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.ProductMapper; |
| | | import com.whyc.pojo.DocUser; |
| | | import com.whyc.pojo.Product; |
| | | import com.whyc.pojo.ProductBom; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.FileUtil; |
| | |
| | | public class ProductService { |
| | | @Autowired(required = false) |
| | | private ProductMapper mapper; |
| | | |
| | | @Autowired |
| | | private ProductHistoryService phService; |
| | | |
| | | @Autowired |
| | | private MaterialProductHistoryService mphService; |
| | | |
| | | |
| | | //查询出所有的产品信息(分页加模糊查询<产品的编码,型号,名字,定制表编号> |
| | | public Response getAllProduct(String parentCode, String parentName, String parentModel, String customCode, int pageCurr, int pageSize) { |
| | |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | public Response add(Product product) { |
| | | String parentCode = product.getParentCode(); |
| | | String customCode = product.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; |
| | | //产品物料关系迁移 |
| | | //查询生效版本的关联关系 |
| | | if(latestProduct!=null &&enabledProduct!=null) { |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | //将产品文件复制至正式路径 |
| | | |
| | | //物料表中不存在的,则添加到物料表中去(包含product这个物料) |
| | | |
| | | return null; |
| | | } |
| | | } |