|  | @@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import com.pj.project.tb_item.TbItem;
 | 
	
		
			
				|  |  |  import com.pj.project.tb_item.TbItemMapper;
 | 
	
		
			
				|  |  | +import com.pj.project.tb_item_type.TbItemType;
 | 
	
		
			
				|  |  | +import com.pj.project.tb_item_type.TbItemTypeService;
 | 
	
		
			
				|  |  |  import com.pj.utils.so.SoMap;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
	
		
			
				|  | @@ -16,6 +18,8 @@ import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import com.pj.utils.sg.*;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import javax.annotation.Resource;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Service: relation_type_item --
 | 
	
		
			
				|  |  |   *
 | 
	
	
		
			
				|  | @@ -30,6 +34,8 @@ public class RelationTypeItemService extends ServiceImpl<RelationTypeItemMapper,
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      RelationTypeItemMapper relationTypeItemMapper;
 | 
	
		
			
				|  |  | +    @Resource
 | 
	
		
			
				|  |  | +    private TbItemTypeService tbItemTypeService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -49,13 +55,14 @@ public class RelationTypeItemService extends ServiceImpl<RelationTypeItemMapper,
 | 
	
		
			
				|  |  |      public void setBatch(String typeId, String itemIds) {
 | 
	
		
			
				|  |  |          List<String> itemIdList = StrUtil.splitTrim(itemIds, ",");
 | 
	
		
			
				|  |  |          List<RelationTypeItem> list = findByTypeId(typeId);
 | 
	
		
			
				|  |  | +        TbItemType tbItemType = tbItemTypeService.getById(typeId);
 | 
	
		
			
				|  |  |          List<String> removeIds = list.stream().filter(relationTypeItem -> !itemIdList.contains(relationTypeItem.getItemId())).map(RelationTypeItem::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |          this.removeByIds(removeIds);
 | 
	
		
			
				|  |  |          List<String> dbItemIdList = list.stream().map(RelationTypeItem::getItemId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |          itemIdList.stream().filter(id -> !dbItemIdList.contains(id)).
 | 
	
		
			
				|  |  |                  forEach(id -> {
 | 
	
		
			
				|  |  |                      RelationTypeItem relationTypeItem = new RelationTypeItem();
 | 
	
		
			
				|  |  | -                    relationTypeItem.setItemId(id).setTypeId(typeId).setNeed(1);
 | 
	
		
			
				|  |  | +                    relationTypeItem.setItemId(id).setTypeId(typeId).setNeed(1).setTypeName(tbItemType.getName());
 | 
	
		
			
				|  |  |                      this.save(relationTypeItem);
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -69,38 +76,46 @@ public class RelationTypeItemService extends ServiceImpl<RelationTypeItemMapper,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void setSingle(String typeId, String itemId) {
 | 
	
		
			
				|  |  |          RelationTypeItem relationTypeItem = new RelationTypeItem();
 | 
	
		
			
				|  |  | -        relationTypeItem.setNeed(1).setItemId(itemId).setTypeId(typeId);
 | 
	
		
			
				|  |  | +        TbItemType tbItemType = tbItemTypeService.getById(typeId);
 | 
	
		
			
				|  |  | +        relationTypeItem.setNeed(1).setItemId(itemId).setTypeId(typeId).setTypeName(tbItemType.getName());
 | 
	
		
			
				|  |  |          this.save(relationTypeItem);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public RelationTypeItem findByTypeIdAndItemId(String typeId, String itemId){
 | 
	
		
			
				|  |  | -        QueryWrapper<RelationTypeItem>ew=new QueryWrapper<>();
 | 
	
		
			
				|  |  | -        ew.eq("type_id",typeId);
 | 
	
		
			
				|  |  | -        ew.eq("item_id",itemId);
 | 
	
		
			
				|  |  | +    public RelationTypeItem findByTypeIdAndItemId(String typeId, String itemId) {
 | 
	
		
			
				|  |  | +        QueryWrapper<RelationTypeItem> ew = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +        ew.eq("type_id", typeId);
 | 
	
		
			
				|  |  | +        ew.eq("item_id", itemId);
 | 
	
		
			
				|  |  |          return getOne(ew);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void updateStatus(String typeId, String itemId, int need) {
 | 
	
		
			
				|  |  | -        RelationTypeItem relationTypeItem= this.findByTypeIdAndItemId(typeId,itemId);
 | 
	
		
			
				|  |  | +        RelationTypeItem relationTypeItem = this.findByTypeIdAndItemId(typeId, itemId);
 | 
	
		
			
				|  |  |          relationTypeItem.setNeed(need);
 | 
	
		
			
				|  |  |          this.updateById(relationTypeItem);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void updateRemarkMust(String typeId, String itemId, int mustRemark) {
 | 
	
		
			
				|  |  | -        RelationTypeItem relationTypeItem= this.findByTypeIdAndItemId(typeId,itemId);
 | 
	
		
			
				|  |  | +        RelationTypeItem relationTypeItem = this.findByTypeIdAndItemId(typeId, itemId);
 | 
	
		
			
				|  |  |          relationTypeItem.setMustRemark(mustRemark);
 | 
	
		
			
				|  |  |          this.updateById(relationTypeItem);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void updateRemarkNeed(String typeId, String itemId, int needRemark) {
 | 
	
		
			
				|  |  | -        RelationTypeItem relationTypeItem= this.findByTypeIdAndItemId(typeId,itemId);
 | 
	
		
			
				|  |  | +        RelationTypeItem relationTypeItem = this.findByTypeIdAndItemId(typeId, itemId);
 | 
	
		
			
				|  |  |          relationTypeItem.setNeedRemark(needRemark);
 | 
	
		
			
				|  |  |          this.updateById(relationTypeItem);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void updateNum(String typeId, String itemId, int inc) {
 | 
	
		
			
				|  |  | -        RelationTypeItem relationTypeItem= this.findByTypeIdAndItemId(typeId,itemId);
 | 
	
		
			
				|  |  | +        RelationTypeItem relationTypeItem = this.findByTypeIdAndItemId(typeId, itemId);
 | 
	
		
			
				|  |  |          relationTypeItem.setInc(inc);
 | 
	
		
			
				|  |  |          this.updateById(relationTypeItem);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void removeRelation(String id, String typeId) {
 | 
	
		
			
				|  |  | +        QueryWrapper<RelationTypeItem>ew=new QueryWrapper<>();
 | 
	
		
			
				|  |  | +        ew.eq("type_id",typeId);
 | 
	
		
			
				|  |  | +        ew.eq("item_id",id);
 | 
	
		
			
				|  |  | +        this.remove(ew);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |