| | |
| | | package com.ld.igds.m.service; |
| | | |
| | | import com.bstek.bdf2.core.orm.hibernate.HibernateDao; |
| | | import com.bstek.dorado.data.entity.EntityUtils; |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.ld.igds.check.mapper.CheckStandardMapper; |
| | | import com.ld.igds.constant.RedisConst; |
| | |
| | | import com.ld.igds.util.RedisUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.hibernate.Session; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private CheckStandardMapper checkStandardMapper; |
| | | |
| | | |
| | | |
| | | public void listQuality(Page<MQuality> page, Map<String, Object> param) throws Exception{ |
| | |
| | | |
| | | /** |
| | | * 获取仓库最新一条质检数据 |
| | | * |
| | | * @param depotId |
| | | * @return |
| | | * @throws Exception |
| | |
| | | |
| | | /** |
| | | * 从缓存获取当前仓库的最新一条质检数据 |
| | | * |
| | | * @param depotId |
| | | * @return |
| | | * @throws Exception |
| | |
| | | } |
| | | return quality; |
| | | } |
| | | |
| | | public void saveQuality(String id, MQuality data) { |
| | | if (null == data.getCompanyId()) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | |
| | | data.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | Session session = this.getSessionFactory().openSession(); |
| | | data.setUpdateTime(new Date()); |
| | | try { |
| | | if (null == data.getId()) { |
| | | data.setId(id); |
| | |
| | | session.update(data); |
| | | } |
| | | redisUtil.del(RedisConst.buildKey(ContextUtil.getCompanyId(),RedisConst.KEY_DEPOT_QUALITY,data.getDepotId())); |
| | | MQuality newData; |
| | | if (EntityUtils.isEntity(data)) { |
| | | newData = new MQuality(); |
| | | BeanUtils.copyProperties(data, newData, new String[]{"checkItems"}); |
| | | } else { |
| | | newData = data; |
| | | } |
| | | |
| | | redisUtil.set(RedisConst.buildKey(ContextUtil.getCompanyId(),RedisConst.KEY_DEPOT_QUALITY,data.getDepotId()),data,60 * 60 *24); |
| | | redisUtil.set(RedisConst.buildKey(ContextUtil.getCompanyId(), RedisConst.KEY_DEPOT_QUALITY, data.getDepotId()), newData, 60 * 60 * 24); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | |
| | | try { |
| | | if (null != data.getId()) { |
| | | session.delete(data); |
| | | redisUtil.del(RedisConst.buildKey(ContextUtil.getCompanyId(), RedisConst.KEY_DEPOT_QUALITY, data.getDepotId())); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |