| | |
| | | package org.jeecg.modules.spare.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.api.ISysBaseAPI; |
| | | import org.jeecg.common.system.vo.DictModel; |
| | | import org.jeecg.modules.spare.entity.SparePart; |
| | | import org.jeecg.modules.spare.entity.SparePartPurchaseStorage; |
| | | import org.jeecg.modules.spare.entity.SparePartPurchaseStorageDetail; |
| | | import org.jeecg.modules.spare.entity.SparesPartInventory; |
| | | import org.jeecg.modules.spare.mapper.SparePartPurchaseStorageDetailMapper; |
| | | import org.jeecg.modules.spare.service.ISparePartPurchaseStorageDetailService; |
| | | import org.jeecg.modules.spare.service.ISparePartPurchaseStorageService; |
| | | import org.jeecg.modules.spare.service.ISparePartService; |
| | | import org.jeecg.modules.spare.service.ISparesPartInventoryService; |
| | | import org.jeecg.modules.spare.vo.SupplierVo; |
| | | import org.jeecg.modules.spare.vo.WarehouseAreaVo; |
| | | import org.jeecg.modules.spare.vo.WarehouseLocationVo; |
| | | import org.jeecg.modules.system.entity.SysRole; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.jeecg.modules.system.service.ISysRoleService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ISparesPartInventoryService sparesPartInventoryService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private ISparePartService sparePartService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private ISysDictService sysDictService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private ISysRoleService sysRoleService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private ISysUserService sysUserService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private ISysBaseAPI sysBaseAPI; |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getSparePartPurchaseStorageDeatilList(String sparePartPurchaseStorageId) { |
| | |
| | | sparePartPurchaseStorage.setStatus("4"); |
| | | sparePartPurchaseStorageService.updateById(sparePartPurchaseStorage); |
| | | } |
| | | |
| | | //4.判断入库后库存是否低于安全库存或出现积压情况 |
| | | List roleList = new ArrayList<>(); |
| | | List<DictModel> dictModelList = sysDictService.getDictItems("warehouse_message"); |
| | | for(DictModel dictModel : dictModelList){ |
| | | roleList.add(dictModel.getText()); |
| | | } |
| | | QueryWrapper<SysRole> queryWrapper = Wrappers.query(); |
| | | queryWrapper.in("role_code", roleList); |
| | | List<SysRole> sysRoleList = sysRoleService.list(queryWrapper); |
| | | List<SysUser> sysUsers = new ArrayList<>(); |
| | | for (SysRole sysRole : sysRoleList) { |
| | | sysUsers.addAll(sysUserService.getAllUsersByRoleId(sysRole.getId())); |
| | | } |
| | | double quantity = 0.0; |
| | | SparePart sparePart = sparePartService.getById(sparesPartInventory.getSparePartId()); |
| | | List<SparesPartInventory> sparesPartInventoryList = sparesPartInventoryService.lambdaQuery().eq(SparesPartInventory::getSparePartId,sparesPartInventory.getSparePartId()).eq(SparesPartInventory::getDelFlag, CommonConstant.DEL_FLAG_0).list(); |
| | | for(SparesPartInventory sparesPartInventory1 : sparesPartInventoryList){ |
| | | quantity = quantity + sparesPartInventory1.getMainQuantity(); |
| | | } |
| | | if(quantity < sparePart.getInventoryLowerLimit()){ |
| | | String messageTitle; |
| | | String messageContent; |
| | | String sysTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | messageTitle = "系统消息:备件编码为 " + sparePart.getNum() + " 的备件库存量不足,请及时处理!"; |
| | | messageContent = "系统消息:备件编码:" + sparePart.getNum() + " 的备件库存量已低于安全库存!" + "\n" + "消息时间:" + sysTime + "\n"; |
| | | for (SysUser sysUser : sysUsers) { |
| | | sysBaseAPI.sendAnnouncement("admin", sysUser.getUsername(), messageTitle, messageContent); |
| | | } |
| | | }else if(quantity > sparePart.getInventoryUpperLimit()){ |
| | | String messageTitle; |
| | | String messageContent; |
| | | String sysTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | messageTitle = "系统消息:备件编码为 " + sparePart.getNum() + " 的备件出现积压情况,请及时处理!"; |
| | | messageContent = "系统消息:备件编码为 " + sparePart.getNum() + " 的备件库存量已高于库存上限值,出现积压情况!" + "\n" + "消息时间:" + sysTime + "\n"; |
| | | for (SysUser sysUser : sysUsers) { |
| | | sysBaseAPI.sendAnnouncement("admin", sysUser.getUsername(), messageTitle, messageContent); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |