|
|
|
@ -15,11 +15,13 @@ import com.dreamchaser.depository_manage.service.PlaceService; |
|
|
|
import com.dreamchaser.depository_manage.service.RoleService; |
|
|
|
import com.dreamchaser.depository_manage.utils.DateUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
|
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.sql.Time; |
|
|
|
import java.util.*; |
|
|
|
@ -139,26 +141,58 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 判断是否有保质期
|
|
|
|
String dateType = (String) map.get("dateType"); |
|
|
|
// 1年2月3天
|
|
|
|
Integer shelfLife = 0; |
|
|
|
int shelfLife = 0; |
|
|
|
if (map.containsKey("shelfLife")) { |
|
|
|
shelfLife = ObjectFormatUtil.toInteger(map.get("shelfLife")); |
|
|
|
String life = map.get("shelfLife").toString(); |
|
|
|
if(!("".equals(life))){ |
|
|
|
shelfLife = ObjectFormatUtil.toInteger(life); |
|
|
|
}else{ |
|
|
|
shelfLife = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
if ("day".equals(dateType)) { |
|
|
|
if ("day".equals(dateType) && shelfLife != -1) { |
|
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("3" + shelfLife)); |
|
|
|
} else if ("month".equals(dateType)) { |
|
|
|
} else if ("month".equals(dateType) && shelfLife != -1) { |
|
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("2" + shelfLife)); |
|
|
|
} else if ("year".equals(dateType)) { |
|
|
|
} else if ("year".equals(dateType) && shelfLife != -1) { |
|
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("1" + shelfLife)); |
|
|
|
}else{ |
|
|
|
map.remove("shelfLife"); |
|
|
|
} |
|
|
|
if (map.containsKey("producedDate")) { |
|
|
|
Long producedDate = DateUtil.DateTimeByMonthToTimeStamp(map.get("producedDate").toString()); |
|
|
|
map.put("producedDate", producedDate); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 开启一个线程去更新对应库存的记录
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
HashMap<String,Object> param = new HashMap<>(); |
|
|
|
param.putAll(map); |
|
|
|
updateInventoryInfo(param); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
return materialMapper.updateMaterial(map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于修改对应的库存记录 |
|
|
|
* @param map |
|
|
|
*/ |
|
|
|
public void updateInventoryInfo(HashMap<String,Object> map){ |
|
|
|
// 获取要修改的物料编码
|
|
|
|
HashMap<String,Object> param = new HashMap<>(); |
|
|
|
param.put("code",map.get("code")); |
|
|
|
List<Material> inventory = materialMapper.findInventory(param); |
|
|
|
List<Integer> list = new ArrayList<>(); |
|
|
|
for (int i = 0; i < inventory.size(); i++) { |
|
|
|
list.add(inventory.get(i).getId()); |
|
|
|
} |
|
|
|
map.put("list",list); |
|
|
|
materialMapper.updateInventory(map); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 根据id删除一条库存记录 |
|
|
|
* |
|
|
|
|