| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.aps.common.core.utils.DateUtils; |
| | |
| | | import com.aps.core.domain.ApsMaterialProductGroupManagement; |
| | | import com.aps.core.mapper.ApsMaterialProductGroupManagementMapper; |
| | | import com.aps.core.service.IApsMaterialProductGroupManagementService; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import io.micrometer.common.util.StringUtils; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | |
| | | @Override |
| | | public int insertApsMaterialProductGroupManagement(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) |
| | | { |
| | | apsMaterialProductGroupManagement.setId(IdUtil.getSnowflakeNextId()); |
| | | apsMaterialProductGroupManagement.setCreateBy(SecurityUtils.getUsername()); |
| | | apsMaterialProductGroupManagement.setCreateTime(DateUtils.getNowDate()); |
| | | return apsMaterialProductGroupManagementMapper.insertApsMaterialProductGroupManagement(apsMaterialProductGroupManagement); |
| | | } |
| | |
| | | public int updateApsMaterialProductGroupManagement(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) |
| | | { |
| | | apsMaterialProductGroupManagement.setUpdateTime(DateUtils.getNowDate()); |
| | | apsMaterialProductGroupManagement.setUpdateBy(SecurityUtils.getUsername()); |
| | | return apsMaterialProductGroupManagementMapper.updateApsMaterialProductGroupManagement(apsMaterialProductGroupManagement); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | if (!list.isEmpty()) { |
| | | apsMaterialProductGroupManagementMapper.insert(list); |
| | | Set<String> facCodeKey = apsMaterialProductGroupManagementMapper.selectByFacOrMaterial( |
| | | list.stream().map(ApsMaterialProductGroupManagement::getFactory).collect(Collectors.toSet()), |
| | | list.stream().map(ApsMaterialProductGroupManagement::getMaterialCode).collect(Collectors.toSet()) |
| | | ); |
| | | if (!facCodeKey.isEmpty()) { |
| | | Iterator<ApsMaterialProductGroupManagement> it = list.iterator(); |
| | | while (it.hasNext()) { |
| | | ApsMaterialProductGroupManagement item = it.next(); |
| | | String key = item.getFactory() + "##" + item.getMaterialCode(); |
| | | if (facCodeKey.contains(key)) { |
| | | LambdaUpdateWrapper<ApsMaterialProductGroupManagement> wrapper = new LambdaUpdateWrapper<>(); |
| | | wrapper.eq(ApsMaterialProductGroupManagement::getFactory, item.getFactory()); |
| | | wrapper.eq(ApsMaterialProductGroupManagement::getMaterialCode, item.getMaterialCode()); |
| | | item.setCreateBy(null); |
| | | item.setCreateTime(null); |
| | | item.setUpdateBy(SecurityUtils.getUsername()); |
| | | item.setUpdateTime(new Timestamp(System.currentTimeMillis())); |
| | | apsMaterialProductGroupManagementMapper.update(item, wrapper); |
| | | it.remove(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!list.isEmpty()) { |
| | | apsMaterialProductGroupManagementMapper.insert(list); |
| | | } |
| | | } |
| | | return list.size(); |
| | | } |