| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.production.pojo.ProductProcessRouteItem; |
| | | import com.ruoyi.production.service.ProductProcessService; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Autowired |
| | | private DeviceLedgerMapper deviceLedgerMapper; |
| | | |
| | | @Override |
| | | public IPage<ProductProcessDto> listPage(Page page, ProductProcessDto productProcessDto) { |
| | | return productProcessMapper.listPage(page, productProcessDto); |
| | | } |
| | | @Autowired |
| | | private SysUserMapper userMapper; |
| | | |
| | | @Override |
| | | public IPage<ProductProcessDto> listPage(Page page, ProductProcessDto productProcessDto) { |
| | | IPage<ProductProcessDto> productProcessDtoIPage = productProcessMapper.listPage(page, productProcessDto); |
| | | productProcessDtoIPage.getRecords().forEach(item -> { |
| | | if (ObjectUtils.isNotEmpty(item.getUserIds())) { |
| | | List<Long> userIds = Arrays.stream(item.getUserIds().split(",")) |
| | | .filter(s -> !s.trim().isEmpty() && !"null".equals(s)) |
| | | .map(Long::parseLong) |
| | | .collect(Collectors.toList()); |
| | | item.setIds(userIds); |
| | | if (!userIds.isEmpty()) { |
| | | List<SysUser> sysUsers = userMapper.selectList(Wrappers.<SysUser>lambdaQuery().in(SysUser::getUserId, userIds)); |
| | | item.setUserNames(sysUsers.stream().map(SysUser::getNickName).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | }); |
| | | return productProcessDtoIPage; |
| | | } |
| | | @Override |
| | | public AjaxResult add(ProductProcessDto productProcessDto) { |
| | | String idStr = String.join(",", productProcessDto.getUserIds()); |
| | | ProductProcess productProcess = new ProductProcess(); |
| | | BeanUtils.copyProperties(productProcessDto,productProcess); |
| | | productProcess.setUserIds(idStr); |
| | | boolean save = productProcessMapper.insert(productProcess) > 0; |
| | | if (save && ObjectUtils.isNull(productProcessDto.getNo())) { |
| | | // 根据id生成no字段:GX + 8位数字(不足8位前面补0) |
| | |
| | | productProcessMapper.deleteBatchIds(ids); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String updateProcess(ProductProcessDto productProcess) { |
| | | if (ObjectUtils.isEmpty(productProcess.getIds())) { |
| | | throw new RuntimeException("报工用户不能为空"); |
| | | } |
| | | productProcess.setUserIds(productProcess.getIds().stream() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(","))); |
| | | productProcessMapper.updateById(productProcess); |
| | | return ""; |
| | | } |
| | | } |