| | |
| | | private SysSupplierInfoDao sysSupplierInfoDao; |
| | | @Autowired |
| | | private ShoppingGoodsCategoryDao shoppingGoodsCategoryDao; |
| | | @Autowired |
| | | private SysGoodsTypeDao sysGoodsTypeDao; |
| | | @Autowired |
| | | private ShoppingGoodsDao shoppingGoodsDao; |
| | | |
| | | @Autowired |
| | | private RedisClient redisClient; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @DS("slave") |
| | | public List<ShoppingGoods> shoppingGoodsOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from shopping_goods"); |
| | | public List<SysGoodsType> goodsTypeOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from sys_goods_type"); |
| | | return mapsToListBean(maps, SysGoodsType.class); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void goodsTypeNew(List<SysGoodsType> goodsTypes) { |
| | | if (CollUtil.isNotEmpty(goodsTypes)) { |
| | | Map<Long, Long> map = new HashMap<>(); |
| | | for (SysGoodsType goodsType : goodsTypes) { |
| | | goodsType.setCompanyId(companyId); |
| | | Long oldID = goodsType.getId(); |
| | | goodsType.setId(null); |
| | | sysGoodsTypeDao.insert(goodsType); |
| | | map.put(oldID, goodsType.getId()); |
| | | } |
| | | |
| | | redisClient.saveMapValue("goods_type", map); |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateGoodsTypeParentId() { |
| | | String goodsTypes = redisClient.getCachedValue("goods_type"); |
| | | Map<String, Integer> maps = JSONObject.parseObject(goodsTypes, HashMap.class); |
| | | for (Map.Entry<String, Integer> entry : maps.entrySet()) { |
| | | String sql = "update sys_goods_type set PARENT_ID="+ entry.getValue() +" where company_id=35 and PARENT_ID="+entry.getKey(); |
| | | jdbcTemplate.update(sql); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 家具产品 |
| | | * @param goodType |
| | | * @return |
| | | */ |
| | | @DS("slave") |
| | | public List<ShoppingGoods> shoppingGoodsOld(String goodType) { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from shopping_goods where good_type='"+goodType+"'"); |
| | | List<ShoppingGoods> shoppingGoods = mapsToListBean(maps, ShoppingGoods.class); |
| | | |
| | | |
| | | Map<String, Integer> goodsTypeIds = getRedisIds("goods_type"); |
| | | Map<String, Integer> supplierInfoIds = getRedisIds("supplier_info"); |
| | | for (ShoppingGoods shoppingGood : shoppingGoods) { |
| | | List<Map<String, Object>> assembleList = jdbcTemplate.queryForList("select * from shopping_goods_assemble where shopping_goods_id=" + shoppingGood.getId()); |
| | | if (CollUtil.isNotEmpty(assembleList)) { |
| | | String goodsName = shoppingGood.getName(); |
| | | ; |
| | | for (Map<String, Object> assemble : assembleList) { |
| | | shoppingGood.setPrice((Double) assemble.get("price")); |
| | | Long goodsId = (Long) assemble.get("assemble_sku_id"); |
| | | if (goodsId == null) { |
| | | continue; |
| | | } |
| | | Map<String, Object> sku = jdbcTemplate.queryForMap("select * from sku where id=" + goodsId); |
| | | Map<String, Object> sysGoods = jdbcTemplate.queryForMap("select * from sys_goods where id=" + sku.get("goods_id")); |
| | | |
| | | shoppingGood.setGoodsNo((String) sysGoods.get("goods_no")); |
| | | shoppingGood.setCode((String) sysGoods.get("goods_no")); |
| | | shoppingGood.setName(goodsName+ "->" + (String) sysGoods.get("name")); |
| | | shoppingGood.setUnit((String) sysGoods.get("unit")); |
| | | shoppingGood.setMeasure((String) sysGoods.get("measure")); |
| | | shoppingGood.setAlarmNum((Integer) sku.get("alarm_num")); |
| | | shoppingGood.setHeadquarters(1); |
| | | shoppingGood.setIsDel(1); |
| | | shoppingGood.setZjm(StringUtils.toHanyuPinyin(shoppingGood.getName()) + "," + StringUtils.toHeadWordHanyuPinyin(shoppingGood.getName())); |
| | | |
| | | shoppingGood.setWeiDescription("数据迁移"); |
| | | Integer goodsSortId = goodsTypeIds.get(sysGoods.get("goods_sort_id").toString()); |
| | | shoppingGood.setGoodsSortId(Long.parseLong(goodsSortId.toString())); |
| | | |
| | | Integer supplierId = supplierInfoIds.get(sysGoods.get("supplier_id").toString()); |
| | | if (supplierId != null) { |
| | | shoppingGood.setSupplierId(Long.parseLong(supplierId.toString())); |
| | | } |
| | | |
| | | // 因为旧系统 sys_order_item 表中,关联商品与sku的id相关 |
| | | shoppingGood.setId(goodsId); |
| | | } |
| | | } else { |
| | | System.out.println("这是ID啊:"+ shoppingGood.getId()); |
| | | } |
| | | } |
| | | return shoppingGoods; |
| | | } |
| | | |
| | | public void shoppingGoodsNew() {} |
| | | @DS("slave") |
| | | public List<ShoppingGoods> shoppingGoodsProjectOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from shopping_goods where good_type='项目'"); |
| | | List<ShoppingGoods> shoppingGoods = mapsToListBean(maps, ShoppingGoods.class); |
| | | |
| | | for (ShoppingGoods shoppingGood : shoppingGoods) { |
| | | Map<String, Object> goodsAssemble = jdbcTemplate.queryForMap("select * from shopping_goods_assemble where shopping_goods_id=" + shoppingGood.getId()); |
| | | Map<String, Object> projInfo = jdbcTemplate.queryForMap("select * from sys_proj_info where id=" + goodsAssemble.get("assemble_proj_id")); |
| | | |
| | | shoppingGood.setTimeLength((Integer) projInfo.get("time_length")); |
| | | shoppingGood.setCode((String) projInfo.get("proj_no")); |
| | | shoppingGood.setCompanyId(companyId); |
| | | shoppingGood.setHeadquarters(1); |
| | | shoppingGood.setIsDel(1); |
| | | shoppingGood.setZjm(StringUtils.toHanyuPinyin(shoppingGood.getName()) + "," + StringUtils.toHeadWordHanyuPinyin(shoppingGood.getName())); |
| | | |
| | | shoppingGood.setWeiDescription("数据迁移"); |
| | | |
| | | } |
| | | return shoppingGoods; |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<ShoppingGoods> shoppingGoodsTcList() { |
| | | return null; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void shoppingGoodsNew(List<ShoppingGoods> list) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> map = new HashMap<>(); |
| | | Map<String, Integer> goodsCategory = getRedisIds("goods_category"); |
| | | for (ShoppingGoods shoppingGoods : list) { |
| | | shoppingGoods.setCompanyId(companyId); |
| | | |
| | | Integer cateId = goodsCategory.get(shoppingGoods.getCateId().toString()); |
| | | if (cateId != null) { |
| | | shoppingGoods.setCateId(Long.parseLong(cateId.toString())); |
| | | } |
| | | |
| | | Long oldId = shoppingGoods.getId(); |
| | | shoppingGoods.setId(null); |
| | | shoppingGoodsDao.insert(shoppingGoods); |
| | | map.put(oldId, shoppingGoods.getId()); |
| | | } |
| | | |
| | | redisClient.saveMapValue("shopping_goods_sku", map); |
| | | } |
| | | } |
| | | |
| | | |
| | | public Map<String, Integer> getRedisIds(String key) { |
| | | String idsStr = redisClient.getCachedValue(key); |
| | | return JSONObject.parseObject(idsStr, HashMap.class); |
| | | } |
| | | |
| | | } |