Commit 89e5e9af by 李小惠

添加装备类别和号型存入ES的定时任务,修改装备导入接口。

parent c72fec69
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -28,4 +28,6 @@ public interface EquipmentTypeMapper extends BaseMapper<EquipmentType> {
List<TypeSizeDto> GetNameBySizeIds(@Param("sizeIds") List<String> sizeIds);
List<TypeDto> alignTypeInfo(@Param("date") String date);
}
\ No newline at end of file
......@@ -34,6 +34,8 @@ public interface EquipmentSizeService extends IService<EquipmentSize> {
List<EquipmentSize> distinctByName(List<EquipmentSize> sizeList);
void addSizeInfoToEs();
//根据typeId拿到装备typeIds
// List<String> selectByTypeIds(List<String> typeIdsList);
......
......@@ -39,4 +39,5 @@ public interface EquipmentTypeService extends IService<EquipmentType> {
String exportSizeAndType(QueryEquipmentTypeReq req);
void addTypeInfoToEs();
}
......@@ -244,6 +244,19 @@ public class EquipmentSizeServiceImpl extends ServiceImpl<EquipmentSizeMapper, E
return equipmentSizeMapper.distinctByName(sizeList);
}
@Override
public void addSizeInfoToEs() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
// 获取昨天的日期
calendar.add(Calendar.DAY_OF_YEAR, -1);
Date yesterday = calendar.getTime();
List<EquipmentSize> list = list(new LambdaQueryWrapper<EquipmentSize>()
.ge(EquipmentSize::getUpdateTime, DateTimeUtil.DaysToZero(yesterday))
.le(EquipmentSize::getUpdateTime, DateTimeUtil.setTimeToMax(yesterday)));
sizeRepository.saveAll(list);
}
public List<String> selectByTypeIds(List<String> typeIdsList){
List<String> list1=new ArrayList<>();
......
package com.junmp.jyzb.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -23,6 +24,7 @@ import com.junmp.jyzb.utils.*;
import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil;
import org.elasticsearch.client.RestHighLevelClient;
import org.joda.time.Days;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -39,6 +41,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Month;
import java.util.*;
import java.util.stream.Collectors;
......@@ -69,6 +73,8 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
@Resource
private PubOrgService pubOrgService;
@Resource
private EquipmentSizeService equipmentSizeService;
private static final String REDIS_TYPE = "Type_";
......@@ -629,6 +635,18 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
}
@Override
public void addTypeInfoToEs() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
// 获取昨天的日期
calendar.add(Calendar.DAY_OF_YEAR, -1);
Date yesterday = calendar.getTime();
List<EquipmentType> list = list(new LambdaQueryWrapper<EquipmentType>()
.ge(EquipmentType::getUpdateTime, DateTimeUtil.DaysToZero(yesterday))
.le(EquipmentType::getUpdateTime, DateTimeUtil.setTimeToMax(yesterday)));
typeRepository.saveAll(list);
}
}
......
......@@ -46,6 +46,7 @@ import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
......@@ -692,6 +693,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
//装备导入(判断导入的数据是否存在redis中,如果不存在,则判断数据库是否存在相同的epc,如果存在提示报错,并且讲该次导入的数据存储到redis中,为下一次进行作比较)
@Override
@Transactional
@Async
public boolean EqsImport(InventoryReq req) {
//将该组织机构下面已经导入的装备删除
remove(new LambdaQueryWrapper<Inventory>().eq(Inventory::getNote,"equipmentImport"));
......@@ -717,9 +719,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
inventory.setNote("equipmentImport");
inventory.setCreateTime(DateTimeUtil.getCurrentDateTime());
inventory.setEpc(epc);
inventory.setLocationState("in");
inventory.setBussinessState("normal");
inventory.setState("normal");
inventory.setProperty(0);
inventory.setLocationState("in");
addInvList.add(inventory);
WarehouseInventory warehouseInventory = new WarehouseInventory();
......@@ -730,6 +730,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
warehouseInventory.setEpc(epc);
warehouseInventory.setOrgName(inv.getOrgName());
warehouseInventory.setLocationState("in");
warehouseInventory.setCreateTime(DateTimeUtil.getCurrentDateTime());
addWareList.add(warehouseInventory);
}
......
package com.junmp.jyzb.task;
import com.junmp.jyzb.service.EquipmentSizeService;
import com.junmp.jyzb.service.EquipmentTypeService;
import com.junmp.v2.job.api.JobAction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Slf4j
@Component
public class AddBaseInfoToESAction implements JobAction {
@Resource
private EquipmentTypeService equipmentTypeService;
@Resource
private EquipmentSizeService equipmentSizeService;
@Override
public void action() {
equipmentSizeService.addSizeInfoToEs();
equipmentTypeService.addTypeInfoToEs();
}
}
......@@ -105,4 +105,5 @@
</select>
</mapper>
\ No newline at end of file
......@@ -40,15 +40,15 @@
<foreach collection="list" item="item" separator=";">
update
base_inventory
<set>
size_id=(select DISTINCT id FROM base_equipment_size where name=#{item.sizeName} and
type_id =(select DISTINCT id FROM base_equipment_type where name=#{item.typeName} limit 1) limit 1),
type_id=(select DISTINCT id FROM base_equipment_type where name=#{item.typeName} limit 1),
location_id=(select DISTINCT id FROM base_warehouse where name=#{item.locationId} limit 1),
state="normal",bussiness_type="normal",update_time=#{updateTime},property=0,epc_type=1,location_state="in",
set
size_id=(select DISTINCT id FROM base_equipment_size where name = #{item.sizeName} and
type_id =(select DISTINCT id FROM base_equipment_type where name = #{item.typeName} limit 1) limit 1),
type_id=(select DISTINCT id FROM base_equipment_type where name = #{item.typeName} limit 1),
location_id=(select DISTINCT id FROM base_warehouse where name = #{item.locationId} limit 1),
state="normal",bussiness_state="normal",update_time=#{updateTime},property=0,epc_type=1,location_state="in",
location_type=0
</set>
where note ="equipmentImport"
where note ="equipmentImport"
</foreach>
</update>
......@@ -843,6 +843,7 @@
and i.price=#{price}
and i.warranty_period=#{warrantyPeriod}
and i.production_date >= #{startTime} and i.production_date &lt; #{endTime}
ORDER BY wi.epc_type desc
</select>
......
......@@ -39,8 +39,9 @@
type_id=(select DISTINCT id FROM base_equipment_type where name=#{item.typeName} limit 1),
location_id=(select DISTINCT id FROM base_warehouse where name=#{item.locationId} limit 1),
update_time=#{updateTime},epc_type=1,location_state="in",location_type=0
where flag =2
</set>
where flag =2
</foreach>
</update>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论