|
|
@ -23,52 +23,56 @@ |
|
|
|
|
|
|
|
// console.log(haveSame("2,5".split(","), ["1"]));
|
|
|
|
|
|
|
|
const arr = [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
house_id: 4, |
|
|
|
coop_id: 2, |
|
|
|
reason_id: 1, |
|
|
|
die_number: 222, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
house_id: 4, |
|
|
|
coop_id: 2, |
|
|
|
reason_id: 1, |
|
|
|
die_number: 222, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 3, |
|
|
|
house_id: 4, |
|
|
|
coop_id: 7, |
|
|
|
reason_id: 1, |
|
|
|
die_number: 222, |
|
|
|
}, |
|
|
|
]; |
|
|
|
let temp = []; |
|
|
|
arr.map((item, index) => { |
|
|
|
if ( |
|
|
|
temp.every( |
|
|
|
(it) => it.house_id != item.house_id || it.coop_id != item.coop_id |
|
|
|
) |
|
|
|
) { |
|
|
|
temp.push(item); |
|
|
|
} else { |
|
|
|
const real = temp.filter( |
|
|
|
(it) => it.house_id == item.house_id && it.coop_id == item.coop_id |
|
|
|
); |
|
|
|
if (real && real.length > 0) { |
|
|
|
real[0].die_number = item.die_number + real[0].die_number; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
// const arr = [
|
|
|
|
// {
|
|
|
|
// id: 1,
|
|
|
|
// house_id: 4,
|
|
|
|
// coop_id: 2,
|
|
|
|
// reason_id: 1,
|
|
|
|
// die_number: 222,
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// id: 2,
|
|
|
|
// house_id: 4,
|
|
|
|
// coop_id: 2,
|
|
|
|
// reason_id: 1,
|
|
|
|
// die_number: 222,
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// id: 3,
|
|
|
|
// house_id: 4,
|
|
|
|
// coop_id: 7,
|
|
|
|
// reason_id: 1,
|
|
|
|
// die_number: 222,
|
|
|
|
// },
|
|
|
|
// ];
|
|
|
|
// let temp = [];
|
|
|
|
// arr.map((item, index) => {
|
|
|
|
// if (
|
|
|
|
// temp.every(
|
|
|
|
// (it) => it.house_id != item.house_id || it.coop_id != item.coop_id
|
|
|
|
// )
|
|
|
|
// ) {
|
|
|
|
// temp.push(item);
|
|
|
|
// } else {
|
|
|
|
// const real = temp.filter(
|
|
|
|
// (it) => it.house_id == item.house_id && it.coop_id == item.coop_id
|
|
|
|
// );
|
|
|
|
// if (real && real.length > 0) {
|
|
|
|
// real[0].die_number = item.die_number + real[0].die_number;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
function getDayLife(out_time, in_time) { |
|
|
|
// 出栏日龄=出栏时间-进鸡时间
|
|
|
|
const dateBegin = new Date(in_time); |
|
|
|
const dateEnd = new Date(out_time); |
|
|
|
var result = dateEnd.getTime() - dateBegin.getTime(); |
|
|
|
var joinTime = Math.floor(result / (24 * 3600 * 1000)); |
|
|
|
console.log(joinTime); |
|
|
|
} |
|
|
|
// function getDayLife(out_time, in_time) {
|
|
|
|
// // 出栏日龄=出栏时间-进鸡时间
|
|
|
|
// const dateBegin = new Date(in_time);
|
|
|
|
// const dateEnd = new Date(out_time);
|
|
|
|
// var result = dateEnd.getTime() - dateBegin.getTime();
|
|
|
|
// var joinTime = Math.floor(result / (24 * 3600 * 1000));
|
|
|
|
// console.log(joinTime);
|
|
|
|
// }
|
|
|
|
|
|
|
|
const { getTimeLastDate } = require("../utils/common"); |
|
|
|
|
|
|
|
console.log(getTimeLastDate("2023-03-28 12:12:12", 3)); |